Integrate IMS single registration feature into APIs
1) Check to ensure IMS single registration feature is enabled
for a device before allowing a SIP delegate to be created.
2) Check to ensure IMS single registration feature is enabled
and communicate this state back to RCS applications in
provisioning code.
3) Add the ability to temporarily enable support for this feature
for CTS testing.
Bug: 173715911
Test: atest CtsTelephonyTestCases TeleServiceTests
Change-Id: I975669af2f8606ae9f42c93df1df102a18bb1933
diff --git a/src/com/android/phone/ImsRcsController.java b/src/com/android/phone/ImsRcsController.java
index 2c87f7c..c91cc3b 100644
--- a/src/com/android/phone/ImsRcsController.java
+++ b/src/com/android/phone/ImsRcsController.java
@@ -67,6 +67,8 @@
private PhoneGlobals mApp;
private TelephonyRcsService mRcsService;
private ImsResolver mImsResolver;
+ // set by shell cmd phone src set-device-enabled true/false
+ private Boolean mSingleRegistrationOverride;
/**
* Initialize the singleton ImsRcsController instance.
@@ -386,6 +388,9 @@
@Override
public boolean isSipDelegateSupported(int subId) {
enforceReadPrivilegedPermission("isSipDelegateSupported");
+ if (!isImsSingleRegistrationSupportedOnDevice()) {
+ return false;
+ }
final long token = Binder.clearCallingIdentity();
try {
SipTransportController transport = getRcsFeatureController(subId).getFeature(
@@ -411,6 +416,11 @@
ISipDelegateConnectionStateCallback delegateState,
ISipDelegateMessageCallback delegateMessage) {
enforceModifyPermission();
+ if (!isImsSingleRegistrationSupportedOnDevice()) {
+ throw new ServiceSpecificException(ImsException.CODE_ERROR_UNSUPPORTED_OPERATION,
+ "SipDelegate creation is only supported for devices supporting IMS single "
+ + "registration");
+ }
if (!UserHandle.getUserHandleForUid(Binder.getCallingUid()).isSystem()) {
throw new ServiceSpecificException(ImsException.CODE_ERROR_UNSUPPORTED_OPERATION,
"SipDelegate creation is only available to primary user.");
@@ -586,7 +596,21 @@
return c;
}
+ private boolean isImsSingleRegistrationSupportedOnDevice() {
+ return mSingleRegistrationOverride != null ? mSingleRegistrationOverride
+ : mApp.getPackageManager().hasSystemFeature(
+ PackageManager.FEATURE_TELEPHONY_IMS_SINGLE_REGISTRATION);
+ }
+
void setRcsService(TelephonyRcsService rcsService) {
mRcsService = rcsService;
}
+
+ /**
+ * Override device RCS single registration support check for CTS testing or remove override
+ * if the Boolean is set to null.
+ */
+ void setDeviceSingleRegistrationSupportOverride(Boolean deviceOverrideValue) {
+ mSingleRegistrationOverride = deviceOverrideValue;
+ }
}
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 486021d..f1be951 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -9757,6 +9757,7 @@
Boolean enabled = "NULL".equalsIgnoreCase(enabledStr) ? null
: Boolean.parseBoolean(enabledStr);
RcsProvisioningMonitor.getInstance().overrideDeviceSingleRegistrationEnabled(enabled);
+ mApp.imsRcsController.setDeviceSingleRegistrationSupportOverride(enabled);
}
/**
diff --git a/src/com/android/phone/RcsProvisioningMonitor.java b/src/com/android/phone/RcsProvisioningMonitor.java
index 7b51eeb..79310ef 100644
--- a/src/com/android/phone/RcsProvisioningMonitor.java
+++ b/src/com/android/phone/RcsProvisioningMonitor.java
@@ -22,6 +22,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Handler;
import android.os.HandlerThread;
@@ -543,7 +544,8 @@
boolean isSingleRegistrationEnabledOnDevice =
mDeviceSingleRegistrationEnabledOverride != null
? mDeviceSingleRegistrationEnabledOverride
- : mPhone.getResources().getBoolean(R.bool.config_rcsVolteSingleRegistrationEnabled);
+ : mPhone.getPackageManager().hasSystemFeature(
+ PackageManager.FEATURE_TELEPHONY_IMS_SINGLE_REGISTRATION);
int value = (isSingleRegistrationEnabledOnDevice ? 0
: ProvisioningManager.STATUS_DEVICE_NOT_CAPABLE) | (