[Settings] To avoid use APIs in IccCard directly, moving APIs into TelephonyManager.
IccCard#changeIccLockPassword IccCard#setIccLockEnabled IccCard#getIccLockEnabled Bug: 146983487 Test: manual Change-Id: I1a3c3b15063ea00d0ca59bd5395f2bca8cdfe391
This commit is contained in:
@@ -10718,6 +10718,7 @@ package android.telephony {
|
||||
public class TelephonyManager {
|
||||
method public int addDevicePolicyOverrideApn(@NonNull android.content.Context, @NonNull android.telephony.data.ApnSetting);
|
||||
method @Deprecated @RequiresPermission(android.Manifest.permission.CALL_PHONE) public void call(String, String);
|
||||
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int changeIccLockPassword(@NonNull String, @NonNull String);
|
||||
method public int checkCarrierPrivilegesForPackage(String);
|
||||
method public int checkCarrierPrivilegesForPackageAnyPhone(String);
|
||||
method public void dial(String);
|
||||
@@ -10786,6 +10787,7 @@ package android.telephony {
|
||||
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isDataEnabledForApn(int);
|
||||
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isEmergencyAssistanceEnabled();
|
||||
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isGlobalModeEnabled();
|
||||
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) @WorkerThread public boolean isIccLockEnabled();
|
||||
method @Deprecated @RequiresPermission(anyOf={android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, android.Manifest.permission.READ_PHONE_STATE}) public boolean isIdle();
|
||||
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isInEmergencySmsMode();
|
||||
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isManualNetworkSelectionAllowed();
|
||||
@@ -10820,6 +10822,7 @@ package android.telephony {
|
||||
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setDataAllowedDuringVoiceCall(boolean);
|
||||
method @Deprecated @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setDataEnabled(int, boolean);
|
||||
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setDataRoamingEnabled(boolean);
|
||||
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public int setIccLockEnabled(boolean, @NonNull String);
|
||||
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setMultiSimCarrierRestriction(boolean);
|
||||
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setOpportunisticNetworkState(boolean);
|
||||
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setPolicyDataEnabled(boolean);
|
||||
@@ -10866,6 +10869,7 @@ package android.telephony {
|
||||
field public static final int CDMA_SUBSCRIPTION_NV = 1; // 0x1
|
||||
field public static final int CDMA_SUBSCRIPTION_RUIM_SIM = 0; // 0x0
|
||||
field public static final int CDMA_SUBSCRIPTION_UNKNOWN = -1; // 0xffffffff
|
||||
field public static final int CHANGE_ICC_LOCK_SUCCESS = 2147483647; // 0x7fffffff
|
||||
field public static final int DEFAULT_PREFERRED_NETWORK_MODE = 0; // 0x0
|
||||
field public static final String EXTRA_ANOMALY_DESCRIPTION = "android.telephony.extra.ANOMALY_DESCRIPTION";
|
||||
field public static final String EXTRA_ANOMALY_ID = "android.telephony.extra.ANOMALY_ID";
|
||||
|
||||
@@ -12508,4 +12508,108 @@ public class TelephonyManager {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* The IccLock state or password was changed successfully.
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public static final int CHANGE_ICC_LOCK_SUCCESS = Integer.MAX_VALUE;
|
||||
|
||||
/**
|
||||
* Check whether ICC pin lock is enabled.
|
||||
* This is a sync call which returns the cached pin enabled state.
|
||||
*
|
||||
* @return {@code true} if ICC lock enabled, {@code false} if ICC lock disabled.
|
||||
*
|
||||
* @throws SecurityException if the caller doesn't have the permission.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
@WorkerThread
|
||||
@RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
|
||||
public boolean isIccLockEnabled() {
|
||||
try {
|
||||
ITelephony telephony = getITelephony();
|
||||
if (telephony != null) {
|
||||
return telephony.isIccLockEnabled(getSubId());
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "isIccLockEnabled RemoteException", e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the ICC pin lock enabled or disabled.
|
||||
*
|
||||
* If enable/disable ICC pin lock successfully, a value of {@link Integer#MAX_VALUE} is
|
||||
* returned.
|
||||
* If an incorrect old password is specified, the return value will indicate how many more
|
||||
* attempts the user can make to change the password before the SIM is locked.
|
||||
* Using PUK code to unlock SIM if enter the incorrect old password 3 times.
|
||||
*
|
||||
* @param enabled "true" for locked, "false" for unlocked.
|
||||
* @param password needed to change the ICC pin state, aka. Pin1
|
||||
* @return an integer representing the status of IccLock enabled or disabled in the following
|
||||
* three cases:
|
||||
* - {@link TelephonyManager#CHANGE_ICC_LOCK_SUCCESS} if enabled or disabled IccLock
|
||||
* successfully.
|
||||
* - Positive number and zero for remaining password attempts.
|
||||
* - Negative number for other failure cases (such like enabling/disabling PIN failed).
|
||||
*
|
||||
* @throws SecurityException if the caller doesn't have the permission.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
|
||||
public int setIccLockEnabled(boolean enabled, @NonNull String password) {
|
||||
checkNotNull(password, "setIccLockEnabled password can't be null.");
|
||||
try {
|
||||
ITelephony telephony = getITelephony();
|
||||
if (telephony != null) {
|
||||
return telephony.setIccLockEnabled(getSubId(), enabled, password);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "setIccLockEnabled RemoteException", e);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the ICC password used in ICC pin lock.
|
||||
*
|
||||
* If the password was changed successfully, a value of {@link Integer#MAX_VALUE} is returned.
|
||||
* If an incorrect old password is specified, the return value will indicate how many more
|
||||
* attempts the user can make to change the password before the SIM is locked.
|
||||
* Using PUK code to unlock SIM if enter the incorrect old password 3 times.
|
||||
*
|
||||
* @param oldPassword is the old password
|
||||
* @param newPassword is the new password
|
||||
* @return an integer representing the status of IccLock changed in the following three cases:
|
||||
* - {@link TelephonyManager#CHANGE_ICC_LOCK_SUCCESS} if changed IccLock successfully.
|
||||
* - Positive number and zero for remaining password attempts.
|
||||
* - Negative number for other failure cases (such like enabling/disabling PIN failed).
|
||||
*
|
||||
* @throws SecurityException if the caller doesn't have the permission.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
|
||||
public int changeIccLockPassword(@NonNull String oldPassword, @NonNull String newPassword) {
|
||||
checkNotNull(oldPassword, "changeIccLockPassword oldPassword can't be null.");
|
||||
checkNotNull(newPassword, "changeIccLockPassword newPassword can't be null.");
|
||||
try {
|
||||
ITelephony telephony = getITelephony();
|
||||
if (telephony != null) {
|
||||
return telephony.changeIccLockPassword(getSubId(), oldPassword, newPassword);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "changeIccLockPassword RemoteException", e);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2147,4 +2147,10 @@ interface ITelephony {
|
||||
* Notify Rcs auto config received.
|
||||
*/
|
||||
void notifyRcsAutoConfigurationReceived(int subId, in byte[] config, boolean isCompressed);
|
||||
|
||||
boolean isIccLockEnabled(int subId);
|
||||
|
||||
int setIccLockEnabled(int subId, boolean enabled, String password);
|
||||
|
||||
int changeIccLockPassword(int subId, String oldPassword, String newPassword);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user