Add API for checking whether the default IME was set by the DO/PO

With this API, the system can determine whether a user's default
IME was set by the user or the user's DO/PO.

Bug: 32692748
Test: DPMS unit tests and CTS CtsDevicePolicyManagerTestCases

Change-Id: Ibd703ff5c9e4c072599ad8d6023c94a97d728109
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index 0eb47a3..d40d388 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -7865,4 +7865,27 @@
             throw re.rethrowFromSystemServer();
         }
     }
+
+    /**
+     * Called by the system to find out whether the user's IME was set by the device/profile owner
+     * or the user.
+     *
+     * @param user The user for whom to retrieve information.
+     * @return {@code true} if the user's IME was set by the device or profile owner, {@code false}
+     *         otherwise.
+     * @throws SecurityException if the caller does not have permission to retrieve information
+     *         about the given user's default IME. Device Owner and Profile Owner can retrieve
+     *         information about the user they run on; the System can retrieve information about any
+     *         user.
+     *
+     * @hide
+     */
+    @TestApi
+    public boolean isDefaultInputMethodSetByOwner(@NonNull UserHandle user) {
+        try {
+            return mService.isDefaultInputMethodSetByOwner(user);
+        } catch (RemoteException re) {
+            throw re.rethrowFromSystemServer();
+        }
+    }
 }