Move factoryReset to service and protect.
bug:16161518
Change-Id: Ie83d3a486bf07d5f2073b23253d0d0351414e180
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 274534c..a88fdde 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -1414,6 +1414,12 @@
null);
}
+ private void enforceConnectivityInternalPermission() {
+ mApp.enforceCallingOrSelfPermission(
+ android.Manifest.permission.CONNECTIVITY_INTERNAL,
+ "ConnectivityService");
+ }
+
private String createTelUrl(String number) {
if (TextUtils.isEmpty(number)) {
return null;
@@ -2353,4 +2359,19 @@
return true;
}
+
+ @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);
+ }
+ }
}