summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/api/system-current.txt11
-rw-r--r--telephony/java/android/telephony/TelephonyManager.java147
-rw-r--r--telephony/java/com/android/internal/telephony/ITelephony.aidl11
3 files changed, 166 insertions, 3 deletions
diff --git a/core/api/system-current.txt b/core/api/system-current.txt
index f6b1d0627312..5bf9042ce32c 100644
--- a/core/api/system-current.txt
+++ b/core/api/system-current.txt
@@ -10214,8 +10214,10 @@ package android.telephony {
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setRadio(boolean);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setRadioEnabled(boolean);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setRadioPower(boolean);
- method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setSimPowerState(int);
- method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setSimPowerStateForSlot(int, int);
+ method @Deprecated @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setSimPowerState(int);
+ method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setSimPowerState(int, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.lang.Integer>);
+ method @Deprecated @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setSimPowerStateForSlot(int, int);
+ method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setSimPowerStateForSlot(int, int, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.lang.Integer>);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setSystemSelectionChannels(@NonNull java.util.List<android.telephony.RadioAccessSpecifier>, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.lang.Boolean>);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setSystemSelectionChannels(@NonNull java.util.List<android.telephony.RadioAccessSpecifier>);
method @Deprecated public void setVisualVoicemailEnabled(android.telecom.PhoneAccountHandle, boolean);
@@ -10299,6 +10301,11 @@ package android.telephony {
field public static final int SET_CARRIER_RESTRICTION_ERROR = 2; // 0x2
field public static final int SET_CARRIER_RESTRICTION_NOT_SUPPORTED = 1; // 0x1
field public static final int SET_CARRIER_RESTRICTION_SUCCESS = 0; // 0x0
+ field public static final int SET_SIM_POWER_STATE_ALREADY_IN_STATE = 1; // 0x1
+ field public static final int SET_SIM_POWER_STATE_MODEM_ERROR = 2; // 0x2
+ field public static final int SET_SIM_POWER_STATE_NOT_SUPPORTED = 4; // 0x4
+ field public static final int SET_SIM_POWER_STATE_SIM_ERROR = 3; // 0x3
+ field public static final int SET_SIM_POWER_STATE_SUCCESS = 0; // 0x0
field public static final int SIM_ACTIVATION_STATE_ACTIVATED = 2; // 0x2
field public static final int SIM_ACTIVATION_STATE_ACTIVATING = 1; // 0x1
field public static final int SIM_ACTIVATION_STATE_DEACTIVATED = 3; // 0x3
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 4a7118ec3590..d43bc1a0bd03 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -9980,6 +9980,16 @@ public class TelephonyManager {
*/
public static final int CARD_POWER_UP_PASS_THROUGH = 2;
+ /** @hide */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(prefix = {"CARD_POWER"},
+ value = {
+ CARD_POWER_DOWN,
+ CARD_POWER_UP,
+ CARD_POWER_UP_PASS_THROUGH,
+ })
+ public @interface SimPowerState {}
+
/**
* Set SIM card power state.
*
@@ -9990,12 +10000,17 @@ public class TelephonyManager {
* Callers should monitor for {@link TelephonyIntents#ACTION_SIM_STATE_CHANGED}
* broadcasts to determine success or failure and timeout if needed.
*
+ * @deprecated prefer {@link setSimPowerState(int, Executor, Consumer<Integer>)}.
+ * There is no guarantee that SIM power changes will trigger ACTION_SIM_STATE_CHANGED on new
+ * devices.
+ *
* <p>Requires Permission:
* {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE}
*
* {@hide}
**/
@SystemApi
+ @Deprecated
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public void setSimPowerState(int state) {
setSimPowerStateForSlot(getSlotIndex(), state);
@@ -10012,12 +10027,16 @@ public class TelephonyManager {
* Callers should monitor for {@link TelephonyIntents#ACTION_SIM_STATE_CHANGED}
* broadcasts to determine success or failure and timeout if needed.
*
+ * @deprecated prefer {@link setSimPowerStateForSlot(int, int, Executor, Consumer<Integer>)}.
+ * changes will trigger ACTION_SIM_STATE_CHANGED on new devices.
+ *
* <p>Requires Permission:
* {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE}
*
* {@hide}
**/
@SystemApi
+ @Deprecated
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
public void setSimPowerStateForSlot(int slotIndex, int state) {
try {
@@ -10033,6 +10052,85 @@ public class TelephonyManager {
}
/**
+ * Set SIM card power state.
+ *
+ * @param state State of SIM (power down, power up, pass through)
+ * @see #CARD_POWER_DOWN
+ * @see #CARD_POWER_UP
+ * @see #CARD_POWER_UP_PASS_THROUGH
+ * @param executor The executor of where the callback will execute.
+ * @param callback Callback will be triggered once it succeeds or failed.
+ * @see #SET_SIM_POWER_STATE_SUCCESS
+ * @see #SET_SIM_POWER_STATE_ALREADY_IN_STATE
+ * @see #SET_SIM_POWER_STATE_MODEM_ERROR
+ * @see #SET_SIM_POWER_STATE_SIM_ERROR
+ * @see #SET_SIM_POWER_STATE_NOT_SUPPORTED
+ * @throws IllegalArgumentException if requested SIM state is invalid
+ *
+ * <p>Requires Permission:
+ * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE}
+ *
+ * {@hide}
+ **/
+ @SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
+ public void setSimPowerState(@SimPowerState int state, @NonNull Executor executor,
+ @NonNull @SetSimPowerStateResult Consumer<Integer> callback) {
+ setSimPowerStateForSlot(getSlotIndex(), state, executor, callback);
+ }
+
+ /**
+ * Set SIM card power state.
+ *
+ * @param slotIndex SIM slot id
+ * @param state State of SIM (power down, power up, pass through)
+ * @see #CARD_POWER_DOWN
+ * @see #CARD_POWER_UP
+ * @see #CARD_POWER_UP_PASS_THROUGH
+ * @param executor The executor of where the callback will execute.
+ * @param callback Callback will be triggered once it succeeds or failed.
+ * @see #SET_SIM_POWER_STATE_SUCCESS
+ * @see #SET_SIM_POWER_STATE_ALREADY_IN_STATE
+ * @see #SET_SIM_POWER_STATE_MODEM_ERROR
+ * @see #SET_SIM_POWER_STATE_SIM_ERROR
+ * @see #SET_SIM_POWER_STATE_NOT_SUPPORTED
+ * @throws IllegalArgumentException if requested SIM state is invalid
+ *
+ * <p>Requires Permission:
+ * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE}
+ *
+ * {@hide}
+ **/
+ @SystemApi
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
+ public void setSimPowerStateForSlot(int slotIndex, @SimPowerState int state,
+ @NonNull Executor executor,
+ @NonNull @SetSimPowerStateResult Consumer<Integer> callback) {
+ if (state != CARD_POWER_DOWN && state != CARD_POWER_UP
+ && state != CARD_POWER_UP_PASS_THROUGH) {
+ throw new IllegalArgumentException("requested SIM state is invalid");
+ }
+ try {
+ ITelephony telephony = getITelephony();
+ IIntegerConsumer internalCallback = new IIntegerConsumer.Stub() {
+ @Override
+ public void accept(int result) {
+ executor.execute(() ->
+ Binder.withCleanCallingIdentity(() -> callback.accept(result)));
+ }
+ };
+ if (telephony != null) {
+ telephony.setSimPowerStateForSlotWithCallback(slotIndex, state, internalCallback);
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelephony#setSimPowerStateForSlot", e);
+ } catch (SecurityException e) {
+ Log.e(TAG, "Permission error calling ITelephony#setSimPowerStateForSlot",
+ e);
+ }
+ }
+
+ /**
* Set baseband version for the default phone.
*
* @param version baseband version
@@ -11028,6 +11126,55 @@ public class TelephonyManager {
public @interface SetCarrierRestrictionResult {}
/**
+ * The SIM power state was successfully set.
+ * @hide
+ */
+ @SystemApi
+ public static final int SET_SIM_POWER_STATE_SUCCESS = 0;
+
+ /**
+ * The SIM is already in the requested power state.
+ * @hide
+ */
+ @SystemApi
+ public static final int SET_SIM_POWER_STATE_ALREADY_IN_STATE = 1;
+
+ /**
+ * Failed to connect to the modem to make the power state request. This may happen if the
+ * modem has an error. The user may want to make the request again later.
+ * @hide
+ */
+ @SystemApi
+ public static final int SET_SIM_POWER_STATE_MODEM_ERROR = 2;
+
+ /**
+ * Failed to connect to the SIM to make the power state request. This may happen if the
+ * SIM has been removed. The user may want to make the request again later.
+ * @hide
+ */
+ @SystemApi
+ public static final int SET_SIM_POWER_STATE_SIM_ERROR = 3;
+
+ /**
+ * The modem version does not support synchronous power.
+ * @hide
+ */
+ @SystemApi
+ public static final int SET_SIM_POWER_STATE_NOT_SUPPORTED = 4;
+
+ /** @hide */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(prefix = {"SET_SIM_POWER_STATE_"},
+ value = {
+ SET_SIM_POWER_STATE_SUCCESS,
+ SET_SIM_POWER_STATE_ALREADY_IN_STATE,
+ SET_SIM_POWER_STATE_MODEM_ERROR,
+ SET_SIM_POWER_STATE_SIM_ERROR,
+ SET_SIM_POWER_STATE_NOT_SUPPORTED
+ })
+ public @interface SetSimPowerStateResult {}
+
+ /**
* Set the allowed carrier list and the excluded carrier list indicating the priority between
* the two lists.
* Requires system privileges.
diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl
index 4895fffa5849..6cbe8d04db89 100644
--- a/telephony/java/com/android/internal/telephony/ITelephony.aidl
+++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl
@@ -1668,10 +1668,19 @@ interface ITelephony {
* @param slotIndex SIM slot id
* @param state State of SIM (power down, power up, pass through)
* @hide
- * */
+ */
void setSimPowerStateForSlot(int slotIndex, int state);
/**
+ * Set SIM card power state.
+ * @param slotIndex SIM slot id
+ * @param state State of SIM (power down, power up, pass through)
+ * @param callback callback to receive result info
+ * @hide
+ */
+ void setSimPowerStateForSlotWithCallback(int slotIndex, int state, IIntegerConsumer callback);
+
+ /**
* Returns a list of Forbidden PLMNs from the specified SIM App
* Returns null if the query fails.
*