[Settings] Implement APIs in PhoneInterfaceManager
Bug: 146983487
Test: manual
Change-Id: I1a6165d1add167e1acf070d94532730fb645f38e
Merged-In: I1a6165d1add167e1acf070d94532730fb645f38e
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 1873482..2191bfc 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -271,6 +271,10 @@
private static final int EVENT_SET_FORBIDDEN_PLMNS_DONE = 73;
private static final int CMD_ERASE_MODEM_CONFIG = 74;
private static final int EVENT_ERASE_MODEM_CONFIG_DONE = 75;
+ private static final int CMD_CHANGE_ICC_LOCK_PASSWORD = 76;
+ private static final int EVENT_CHANGE_ICC_LOCK_PASSWORD_DONE = 77;
+ private static final int CMD_SET_ICC_LOCK_ENABLED = 78;
+ private static final int EVENT_SET_ICC_LOCK_ENABLED_DONE = 79;
private static final int CMD_GET_CALL_FORWARDING = 83;
private static final int EVENT_GET_CALL_FORWARDING_DONE = 84;
private static final int CMD_SET_CALL_FORWARDING = 85;
@@ -1384,6 +1388,43 @@
case EVENT_ERASE_MODEM_CONFIG_DONE:
handleNullReturnEvent(msg, "eraseModemConfig");
break;
+
+ case CMD_CHANGE_ICC_LOCK_PASSWORD:
+ request = (MainThreadRequest) msg.obj;
+ onCompleted = obtainMessage(EVENT_CHANGE_ICC_LOCK_PASSWORD_DONE, request);
+ Pair<String, String> changed = (Pair<String, String>) request.argument;
+ getPhoneFromRequest(request).getIccCard().changeIccLockPassword(
+ changed.first, changed.second, onCompleted);
+ break;
+ case EVENT_CHANGE_ICC_LOCK_PASSWORD_DONE:
+ ar = (AsyncResult) msg.obj;
+ request = (MainThreadRequest) ar.userObj;
+ if (ar.exception == null) {
+ request.result = TelephonyManager.CHANGE_ICC_LOCK_SUCCESS;
+ } else {
+ request.result = msg.arg1;
+ }
+ notifyRequester(request);
+ break;
+
+ case CMD_SET_ICC_LOCK_ENABLED:
+ request = (MainThreadRequest) msg.obj;
+ onCompleted = obtainMessage(EVENT_SET_ICC_LOCK_ENABLED_DONE, request);
+ Pair<Boolean, String> enabled = (Pair<Boolean, String>) request.argument;
+ getPhoneFromRequest(request).getIccCard().setIccLockEnabled(
+ enabled.first, enabled.second, onCompleted);
+ break;
+ case EVENT_SET_ICC_LOCK_ENABLED_DONE:
+ ar = (AsyncResult) msg.obj;
+ request = (MainThreadRequest) ar.userObj;
+ if (ar.exception == null) {
+ request.result = TelephonyManager.CHANGE_ICC_LOCK_SUCCESS;
+ } else {
+ request.result = msg.arg1;
+ }
+ notifyRequester(request);
+ break;
+
default:
Log.w(LOG_TAG, "MainThreadHandler: unexpected message code: " + msg.what);
break;
@@ -8305,4 +8346,82 @@
Rlog.e(LOG_TAG, "fail to getImsConfig " + e.getMessage());
}
}
+
+ @Override
+ public boolean isIccLockEnabled(int subId) {
+ enforceReadPrivilegedPermission("isIccLockEnabled");
+
+ // Now that all security checks passes, perform the operation as ourselves.
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ Phone phone = getPhone(subId);
+ if (phone != null && phone.getIccCard() != null) {
+ return phone.getIccCard().getIccLockEnabled();
+ } else {
+ return false;
+ }
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ }
+
+ /**
+ * Set the ICC pin lock enabled or disabled..
+ *
+ * @return Integer.MAX_VALUE if enable/disable IccLock successfully. If failed it will return
+ * 0 or a positive integer as the attempts remaining value.
+ *
+ */
+ @Override
+ public int setIccLockEnabled(int subId, boolean enabled, String password) {
+ enforceModifyPermission();
+
+ Phone phone = getPhone(subId);
+ if (phone == null) {
+ return 0;
+ }
+ // Now that all security checks passes, perform the operation as ourselves.
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ int attemptsRemaining = (int) sendRequest(CMD_SET_ICC_LOCK_ENABLED,
+ new Pair<Boolean, String>(enabled, password), phone, null);
+ return attemptsRemaining;
+
+ } catch (Exception e) {
+ Log.e(LOG_TAG, "setIccLockEnabled. Exception e =" + e);
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ return 0;
+ }
+
+ /**
+ * Change the ICC password used in ICC pin lock.
+ *
+ * @return Integer.MAX_VALUE if enable/disable IccLock successfully. If failed it will return
+ * 0 or a positive integer as the attempts remaining value.
+ *
+ */
+ @Override
+ public int changeIccLockPassword(int subId, String oldPassword, String newPassword) {
+ enforceModifyPermission();
+
+ Phone phone = getPhone(subId);
+ if (phone == null) {
+ return 0;
+ }
+ // Now that all security checks passes, perform the operation as ourselves.
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ int attemptsRemaining = (int) sendRequest(CMD_CHANGE_ICC_LOCK_PASSWORD,
+ new Pair<String, String>(oldPassword, newPassword), phone, null);
+ return attemptsRemaining;
+
+ } catch (Exception e) {
+ Log.e(LOG_TAG, "changeIccLockPassword. Exception e =" + e);
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ return 0;
+ }
}