FileDocCategorySizeDatePackage
KeyguardSimPukView.javaAPI DocAndroid 5.1 API13769Thu Mar 12 22:22:42 GMT 2015com.android.keyguard

KeyguardSimPukView

public class KeyguardSimPukView extends KeyguardPinBasedInputView
Displays a PIN pad for entering a PUK (Pin Unlock Kode) provided by a carrier.

Fields Summary
private static final String
LOG_TAG
private static final boolean
DEBUG
public static final String
TAG
private android.app.ProgressDialog
mSimUnlockProgressDialog
private CheckSimPuk
mCheckSimPukThread
private String
mPukText
private String
mPinText
private StateMachine
mStateMachine
private android.app.AlertDialog
mRemainingAttemptsDialog
private int
mSubId
private android.widget.ImageView
mSimImageView
KeyguardUpdateMonitorCallback
mUpdateMonitorCallback
Constructors Summary
public KeyguardSimPukView(android.content.Context context)


       
        this(context, null);
    
public KeyguardSimPukView(android.content.Context context, android.util.AttributeSet attrs)

        super(context, attrs);
    
Methods Summary
private booleancheckPin()

        // make sure the PIN is between 4 and 8 digits
        int length = mPasswordEntry.getText().length();
        if (length >= 4 && length <= 8) {
            mPinText = mPasswordEntry.getText();
            return true;
        }
        return false;
    
private booleancheckPuk()

        // make sure the puk is at least 8 digits long.
        if (mPasswordEntry.getText().length() == 8) {
            mPukText = mPasswordEntry.getText();
            return true;
        }
        return false;
    
public booleanconfirmPin()

        return mPinText.equals(mPasswordEntry.getText());
    
protected intgetPasswordTextViewId()

        return R.id.pukEntry;
    
private java.lang.StringgetPukPasswordErrorMessage(int attemptsRemaining)

        String displayMessage;

        if (attemptsRemaining == 0) {
            displayMessage = getContext().getString(R.string.kg_password_wrong_puk_code_dead);
        } else if (attemptsRemaining > 0) {
            displayMessage = getContext().getResources()
                    .getQuantityString(R.plurals.kg_password_wrong_puk_code, attemptsRemaining,
                            attemptsRemaining);
        } else {
            displayMessage = getContext().getString(R.string.kg_password_puk_failed);
        }
        if (DEBUG) Log.d(LOG_TAG, "getPukPasswordErrorMessage:"
                + " attemptsRemaining=" + attemptsRemaining + " displayMessage=" + displayMessage);
        return displayMessage;
    
private android.app.DialoggetPukRemainingAttemptsDialog(int remaining)

        String msg = getPukPasswordErrorMessage(remaining);
        if (mRemainingAttemptsDialog == null) {
            AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
            builder.setMessage(msg);
            builder.setCancelable(false);
            builder.setNeutralButton(R.string.ok, null);
            mRemainingAttemptsDialog = builder.create();
            mRemainingAttemptsDialog.getWindow().setType(
                    WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
        } else {
            mRemainingAttemptsDialog.setMessage(msg);
        }
        return mRemainingAttemptsDialog;
    
private android.app.DialoggetSimUnlockProgressDialog()

        if (mSimUnlockProgressDialog == null) {
            mSimUnlockProgressDialog = new ProgressDialog(mContext);
            mSimUnlockProgressDialog.setMessage(
                    mContext.getString(R.string.kg_sim_unlock_progress_dialog_message));
            mSimUnlockProgressDialog.setIndeterminate(true);
            mSimUnlockProgressDialog.setCancelable(false);
            if (!(mContext instanceof Activity)) {
                mSimUnlockProgressDialog.getWindow().setType(
                        WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
            }
        }
        return mSimUnlockProgressDialog;
    
protected voidonAttachedToWindow()

        super.onAttachedToWindow();
        KeyguardUpdateMonitor.getInstance(mContext).registerCallback(mUpdateMonitorCallback);
    
protected voidonDetachedFromWindow()

        super.onDetachedFromWindow();
        KeyguardUpdateMonitor.getInstance(mContext).removeCallback(mUpdateMonitorCallback);
    
protected voidonFinishInflate()

        super.onFinishInflate();

        mSecurityMessageDisplay.setTimeout(0); // don't show ownerinfo/charging status by default
        if (mEcaView instanceof EmergencyCarrierArea) {
            ((EmergencyCarrierArea) mEcaView).setCarrierTextVisible(true);
        }
        mSimImageView = (ImageView) findViewById(R.id.keyguard_sim);
    
public voidonPause()

        // dismiss the dialog.
        if (mSimUnlockProgressDialog != null) {
            mSimUnlockProgressDialog.dismiss();
            mSimUnlockProgressDialog = null;
        }
    
public voidresetState()

        super.resetState();
        mStateMachine.reset();
    
protected booleanshouldLockout(long deadline)

        // SIM PUK doesn't have a timed lockout
        return false;
    
public voidshowUsabilityHint()

    
public voidstartAppearAnimation()

        // noop.
    
public booleanstartDisappearAnimation(java.lang.Runnable finishRunnable)

        return false;
    
private voidupdateSim()

        getSimUnlockProgressDialog().show();

        if (mCheckSimPukThread == null) {
            mCheckSimPukThread = new CheckSimPuk(mPukText, mPinText, mSubId) {
                void onSimLockChangedResponse(final int result, final int attemptsRemaining) {
                    post(new Runnable() {
                        public void run() {
                            if (mSimUnlockProgressDialog != null) {
                                mSimUnlockProgressDialog.hide();
                            }
                            resetPasswordText(true /* animate */);
                            if (result == PhoneConstants.PIN_RESULT_SUCCESS) {
                                KeyguardUpdateMonitor.getInstance(getContext())
                                        .reportSimUnlocked(mSubId);
                                mCallback.dismiss(true);
                            } else {
                                if (result == PhoneConstants.PIN_PASSWORD_INCORRECT) {
                                    if (attemptsRemaining <= 2) {
                                        // this is getting critical - show dialog
                                        getPukRemainingAttemptsDialog(attemptsRemaining).show();
                                    } else {
                                        // show message
                                        mSecurityMessageDisplay.setMessage(
                                                getPukPasswordErrorMessage(attemptsRemaining), true);
                                    }
                                } else {
                                    mSecurityMessageDisplay.setMessage(getContext().getString(
                                            R.string.kg_password_puk_failed), true);
                                }
                                if (DEBUG) Log.d(LOG_TAG, "verifyPasswordAndUnlock "
                                        + " UpdateSim.onSimCheckResponse: "
                                        + " attemptsRemaining=" + attemptsRemaining);
                                mStateMachine.reset();
                            }
                            mCheckSimPukThread = null;
                        }
                    });
                }
            };
            mCheckSimPukThread.start();
        }
    
protected voidverifyPasswordAndUnlock()

        mStateMachine.next();