Implement the Telephony API to set the capabilities request timeout
Bug: 188440601
Test: atest ImsServiceTest RcsUceAdapterTest
Change-Id: I19d06875a7d3b0459b7be681f57b2d70fd661939
diff --git a/src/com/android/phone/ImsRcsController.java b/src/com/android/phone/ImsRcsController.java
index 90c9df4..2e4ee94 100644
--- a/src/com/android/phone/ImsRcsController.java
+++ b/src/com/android/phone/ImsRcsController.java
@@ -421,6 +421,19 @@
return uceCtrlManager.removeUceRequestDisallowedStatus();
}
+ /**
+ * Set the timeout for contact capabilities request.
+ */
+ // Used for SHELL command only right now.
+ public boolean setCapabilitiesRequestTimeout(int subId, long timeoutAfter) throws ImsException {
+ UceControllerManager uceCtrlManager = getRcsFeatureController(subId).getFeature(
+ UceControllerManager.class);
+ if (uceCtrlManager == null) {
+ return false;
+ }
+ return uceCtrlManager.setCapabilitiesRequestTimeout(timeoutAfter);
+ }
+
@Override
public void registerUcePublishStateCallback(int subId, IRcsUcePublishStateCallback c) {
enforceReadPrivilegedPermission("registerUcePublishStateCallback");
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index f3a0a26..43cf6f6 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -10519,6 +10519,22 @@
}
}
+ /**
+ * Remove UCE requests cannot be sent to the network status.
+ */
+ // Used for SHELL command only.
+ @Override
+ public boolean setCapabilitiesRequestTimeout(int subId, long timeoutAfterMs) {
+ TelephonyPermissions.enforceShellOnly(Binder.getCallingUid(), "setCapRequestTimeout");
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ return mApp.imsRcsController.setCapabilitiesRequestTimeout(subId, timeoutAfterMs);
+ } catch (ImsException e) {
+ throw new ServiceSpecificException(e.getCode(), e.getMessage());
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ }
@Override
public void setSignalStrengthUpdateRequest(int subId, SignalStrengthUpdateRequest request,
diff --git a/src/com/android/phone/TelephonyShellCommand.java b/src/com/android/phone/TelephonyShellCommand.java
index c83ea64..090f405 100644
--- a/src/com/android/phone/TelephonyShellCommand.java
+++ b/src/com/android/phone/TelephonyShellCommand.java
@@ -147,6 +147,8 @@
private static final String UCE_GET_LAST_PIDF_XML = "get-last-publish-pidf";
private static final String UCE_REMOVE_REQUEST_DISALLOWED_STATUS =
"remove-request-disallowed-status";
+ private static final String UCE_SET_CAPABILITY_REQUEST_TIMEOUT =
+ "set-capabilities-request-timeout";
// Check if a package has carrier privileges on any SIM, regardless of subId/phoneId.
private static final String HAS_CARRIER_PRIVILEGES_COMMAND = "has-carrier-privileges";
@@ -476,6 +478,8 @@
pw.println(" PUBLISH is active");
pw.println(" uce remove-request-disallowed-status [-s SLOT_ID]");
pw.println(" Remove the UCE is disallowed to execute UCE requests status");
+ pw.println(" uce set-capabilities-request-timeout [-s SLOT_ID] [REQUEST_TIMEOUT_MS]");
+ pw.println(" Set the timeout for contact capabilities request.");
}
private void onHelpNumberVerification() {
@@ -2093,6 +2097,8 @@
return handleUceGetPidfXml();
case UCE_REMOVE_REQUEST_DISALLOWED_STATUS:
return handleUceRemoveRequestDisallowedStatus();
+ case UCE_SET_CAPABILITY_REQUEST_TIMEOUT:
+ return handleUceSetCapRequestTimeout();
}
return -1;
}
@@ -2199,6 +2205,27 @@
return 0;
}
+ private int handleUceSetCapRequestTimeout() {
+ int subId = getSubId("uce set-capabilities-request-timeout");
+ if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
+ Log.w(LOG_TAG, "uce set-capabilities-request-timeout, Invalid subscription ID");
+ return -1;
+ }
+ long timeoutAfterMs = Long.valueOf(getNextArg());
+ boolean result;
+ try {
+ result = mInterface.setCapabilitiesRequestTimeout(subId, timeoutAfterMs);
+ } catch (RemoteException e) {
+ Log.w(LOG_TAG, "uce set-capabilities-request-timeout, error " + e.getMessage());
+ return -1;
+ }
+ if (VDBG) {
+ Log.v(LOG_TAG, "uce set-capabilities-request-timeout, returned: " + result);
+ }
+ getOutPrintWriter().println(result);
+ return 0;
+ }
+
private int handleSrcSetTestEnabledCommand() {
String enabledStr = getNextArg();
if (enabledStr == null) {
diff --git a/src/com/android/services/telephony/rcs/UceControllerManager.java b/src/com/android/services/telephony/rcs/UceControllerManager.java
index 2897113..995d685 100644
--- a/src/com/android/services/telephony/rcs/UceControllerManager.java
+++ b/src/com/android/services/telephony/rcs/UceControllerManager.java
@@ -359,6 +359,33 @@
}
/**
+ * Set the timeout for contact capabilities request.
+ * @param timeoutAfterMs How long when the capabilities request will time up.
+ * @return true if this command is successful.
+ */
+ public boolean setCapabilitiesRequestTimeout(long timeoutAfterMs) throws ImsException {
+ Future<Boolean> future = mExecutorService.submit(() -> {
+ if (mUceController == null) {
+ throw new ImsException("UCE controller is null",
+ ImsException.CODE_ERROR_SERVICE_UNAVAILABLE);
+ }
+ mUceController.setCapabilitiesRequestTimeout(timeoutAfterMs);
+ return true;
+ });
+
+ try {
+ return future.get();
+ } catch (ExecutionException | InterruptedException e) {
+ Log.w(LOG_TAG, "setCapabilitiesRequestTimeout exception: " + e);
+ Throwable cause = e.getCause();
+ if (cause instanceof ImsException) {
+ throw (ImsException) cause;
+ }
+ return false;
+ }
+ }
+
+ /**
* Register the Publish state changed callback.
*
* @throws ImsException if the ImsService connected to this controller is currently down.