Made changes to fix some policy transparency options.
Add isInputMethodPermittedByAdmin and
isAccessibilityServicePermittedByAdmin APIs in DevicePolicyManager.
And update utility methods in RestrictedLockUtils to use the correct
userId when checking if disabled by admin.
Bug: 26897250
Bug: 26767564
Bug: 26966213
Change-Id: I0b74b3e57904a82f8ce72d856769d35b5e8403e5
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index f04e76e..6c8010d 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -4068,6 +4068,29 @@
}
/**
+ * Called by the system to check if a specific accessibility service is disabled by admin.
+ *
+ * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
+ * @param packageName Accessibility service package name that needs to be checked.
+ * @param userHandle user id the admin is running as.
+ * @return true if the accessibility service is permitted, otherwise false.
+ *
+ * @hide
+ */
+ public boolean isAccessibilityServicePermittedByAdmin(@NonNull ComponentName admin,
+ @NonNull String packageName, int userHandle) {
+ if (mService != null) {
+ try {
+ return mService.isAccessibilityServicePermittedByAdmin(admin, packageName,
+ userHandle);
+ } catch (RemoteException e) {
+ Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ }
+ }
+ return false;
+ }
+
+ /**
* Returns the list of accessibility services permitted by the device or profiles
* owners of this user.
*
@@ -4147,6 +4170,28 @@
}
/**
+ * Called by the system to check if a specific input method is disabled by admin.
+ *
+ * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
+ * @param packageName Input method package name that needs to be checked.
+ * @param userHandle user id the admin is running as.
+ * @return true if the input method is permitted, otherwise false.
+ *
+ * @hide
+ */
+ public boolean isInputMethodPermittedByAdmin(@NonNull ComponentName admin,
+ @NonNull String packageName, int userHandle) {
+ if (mService != null) {
+ try {
+ return mService.isInputMethodPermittedByAdmin(admin, packageName, userHandle);
+ } catch (RemoteException e) {
+ Log.w(TAG, REMOTE_EXCEPTION_MESSAGE, e);
+ }
+ }
+ return false;
+ }
+
+ /**
* Returns the list of input methods permitted by the device or profiles
* owners of the current user. (*Not* calling user, due to a limitation in InputMethodManager.)
*