diff options
Diffstat (limited to 'telephony/java')
7 files changed, 202 insertions, 12 deletions
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index c34f745b7656..8368e3a72734 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -9985,6 +9985,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. * @@ -9995,12 +10005,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); @@ -10017,12 +10032,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 { @@ -10038,6 +10057,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 @@ -11033,6 +11131,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/android/telephony/ims/DelegateRegistrationState.java b/telephony/java/android/telephony/ims/DelegateRegistrationState.java index 3558a9b79ce0..66281edc0de1 100644 --- a/telephony/java/android/telephony/ims/DelegateRegistrationState.java +++ b/telephony/java/android/telephony/ims/DelegateRegistrationState.java @@ -62,7 +62,8 @@ public final class DelegateRegistrationState implements Parcelable { /** * This feature tag is being deregistered because the PDN that the IMS registration is on is *changing. - * All open SIP dialogs need to be closed before the PDN change can proceed. + * All open SIP dialogs need to be closed before the PDN change can proceed using + * {@link SipDelegateConnection#closeDialog(String)}. */ public static final int DEREGISTERING_REASON_PDN_CHANGE = 3; @@ -73,7 +74,8 @@ public final class DelegateRegistrationState implements Parcelable { * a user triggered hange, such as data being enabled/disabled. * <p> * All open SIP dialogs associated with the new deprovisioned feature tag need to be closed - * before the IMS registration modification can proceed. + * using {@link SipDelegateConnection#closeDialog(String)} before the IMS registration + * modification can proceed. */ public static final int DEREGISTERING_REASON_PROVISIONING_CHANGE = 4; @@ -81,8 +83,8 @@ public final class DelegateRegistrationState implements Parcelable { * This feature tag is deregistering because the SipDelegate associated with this feature tag * needs to change its supported feature set. * <p> - * All open SIP Dialogs associated with this feature tag must be closed before this operation - * can proceed. + * All open SIP Dialogs associated with this feature tag must be closed + * using {@link SipDelegateConnection#closeDialog(String)} before this operation can proceed. */ public static final int DEREGISTERING_REASON_FEATURE_TAGS_CHANGING = 5; @@ -90,8 +92,8 @@ public final class DelegateRegistrationState implements Parcelable { * This feature tag is deregistering because the SipDelegate is in the process of being * destroyed. * <p> - * All open SIP Dialogs associated with this feature tag must be closed before this operation - * can proceed. + * All open SIP Dialogs associated with this feature tag must be closed + * using {@link SipDelegateConnection#closeDialog(String)} before this operation can proceed. */ public static final int DEREGISTERING_REASON_DESTROY_PENDING = 6; diff --git a/telephony/java/android/telephony/ims/SipDelegateConnection.java b/telephony/java/android/telephony/ims/SipDelegateConnection.java index c3cc1edf590b..04a772cd873d 100644 --- a/telephony/java/android/telephony/ims/SipDelegateConnection.java +++ b/telephony/java/android/telephony/ims/SipDelegateConnection.java @@ -62,6 +62,22 @@ public interface SipDelegateConnection { void notifyMessageReceived(@NonNull String viaTransactionId); /** + * The SIP Dialog associated with the provided Call-ID is being closed and routing resources + * associated with the SIP dialog are free to be released. + * <p> + * Calling this method is also mandatory for situations where the framework IMS stack is waiting + * for pending SIP dialogs to be closed before it can perform a handover or apply a provisioning + * change. See {@link DelegateRegistrationState} for more information about + * the scenarios where this can occur. + * <p> + * This method will need to be called for each SIP dialog managed by this application when it is + * closed. + * @param callId The call-ID header value associated with the ongoing SIP Dialog that is + * closing. + */ + void closeDialog(@NonNull String callId); + + /** * Notify the SIP delegate that the SIP message has been received from * {@link DelegateMessageCallback#onMessageReceived(SipMessage)}, however there was an error * processing it. diff --git a/telephony/java/android/telephony/ims/aidl/ISipDelegate.aidl b/telephony/java/android/telephony/ims/aidl/ISipDelegate.aidl index 5d6766a65155..ad75be439da8 100644 --- a/telephony/java/android/telephony/ims/aidl/ISipDelegate.aidl +++ b/telephony/java/android/telephony/ims/aidl/ISipDelegate.aidl @@ -26,7 +26,5 @@ oneway interface ISipDelegate { void sendMessage(in SipMessage sipMessage, long configVersion); void notifyMessageReceived(in String viaTransactionId); void notifyMessageReceiveError(in String viaTransactionId, int reason); - - // only used by SipDelegate. void closeDialog(in String callId); } diff --git a/telephony/java/android/telephony/ims/aidl/SipDelegateConnectionAidlWrapper.java b/telephony/java/android/telephony/ims/aidl/SipDelegateConnectionAidlWrapper.java index 29ba8e2d50c4..a35039bd7668 100644 --- a/telephony/java/android/telephony/ims/aidl/SipDelegateConnectionAidlWrapper.java +++ b/telephony/java/android/telephony/ims/aidl/SipDelegateConnectionAidlWrapper.java @@ -199,6 +199,19 @@ public class SipDelegateConnectionAidlWrapper implements SipDelegateConnection, } } + @Override + public void closeDialog(String callId) { + try { + ISipDelegate conn = getSipDelegateBinder(); + if (conn == null) { + return; + } + conn.closeDialog(callId); + } catch (RemoteException e) { + // Nothing to do here, app will eventually get remote death callback. + } + } + // Also called upon IImsRcsController death (telephony process dies). @Override public void binderDied() { diff --git a/telephony/java/android/telephony/ims/stub/SipDelegate.java b/telephony/java/android/telephony/ims/stub/SipDelegate.java index d7e7b62dd550..b036b5e71125 100644 --- a/telephony/java/android/telephony/ims/stub/SipDelegate.java +++ b/telephony/java/android/telephony/ims/stub/SipDelegate.java @@ -19,7 +19,9 @@ package android.telephony.ims.stub; import android.annotation.NonNull; import android.annotation.SystemApi; import android.telephony.ims.DelegateMessageCallback; +import android.telephony.ims.DelegateRegistrationState; import android.telephony.ims.ImsService; +import android.telephony.ims.SipDelegateConnection; import android.telephony.ims.SipDelegateImsConfiguration; import android.telephony.ims.SipDelegateManager; import android.telephony.ims.SipMessage; @@ -65,10 +67,13 @@ public interface SipDelegate { * The framework is requesting that routing resources associated with the SIP dialog using the * provided Call-ID to be cleaned up. * <p> - * Typically a SIP Dialog close event will be signalled by that dialog receiving a BYE or 200 OK - * message, however, in some cases, the framework will request that the ImsService close the + * Typically, a SIP Dialog close event will be signalled by that dialog receiving a BYE or + * 200 OK message, however, the IMS application will still call + * {@link SipDelegateConnection#closeDialog(String)} to signal to the framework that resources + * can be released. In some cases, the framework will request that the ImsService close the * dialog due to the open dialog holding up an event such as applying a provisioning change or - * handing over to another transport type. + * handing over to another transport type. See {@link DelegateRegistrationState}. + * * @param callId The call-ID header value associated with the ongoing SIP Dialog that the * framework is requesting be closed. */ diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index fc83f759aa3d..205a425a5161 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -1676,10 +1676,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. * |