Loading services/core/java/com/android/server/notification/NotificationManagerService.java +0 −2 Original line number Diff line number Diff line Loading @@ -1775,7 +1775,6 @@ public class NotificationManagerService extends SystemService { mConditionProviders.onUserSwitched(userId); mListeners.onUserSwitched(userId); mZenModeHelper.onUserSwitched(userId); mPreferencesHelper.onUserSwitched(userId); } // assistant is the only thing that cares about managed profiles specifically mAssistants.onUserSwitched(userId); Loading Loading @@ -1805,7 +1804,6 @@ public class NotificationManagerService extends SystemService { mConditionProviders.onUserUnlocked(userId); mListeners.onUserUnlocked(userId); mZenModeHelper.onUserUnlocked(userId); mPreferencesHelper.onUserUnlocked(userId); } } } Loading services/core/java/com/android/server/notification/PreferencesHelper.java +10 −20 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.ParceledListSlice; import android.metrics.LogMaker; import android.os.Binder; import android.os.Build; import android.os.UserHandle; import android.provider.Settings; Loading Loading @@ -190,8 +191,6 @@ public class PreferencesHelper implements RankingConfig { private Map<String, List<String>> mOemLockedApps = new HashMap(); private int mCurrentUserId = UserHandle.USER_NULL; public PreferencesHelper(Context context, PackageManager pm, RankingHandler rankingHandler, ZenModeHelper zenHelper, PermissionHelper permHelper, NotificationChannelLogger notificationChannelLogger, Loading @@ -215,7 +214,6 @@ public class PreferencesHelper implements RankingConfig { updateBadgingEnabled(); updateBubblesEnabled(); updateMediaNotificationFilteringEnabled(); mCurrentUserId = ActivityManager.getCurrentUser(); syncChannelsBypassingDnd(); } Loading Loading @@ -1762,12 +1760,13 @@ public class PreferencesHelper implements RankingConfig { private void updateChannelsBypassingDnd() { ArraySet<Pair<String, Integer>> candidatePkgs = new ArraySet<>(); final int currentUserId = getCurrentUser(); synchronized (mPackagePreferences) { final int numPackagePreferences = mPackagePreferences.size(); for (int i = 0; i < numPackagePreferences; i++) { final PackagePreferences r = mPackagePreferences.valueAt(i); // Package isn't associated with the current userId if (mCurrentUserId != UserHandle.getUserId(r.uid)) { if (currentUserId != UserHandle.getUserId(r.uid)) { continue; } Loading Loading @@ -1804,6 +1803,13 @@ public class PreferencesHelper implements RankingConfig { } } private int getCurrentUser() { final long identity = Binder.clearCallingIdentity(); int currentUserId = ActivityManager.getCurrentUser(); Binder.restoreCallingIdentity(identity); return currentUserId; } private boolean channelIsLiveLocked(PackagePreferences pkgPref, NotificationChannel channel) { // Channel is in a group that's blocked if (isGroupBlocked(pkgPref.pkg, pkgPref.uid, channel.getGroup())) { Loading Loading @@ -2509,22 +2515,6 @@ public class PreferencesHelper implements RankingConfig { return packageChannels; } /** * Called when user switches */ public void onUserSwitched(int userId) { mCurrentUserId = userId; syncChannelsBypassingDnd(); } /** * Called when user is unlocked */ public void onUserUnlocked(int userId) { mCurrentUserId = userId; syncChannelsBypassingDnd(); } public void onUserRemoved(int userId) { synchronized (mPackagePreferences) { int N = mPackagePreferences.size(); Loading services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java +0 −18 Original line number Diff line number Diff line Loading @@ -1800,24 +1800,6 @@ public class PreferencesHelperTest extends UiServiceTestCase { assertEquals(0, mHelper.getBlockedChannelCount("pkg2", UID_O)); } @Test public void testUpdateChannelsBypassingDnd_onUserSwitch_onUserUnlocked() throws Exception { int user = USER.getIdentifier(); NotificationChannelGroup ncg = new NotificationChannelGroup("group1", "name1"); NotificationChannel channel1 = new NotificationChannel("id1", "name1", NotificationManager.IMPORTANCE_MAX); channel1.setBypassDnd(true); channel1.setGroup(ncg.getId()); // channel is associated with a group, then group is deleted mHelper.createNotificationChannelGroup(PKG_N_MR1, user, ncg, /* fromTargetApp */ true); mHelper.createNotificationChannel(PKG_N_MR1, user, channel1, true, /*has DND access*/ true); mHelper.deleteNotificationChannelGroup(PKG_N_MR1, user, ncg.getId()); mHelper.onUserSwitched(user); mHelper.onUserUnlocked(user); } @Test public void testGetChannelsBypassingDndCount_noChannelsBypassing() throws Exception { assertEquals(0, mHelper.getNotificationChannelsBypassingDnd(PKG_N_MR1, Loading Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +0 −2 Original line number Diff line number Diff line Loading @@ -1775,7 +1775,6 @@ public class NotificationManagerService extends SystemService { mConditionProviders.onUserSwitched(userId); mListeners.onUserSwitched(userId); mZenModeHelper.onUserSwitched(userId); mPreferencesHelper.onUserSwitched(userId); } // assistant is the only thing that cares about managed profiles specifically mAssistants.onUserSwitched(userId); Loading Loading @@ -1805,7 +1804,6 @@ public class NotificationManagerService extends SystemService { mConditionProviders.onUserUnlocked(userId); mListeners.onUserUnlocked(userId); mZenModeHelper.onUserUnlocked(userId); mPreferencesHelper.onUserUnlocked(userId); } } } Loading
services/core/java/com/android/server/notification/PreferencesHelper.java +10 −20 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.ParceledListSlice; import android.metrics.LogMaker; import android.os.Binder; import android.os.Build; import android.os.UserHandle; import android.provider.Settings; Loading Loading @@ -190,8 +191,6 @@ public class PreferencesHelper implements RankingConfig { private Map<String, List<String>> mOemLockedApps = new HashMap(); private int mCurrentUserId = UserHandle.USER_NULL; public PreferencesHelper(Context context, PackageManager pm, RankingHandler rankingHandler, ZenModeHelper zenHelper, PermissionHelper permHelper, NotificationChannelLogger notificationChannelLogger, Loading @@ -215,7 +214,6 @@ public class PreferencesHelper implements RankingConfig { updateBadgingEnabled(); updateBubblesEnabled(); updateMediaNotificationFilteringEnabled(); mCurrentUserId = ActivityManager.getCurrentUser(); syncChannelsBypassingDnd(); } Loading Loading @@ -1762,12 +1760,13 @@ public class PreferencesHelper implements RankingConfig { private void updateChannelsBypassingDnd() { ArraySet<Pair<String, Integer>> candidatePkgs = new ArraySet<>(); final int currentUserId = getCurrentUser(); synchronized (mPackagePreferences) { final int numPackagePreferences = mPackagePreferences.size(); for (int i = 0; i < numPackagePreferences; i++) { final PackagePreferences r = mPackagePreferences.valueAt(i); // Package isn't associated with the current userId if (mCurrentUserId != UserHandle.getUserId(r.uid)) { if (currentUserId != UserHandle.getUserId(r.uid)) { continue; } Loading Loading @@ -1804,6 +1803,13 @@ public class PreferencesHelper implements RankingConfig { } } private int getCurrentUser() { final long identity = Binder.clearCallingIdentity(); int currentUserId = ActivityManager.getCurrentUser(); Binder.restoreCallingIdentity(identity); return currentUserId; } private boolean channelIsLiveLocked(PackagePreferences pkgPref, NotificationChannel channel) { // Channel is in a group that's blocked if (isGroupBlocked(pkgPref.pkg, pkgPref.uid, channel.getGroup())) { Loading Loading @@ -2509,22 +2515,6 @@ public class PreferencesHelper implements RankingConfig { return packageChannels; } /** * Called when user switches */ public void onUserSwitched(int userId) { mCurrentUserId = userId; syncChannelsBypassingDnd(); } /** * Called when user is unlocked */ public void onUserUnlocked(int userId) { mCurrentUserId = userId; syncChannelsBypassingDnd(); } public void onUserRemoved(int userId) { synchronized (mPackagePreferences) { int N = mPackagePreferences.size(); Loading
services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java +0 −18 Original line number Diff line number Diff line Loading @@ -1800,24 +1800,6 @@ public class PreferencesHelperTest extends UiServiceTestCase { assertEquals(0, mHelper.getBlockedChannelCount("pkg2", UID_O)); } @Test public void testUpdateChannelsBypassingDnd_onUserSwitch_onUserUnlocked() throws Exception { int user = USER.getIdentifier(); NotificationChannelGroup ncg = new NotificationChannelGroup("group1", "name1"); NotificationChannel channel1 = new NotificationChannel("id1", "name1", NotificationManager.IMPORTANCE_MAX); channel1.setBypassDnd(true); channel1.setGroup(ncg.getId()); // channel is associated with a group, then group is deleted mHelper.createNotificationChannelGroup(PKG_N_MR1, user, ncg, /* fromTargetApp */ true); mHelper.createNotificationChannel(PKG_N_MR1, user, channel1, true, /*has DND access*/ true); mHelper.deleteNotificationChannelGroup(PKG_N_MR1, user, ncg.getId()); mHelper.onUserSwitched(user); mHelper.onUserUnlocked(user); } @Test public void testGetChannelsBypassingDndCount_noChannelsBypassing() throws Exception { assertEquals(0, mHelper.getNotificationChannelsBypassingDnd(PKG_N_MR1, Loading