diff options
author | Jason Monk <jmonk@google.com> | 2014-08-13 16:29:08 -0400 |
---|---|---|
committer | Jason Monk <jmonk@google.com> | 2014-08-14 11:37:58 -0400 |
commit | 48aacba761527a529c2b668c8151c7f98ff70524 (patch) | |
tree | f005c849cb57791dfe72c2655633569bdc52ff72 /core/java/android/app/admin | |
parent | d4c25dbe67ca1c46105d09905be7bd6fdcecf35b (diff) | |
download | frameworks_base-48aacba761527a529c2b668c8151c7f98ff70524.zip frameworks_base-48aacba761527a529c2b668c8151c7f98ff70524.tar.gz frameworks_base-48aacba761527a529c2b668c8151c7f98ff70524.tar.bz2 |
Fixes to lock task API from API review
Adding ComponentNames and some splitting/renaming of broadcasts.
Bug: 17005622
Change-Id: I9ece3553310fb20b0c3c3e4032b408e86384363a
Diffstat (limited to 'core/java/android/app/admin')
-rw-r--r-- | core/java/android/app/admin/DeviceAdminReceiver.java | 51 | ||||
-rw-r--r-- | core/java/android/app/admin/DevicePolicyManager.java | 12 | ||||
-rw-r--r-- | core/java/android/app/admin/IDevicePolicyManager.aidl | 4 |
3 files changed, 41 insertions, 26 deletions
diff --git a/core/java/android/app/admin/DeviceAdminReceiver.java b/core/java/android/app/admin/DeviceAdminReceiver.java index 1f168c3..15def09 100644 --- a/core/java/android/app/admin/DeviceAdminReceiver.java +++ b/core/java/android/app/admin/DeviceAdminReceiver.java @@ -167,28 +167,30 @@ public class DeviceAdminReceiver extends BroadcastReceiver { /** * Action sent to a device administrator to notify that the device is entering - * or exiting lock task mode from an authorized package. The extra - * {@link #EXTRA_LOCK_TASK_ENTERING} will describe whether entering or exiting - * the mode. If entering, the extra {@link #EXTRA_LOCK_TASK_PACKAGE} will describe - * the authorized package using lock task mode. + * lock task mode from an authorized package. The extra {@link #EXTRA_LOCK_TASK_PACKAGE} + * will describe the authorized package using lock task mode. * - * @see DevicePolicyManager#isLockTaskPermitted + * @see DevicePolicyManager#isLockTaskPermitted(String) * * <p>The calling device admin must be the device owner or profile * owner to receive this broadcast. */ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) - public static final String ACTION_LOCK_TASK_CHANGED - = "android.app.action.ACTION_LOCK_TASK_CHANGED"; + public static final String ACTION_LOCK_TASK_ENTERING + = "android.app.action.ACTION_LOCK_TASK_ENTERING"; /** - * A boolean describing whether the device is currently entering or exiting - * lock task mode. + * Action sent to a device administrator to notify that the device is exiting + * lock task mode from an authorized package. * - * @see #ACTION_LOCK_TASK_CHANGED + * @see DevicePolicyManager#isLockTaskPermitted(String) + * + * <p>The calling device admin must be the device owner or profile + * owner to receive this broadcast. */ - public static final String EXTRA_LOCK_TASK_ENTERING = - "android.app.extra.LOCK_TASK_ENTERING"; + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String ACTION_LOCK_TASK_EXITING + = "android.app.action.ACTION_LOCK_TASK_EXITING"; /** * A boolean describing whether the device is currently entering or exiting @@ -380,16 +382,24 @@ public class DeviceAdminReceiver extends BroadcastReceiver { } /** - * Called when a device is entering or exiting lock task mode by a package - * authorized by {@link DevicePolicyManager#isLockTaskPermitted(String)} + * Called when a device is entering lock task mode by a package authorized + * by {@link DevicePolicyManager#isLockTaskPermitted(String)} * * @param context The running context as per {@link #onReceive}. * @param intent The received intent as per {@link #onReceive}. - * @param isEnteringLockTask Whether the device is entering or exiting lock task mode. * @param pkg If entering, the authorized package using lock task mode, otherwise null. */ - public void onLockTaskModeChanged(Context context, Intent intent, boolean isEnteringLockTask, - String pkg) { + public void onLockTaskModeEntering(Context context, Intent intent, String pkg) { + } + + /** + * Called when a device is exiting lock task mode by a package authorized + * by {@link DevicePolicyManager#isLockTaskPermitted(String)} + * + * @param context The running context as per {@link #onReceive}. + * @param intent The received intent as per {@link #onReceive}. + */ + public void onLockTaskModeExiting(Context context, Intent intent) { } /** @@ -421,10 +431,11 @@ public class DeviceAdminReceiver extends BroadcastReceiver { onPasswordExpiring(context, intent); } else if (ACTION_PROFILE_PROVISIONING_COMPLETE.equals(action)) { onProfileProvisioningComplete(context, intent); - } else if (ACTION_LOCK_TASK_CHANGED.equals(action)) { - boolean isEntering = intent.getBooleanExtra(EXTRA_LOCK_TASK_ENTERING, false); + } else if (ACTION_LOCK_TASK_ENTERING.equals(action)) { String pkg = intent.getStringExtra(EXTRA_LOCK_TASK_PACKAGE); - onLockTaskModeChanged(context, intent, isEntering, pkg); + onLockTaskModeEntering(context, intent, pkg); + } else if (ACTION_LOCK_TASK_EXITING.equals(action)) { + onLockTaskModeExiting(context, intent); } } } diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java index ca6b1e8..4bf0354 100644 --- a/core/java/android/app/admin/DevicePolicyManager.java +++ b/core/java/android/app/admin/DevicePolicyManager.java @@ -2906,15 +2906,17 @@ public class DevicePolicyManager { * * This function can only be called by the device owner. * @param packages The list of packages allowed to enter lock task mode + * @param admin Which {@link DeviceAdminReceiver} this request is associated with. * * @see Activity#startLockTask() * @see DeviceAdminReceiver#onLockTaskModeChanged(Context, Intent, boolean, String) * @see UserManager#DISALLOW_CREATE_WINDOWS */ - public void setLockTaskPackages(String[] packages) throws SecurityException { + public void setLockTaskPackages(ComponentName admin, String[] packages) + throws SecurityException { if (mService != null) { try { - mService.setLockTaskPackages(packages); + mService.setLockTaskPackages(admin, packages); } catch (RemoteException e) { Log.w(TAG, "Failed talking with device policy service", e); } @@ -2923,12 +2925,14 @@ public class DevicePolicyManager { /** * This function returns the list of packages allowed to start the lock task mode. + * + * @param admin Which {@link DeviceAdminReceiver} this request is associated with. * @hide */ - public String[] getLockTaskPackages() { + public String[] getLockTaskPackages(ComponentName admin) { if (mService != null) { try { - return mService.getLockTaskPackages(); + return mService.getLockTaskPackages(admin); } catch (RemoteException e) { Log.w(TAG, "Failed talking with device policy service", e); } diff --git a/core/java/android/app/admin/IDevicePolicyManager.aidl b/core/java/android/app/admin/IDevicePolicyManager.aidl index 8954c0d..324b963 100644 --- a/core/java/android/app/admin/IDevicePolicyManager.aidl +++ b/core/java/android/app/admin/IDevicePolicyManager.aidl @@ -153,8 +153,8 @@ interface IDevicePolicyManager { String[] getAccountTypesWithManagementDisabled(); String[] getAccountTypesWithManagementDisabledAsUser(int userId); - void setLockTaskPackages(in String[] packages); - String[] getLockTaskPackages(); + void setLockTaskPackages(in ComponentName who, in String[] packages); + String[] getLockTaskPackages(in ComponentName who); boolean isLockTaskPermitted(in String pkg); void setGlobalSetting(in ComponentName who, in String setting, in String value); |