Add ImsStateCallbackController
registerImsStateCallback and unregisterImsStateCallback are
added to ImsMmTelManager, ImsRcsManager, and SipDelegateManager.
Those are used to receive updates about the connection state
of the underlying ImsService.
ImsStateCallbackController notifies the state of the ImsService
via the registered IImsStateCallback callback interface.
Bug: 178016400
Test: atest ImsStateCallbackControllerTest
Change-Id: I336761a7174bf35d72b6bd0e3040db58fef54daa
Merged-In: I336761a7174bf35d72b6bd0e3040db58fef54daa
Merged-In: I10a099043301f61cb32ca88a89543a1136ee4d80
Merged-In: I654b23cc526e0d7916250f7a72763d2eea9856d9
Merged-In: I2009b184b3122f158c34464e9adcc96c4b9e2fdd
Merged-In: I04abab941b55b81305a9e3fd327874dab3779323
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index b5c4e01..f3f756c 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -152,6 +152,7 @@
import com.android.internal.telephony.HalVersion;
import com.android.internal.telephony.IBooleanConsumer;
import com.android.internal.telephony.ICallForwardingInfoCallback;
+import com.android.internal.telephony.IImsStateCallback;
import com.android.internal.telephony.IIntegerConsumer;
import com.android.internal.telephony.INumberVerificationCallback;
import com.android.internal.telephony.ITelephony;
@@ -10869,4 +10870,73 @@
Binder.restoreCallingIdentity(identity);
}
}
+
+ /**
+ * Register an IMS connection state callback
+ */
+ @Override
+ public void registerImsStateCallback(int subId, int feature, IImsStateCallback cb,
+ String callingPackage) {
+ if (feature == ImsFeature.FEATURE_MMTEL) {
+ // ImsMmTelManager
+ // The following also checks READ_PRIVILEGED_PHONE_STATE.
+ TelephonyPermissions
+ .enforceCallingOrSelfReadPrecisePhoneStatePermissionOrCarrierPrivilege(
+ mApp, subId, "registerImsStateCallback");
+ } else if (feature == ImsFeature.FEATURE_RCS) {
+ // ImsRcsManager or SipDelegateManager
+ TelephonyPermissions.enforceAnyPermissionGrantedOrCarrierPrivileges(mApp, subId,
+ Binder.getCallingUid(), "registerImsStateCallback",
+ Manifest.permission.READ_PRIVILEGED_PHONE_STATE,
+ Manifest.permission.READ_PRECISE_PHONE_STATE,
+ Manifest.permission.ACCESS_RCS_USER_CAPABILITY_EXCHANGE,
+ Manifest.permission.PERFORM_IMS_SINGLE_REGISTRATION);
+ }
+
+ if (!ImsManager.isImsSupportedOnDevice(mApp)) {
+ throw new ServiceSpecificException(ImsException.CODE_ERROR_UNSUPPORTED_OPERATION,
+ "IMS not available on device.");
+ }
+
+ if (subId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID) {
+ throw new ServiceSpecificException(ImsException.CODE_ERROR_INVALID_SUBSCRIPTION);
+ }
+
+ ImsStateCallbackController controller = ImsStateCallbackController.getInstance();
+ if (controller == null) {
+ throw new ServiceSpecificException(ImsException.CODE_ERROR_UNSUPPORTED_OPERATION,
+ "IMS not available on device.");
+ }
+
+ if (callingPackage == null) {
+ callingPackage = getCurrentPackageName();
+ }
+
+ final long token = Binder.clearCallingIdentity();
+ try {
+ int slotId = getSlotIndexOrException(subId);
+ controller.registerImsStateCallback(subId, feature, cb, callingPackage);
+ } catch (ImsException e) {
+ throw new ServiceSpecificException(e.getCode());
+ } finally {
+ Binder.restoreCallingIdentity(token);
+ }
+ }
+
+ /**
+ * Unregister an IMS connection state callback
+ */
+ @Override
+ public void unregisterImsStateCallback(IImsStateCallback cb) {
+ final long token = Binder.clearCallingIdentity();
+ ImsStateCallbackController controller = ImsStateCallbackController.getInstance();
+ if (controller == null) {
+ return;
+ }
+ try {
+ controller.unregisterImsStateCallback(cb);
+ } finally {
+ Binder.restoreCallingIdentity(token);
+ }
+ }
}