Add TelephonyShellCommand to get EAB capability

Bug: 192370112
Test: atest
Change-Id: I27de6820059f6fb7a9e562bdb1e9ade7185c9445
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index a349061..2c9d012 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -10417,6 +10417,21 @@
     }
 
     /**
+     * Get the EAB capability from the EAB database.
+     */
+    @Override
+    public String getCapabilityFromEab(String contact) {
+        TelephonyPermissions.enforceShellOnly(Binder.getCallingUid(), "getCapabilityFromEab");
+        enforceModifyPermission();
+        final long identity = Binder.clearCallingIdentity();
+        try {
+            return EabUtil.getCapabilityFromEab(getDefaultPhone().getContext(), contact);
+        } finally {
+            Binder.restoreCallingIdentity(identity);
+        }
+    }
+
+    /**
      * Remove the EAB contacts from the EAB database.
      */
     @Override
diff --git a/src/com/android/phone/TelephonyShellCommand.java b/src/com/android/phone/TelephonyShellCommand.java
index 090f405..dbeb7ce 100644
--- a/src/com/android/phone/TelephonyShellCommand.java
+++ b/src/com/android/phone/TelephonyShellCommand.java
@@ -140,6 +140,7 @@
 
     private static final String RCS_UCE_COMMAND = "uce";
     private static final String UCE_GET_EAB_CONTACT = "get-eab-contact";
+    private static final String UCE_GET_EAB_CAPABILITY = "get-eab-capability";
     private static final String UCE_REMOVE_EAB_CONTACT = "remove-eab-contact";
     private static final String UCE_GET_DEVICE_ENABLED = "get-device-enabled";
     private static final String UCE_SET_DEVICE_ENABLED = "set-device-enabled";
@@ -2087,6 +2088,8 @@
                 return handleRemovingEabContactCommand();
             case UCE_GET_EAB_CONTACT:
                 return handleGettingEabContactCommand();
+            case UCE_GET_EAB_CAPABILITY:
+                return handleGettingEabCapabilityCommand();
             case UCE_GET_DEVICE_ENABLED:
                 return handleUceGetDeviceEnabledCommand();
             case UCE_SET_DEVICE_ENABLED:
@@ -2136,7 +2139,6 @@
         String result = "";
         try {
             result = mInterface.getContactFromEab(phoneNumber);
-
         } catch (RemoteException e) {
             Log.w(LOG_TAG, "uce get-eab-contact, error " + e.getMessage());
             getErrPrintWriter().println("Exception: " + e.getMessage());
@@ -2150,6 +2152,27 @@
         return 0;
     }
 
+    private int handleGettingEabCapabilityCommand() {
+        String phoneNumber = getNextArgRequired();
+        if (TextUtils.isEmpty(phoneNumber)) {
+            return -1;
+        }
+        String result = "";
+        try {
+            result = mInterface.getCapabilityFromEab(phoneNumber);
+        } catch (RemoteException e) {
+            Log.w(LOG_TAG, "uce get-eab-capability, error " + e.getMessage());
+            getErrPrintWriter().println("Exception: " + e.getMessage());
+            return -1;
+        }
+
+        if (VDBG) {
+            Log.v(LOG_TAG, "uce get-eab-capability, result: " + result);
+        }
+        getOutPrintWriter().println(result);
+        return 0;
+    }
+
     private int handleUceGetDeviceEnabledCommand() {
         boolean result = false;
         try {