diff options
author | Stuart Scott <stuartscott@google.com> | 2015-03-30 13:17:11 -0700 |
---|---|---|
committer | Stuart Scott <stuartscott@google.com> | 2015-03-30 18:02:55 -0700 |
commit | 984dc850b4caeb4470e52bce773935be5305cf8e (patch) | |
tree | 89c420f41e4c9ccab406a1de463babe5c4ff4a5c /telephony | |
parent | 607f1f09c3da3a52557394d2e764326a29151173 (diff) | |
download | frameworks_base-984dc850b4caeb4470e52bce773935be5305cf8e.zip frameworks_base-984dc850b4caeb4470e52bce773935be5305cf8e.tar.gz frameworks_base-984dc850b4caeb4470e52bce773935be5305cf8e.tar.bz2 |
Move reset network settings into framework.
bug: 16161518
Change-Id: Ic3b537ebd09d1b9723feff9dcc96e20fda05a94f
Diffstat (limited to 'telephony')
-rw-r--r-- | telephony/java/android/telephony/TelephonyManager.java | 51 | ||||
-rw-r--r-- | telephony/java/com/android/internal/telephony/ITelephony.aidl | 13 |
2 files changed, 57 insertions, 7 deletions
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index fbc70db..6bc6de63 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -3316,11 +3316,11 @@ public class TelephonyManager { * @return the preferred network type, defined in RILConstants.java. * @hide */ - public int getPreferredNetworkType() { + public int getPreferredNetworkType(int subId) { try { ITelephony telephony = getITelephony(); if (telephony != null) - return telephony.getPreferredNetworkType(); + return telephony.getPreferredNetworkType(subId); } catch (RemoteException ex) { Rlog.e(TAG, "getPreferredNetworkType RemoteException", ex); } catch (NullPointerException ex) { @@ -3330,6 +3330,27 @@ public class TelephonyManager { } /** + * Sets the network selection mode to automatic. + * <p> + * Requires Permission: + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} + * Or the calling app has carrier privileges. @see #hasCarrierPrivileges + * + * @hide + */ + public void setNetworkSelectionModeAutomatic(int subId) { + try { + ITelephony telephony = getITelephony(); + if (telephony != null) + telephony.setNetworkSelectionModeAutomatic(subId); + } catch (RemoteException ex) { + Rlog.e(TAG, "setNetworkSelectionModeAutomatic RemoteException", ex); + } catch (NullPointerException ex) { + Rlog.e(TAG, "setNetworkSelectionModeAutomatic NPE", ex); + } + } + + /** * Set the preferred network type. * Used for device configuration by some CDMA operators. * <p> @@ -3337,15 +3358,16 @@ public class TelephonyManager { * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} * Or the calling app has carrier privileges. @see #hasCarrierPrivileges * + * @param subId the id of the subscription to set the preferred network type for. * @param networkType the preferred network type, defined in RILConstants.java. * @return true on success; false on any failure. * @hide */ - public boolean setPreferredNetworkType(int networkType) { + public boolean setPreferredNetworkType(int subId, int networkType) { try { ITelephony telephony = getITelephony(); if (telephony != null) - return telephony.setPreferredNetworkType(networkType); + return telephony.setPreferredNetworkType(subId, networkType); } catch (RemoteException ex) { Rlog.e(TAG, "setPreferredNetworkType RemoteException", ex); } catch (NullPointerException ex) { @@ -3364,7 +3386,8 @@ public class TelephonyManager { * @return true on success; false on any failure. */ public boolean setPreferredNetworkTypeToGlobal() { - return setPreferredNetworkType(RILConstants.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA); + return setPreferredNetworkType(getDefaultSubscription(), + RILConstants.NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA); } /** @@ -4448,4 +4471,22 @@ public class TelephonyManager { return retval; } + + /** + * Resets telephony manager settings back to factory defaults. + * + * @hide + */ + public void factoryReset(int subId) { + 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, RILConstants.PREFERRED_NETWORK_MODE); + // Turn off roaming + SubscriptionManager.from(mContext).setDataRoaming(0, subId); + } + } } diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index c18e3b6..a24859b 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -653,9 +653,10 @@ interface ITelephony { * Get the preferred network type. * Used for device configuration by some CDMA operators. * + * @param subId the id of the subscription to query. * @return the preferred network type, defined in RILConstants.java. */ - int getPreferredNetworkType(); + int getPreferredNetworkType(int subId); /** * Check TETHER_DUN_REQUIRED and TETHER_DUN_APN settings, net.tethering.noprovisioning @@ -667,13 +668,21 @@ interface ITelephony { int getTetherApnRequired(); /** + * Set the network selection mode to automatic. + * + * @param subId the id of the subscription to update. + */ + void setNetworkSelectionModeAutomatic(int subId); + + /** * Set the preferred network type. * Used for device configuration by some CDMA operators. * + * @param subId the id of the subscription to update. * @param networkType the preferred network type, defined in RILConstants.java. * @return true on success; false on any failure. */ - boolean setPreferredNetworkType(int networkType); + boolean setPreferredNetworkType(int subId, int networkType); /** * User enable/disable Mobile Data. |