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

EnableFdnScreen

public class EnableFdnScreen extends android.app.Activity
UI to enable/disable FDN.

Fields Summary
private static final String
LOG_TAG
private static final boolean
DBG
private static final int
ENABLE_FDN_COMPLETE
private android.widget.LinearLayout
mPinFieldContainer
private android.widget.EditText
mPin2Field
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 voidenableFdn()

        Message callback = Message.obtain(mHandler, ENABLE_FDN_COMPLETE);
        mPhone.getSimCard().setSimFdnEnabled(mEnable, getPin2(), callback);
        if (DBG) log("enableFdn: please wait...");
    
private java.lang.StringgetPin2()

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

        if (ar.exception == null) {
            if (DBG) log("handleResult: success!");
            showStatus(getResources().getText(mEnable ?
                            R.string.enable_fdn_ok : R.string.disable_fdn_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_fdn_screen);
        setupView();

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

        int id = mEnable ? R.string.enable_fdn : R.string.disable_fdn;
        setTitle(getResources().getText(id));
    
protected voidonResume()

        super.onResume();
    
private voidsetupView()

        mPin2Field = (EditText) findViewById(R.id.pin);
        mPin2Field.setKeyListener(DigitsKeyListener.getInstance());
        mPin2Field.setMovementMethod(null);
        mPin2Field.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);
        }