Add new ITelephony ShellCommand interface

Adds the ability for shell commands to be processed
for testing. Also adds four IMS commands to start.

Bug: 77141737
Test: "adb shell cmd phone"
Change-Id: I5947717f2545c64a780951f4d7df2fa50b6605d8
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 5cbb6f6..fad4698 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -42,6 +42,7 @@
 import android.os.RemoteException;
 import android.os.ResultReceiver;
 import android.os.ServiceManager;
+import android.os.ShellCallback;
 import android.os.SystemProperties;
 import android.os.UserHandle;
 import android.os.UserManager;
@@ -2722,6 +2723,37 @@
         return PhoneFactory.getImsResolver().isResolvingBinding();
     }
 
+    /**
+     * Sets the ImsService Package Name that Telephony will bind to.
+     *
+     * @param slotId the slot ID that the ImsService should bind for.
+     * @param isCarrierImsService true if the ImsService is the carrier override, false if the
+     *         ImsService is the device default ImsService.
+     * @param packageName The package name of the application that contains the ImsService to bind
+     *         to.
+     * @return true if setting the ImsService to bind to succeeded, false if it did not.
+     * @hide
+     */
+    public boolean setImsService(int slotId, boolean isCarrierImsService, String packageName) {
+        enforceModifyPermission();
+        return PhoneFactory.getImsResolver().overrideImsServiceConfiguration(slotId,
+                isCarrierImsService, packageName);
+    }
+
+    /**
+     * Return the ImsService configuration.
+     *
+     * @param slotId The slot that the ImsService is associated with.
+     * @param isCarrierImsService true, if the ImsService is a carrier override, false if it is
+     *         the device default.
+     * @return the package name of the ImsService configuration.
+     */
+    public String getImsService(int slotId, boolean isCarrierImsService) {
+        enforceReadPrivilegedPermission();
+        return PhoneFactory.getImsResolver().getImsServiceConfiguration(slotId,
+                isCarrierImsService);
+    }
+
     public void setImsRegistrationState(boolean registered) {
         enforceModifyPermission();
         mPhone.setImsRegistrationState(registered);
@@ -3953,6 +3985,13 @@
         DumpsysHandler.dump(mPhone.getContext(), fd, writer, args);
     }
 
+    @Override
+    public void onShellCommand(FileDescriptor in, FileDescriptor out, FileDescriptor err,
+            String[] args, ShellCallback callback, ResultReceiver resultReceiver)
+            throws RemoteException {
+        (new TelephonyShellCommand(this)).exec(this, in, out, err, args, callback, resultReceiver);
+    }
+
     /**
      * Get aggregated video call data usage since boot.
      *