summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Julia Reynolds <juliacr@google.com> 2018-09-24 14:53:54 -0400
committer Julia Reynolds <juliacr@google.com> 2018-09-24 23:50:49 +0000
commit4ff9749b23cf9bd578335d54cf1df3d9f16166c3 (patch)
tree926c98d96b6e6c68f5c606a6bc64712f8e337d3d
parentcc704723bdd4e26d476898bfa3f09b1f3ee0bc0f (diff)
Selectively inform subservices about managed profiles
Test: check bugreport, make sure loaded DND config belongs to the primary user, not the managed profile user Fixes: 116477174 Change-Id: I148445d2e32fd286fe8a9387aaffb66306b6534d
-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;