diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java index e52ae5186180c..fde9b961dcb85 100644 --- a/core/java/android/app/admin/DevicePolicyManager.java +++ b/core/java/android/app/admin/DevicePolicyManager.java @@ -9713,9 +9713,9 @@ public class DevicePolicyManager { * service. When zero or more packages have been added, accessibility services that are not in * the list and not part of the system can not be enabled by the user. *

- * Calling with a null value for the list disables the restriction so that all services can be - * used, calling with an empty list only allows the built-in system services. Any non-system - * accessibility service that's currently enabled must be included in the list. + * Calling with a {@code null} value for the list disables the restriction so that all services + * can be used, calling with an empty list only allows the built-in system services. Any + * non-system accessibility service that's currently enabled must be included in the list. *

* System accessibility services are always available to the user and this method can't * disable them. @@ -9741,8 +9741,8 @@ public class DevicePolicyManager { /** * Returns the list of permitted accessibility services set by this device or profile owner. *

- * An empty list means no accessibility services except system services are allowed. Null means - * all accessibility services are allowed. + * An empty list means no accessibility services except system services are allowed. + * {@code null} means all accessibility services are allowed. * * @param admin Which {@link DeviceAdminReceiver} this request is associated with. * @return List of accessiblity service package names. @@ -9787,7 +9787,7 @@ public class DevicePolicyManager { * Returns the list of accessibility services permitted by the device or profiles * owners of this user. * - *

Null means all accessibility services are allowed, if a non-null list is returned + *

{@code null} means all accessibility services are allowed, if a non-null list is returned * it will contain the intersection of the permitted lists for any device or profile * owners that apply to this user. It will also include any system accessibility services. * @@ -9933,6 +9933,8 @@ public class DevicePolicyManager { * * @return List of input method package names. * @hide + * + * @see #setPermittedAccessibilityServices(ComponentName, List) */ @SystemApi @RequiresPermission(anyOf = { @@ -9953,29 +9955,30 @@ public class DevicePolicyManager { /** * Returns the list of input methods permitted. * - *

When this method returns empty list means all input methods are allowed, if a non-empty - * list is returned it will contain the intersection of the permitted lists for any device or - * profile owners that apply to this user. It will also include any system input methods. + *

{@code null} means all input methods are allowed, if a non-null list is returned + * it will contain the intersection of the permitted lists for any device or profile + * owners that apply to this user. It will also include any system input methods. * * @return List of input method package names. * @hide + * + * @see #setPermittedAccessibilityServices(ComponentName, List) */ @UserHandleAware @RequiresPermission(allOf = { android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, android.Manifest.permission.MANAGE_USERS }, conditional = true) - public @NonNull List getPermittedInputMethods() { + public @Nullable List getPermittedInputMethods() { throwIfParentInstance("getPermittedInputMethods"); - List result = null; if (mService != null) { try { - result = mService.getPermittedInputMethodsAsUser(myUserId()); + return mService.getPermittedInputMethodsAsUser(myUserId()); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } - return result != null ? result : Collections.emptyList(); + return null; } /** diff --git a/packages/SettingsLib/src/com/android/settingslib/inputmethod/InputMethodPreference.java b/packages/SettingsLib/src/com/android/settingslib/inputmethod/InputMethodPreference.java index 484ca9321c234..1f4cafce835fb 100644 --- a/packages/SettingsLib/src/com/android/settingslib/inputmethod/InputMethodPreference.java +++ b/packages/SettingsLib/src/com/android/settingslib/inputmethod/InputMethodPreference.java @@ -221,8 +221,8 @@ public class InputMethodPreference extends PrimarySwitchPreference setSwitchEnabled(false); } else if (!mIsAllowedByOrganization) { EnforcedAdmin admin = - RestrictedLockUtilsInternal.checkIfInputMethodDisallowed(getContext(), - mImi.getPackageName(), UserHandle.myUserId()); + RestrictedLockUtilsInternal.checkIfInputMethodDisallowed( + getContext(), mImi.getPackageName(), mUserId); setDisabledByAdmin(admin); } else { setEnabled(true);