From ac383e52a9c76dcc1a14a82848abb49b81c49f99 Mon Sep 17 00:00:00 2001 From: Adam Connors Date: Mon, 9 Jun 2014 13:55:47 +0100 Subject: [PATCH] DO NOT MERGE : Api review: Make ACTION_MANAGED_PROFILE_REMOVED registered only. And update the javadoc to explain use-case. Bug: 15025562 Change-Id: I8eb2666c8480f873e042687223b1a1f82e7919c9 --- core/java/android/content/Intent.java | 10 +++++++--- .../java/com/android/server/pm/UserManagerService.java | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index 5ad6b246c7a2b..6e53a6fb59692 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -2656,7 +2656,9 @@ public class Intent implements Parcelable, Cloneable { /** * Broadcast sent to the primary user when an associated managed profile is added (the profile * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies - * the UserHandle of the profile that was added. This is only sent to registered receivers, + * the UserHandle of the profile that was added. Only applications (for example Launchers) + * that need to display merged content across both primary and managed profiles need to + * worry about this broadcast. This is only sent to registered receivers, * not manifest receivers. */ public static final String ACTION_MANAGED_PROFILE_ADDED = @@ -2664,8 +2666,10 @@ public class Intent implements Parcelable, Cloneable { /** * Broadcast sent to the primary user when an associated managed profile is removed. Carries an - * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed. This - * is only sent to registered receivers, not manifest receivers. + * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed. + * Only applications (for example Launchers) that need to display merged content across both + * primary and managed profiles need to worry about this broadcast. This is only sent to + * registered receivers, not manifest receivers. */ public static final String ACTION_MANAGED_PROFILE_REMOVED = "android.intent.action.MANAGED_PROFILE_REMOVED"; diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java index 102b2d40448ad..a8f61160a8b6c 100644 --- a/services/core/java/com/android/server/pm/UserManagerService.java +++ b/services/core/java/com/android/server/pm/UserManagerService.java @@ -1268,7 +1268,8 @@ public class UserManagerService extends IUserManager.Stub { private void sendProfileRemovedBroadcast(int parentUserId, int removedUserId) { Intent managedProfileIntent = new Intent(Intent.ACTION_MANAGED_PROFILE_REMOVED); - managedProfileIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); + managedProfileIntent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY | + Intent.FLAG_RECEIVER_FOREGROUND); managedProfileIntent.putExtra(Intent.EXTRA_USER, new UserHandle(removedUserId)); mContext.sendBroadcastAsUser(managedProfileIntent, new UserHandle(parentUserId), null); }