Exemple #1
0
  /** Process a MMI PUK code */
  void processCode() {
    try {
      if (isPinPukCommand()) {
        // TODO: This is the same as the code in GsmMmiCode.java,
        // MmiCode should be an abstract or base class and this and
        // other common variables and code should be promoted.

        // sia = old PIN or PUK
        // sib = new PIN
        // sic = new PIN
        String oldPinOrPuk = mSia;
        String newPinOrPuk = mSib;
        int pinLen = newPinOrPuk.length();
        if (isRegister()) {
          if (!newPinOrPuk.equals(mSic)) {
            // password mismatch; return error
            handlePasswordError(com.android.internal.R.string.mismatchPin);
          } else if (pinLen < 4 || pinLen > 8) {
            // invalid length
            handlePasswordError(com.android.internal.R.string.invalidPin);
          } else if (mSc.equals(SC_PIN)
              && mUiccApplication != null
              && mUiccApplication.getState() == AppState.APPSTATE_PUK) {
            // Sim is puk-locked
            handlePasswordError(com.android.internal.R.string.needPuk);
          } else if (mUiccApplication != null) {
            Rlog.d(LOG_TAG, "process mmi service code using UiccApp sc=" + mSc);

            // We have an app and the pre-checks are OK
            if (mSc.equals(SC_PIN)) {
              mUiccApplication.changeIccLockPassword(
                  oldPinOrPuk, newPinOrPuk, obtainMessage(EVENT_SET_COMPLETE, this));
            } else if (mSc.equals(SC_PIN2)) {
              mUiccApplication.changeIccFdnPassword(
                  oldPinOrPuk, newPinOrPuk, obtainMessage(EVENT_SET_COMPLETE, this));
            } else if (mSc.equals(SC_PUK)) {
              mUiccApplication.supplyPuk(
                  oldPinOrPuk, newPinOrPuk, obtainMessage(EVENT_SET_COMPLETE, this));
            } else if (mSc.equals(SC_PUK2)) {
              mUiccApplication.supplyPuk2(
                  oldPinOrPuk, newPinOrPuk, obtainMessage(EVENT_SET_COMPLETE, this));
            } else {
              throw new RuntimeException("Unsupported service code=" + mSc);
            }
          } else {
            throw new RuntimeException("No application mUiccApplicaiton is null");
          }
        } else {
          throw new RuntimeException("Ivalid register/action=" + mAction);
        }
      }
    } catch (RuntimeException exc) {
      mState = State.FAILED;
      mMessage = mContext.getText(com.android.internal.R.string.mmiError);
      mPhone.onMMIDone(this);
    }
  }