diff options
author | Kenny Guy <kennyguy@google.com> | 2014-08-21 10:54:25 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-08-21 10:54:26 +0000 |
commit | b9e468cb9d77abf57473436e29042e1b27d9f70b (patch) | |
tree | f157ece3f6f970274f364c36c38442caf6dba72e /core/java/android/app/admin | |
parent | 671be93cbbd31526155169cff335d24cc620f5f1 (diff) | |
parent | fa80a4faa3ab32f61742b684e832126dae8468e7 (diff) | |
download | frameworks_base-b9e468cb9d77abf57473436e29042e1b27d9f70b.zip frameworks_base-b9e468cb9d77abf57473436e29042e1b27d9f70b.tar.gz frameworks_base-b9e468cb9d77abf57473436e29042e1b27d9f70b.tar.bz2 |
Merge "Add apis for whitelisting IMEs and accessibility services." into lmp-dev
Diffstat (limited to 'core/java/android/app/admin')
-rw-r--r-- | core/java/android/app/admin/DevicePolicyManager.java | 155 | ||||
-rw-r--r-- | core/java/android/app/admin/IDevicePolicyManager.aidl | 9 |
2 files changed, 164 insertions, 0 deletions
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java index bc4d2c1..7111445 100644 --- a/core/java/android/app/admin/DevicePolicyManager.java +++ b/core/java/android/app/admin/DevicePolicyManager.java @@ -2643,6 +2643,161 @@ public class DevicePolicyManager { } /** + * Called by a profile or device owner to set the permitted accessibility services. When + * set by a device owner or profile owner the restriction applies to all profiles of the + * user the device owner or profile owner is an admin for. + * + * By default the user can use any accessiblity service. When zero or more packages have + * been added, accessiblity 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 builtin system's services. + * + * <p> System accesibility services are always available to the user the list can't modify + * this. + * + * @param admin Which {@link DeviceAdminReceiver} this request is associated with. + * @param packageNames List of accessibility service package names. + * + * @return true if setting the restriction succeeded. It fail if there is + * one or more non-system accessibility services enabled, that are not in the list. + */ + public boolean setPermittedAccessibilityServices(ComponentName admin, + List<String> packageNames) { + if (mService != null) { + try { + return mService.setPermittedAccessibilityServices(admin, packageNames); + } catch (RemoteException e) { + Log.w(TAG, "Failed talking with device policy service", e); + } + } + return false; + } + + /** + * 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. + * + * @param admin Which {@link DeviceAdminReceiver} this request is associated with. + * @return List of accessiblity service package names. + */ + public List<String> getPermittedAccessibilityServices(ComponentName admin) { + if (mService != null) { + try { + return mService.getPermittedAccessibilityServices(admin); + } catch (RemoteException e) { + Log.w(TAG, "Failed talking with device policy service", e); + } + } + return null; + } + + /** + * 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 + * 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. + * + * @param userId which user to check for. + * @return List of accessiblity service package names. + * @hide + */ + @SystemApi + public List<String> getPermittedAccessibilityServices(int userId) { + if (mService != null) { + try { + return mService.getPermittedAccessibilityServicesForUser(userId); + } catch (RemoteException e) { + Log.w(TAG, "Failed talking with device policy service", e); + } + } + return null; + } + + /** + * Called by a profile or device owner to set the permitted input methods services. When + * set by a device owner or profile owner the restriction applies to all profiles of the + * user the device owner or profile owner is an admin for. + * + * By default the user can use any input method. When zero or more packages have + * been added, input method that are not in the list and not part of the system + * can not be enabled by the user. + * + * This method will fail if it is called for a admin that is not for the foreground user + * or a profile of the foreground user. + * + * <p> Calling with a null value for the list disables the restriction so that all input methods + * can be used, calling with an empty list disables all but the system's own input methods. + * + * <p> System input methods are always available to the user this method can't modify this. + * + * @param admin Which {@link DeviceAdminReceiver} this request is associated with. + * @param packageNames List of input method package names. + * @return true if setting the restriction succeeded. It will fail if there is + * one or more input method enabled, that are not in the list or user if the foreground + * user. + */ + public boolean setPermittedInputMethods(ComponentName admin, List<String> packageNames) { + if (mService != null) { + try { + return mService.setPermittedInputMethods(admin, packageNames); + } catch (RemoteException e) { + Log.w(TAG, "Failed talking with device policy service", e); + } + } + return false; + } + + + /** + * Returns the list of permitted input methods set by this device or profile owner. + * + * <p>An empty list means no input methods except system input methods are allowed. + * Null means all input methods are allowed. + * + * @param admin Which {@link DeviceAdminReceiver} this request is associated with. + * @return List of input method package names. + */ + public List<String> getPermittedInputMethods(ComponentName admin) { + if (mService != null) { + try { + return mService.getPermittedInputMethods(admin); + } catch (RemoteException e) { + Log.w(TAG, "Failed talking with device policy service", e); + } + } + return null; + } + + /** + * Returns the list of input methods permitted by the device or profiles + * owners of the current user. + * + * <p>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 + */ + @SystemApi + public List<String> getPermittedInputMethodsForCurrentUser() { + if (mService != null) { + try { + return mService.getPermittedInputMethodsForCurrentUser(); + } catch (RemoteException e) { + Log.w(TAG, "Failed talking with device policy service", e); + } + } + return null; + } + + /** * Called by a device owner to create a user with the specified name. The UserHandle returned * by this method should not be persisted as user handles are recycled as users are removed and * created. If you need to persist an identifier for this user, use diff --git a/core/java/android/app/admin/IDevicePolicyManager.aidl b/core/java/android/app/admin/IDevicePolicyManager.aidl index 324b963..5f8a2a4 100644 --- a/core/java/android/app/admin/IDevicePolicyManager.aidl +++ b/core/java/android/app/admin/IDevicePolicyManager.aidl @@ -24,6 +24,7 @@ import android.net.ProxyInfo; import android.os.Bundle; import android.os.RemoteCallback; import android.os.UserHandle; +import java.util.List; /** * Internal IPC interface to the device policy service. @@ -137,6 +138,14 @@ interface IDevicePolicyManager { void addCrossProfileIntentFilter(in ComponentName admin, in IntentFilter filter, int flags); void clearCrossProfileIntentFilters(in ComponentName admin); + boolean setPermittedAccessibilityServices(in ComponentName admin,in List packageList); + List getPermittedAccessibilityServices(in ComponentName admin); + List getPermittedAccessibilityServicesForUser(int userId); + + boolean setPermittedInputMethods(in ComponentName admin,in List packageList); + List getPermittedInputMethods(in ComponentName admin); + List getPermittedInputMethodsForCurrentUser(); + boolean setApplicationHidden(in ComponentName admin, in String packageName, boolean hidden); int setApplicationsHidden(in ComponentName admin, in Intent intent, boolean hidden); boolean isApplicationHidden(in ComponentName admin, in String packageName); |