Loading services/core/java/com/android/server/pm/UserManagerService.java +27 −9 Original line number Diff line number Diff line Loading @@ -1387,17 +1387,22 @@ public class UserManagerService extends IUserManager.Stub { @Override public void setUserEnabled(@UserIdInt int userId) { checkManageUsersPermission("enable user"); synchronized (mPackagesLock) { UserInfo info; boolean wasUserDisabled = false; synchronized (mPackagesLock) { synchronized (mUsersLock) { info = getUserInfoLU(userId); } if (info != null && !info.isEnabled()) { wasUserDisabled = true; info.flags ^= UserInfo.FLAG_DISABLED; writeUserLP(getUserDataLU(info.id)); } } } if (wasUserDisabled && info != null && info.isProfile()) { sendProfileAddedBroadcast(info.profileGroupId, info.id); } } @Override public void setUserAdmin(@UserIdInt int userId) { Loading Loading @@ -4867,7 +4872,9 @@ public class UserManagerService extends IUserManager.Stub { MetricsLogger.count(mContext, userInfo.isGuest() ? TRON_GUEST_CREATED : (userInfo.isDemo() ? TRON_DEMO_CREATED : TRON_USER_CREATED), 1); if (!userInfo.isProfile()) { if (userInfo.isProfile()) { sendProfileAddedBroadcast(userInfo.profileGroupId, userInfo.id); } else { // If the user switch hasn't been explicitly toggled on or off by the user, turn it on. if (android.provider.Settings.Global.getString(mContext.getContentResolver(), android.provider.Settings.Global.USER_SWITCHER_ENABLED) == null) { Loading Loading @@ -5466,6 +5473,17 @@ public class UserManagerService extends IUserManager.Stub { } } /** * Send {@link Intent#ACTION_PROFILE_ADDED} broadcast when a user of type * {@link UserInfo#isProfile()} is added. This broadcast is sent only to dynamic receivers * created with {@link Context#registerReceiver}. */ private void sendProfileAddedBroadcast(int parentUserId, int addedUserId) { sendProfileBroadcast( new Intent(Intent.ACTION_PROFILE_ADDED), parentUserId, addedUserId); } /** * Send {@link Intent#ACTION_PROFILE_REMOVED} broadcast when a user of type * {@link UserInfo#isProfile()} is removed. Additionally sends Loading @@ -5484,12 +5502,12 @@ public class UserManagerService extends IUserManager.Stub { if (Objects.equals(userType, UserManager.USER_TYPE_PROFILE_MANAGED)) { sendManagedProfileRemovedBroadcast(parentUserId, removedUserId); } sendProfileBroadcastToRegisteredReceivers( sendProfileBroadcast( new Intent(Intent.ACTION_PROFILE_REMOVED), parentUserId, removedUserId); } private void sendProfileBroadcastToRegisteredReceivers(Intent intent, private void sendProfileBroadcast(Intent intent, int parentUserId, int userId) { final UserHandle parentHandle = UserHandle.of(parentUserId); intent.putExtra(Intent.EXTRA_USER, UserHandle.of(userId)); Loading @@ -5500,7 +5518,7 @@ public class UserManagerService extends IUserManager.Stub { private void sendManagedProfileRemovedBroadcast(int parentUserId, int removedUserId) { Intent managedProfileIntent = new Intent(Intent.ACTION_MANAGED_PROFILE_REMOVED); managedProfileIntent.putExtra(Intent.EXTRA_USER, new UserHandle(removedUserId)); managedProfileIntent.putExtra(Intent.EXTRA_USER, UserHandle.of(removedUserId)); managedProfileIntent.putExtra(Intent.EXTRA_USER_HANDLE, removedUserId); final UserHandle parentHandle = UserHandle.of(parentUserId); getDevicePolicyManagerInternal().broadcastIntentToManifestReceivers( Loading Loading
services/core/java/com/android/server/pm/UserManagerService.java +27 −9 Original line number Diff line number Diff line Loading @@ -1387,17 +1387,22 @@ public class UserManagerService extends IUserManager.Stub { @Override public void setUserEnabled(@UserIdInt int userId) { checkManageUsersPermission("enable user"); synchronized (mPackagesLock) { UserInfo info; boolean wasUserDisabled = false; synchronized (mPackagesLock) { synchronized (mUsersLock) { info = getUserInfoLU(userId); } if (info != null && !info.isEnabled()) { wasUserDisabled = true; info.flags ^= UserInfo.FLAG_DISABLED; writeUserLP(getUserDataLU(info.id)); } } } if (wasUserDisabled && info != null && info.isProfile()) { sendProfileAddedBroadcast(info.profileGroupId, info.id); } } @Override public void setUserAdmin(@UserIdInt int userId) { Loading Loading @@ -4867,7 +4872,9 @@ public class UserManagerService extends IUserManager.Stub { MetricsLogger.count(mContext, userInfo.isGuest() ? TRON_GUEST_CREATED : (userInfo.isDemo() ? TRON_DEMO_CREATED : TRON_USER_CREATED), 1); if (!userInfo.isProfile()) { if (userInfo.isProfile()) { sendProfileAddedBroadcast(userInfo.profileGroupId, userInfo.id); } else { // If the user switch hasn't been explicitly toggled on or off by the user, turn it on. if (android.provider.Settings.Global.getString(mContext.getContentResolver(), android.provider.Settings.Global.USER_SWITCHER_ENABLED) == null) { Loading Loading @@ -5466,6 +5473,17 @@ public class UserManagerService extends IUserManager.Stub { } } /** * Send {@link Intent#ACTION_PROFILE_ADDED} broadcast when a user of type * {@link UserInfo#isProfile()} is added. This broadcast is sent only to dynamic receivers * created with {@link Context#registerReceiver}. */ private void sendProfileAddedBroadcast(int parentUserId, int addedUserId) { sendProfileBroadcast( new Intent(Intent.ACTION_PROFILE_ADDED), parentUserId, addedUserId); } /** * Send {@link Intent#ACTION_PROFILE_REMOVED} broadcast when a user of type * {@link UserInfo#isProfile()} is removed. Additionally sends Loading @@ -5484,12 +5502,12 @@ public class UserManagerService extends IUserManager.Stub { if (Objects.equals(userType, UserManager.USER_TYPE_PROFILE_MANAGED)) { sendManagedProfileRemovedBroadcast(parentUserId, removedUserId); } sendProfileBroadcastToRegisteredReceivers( sendProfileBroadcast( new Intent(Intent.ACTION_PROFILE_REMOVED), parentUserId, removedUserId); } private void sendProfileBroadcastToRegisteredReceivers(Intent intent, private void sendProfileBroadcast(Intent intent, int parentUserId, int userId) { final UserHandle parentHandle = UserHandle.of(parentUserId); intent.putExtra(Intent.EXTRA_USER, UserHandle.of(userId)); Loading @@ -5500,7 +5518,7 @@ public class UserManagerService extends IUserManager.Stub { private void sendManagedProfileRemovedBroadcast(int parentUserId, int removedUserId) { Intent managedProfileIntent = new Intent(Intent.ACTION_MANAGED_PROFILE_REMOVED); managedProfileIntent.putExtra(Intent.EXTRA_USER, new UserHandle(removedUserId)); managedProfileIntent.putExtra(Intent.EXTRA_USER, UserHandle.of(removedUserId)); managedProfileIntent.putExtra(Intent.EXTRA_USER_HANDLE, removedUserId); final UserHandle parentHandle = UserHandle.of(parentUserId); getDevicePolicyManagerInternal().broadcastIntentToManifestReceivers( Loading