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