am 11cd8c5a
: Fix for 1785342: The old PIN is required after entering New PIN
Merge commit '11cd8c5ac95334c9363a82fd81d05d85623f9d17' * commit '11cd8c5ac95334c9363a82fd81d05d85623f9d17': Fix for 1785342: The old PIN is required after entering New PIN
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.settings;
|
package com.android.settings;
|
||||||
|
|
||||||
|
import android.app.Dialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.preference.EditTextPreference;
|
import android.preference.EditTextPreference;
|
||||||
import android.text.method.DigitsKeyListener;
|
import android.text.method.DigitsKeyListener;
|
||||||
@@ -24,15 +25,11 @@ import android.util.AttributeSet;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Add a soft dialpad for PIN entry.
|
* TODO: Add a soft dialpad for PIN entry.
|
||||||
*/
|
*/
|
||||||
class EditPinPreference extends EditTextPreference {
|
class EditPinPreference extends EditTextPreference {
|
||||||
|
|
||||||
private boolean mDialogOpen;
|
|
||||||
|
|
||||||
interface OnPinEnteredListener {
|
interface OnPinEnteredListener {
|
||||||
void onPinEntered(EditPinPreference preference, boolean positiveResult);
|
void onPinEntered(EditPinPreference preference, boolean positiveResult);
|
||||||
}
|
}
|
||||||
@@ -50,13 +47,13 @@ class EditPinPreference extends EditTextPreference {
|
|||||||
public void setOnPinEnteredListener(OnPinEnteredListener listener) {
|
public void setOnPinEnteredListener(OnPinEnteredListener listener) {
|
||||||
mPinListener = listener;
|
mPinListener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onBindDialogView(View view) {
|
protected void onBindDialogView(View view) {
|
||||||
super.onBindDialogView(view);
|
super.onBindDialogView(view);
|
||||||
|
|
||||||
final EditText editText = (EditText) view.findViewById(android.R.id.edit);
|
final EditText editText = (EditText) view.findViewById(android.R.id.edit);
|
||||||
|
|
||||||
if (editText != null) {
|
if (editText != null) {
|
||||||
editText.setSingleLine(true);
|
editText.setSingleLine(true);
|
||||||
editText.setTransformationMethod(PasswordTransformationMethod.getInstance());
|
editText.setTransformationMethod(PasswordTransformationMethod.getInstance());
|
||||||
@@ -65,20 +62,22 @@ class EditPinPreference extends EditTextPreference {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDialogOpen() {
|
public boolean isDialogOpen() {
|
||||||
return mDialogOpen;
|
Dialog dialog = getDialog();
|
||||||
|
return dialog != null && dialog.isShowing();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDialogClosed(boolean positiveResult) {
|
protected void onDialogClosed(boolean positiveResult) {
|
||||||
super.onDialogClosed(positiveResult);
|
super.onDialogClosed(positiveResult);
|
||||||
mDialogOpen = false;
|
|
||||||
if (mPinListener != null) {
|
if (mPinListener != null) {
|
||||||
mPinListener.onPinEntered(this, positiveResult);
|
mPinListener.onPinEntered(this, positiveResult);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showPinDialog() {
|
public void showPinDialog() {
|
||||||
mDialogOpen = true;
|
Dialog dialog = getDialog();
|
||||||
showDialog(null);
|
if (dialog == null || !dialog.isShowing()) {
|
||||||
|
showDialog(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -261,10 +261,13 @@ public class IccLockSettings extends PreferenceActivity
|
|||||||
mPinToggle.setChecked(!mToState);
|
mPinToggle.setChecked(!mToState);
|
||||||
mDialogState = ICC_LOCK_MODE;
|
mDialogState = ICC_LOCK_MODE;
|
||||||
showPinDialog();
|
showPinDialog();
|
||||||
|
} else if (preference == mPinDialog) {
|
||||||
|
mDialogState = ICC_OLD_MODE;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tryChangeIccLockState() {
|
private void tryChangeIccLockState() {
|
||||||
// Try to change icc lock. If it succeeds, toggle the lock state and
|
// Try to change icc lock. If it succeeds, toggle the lock state and
|
||||||
// reset dialog state. Else inject error message and show dialog again.
|
// reset dialog state. Else inject error message and show dialog again.
|
||||||
@@ -277,7 +280,6 @@ public class IccLockSettings extends PreferenceActivity
|
|||||||
if (success) {
|
if (success) {
|
||||||
mPinToggle.setChecked(mToState);
|
mPinToggle.setChecked(mToState);
|
||||||
} else {
|
} else {
|
||||||
// TODO: I18N
|
|
||||||
Toast.makeText(this, mRes.getString(R.string.sim_lock_failed), Toast.LENGTH_SHORT)
|
Toast.makeText(this, mRes.getString(R.string.sim_lock_failed), Toast.LENGTH_SHORT)
|
||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
@@ -286,7 +288,6 @@ public class IccLockSettings extends PreferenceActivity
|
|||||||
|
|
||||||
private void iccPinChanged(boolean success) {
|
private void iccPinChanged(boolean success) {
|
||||||
if (!success) {
|
if (!success) {
|
||||||
// TODO: I18N
|
|
||||||
Toast.makeText(this, mRes.getString(R.string.sim_change_failed),
|
Toast.makeText(this, mRes.getString(R.string.sim_change_failed),
|
||||||
Toast.LENGTH_SHORT)
|
Toast.LENGTH_SHORT)
|
||||||
.show();
|
.show();
|
||||||
@@ -304,7 +305,7 @@ public class IccLockSettings extends PreferenceActivity
|
|||||||
mPhone.getIccCard().changeIccLockPassword(mOldPin,
|
mPhone.getIccCard().changeIccLockPassword(mOldPin,
|
||||||
mNewPin, callback);
|
mNewPin, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean reasonablePin(String pin) {
|
private boolean reasonablePin(String pin) {
|
||||||
if (pin == null || pin.length() < MIN_PIN_LENGTH || pin.length() > MAX_PIN_LENGTH) {
|
if (pin == null || pin.length() < MIN_PIN_LENGTH || pin.length() > MAX_PIN_LENGTH) {
|
||||||
return false;
|
return false;
|
||||||
@@ -312,11 +313,12 @@ public class IccLockSettings extends PreferenceActivity
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetDialogState() {
|
private void resetDialogState() {
|
||||||
mError = null;
|
mError = null;
|
||||||
mDialogState = ICC_OLD_MODE; // Default for when Change PIN is clicked
|
mDialogState = ICC_OLD_MODE; // Default for when Change PIN is clicked
|
||||||
mPin = "";
|
mPin = "";
|
||||||
setDialogValues();
|
setDialogValues();
|
||||||
|
mDialogState = OFF_MODE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user