Fields Summary |
---|
private static final boolean | DBG |
private static final int | EVENT_SIM_UNLOCKED_RESULT |
private SimLockState | mState |
private String | mPUKCode |
private String | mNewPinCode |
private android.widget.EditText | mEntry |
private android.widget.TextView | mFailure |
private android.widget.TextView | mLabel |
private android.widget.TextView | mStatus |
private android.widget.Button | mUnlockButton |
private android.widget.Button | mDismissButton |
private android.widget.LinearLayout | mUnlockPane |
private android.widget.LinearLayout | mUnlockInProgressPane |
private android.os.Handler | mHandler |
View.OnClickListener | mUnlockListener |
View.OnClickListener | mDismissListener |
Methods Summary |
---|
com.android.phone.SimPinUnlockPanel$SimLockState | getState()
return mState;
|
void | handleFailure()
if (DBG) log("unlock failed");
showIncorrectPinMessage();
mEntry.getText().clear();
updateState();
updateView();
|
void | handleSuccess()
if (DBG) log("unlock successful!");
showUnlockSuccess();
// store the SIM pin in memory, to be used later for keyguard lock
// and radio reboots.
PhoneApp.getInstance().setCachedSimPin(mEntry.getText().toString());
|
void | handleUnlockResult(android.os.AsyncResult ar)
if (ar.exception == null) {
handleSuccess();
return;
}
// pin/puk unlock failed!
if (ar.exception instanceof com.android.internal.telephony.gsm.CommandException &&
((CommandException) ar.exception).getCommandError() ==
CommandException.Error.PASSWORD_INCORRECT) {
hidePinUnlockInProgress();
handleFailure();
}
// PENDING: any other failure types?
|
void | hideIncorrectPinMessage()
mFailure.setVisibility(View.GONE);
|
void | hidePinUnlockInProgress()
mUnlockInProgressPane.setVisibility(View.GONE);
mUnlockPane.setVisibility(View.VISIBLE);
|
void | initView()
mUnlockPane = (LinearLayout) findViewById(R.id.simPINPane);
mUnlockInProgressPane = (LinearLayout) findViewById(R.id.progress);
mEntry = (EditText) findViewById(R.id.entry);
mEntry.setKeyListener(DialerKeyListener.getInstance());
mEntry.setMovementMethod(null);
mEntry.setOnClickListener(mUnlockListener);
// set up the text watcher
CharSequence text = mEntry.getText();
Spannable span = (Spannable) text;
span.setSpan(new MyTextWatcher(this.getContext()),
0, text.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
mFailure = (TextView) findViewById(R.id.failure);
mLabel = (TextView) findViewById(R.id.label);
mStatus = (TextView) findViewById(R.id.status);
mUnlockButton = (Button) findViewById(R.id.unlock);
mUnlockButton.setOnClickListener(mUnlockListener);
mDismissButton = (Button) findViewById(R.id.dismiss);
// if we are using the SIM pin for keyguard password, force the
// user to enter the correct PIN to proceed. Otherwise, we won't
// know what the correct keyguard password is.
mDismissButton.setOnClickListener(mDismissListener);
|
private void | log(java.lang.String msg)
Log.v(TAG, "[SimPinUnlock] " + msg);
|
protected void | onCreate(android.os.Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.sim_unlock);
updateState();
initView();
updateView();
|
public boolean | onKeyDown(int keyCode, android.view.KeyEvent event)
if (keyCode == KeyEvent.KEYCODE_BACK) {
return true;
}
return super.onKeyDown(keyCode, event);
|
protected void | onStart()
super.onStart();
if (updateState()) {
updateView(); // need to update the view only if state changed
}
|
void | setState(com.android.phone.SimPinUnlockPanel$SimLockState state)
mState = state;
|
void | showIncorrectPinMessage()
CharSequence msg;
Context context = getContext();
if (getState() == SimLockState.REQUIRE_PIN) {
msg = context.getText(R.string.badPin);
} else {
msg = context.getText(R.string.badPuk);
}
mFailure.setText(msg);
mFailure.setVisibility(View.VISIBLE);
|
void | showUnlockInProgress()
mUnlockInProgressPane.setVisibility(View.VISIBLE);
mUnlockPane.setVisibility(View.GONE);
|
void | showUnlockSuccess()
mStatus.setText(getContext().getText(R.string.pinUnlocked));
mHandler.postDelayed(
new Runnable() {
public void run() {
dismiss();
}
}, 1000);
|
boolean | updateState()
PhoneApp app = PhoneApp.getInstance();
SimCard simCardInterface = app.phone.getSimCard();
try {
if (simCardInterface.getState() == SimCard.State.PUK_REQUIRED) {
if (getState() != SimLockState.REQUIRE_PUK) {
setState(SimLockState.REQUIRE_PUK);
return true;
}
} else if (getState() != SimLockState.REQUIRE_PIN){
setState(SimLockState.REQUIRE_PIN);
return true;
}
} catch (Exception ex) {
}
return false;
|
void | updateView()
Context context = getContext();
switch (mState) {
case REQUIRE_PIN:
mLabel.setText(context.getText(R.string.enterPin));
break;
case REQUIRE_PUK:
mLabel.setText(context.getText(R.string.enterPuk));
mUnlockButton.setText(
context.getText(R.string.buttonTxtContinue));
break;
case REQUIRE_NEW_PIN:
hideIncorrectPinMessage();
mLabel.setText(context.getText(R.string.enterNewPin));
break;
case VERIFY_NEW_PIN:
mLabel.setText(context.getText(R.string.verifyNewPin));
break;
case VERIFY_NEW_PIN_FAILED:
mLabel.setText(context.getText(R.string.verifyFailed));
setState(SimLockState.REQUIRE_NEW_PIN);
break;
}
mEntry.getText().clear();
mEntry.requestFocus(View.FOCUS_FORWARD);
|
private boolean | verifyNewPin(java.lang.String pin2)
if (mNewPinCode.equals(pin2)) {
return true;
}
return false;
|