diff options
| -rw-r--r-- | api/system-current.txt | 2 | ||||
| -rw-r--r-- | telephony/java/android/telephony/TelephonyManager.java | 70 | ||||
| -rw-r--r-- | telephony/java/com/android/internal/telephony/ITelephony.aidl | 27 |
3 files changed, 91 insertions, 8 deletions
diff --git a/api/system-current.txt b/api/system-current.txt index 9b1400c377de..b2c7a2f3233f 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -5307,6 +5307,8 @@ package android.telephony { method public boolean isVideoCallingEnabled(); method public deprecated boolean isVisualVoicemailEnabled(android.telecom.PhoneAccountHandle); method public boolean needsOtaServiceProvisioning(); + method public boolean rebootRadio(); + method public boolean resetRadioConfig(); method public int setAllowedCarriers(int, java.util.List<android.service.carrier.CarrierIdentifier>); method public void setCarrierDataEnabled(boolean); method public void setDataActivationState(int); diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 2508b6d160d0..8cd53e0eec09 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -20,6 +20,7 @@ import static android.content.Context.TELECOM_SERVICE; import static com.android.internal.util.Preconditions.checkNotNull; +import android.Manifest; import android.annotation.IntDef; import android.annotation.Nullable; import android.annotation.RequiresPermission; @@ -5121,6 +5122,9 @@ public class TelephonyManager { * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the calling * app has carrier privileges (see {@link #hasCarrierPrivileges}). * + * TODO: remove this one. use {@link #rebootRadio()} for reset type 1 and + * {@link #resetRadioConfig()} for reset type 3 + * * @param resetType reset type: 1: reload NV reset, 2: erase NV reset, 3: factory NV reset * @return true on success; false on any failure. * @@ -5130,8 +5134,15 @@ public class TelephonyManager { public boolean nvResetConfig(int resetType) { try { ITelephony telephony = getITelephony(); - if (telephony != null) - return telephony.nvResetConfig(resetType); + if (telephony != null) { + if (resetType == 1 /*1: reload NV reset */) { + return telephony.rebootModem(getSlotIndex()); + } else if (resetType == 3 /*3: factory NV reset */) { + return telephony.resetModemConfig(getSlotIndex()); + } else { + Rlog.e(TAG, "nvResetConfig unsupported reset type"); + } + } } catch (RemoteException ex) { Rlog.e(TAG, "nvResetConfig RemoteException", ex); } catch (NullPointerException ex) { @@ -5141,6 +5152,61 @@ public class TelephonyManager { } /** + * Rollback modem configurations to factory default except some config which are in whitelist. + * Used for device configuration by some CDMA operators. + * + * <p>Requires Permission: + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the calling + * app has carrier privileges (see {@link #hasCarrierPrivileges}). + * + * @return {@code true} on success; {@code false} on any failure. + * + * @hide + */ + @RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE) + @SystemApi + public boolean resetRadioConfig() { + try { + ITelephony telephony = getITelephony(); + if (telephony != null) { + return telephony.resetModemConfig(getSlotIndex()); + } + } catch (RemoteException ex) { + Rlog.e(TAG, "resetRadioConfig RemoteException", ex); + } catch (NullPointerException ex) { + Rlog.e(TAG, "resetRadioConfig NPE", ex); + } + return false; + } + + /** + * Generate a radio modem reset. Used for device configuration by some CDMA operators. + * + * <p>Requires Permission: + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the calling + * app has carrier privileges (see {@link #hasCarrierPrivileges}). + * + * @return {@code true} on success; {@code false} on any failure. + * + * @hide + */ + @RequiresPermission(Manifest.permission.MODIFY_PHONE_STATE) + @SystemApi + public boolean rebootRadio() { + try { + ITelephony telephony = getITelephony(); + if (telephony != null) { + return telephony.rebootModem(getSlotIndex()); + } + } catch (RemoteException ex) { + Rlog.e(TAG, "rebootRadio RemoteException", ex); + } catch (NullPointerException ex) { + Rlog.e(TAG, "rebootRadio NPE", ex); + } + return false; + } + + /** * Return an appropriate subscription ID for any situation. * * If this object has been created with {@link #createForSubscriptionId}, then the provided diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index 84c2a5d78018..cf13b431daac 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -638,15 +638,30 @@ interface ITelephony { boolean nvWriteCdmaPrl(in byte[] preferredRoamingList); /** - * Perform the specified type of NV config reset. The radio will be taken offline - * and the device must be rebooted after the operation. Used for device - * configuration by some CDMA operators. + * Rollback modem configurations to factory default except some config which are in whitelist. + * Used for device configuration by some CDMA operators. * - * @param resetType the type of reset to perform (1 == factory reset; 2 == NV-only reset). - * @return true on success; false on any failure. + * <p>Requires Permission: + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the calling + * app has carrier privileges (see {@link #hasCarrierPrivileges}). + * + * @param slotIndex - device slot. + * @return {@code true} on success; {@code false} on any failure. */ - boolean nvResetConfig(int resetType); + boolean resetModemConfig(int slotIndex); + /** + * Generate a radio modem reset. Used for device configuration by some CDMA operators. + * Different than {@link #setRadioPower(boolean)}, modem reboot will power down sim card. + * + * <p>Requires Permission: + * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE} or that the calling + * app has carrier privileges (see {@link #hasCarrierPrivileges}). + * + * @param slotIndex - device slot. + * @return {@code true} on success; {@code false} on any failure. + */ + boolean rebootModem(int slotIndex); /* * Get the calculated preferred network type. * Used for device configuration by some CDMA operators. |