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/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) {