Merge "Make distinction between null and empty IM list."

This commit is contained in:
Pavel Grafov
2022-02-11 12:13:27 +00:00
committed by Android (Google) Code Review
2 changed files with 18 additions and 15 deletions

View File

@@ -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.
* <p>
* 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.
* <p>
* 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.
* <p>
* 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.
*
* <p>Null means all accessibility services are allowed, if a non-null list is returned
* <p>{@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.
*
* <p>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.
* <p>{@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<String> getPermittedInputMethods() {
public @Nullable List<String> getPermittedInputMethods() {
throwIfParentInstance("getPermittedInputMethods");
List<String> 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;
}
/**

View File

@@ -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);