From 1e7346402ce777d356aec86843afa77dfe5e6c87 Mon Sep 17 00:00:00 2001 From: Hunsuk Choi Date: Fri, 4 Feb 2022 08:47:53 +0000 Subject: [PATCH] Add api, ImsRegistrationImplBase#triggerDeregistration Bug: 219242993 Test: atest ImsServiceTestOnMockModem#testTriggerImsDeregistration Change-Id: Icbf27889915169f996c524ea65491efb49ff3981 --- .../telephony/ims/aidl/IImsRegistration.aidl | 1 + .../ims/stub/ImsRegistrationImplBase.java | 86 +++++++++++++++++++ 2 files changed, 87 insertions(+) diff --git a/telephony/java/android/telephony/ims/aidl/IImsRegistration.aidl b/telephony/java/android/telephony/ims/aidl/IImsRegistration.aidl index 4fd904041365f..219c9c88d8251 100644 --- a/telephony/java/android/telephony/ims/aidl/IImsRegistration.aidl +++ b/telephony/java/android/telephony/ims/aidl/IImsRegistration.aidl @@ -31,4 +31,5 @@ interface IImsRegistration { oneway void triggerFullNetworkRegistration(int sipCode, String sipReason); oneway void triggerUpdateSipDelegateRegistration(); oneway void triggerSipDelegateDeregistration(); + oneway void triggerDeregistration(int reason); } diff --git a/telephony/java/android/telephony/ims/stub/ImsRegistrationImplBase.java b/telephony/java/android/telephony/ims/stub/ImsRegistrationImplBase.java index 6fc1cc828a2c8..b69eb6f3d6ce2 100644 --- a/telephony/java/android/telephony/ims/stub/ImsRegistrationImplBase.java +++ b/telephony/java/android/telephony/ims/stub/ImsRegistrationImplBase.java @@ -104,6 +104,73 @@ public class ImsRegistrationImplBase { // yet. private static final int REGISTRATION_STATE_UNKNOWN = -1; + /** @hide */ + @Retention(RetentionPolicy.SOURCE) + @IntDef( + prefix = {"REASON_"}, + value = { + REASON_UNKNOWN, + REASON_SIM_REMOVED, + REASON_SIM_REFRESH, + REASON_ALLOWED_NETWORK_TYPES_CHANGED, + REASON_NON_IMS_CAPABLE_NETWORK, + REASON_RADIO_POWER_OFF, + REASON_HANDOVER_FAILED, + REASON_VOPS_NOT_SUPPORTED, + }) + public @interface ImsDeregistrationReason{} + + /** + * Unspecified reason. + * @hide + */ + public static final int REASON_UNKNOWN = 0; + + /** + * Since SIM is removed, the credentials for IMS service is also removed. + * @hide + */ + public static final int REASON_SIM_REMOVED = 1; + + /** + * Detach from the network shall be performed due to the SIM refresh. IMS service should be + * deregistered before that procedure. + * @hide + */ + public static final int REASON_SIM_REFRESH = 2; + + /** + * The allowed network types have changed, resulting in a network type + * that does not support IMS. + * @hide + */ + public static final int REASON_ALLOWED_NETWORK_TYPES_CHANGED = 3; + + /** + * The device camped on a network that does not support IMS. + * @hide + */ + public static final int REASON_NON_IMS_CAPABLE_NETWORK = 4; + + /** + * IMS service should be deregistered from the network before turning off the radio. + * @hide + */ + public static final int REASON_RADIO_POWER_OFF = 5; + + /** + * Since the handover is failed or not allowed, the data service for IMS shall be + * disconnected. + * @hide + */ + public static final int REASON_HANDOVER_FAILED = 6; + + /** + * The network is changed to a network that does not support voice over IMS. + * @hide + */ + public static final int REASON_VOPS_NOT_SUPPORTED = 7; + private Executor mExecutor; /** @@ -182,6 +249,12 @@ public class ImsRegistrationImplBase { .triggerSipDelegateDeregistration(), "triggerSipDelegateDeregistration"); } + @Override + public void triggerDeregistration(@ImsDeregistrationReason int reason) { + executeMethodAsyncNoException(() -> ImsRegistrationImplBase.this + .triggerDeregistration(reason), "triggerDeregistration"); + } + // Call the methods with a clean calling identity on the executor and wait indefinitely for // the future to return. private void executeMethodAsync(Runnable r, String errorLogName) throws RemoteException { @@ -303,6 +376,19 @@ public class ImsRegistrationImplBase { // Stub implementation, ImsService should implement this } + /** + * Requests IMS stack to perform graceful IMS deregistration before radio performing + * network detach in the events of SIM remove, refresh or and so on. The radio waits for + * the IMS deregistration, which will be notified by telephony via + * {@link android.hardware.radio.ims.IRadioIms#updateImsRegistrationInfo()}, + * or a certain timeout interval to start the network detach procedure. + * + * @param reason the reason why the deregistration is triggered. + * @hide + */ + public void triggerDeregistration(@ImsDeregistrationReason int reason) { + // Stub Implementation, can be overridden by ImsService + } /** * Notify the framework that the device is connected to the IMS network.