FileDocCategorySizeDatePackage
EnableSimPinScreen.javaAPI DocAndroid 1.5 API4720Wed May 06 22:42:46 BST 2009com.android.phone

EnableSimPinScreen

public class EnableSimPinScreen extends android.app.Activity
UI to enable/disable the SIM PIN.

Fields Summary
private static final String
LOG_TAG
private static final int
ENABLE_SIM_PIN_COMPLETE
private static final boolean
DBG
private android.widget.LinearLayout
mPinFieldContainer
private android.widget.EditText
mPinField
private android.widget.TextView
mStatusField
private boolean
mEnable
private com.android.internal.telephony.Phone
mPhone
private android.os.Handler
mHandler
private View.OnClickListener
mClicked
Constructors Summary
Methods Summary
private voidenableSimPin()

        Message callback = Message.obtain(mHandler, ENABLE_SIM_PIN_COMPLETE);
        if (DBG) log("enableSimPin:");
        mPhone.getSimCard().setSimLockEnabled(mEnable, getPin(), callback);
        if (DBG) log("enableSimPin: please wait...");
    
private java.lang.StringgetPin()

        return mPinField.getText().toString();
    
private voidhandleResult(android.os.AsyncResult ar)

        if (ar.exception == null) {
            if (DBG) log("handleResult: success!");
            showStatus(getResources().getText(
                    mEnable ? R.string.enable_pin_ok : R.string.disable_pin_ok));
        } else if (ar.exception instanceof CommandException
                /* && ((CommandException)ar.exception).getCommandError() ==
                    CommandException.Error.GENERIC_FAILURE */ ) {
            if (DBG) log("handleResult: failed!");
            showStatus(getResources().getText(
                    R.string.pin_failed));
        }

        mHandler.postDelayed(new Runnable() {
            public void run() {
                finish();
            }
        }, 3000);
    
private voidlog(java.lang.String msg)


        
        Log.d(LOG_TAG, "[EnableSimPin] " + msg);
    
protected voidonCreate(android.os.Bundle icicle)


    
        
        super.onCreate(icicle);

        setContentView(R.layout.enable_sim_pin_screen);
        setupView();

        mPhone = PhoneFactory.getDefaultPhone();
        mEnable = !mPhone.getSimCard().getSimLockEnabled();

        int id = mEnable ? R.string.enable_sim_pin : R.string.disable_sim_pin;
        setTitle(getResources().getText(id));
    
private voidsetupView()

        mPinField = (EditText) findViewById(R.id.pin);
        mPinField.setKeyListener(DigitsKeyListener.getInstance());
        mPinField.setMovementMethod(null);
        mPinField.setOnClickListener(mClicked);

        mPinFieldContainer = (LinearLayout) findViewById(R.id.pinc);
        mStatusField = (TextView) findViewById(R.id.status);
    
private voidshowStatus(java.lang.CharSequence statusMsg)

        if (statusMsg != null) {
            mStatusField.setText(statusMsg);
            mStatusField.setVisibility(View.VISIBLE);
            mPinFieldContainer.setVisibility(View.GONE);
        } else {
            mPinFieldContainer.setVisibility(View.VISIBLE);
            mStatusField.setVisibility(View.GONE);
        }