use of com.android.internal.telephony.CommandException in project android_frameworks_opt_telephony by LineageOS.
the class GsmMmiCode method onSetComplete.
private void onSetComplete(Message msg, 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()) {
// 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 if (err == CommandException.Error.FDN_CHECK_FAILURE) {
Rlog.i(LOG_TAG, "FDN_CHECK_FAILURE");
sb.append(mContext.getText(com.android.internal.R.string.mmiFdnError));
} else if (err == CommandException.Error.MODEM_ERR) {
// and will return an error from the modem.
if (isServiceCodeCallForwarding(mSc) && mPhone.getServiceState().getVoiceRoaming() && !mPhone.supports3gppCallForwardingWhileRoaming()) {
sb.append(mContext.getText(com.android.internal.R.string.mmiErrorWhileRoaming));
} else {
sb.append(getErrorMessage(ar));
}
} else {
sb.append(getErrorMessage(ar));
}
} else {
sb.append(mContext.getText(com.android.internal.R.string.mmiError));
}
} else if (isActivate()) {
mState = State.COMPLETE;
if (mIsCallFwdReg) {
sb.append(mContext.getText(com.android.internal.R.string.serviceRegistered));
} else {
sb.append(mContext.getText(com.android.internal.R.string.serviceEnabled));
}
// Record CLIR setting
if (mSc.equals(SC_CLIR)) {
mPhone.saveClirSetting(CommandsInterface.CLIR_INVOCATION);
}
} else if (isDeactivate()) {
mState = State.COMPLETE;
sb.append(mContext.getText(com.android.internal.R.string.serviceDisabled));
// Record CLIR setting
if (mSc.equals(SC_CLIR)) {
mPhone.saveClirSetting(CommandsInterface.CLIR_SUPPRESSION);
}
} else if (isRegister()) {
mState = State.COMPLETE;
sb.append(mContext.getText(com.android.internal.R.string.serviceRegistered));
} else if (isErasure()) {
mState = State.COMPLETE;
sb.append(mContext.getText(com.android.internal.R.string.serviceErased));
} else {
mState = State.FAILED;
sb.append(mContext.getText(com.android.internal.R.string.mmiError));
}
mMessage = sb;
Rlog.d(LOG_TAG, "onSetComplete mmi=" + this);
mPhone.onMMIDone(this);
}
use of com.android.internal.telephony.CommandException in project XobotOS by xamarin.
the class SimulatedCommands method supplyIccPin.
public void supplyIccPin(String pin, Message result) {
if (mSimLockedState != SimLockState.REQUIRE_PIN) {
Log.i(LOG_TAG, "[SimCmd] supplyIccPin: wrong state, state=" + mSimLockedState);
CommandException ex = new CommandException(CommandException.Error.PASSWORD_INCORRECT);
AsyncResult.forMessage(result, null, ex);
result.sendToTarget();
return;
}
if (pin != null && pin.equals(mPinCode)) {
Log.i(LOG_TAG, "[SimCmd] supplyIccPin: success!");
setRadioState(RadioState.SIM_READY);
mPinUnlockAttempts = 0;
mSimLockedState = SimLockState.NONE;
if (result != null) {
AsyncResult.forMessage(result, null, null);
result.sendToTarget();
}
return;
}
if (result != null) {
mPinUnlockAttempts++;
Log.i(LOG_TAG, "[SimCmd] supplyIccPin: failed! attempt=" + mPinUnlockAttempts);
if (mPinUnlockAttempts >= 3) {
Log.i(LOG_TAG, "[SimCmd] supplyIccPin: set state to REQUIRE_PUK");
mSimLockedState = SimLockState.REQUIRE_PUK;
}
CommandException ex = new CommandException(CommandException.Error.PASSWORD_INCORRECT);
AsyncResult.forMessage(result, null, ex);
result.sendToTarget();
}
}
use of com.android.internal.telephony.CommandException in project XobotOS by xamarin.
the class SimulatedCommands method changeIccPin.
public void changeIccPin(String oldPin, String newPin, Message result) {
if (oldPin != null && oldPin.equals(mPinCode)) {
mPinCode = newPin;
if (result != null) {
AsyncResult.forMessage(result, null, null);
result.sendToTarget();
}
return;
}
if (result != null) {
Log.i(LOG_TAG, "[SimCmd] changeIccPin: pin failed!");
CommandException ex = new CommandException(CommandException.Error.PASSWORD_INCORRECT);
AsyncResult.forMessage(result, null, ex);
result.sendToTarget();
}
}
use of com.android.internal.telephony.CommandException in project XobotOS by xamarin.
the class SimulatedCommands method changeIccPin2.
public void changeIccPin2(String oldPin2, String newPin2, Message result) {
if (oldPin2 != null && oldPin2.equals(mPin2Code)) {
mPin2Code = newPin2;
if (result != null) {
AsyncResult.forMessage(result, null, null);
result.sendToTarget();
}
return;
}
if (result != null) {
Log.i(LOG_TAG, "[SimCmd] changeIccPin2: pin2 failed!");
CommandException ex = new CommandException(CommandException.Error.PASSWORD_INCORRECT);
AsyncResult.forMessage(result, null, ex);
result.sendToTarget();
}
}
use of com.android.internal.telephony.CommandException in project XobotOS by xamarin.
the class SimulatedCommands method setFacilityLockForApp.
@Override
public void setFacilityLockForApp(String facility, boolean lockEnabled, String pin, int serviceClass, String appId, Message result) {
if (facility != null && facility.equals(CommandsInterface.CB_FACILITY_BA_SIM)) {
if (pin != null && pin.equals(mPinCode)) {
Log.i(LOG_TAG, "[SimCmd] setFacilityLock: pin is valid");
mSimLockEnabled = lockEnabled;
if (result != null) {
AsyncResult.forMessage(result, null, null);
result.sendToTarget();
}
return;
}
if (result != null) {
Log.i(LOG_TAG, "[SimCmd] setFacilityLock: pin failed!");
CommandException ex = new CommandException(CommandException.Error.GENERIC_FAILURE);
AsyncResult.forMessage(result, null, ex);
result.sendToTarget();
}
return;
} else if (facility != null && facility.equals(CommandsInterface.CB_FACILITY_BA_FD)) {
if (pin != null && pin.equals(mPin2Code)) {
Log.i(LOG_TAG, "[SimCmd] setFacilityLock: pin2 is valid");
mSimFdnEnabled = lockEnabled;
if (result != null) {
AsyncResult.forMessage(result, null, null);
result.sendToTarget();
}
return;
}
if (result != null) {
Log.i(LOG_TAG, "[SimCmd] setFacilityLock: pin2 failed!");
CommandException ex = new CommandException(CommandException.Error.GENERIC_FAILURE);
AsyncResult.forMessage(result, null, ex);
result.sendToTarget();
}
return;
}
unimplemented(result);
}
Aggregations