import static com.android.internal.util.Preconditions.checkNotNull;
+import android.Manifest;
import android.annotation.IntDef;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
* {@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.
*
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) {
}
/**
+ * 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
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.