Add TelephonyShellCommand to get EAB contact

Bug: 174166728
Test: atest
Change-Id: I858e547d6c76263c0cb3438b0c9ae0d8cea556de
diff --git a/src/com/android/phone/TelephonyShellCommand.java b/src/com/android/phone/TelephonyShellCommand.java
index d526e2f..1e87fbe 100644
--- a/src/com/android/phone/TelephonyShellCommand.java
+++ b/src/com/android/phone/TelephonyShellCommand.java
@@ -106,6 +106,7 @@
     private static final String D2D_SEND = "send";
 
     private static final String RCS_UCE_COMMAND = "uce";
+    private static final String UCE_GET_EAB_CONTACT = "get-eab-contact";
     private static final String UCE_REMOVE_EAB_CONTACT = "remove-eab-contact";
 
     // Take advantage of existing methods that already contain permissions checks when possible.
@@ -294,6 +295,12 @@
     private void onHelpUce() {
         PrintWriter pw = getOutPrintWriter();
         pw.println("User Capability Exchange Commands:");
+        pw.println("  uce get-eab-contact [PHONE_NUMBER]");
+        pw.println("    Get the EAB contacts from the EAB database.");
+        pw.println("    Options are:");
+        pw.println("      PHONE_NUMBER: The phone numbers to be removed from the EAB databases");
+        pw.println("    Expected output format :");
+        pw.println("      [PHONE_NUMBER],[RAW_CONTACT_ID],[CONTACT_ID],[DATA_ID]");
         pw.println("  uce remove-eab-contact [-s SLOT_ID] [PHONE_NUMBER]");
         pw.println("    Remove the EAB contacts from the EAB database.");
         pw.println("    Options are:");
@@ -1612,6 +1619,8 @@
         switch (arg) {
             case UCE_REMOVE_EAB_CONTACT:
                 return handleRemovingEabContactCommand();
+            case UCE_GET_EAB_CONTACT:
+                return handleGettingEabContactCommand();
         }
         return -1;
     }
@@ -1641,6 +1650,28 @@
         return result;
     }
 
+    private int handleGettingEabContactCommand() {
+        String phoneNumber = getNextArgRequired();
+        if (TextUtils.isEmpty(phoneNumber)) {
+            return -1;
+        }
+        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());
+            return -1;
+        }
+
+        if (VDBG) {
+            Log.v(LOG_TAG, "uce get-eab-contact, result: " + result);
+        }
+        getOutPrintWriter().println(result);
+        return 0;
+    }
+
     private int handleSrcSetDeviceEnabledCommand() {
         String enabledStr = getNextArg();
         if (enabledStr == null) {