Update ICC lock API methods
Test: atest TelephonyManagerTest Bug: 171884262 Change-Id: Ia4ba222dfa7d7756a3675f75b3467d0265967516
This commit is contained in:
@@ -30,6 +30,7 @@ import android.os.Handler;
|
|||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.PersistableBundle;
|
import android.os.PersistableBundle;
|
||||||
import android.telephony.CarrierConfigManager;
|
import android.telephony.CarrierConfigManager;
|
||||||
|
import android.telephony.PinResult;
|
||||||
import android.telephony.SubscriptionInfo;
|
import android.telephony.SubscriptionInfo;
|
||||||
import android.telephony.SubscriptionManager;
|
import android.telephony.SubscriptionManager;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
@@ -532,30 +533,25 @@ public class IccLockSettings extends SettingsPreferenceFragment
|
|||||||
mPinToggle.setEnabled(false);
|
mPinToggle.setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SetIccLockEnabled extends AsyncTask<Void, Void, Void> {
|
private class SetIccLockEnabled extends AsyncTask<Void, Void, PinResult> {
|
||||||
private final boolean mState;
|
private final boolean mState;
|
||||||
private final String mPassword;
|
private final String mPin;
|
||||||
private int mAttemptsRemaining;
|
|
||||||
|
|
||||||
private SetIccLockEnabled(boolean state, String pin) {
|
private SetIccLockEnabled(boolean state, String pin) {
|
||||||
mState = state;
|
mState = state;
|
||||||
mPassword = pin;
|
mPin = pin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Void... params) {
|
protected PinResult doInBackground(Void... params) {
|
||||||
mTelephonyManager = mTelephonyManager.createForSubscriptionId(mSubId);
|
mTelephonyManager = mTelephonyManager.createForSubscriptionId(mSubId);
|
||||||
mAttemptsRemaining = mTelephonyManager.setIccLockEnabled(mState, mPassword);
|
return mTelephonyManager.setIccLockEnabled(mState, mPin);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Void aVoid) {
|
protected void onPostExecute(PinResult pinResult) {
|
||||||
if (mAttemptsRemaining == TelephonyManager.CHANGE_ICC_LOCK_SUCCESS) {
|
iccLockChanged(pinResult.getResult() == PinResult.PIN_RESULT_TYPE_SUCCESS /* success */,
|
||||||
iccLockChanged(true, mAttemptsRemaining);
|
pinResult.getAttemptsRemaining() /* attemptsRemaining */);
|
||||||
} else {
|
|
||||||
iccLockChanged(false, mAttemptsRemaining);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -641,33 +637,28 @@ public class IccLockSettings extends SettingsPreferenceFragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void tryChangePin() {
|
private void tryChangePin() {
|
||||||
new ChangeIccLockPassword(mOldPin, mNewPin).execute();
|
new ChangeIccLockPin(mOldPin, mNewPin).execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ChangeIccLockPassword extends AsyncTask<Void, Void, Void> {
|
private class ChangeIccLockPin extends AsyncTask<Void, Void, PinResult> {
|
||||||
private final String mOldPwd;
|
private final String mOldPin;
|
||||||
private final String mNewPwd;
|
private final String mNewPin;
|
||||||
private int mAttemptsRemaining;
|
|
||||||
|
|
||||||
private ChangeIccLockPassword(String oldPin, String newPin) {
|
private ChangeIccLockPin(String oldPin, String newPin) {
|
||||||
mOldPwd = oldPin;
|
mOldPin = oldPin;
|
||||||
mNewPwd = newPin;
|
mNewPin = newPin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Void... params) {
|
protected PinResult doInBackground(Void... params) {
|
||||||
mTelephonyManager = mTelephonyManager.createForSubscriptionId(mSubId);
|
mTelephonyManager = mTelephonyManager.createForSubscriptionId(mSubId);
|
||||||
mAttemptsRemaining = mTelephonyManager.changeIccLockPassword(mOldPwd, mNewPwd);
|
return mTelephonyManager.changeIccLockPin(mOldPin, mNewPin);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Void aVoid) {
|
protected void onPostExecute(PinResult pinResult) {
|
||||||
if (mAttemptsRemaining == TelephonyManager.CHANGE_ICC_LOCK_SUCCESS) {
|
iccPinChanged(pinResult.getResult() == PinResult.PIN_RESULT_TYPE_SUCCESS /* success */,
|
||||||
iccPinChanged(true, mAttemptsRemaining);
|
pinResult.getAttemptsRemaining() /* attemptsRemaining */);
|
||||||
} else {
|
|
||||||
iccPinChanged(false, mAttemptsRemaining);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user