summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/core/java/com/android/server/notification/NotificationManagerService.java44
-rw-r--r--services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java1
2 files changed, 26 insertions, 19 deletions
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index e81b32c4a7a2..67c5e0034bf6 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -1152,15 +1152,18 @@ public class NotificationManagerService extends SystemService {
// turn off LED when user passes through lock screen
mNotificationLight.turnOff();
} else if (action.equals(Intent.ACTION_USER_SWITCHED)) {
- final int user = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, USER_NULL);
- // reload per-user settings
- mSettingsObserver.update(null);
+ final int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, USER_NULL);
mUserProfiles.updateCache(context);
- // Refresh managed services
- mConditionProviders.onUserSwitched(user);
- mListeners.onUserSwitched(user);
- mAssistants.onUserSwitched(user);
- mZenModeHelper.onUserSwitched(user);
+ if (!mUserProfiles.isManagedProfile(userId)) {
+ // reload per-user settings
+ mSettingsObserver.update(null);
+ // Refresh managed services
+ mConditionProviders.onUserSwitched(userId);
+ mListeners.onUserSwitched(userId);
+ mZenModeHelper.onUserSwitched(userId);
+ }
+ // assistant is the only thing that cares about managed profiles specifically
+ mAssistants.onUserSwitched(userId);
} else if (action.equals(Intent.ACTION_USER_ADDED)) {
final int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, USER_NULL);
if (userId != USER_NULL) {
@@ -1170,20 +1173,23 @@ public class NotificationManagerService extends SystemService {
}
}
} else if (action.equals(Intent.ACTION_USER_REMOVED)) {
- final int user = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, USER_NULL);
+ final int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, USER_NULL);
mUserProfiles.updateCache(context);
- mZenModeHelper.onUserRemoved(user);
- mPreferencesHelper.onUserRemoved(user);
- mListeners.onUserRemoved(user);
- mConditionProviders.onUserRemoved(user);
- mAssistants.onUserRemoved(user);
+ mZenModeHelper.onUserRemoved(userId);
+ mPreferencesHelper.onUserRemoved(userId);
+ mListeners.onUserRemoved(userId);
+ mConditionProviders.onUserRemoved(userId);
+ mAssistants.onUserRemoved(userId);
savePolicyFile();
} else if (action.equals(Intent.ACTION_USER_UNLOCKED)) {
- final int user = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, USER_NULL);
- mConditionProviders.onUserUnlocked(user);
- mListeners.onUserUnlocked(user);
- mAssistants.onUserUnlocked(user);
- mZenModeHelper.onUserUnlocked(user);
+ final int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, USER_NULL);
+ mUserProfiles.updateCache(context);
+ mAssistants.onUserUnlocked(userId);
+ if (!mUserProfiles.isManagedProfile(userId)) {
+ mConditionProviders.onUserUnlocked(userId);
+ mListeners.onUserUnlocked(userId);
+ mZenModeHelper.onUserUnlocked(userId);
+ }
}
}
};
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
index 4344285e31e7..cbf6c6ecd331 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
@@ -97,6 +97,7 @@ import android.os.IBinder;
import android.os.Process;
import android.os.RemoteException;
import android.os.UserHandle;
+import android.os.UserManager;
import android.provider.MediaStore;
import android.provider.Settings.Secure;
import android.service.notification.Adjustment;