Clear calling identity when performing phone factory reset.
Now that we have app ops we are checking whether the package making
the call is in a given UID and has its app op enabled. Hence, if
a process A calls in B, B verifies that A has a permission to ask A
to do something, and B calls API that it has permissions/app ops to
perform, then B has to clear the IPC calling identity since even if
A has permission to do the operation which B is performing on its
behalf, the app op package name of the operation will not be in A's
UID resulting in an error.
bug:21073493
Change-Id: If3d8aaeb6ad672b33d241289900d9c89b3bfbd03
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 3b629d5..e4b8c35 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -2382,15 +2382,20 @@
@Override
public void factoryReset(int subId) {
enforceConnectivityInternalPermission();
- if (SubscriptionManager.isUsableSubIdValue(subId)) {
- // Enable data
- setDataEnabled(subId, true);
- // Set network selection mode to automatic
- setNetworkSelectionModeAutomatic(subId);
- // Set preferred mobile network type to the best available
- setPreferredNetworkType(subId, Phone.PREFERRED_NT_MODE);
- // Turn off roaming
- SubscriptionManager.from(mApp).setDataRoaming(0, subId);
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ if (SubscriptionManager.isUsableSubIdValue(subId)) {
+ // Enable data
+ setDataEnabled(subId, true);
+ // Set network selection mode to automatic
+ setNetworkSelectionModeAutomatic(subId);
+ // Set preferred mobile network type to the best available
+ setPreferredNetworkType(subId, Phone.PREFERRED_NT_MODE);
+ // Turn off roaming
+ SubscriptionManager.from(mApp).setDataRoaming(0, subId);
+ }
+ } finally {
+ Binder.restoreCallingIdentity(identity);
}
}
}