Methods Summary |
---|
public void | cancel()
// Complete or failed cannot be cancelled
if (mState == State.COMPLETE || mState == State.FAILED) {
return;
}
mState = State.CANCELLED;
mPhone.onMMIDone (this);
|
public java.lang.CharSequence | getMessage()
return mMessage;
|
public com.android.internal.telephony.Phone | getPhone()
return ((Phone) mPhone);
|
private java.lang.CharSequence | getScString()
if (mSc != null) {
if (isPinPukCommand()) {
return mContext.getText(com.android.internal.R.string.PinMmi);
}
}
return "";
|
public State | getState()
return mState;
|
public void | handleMessage(android.os.Message msg)
AsyncResult ar;
if (msg.what == EVENT_SET_COMPLETE) {
ar = (AsyncResult) (msg.obj);
onSetComplete(msg, ar);
} else {
Rlog.e(LOG_TAG, "Unexpected reply");
}
|
private void | handlePasswordError(int res)
mState = State.FAILED;
StringBuilder sb = new StringBuilder(getScString());
sb.append("\n");
sb.append(mContext.getText(res));
mMessage = sb;
mPhone.onMMIDone(this);
|
public boolean | isCancelable()
return false;
|
boolean | isPinPukCommand()
return mSc != null && (mSc.equals(SC_PIN) || mSc.equals(SC_PIN2)
|| mSc.equals(SC_PUK) || mSc.equals(SC_PUK2));
|
boolean | isRegister()
return mAction != null && mAction.equals(ACTION_REGISTER);
|
public boolean | isUssdRequest()
Rlog.w(LOG_TAG, "isUssdRequest is not implemented in CdmaMmiCode");
return false;
|
private static java.lang.String | makeEmptyNull(java.lang.String s)make empty strings be null.
Regexp returns empty strings for empty groups
if (s != null && s.length() == 0) return null;
return s;
|
public static com.android.internal.telephony.cdma.CdmaMmiCode | newFromDialString(java.lang.String dialString, CDMAPhone phone, com.android.internal.telephony.uicc.UiccCardApplication app)Check if provided string contains Mmi code in it and create corresponding
Mmi if it does
// Public Class methods
Matcher m;
CdmaMmiCode ret = null;
m = sPatternSuppService.matcher(dialString);
// Is this formatted like a standard supplementary service code?
if (m.matches()) {
ret = new CdmaMmiCode(phone,app);
ret.mPoundString = makeEmptyNull(m.group(MATCH_GROUP_POUND_STRING));
ret.mAction = makeEmptyNull(m.group(MATCH_GROUP_ACTION));
ret.mSc = makeEmptyNull(m.group(MATCH_GROUP_SERVICE_CODE));
ret.mSia = makeEmptyNull(m.group(MATCH_GROUP_SIA));
ret.mSib = makeEmptyNull(m.group(MATCH_GROUP_SIB));
ret.mSic = makeEmptyNull(m.group(MATCH_GROUP_SIC));
ret.mPwd = makeEmptyNull(m.group(MATCH_GROUP_PWD_CONFIRM));
ret.mDialingNumber = makeEmptyNull(m.group(MATCH_GROUP_DIALING_NUMBER));
}
return ret;
|
private void | onSetComplete(android.os.Message msg, android.os.AsyncResult ar)
StringBuilder sb = new StringBuilder(getScString());
sb.append("\n");
if (ar.exception != null) {
mState = State.FAILED;
if (ar.exception instanceof CommandException) {
CommandException.Error err = ((CommandException)(ar.exception)).getCommandError();
if (err == CommandException.Error.PASSWORD_INCORRECT) {
if (isPinPukCommand()) {
// look specifically for the PUK commands and adjust
// the message accordingly.
if (mSc.equals(SC_PUK) || mSc.equals(SC_PUK2)) {
sb.append(mContext.getText(
com.android.internal.R.string.badPuk));
} else {
sb.append(mContext.getText(
com.android.internal.R.string.badPin));
}
// Get the No. of retries remaining to unlock PUK/PUK2
int attemptsRemaining = msg.arg1;
if (attemptsRemaining <= 0) {
Rlog.d(LOG_TAG, "onSetComplete: PUK locked,"
+ " cancel as lock screen will handle this");
mState = State.CANCELLED;
} else if (attemptsRemaining > 0) {
Rlog.d(LOG_TAG, "onSetComplete: attemptsRemaining="+attemptsRemaining);
sb.append(mContext.getResources().getQuantityString(
com.android.internal.R.plurals.pinpuk_attempts,
attemptsRemaining, attemptsRemaining));
}
} else {
sb.append(mContext.getText(
com.android.internal.R.string.passwordIncorrect));
}
} else if (err == CommandException.Error.SIM_PUK2) {
sb.append(mContext.getText(
com.android.internal.R.string.badPin));
sb.append("\n");
sb.append(mContext.getText(
com.android.internal.R.string.needPuk2));
} else if (err == CommandException.Error.REQUEST_NOT_SUPPORTED) {
if (mSc.equals(SC_PIN)) {
sb.append(mContext.getText(com.android.internal.R.string.enablePin));
}
} else {
sb.append(mContext.getText(
com.android.internal.R.string.mmiError));
}
} else {
sb.append(mContext.getText(
com.android.internal.R.string.mmiError));
}
} else if (isRegister()) {
mState = State.COMPLETE;
sb.append(mContext.getText(
com.android.internal.R.string.serviceRegistered));
} else {
mState = State.FAILED;
sb.append(mContext.getText(
com.android.internal.R.string.mmiError));
}
mMessage = sb;
mPhone.onMMIDone(this);
|
void | processCode()Process a MMI PUK code
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);
}
|