Loading core/java/android/util/IntArray.java +5 −0 Original line number Original line Diff line number Diff line Loading @@ -212,6 +212,11 @@ public class IntArray implements Cloneable { return -1; return -1; } } /** Returns {@code true} if this array contains the specified value. */ public boolean contains(int value) { return indexOf(value) != -1; } /** /** * Removes the value at the specified index from this array. * Removes the value at the specified index from this array. */ */ Loading core/tests/utiltests/src/android/util/IntArrayTest.java +3 −0 Original line number Original line Diff line number Diff line Loading @@ -55,9 +55,11 @@ public class IntArrayTest { a.add(5, 20); a.add(5, 20); assertThat(a.get(5)).isEqualTo(20); assertThat(a.get(5)).isEqualTo(20); assertThat(a.indexOf(20)).isEqualTo(5); assertThat(a.indexOf(20)).isEqualTo(5); assertThat(a.contains(20)).isTrue(); verify(a, 1, 2, 0, 0, 0, 20, 10, 0, 0); verify(a, 1, 2, 0, 0, 0, 20, 10, 0, 0); assertThat(a.indexOf(99)).isEqualTo(-1); assertThat(a.indexOf(99)).isEqualTo(-1); assertThat(a.contains(99)).isFalse(); a.resize(15); a.resize(15); a.set(14, 30); a.set(14, 30); Loading @@ -71,6 +73,7 @@ public class IntArrayTest { backingArray[2] = 30; backingArray[2] = 30; verify(a, backingArray); verify(a, backingArray); assertThat(a.indexOf(30)).isEqualTo(2); assertThat(a.indexOf(30)).isEqualTo(2); assertThat(a.contains(30)).isTrue(); a.resize(2); a.resize(2); assertThat(backingArray[2]).isEqualTo(0); assertThat(backingArray[2]).isEqualTo(0); Loading services/core/java/com/android/server/notification/NotificationManagerService.java +3 −2 Original line number Original line Diff line number Diff line Loading @@ -1928,6 +1928,7 @@ public class NotificationManagerService extends SystemService { mConditionProviders.onUserRemoved(userId); mConditionProviders.onUserRemoved(userId); mAssistants.onUserRemoved(userId); mAssistants.onUserRemoved(userId); mHistoryManager.onUserRemoved(userId); mHistoryManager.onUserRemoved(userId); mPreferencesHelper.syncChannelsBypassingDnd(); handleSavePolicyFile(); handleSavePolicyFile(); } else if (action.equals(Intent.ACTION_USER_UNLOCKED)) { } else if (action.equals(Intent.ACTION_USER_UNLOCKED)) { final int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, USER_NULL); final int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, USER_NULL); Loading Loading @@ -2379,6 +2380,7 @@ public class NotificationManagerService extends SystemService { }); }); mPermissionHelper = permissionHelper; mPermissionHelper = permissionHelper; mNotificationChannelLogger = channelLogger; mNotificationChannelLogger = channelLogger; mUserProfiles.updateCache(getContext()); mPreferencesHelper = new PreferencesHelper(getContext(), mPreferencesHelper = new PreferencesHelper(getContext(), mPackageManagerClient, mPackageManagerClient, mRankingHandler, mRankingHandler, Loading @@ -2387,6 +2389,7 @@ public class NotificationManagerService extends SystemService { mPermissionManager, mPermissionManager, mNotificationChannelLogger, mNotificationChannelLogger, mAppOps, mAppOps, mUserProfiles, new SysUiStatsEvent.BuilderFactory(), new SysUiStatsEvent.BuilderFactory(), mShowReviewPermissionsNotification); mShowReviewPermissionsNotification); mRankingHelper = new RankingHelper(getContext(), mRankingHelper = new RankingHelper(getContext(), Loading Loading @@ -2442,8 +2445,6 @@ public class NotificationManagerService extends SystemService { mZenModeHelper.initZenMode(); mZenModeHelper.initZenMode(); mInterruptionFilter = mZenModeHelper.getZenModeListenerInterruptionFilter(); mInterruptionFilter = mZenModeHelper.getZenModeListenerInterruptionFilter(); mUserProfiles.updateCache(getContext()); if (mPackageManagerClient.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) { if (mPackageManagerClient.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) { telephonyManager.listen(new PhoneStateListener() { telephonyManager.listen(new PhoneStateListener() { @Override @Override Loading services/core/java/com/android/server/notification/PreferencesHelper.java +12 −22 Original line number Original line Diff line number Diff line Loading @@ -38,7 +38,6 @@ import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.Nullable; import android.annotation.UserIdInt; import android.annotation.UserIdInt; import android.app.ActivityManager; import android.app.AppOpsManager; import android.app.AppOpsManager; import android.app.Notification; import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationChannel; Loading @@ -53,7 +52,6 @@ import android.content.pm.ParceledListSlice; import android.content.pm.UserInfo; import android.content.pm.UserInfo; import android.metrics.LogMaker; import android.metrics.LogMaker; import android.net.Uri; import android.net.Uri; import android.os.Binder; import android.os.Build; import android.os.Build; import android.os.Process; import android.os.Process; import android.os.UserHandle; import android.os.UserHandle; Loading Loading @@ -114,7 +112,6 @@ public class PreferencesHelper implements RankingConfig { private static final int XML_VERSION_REVIEW_PERMISSIONS_NOTIFICATION = 4; private static final int XML_VERSION_REVIEW_PERMISSIONS_NOTIFICATION = 4; @VisibleForTesting @VisibleForTesting static final int UNKNOWN_UID = UserHandle.USER_NULL; static final int UNKNOWN_UID = UserHandle.USER_NULL; private static final String NON_BLOCKABLE_CHANNEL_DELIM = ":"; @VisibleForTesting @VisibleForTesting static final int NOTIFICATION_CHANNEL_COUNT_LIMIT = 5000; static final int NOTIFICATION_CHANNEL_COUNT_LIMIT = 5000; Loading Loading @@ -196,6 +193,7 @@ public class PreferencesHelper implements RankingConfig { private final PermissionManager mPermissionManager; private final PermissionManager mPermissionManager; private final NotificationChannelLogger mNotificationChannelLogger; private final NotificationChannelLogger mNotificationChannelLogger; private final AppOpsManager mAppOps; private final AppOpsManager mAppOps; private final ManagedServices.UserProfiles mUserProfiles; private SparseBooleanArray mBadgingEnabled; private SparseBooleanArray mBadgingEnabled; private SparseBooleanArray mBubblesEnabled; private SparseBooleanArray mBubblesEnabled; Loading @@ -204,14 +202,12 @@ public class PreferencesHelper implements RankingConfig { private boolean mIsMediaNotificationFilteringEnabled = DEFAULT_MEDIA_NOTIFICATION_FILTERING; private boolean mIsMediaNotificationFilteringEnabled = DEFAULT_MEDIA_NOTIFICATION_FILTERING; private boolean mCurrentUserHasChannelsBypassingDnd; private boolean mCurrentUserHasChannelsBypassingDnd; private boolean mHideSilentStatusBarIcons = DEFAULT_HIDE_SILENT_STATUS_BAR_ICONS; private boolean mHideSilentStatusBarIcons = DEFAULT_HIDE_SILENT_STATUS_BAR_ICONS; private boolean mShowReviewPermissionsNotification; private final boolean mShowReviewPermissionsNotification; private boolean mAllowInvalidShortcuts = false; public PreferencesHelper(Context context, PackageManager pm, RankingHandler rankingHandler, public PreferencesHelper(Context context, PackageManager pm, RankingHandler rankingHandler, ZenModeHelper zenHelper, PermissionHelper permHelper, PermissionManager permManager, ZenModeHelper zenHelper, PermissionHelper permHelper, PermissionManager permManager, NotificationChannelLogger notificationChannelLogger, NotificationChannelLogger notificationChannelLogger, AppOpsManager appOpsManager, AppOpsManager appOpsManager, ManagedServices.UserProfiles userProfiles, SysUiStatsEvent.BuilderFactory statsEventBuilderFactory, SysUiStatsEvent.BuilderFactory statsEventBuilderFactory, boolean showReviewPermissionsNotification) { boolean showReviewPermissionsNotification) { mContext = context; mContext = context; Loading @@ -222,6 +218,7 @@ public class PreferencesHelper implements RankingConfig { mPm = pm; mPm = pm; mNotificationChannelLogger = notificationChannelLogger; mNotificationChannelLogger = notificationChannelLogger; mAppOps = appOpsManager; mAppOps = appOpsManager; mUserProfiles = userProfiles; mStatsEventBuilderFactory = statsEventBuilderFactory; mStatsEventBuilderFactory = statsEventBuilderFactory; mShowReviewPermissionsNotification = showReviewPermissionsNotification; mShowReviewPermissionsNotification = showReviewPermissionsNotification; Loading Loading @@ -435,7 +432,7 @@ public class PreferencesHelper implements RankingConfig { channel.getConversationId() != null && channel.getConversationId() != null && channel.getConversationId().contains( channel.getConversationId().contains( PLACEHOLDER_CONVERSATION_ID); PLACEHOLDER_CONVERSATION_ID); return mAllowInvalidShortcuts || (!mAllowInvalidShortcuts && !isInvalidShortcutChannel); return !isInvalidShortcutChannel; } } private boolean isDeletionOk(NotificationChannel nc) { private boolean isDeletionOk(NotificationChannel nc) { Loading Loading @@ -1790,8 +1787,9 @@ public class PreferencesHelper implements RankingConfig { * Syncs {@link #mCurrentUserHasChannelsBypassingDnd} with the current user's notification * Syncs {@link #mCurrentUserHasChannelsBypassingDnd} with the current user's notification * policy before updating. Must be called: * policy before updating. Must be called: * <ul> * <ul> * <li>On system init, after channels and DND configurations are loaded.</li> * <li>On system init, after channels and DND configurations are loaded. * <li>When the current user changes, after the corresponding DND config is loaded.</li> * <li>When the current user is switched, after the corresponding DND config is loaded. * <li>If users are removed (the removed user could've been a profile of the current one). * </ul> * </ul> */ */ void syncChannelsBypassingDnd() { void syncChannelsBypassingDnd() { Loading @@ -1805,20 +1803,19 @@ public class PreferencesHelper implements RankingConfig { /** /** * Updates the user's NotificationPolicy based on whether the current userId has channels * Updates the user's NotificationPolicy based on whether the current userId has channels * bypassing DND. It should be called whenever a channel is created, updated, or deleted, or * bypassing DND. It should be called whenever a channel is created, updated, or deleted, or * when the current user is switched. * when the current user (or its profiles) change. */ */ private void updateCurrentUserHasChannelsBypassingDnd(int callingUid, private void updateCurrentUserHasChannelsBypassingDnd(int callingUid, boolean fromSystemOrSystemUi) { boolean fromSystemOrSystemUi) { ArraySet<Pair<String, Integer>> candidatePkgs = new ArraySet<>(); ArraySet<Pair<String, Integer>> candidatePkgs = new ArraySet<>(); final int currentUserId = getCurrentUser(); final IntArray currentUserIds = mUserProfiles.getCurrentProfileIds(); synchronized (mPackagePreferences) { synchronized (mPackagePreferences) { final int numPackagePreferences = mPackagePreferences.size(); final int numPackagePreferences = mPackagePreferences.size(); for (int i = 0; i < numPackagePreferences; i++) { for (int i = 0; i < numPackagePreferences; i++) { final PackagePreferences r = mPackagePreferences.valueAt(i); final PackagePreferences r = mPackagePreferences.valueAt(i); // Package isn't associated with the current userId if (!currentUserIds.contains(UserHandle.getUserId(r.uid))) { if (currentUserId != UserHandle.getUserId(r.uid)) { continue; // Package isn't associated with any profile of the current userId. continue; } } for (NotificationChannel channel : r.channels.values()) { for (NotificationChannel channel : r.channels.values()) { Loading @@ -1842,13 +1839,6 @@ 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) { private boolean channelIsLiveLocked(PackagePreferences pkgPref, NotificationChannel channel) { // Channel is in a group that's blocked // Channel is in a group that's blocked if (isGroupBlocked(pkgPref.pkg, pkgPref.uid, channel.getGroup())) { if (isGroupBlocked(pkgPref.pkg, pkgPref.uid, channel.getGroup())) { Loading services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java +63 −101 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
core/java/android/util/IntArray.java +5 −0 Original line number Original line Diff line number Diff line Loading @@ -212,6 +212,11 @@ public class IntArray implements Cloneable { return -1; return -1; } } /** Returns {@code true} if this array contains the specified value. */ public boolean contains(int value) { return indexOf(value) != -1; } /** /** * Removes the value at the specified index from this array. * Removes the value at the specified index from this array. */ */ Loading
core/tests/utiltests/src/android/util/IntArrayTest.java +3 −0 Original line number Original line Diff line number Diff line Loading @@ -55,9 +55,11 @@ public class IntArrayTest { a.add(5, 20); a.add(5, 20); assertThat(a.get(5)).isEqualTo(20); assertThat(a.get(5)).isEqualTo(20); assertThat(a.indexOf(20)).isEqualTo(5); assertThat(a.indexOf(20)).isEqualTo(5); assertThat(a.contains(20)).isTrue(); verify(a, 1, 2, 0, 0, 0, 20, 10, 0, 0); verify(a, 1, 2, 0, 0, 0, 20, 10, 0, 0); assertThat(a.indexOf(99)).isEqualTo(-1); assertThat(a.indexOf(99)).isEqualTo(-1); assertThat(a.contains(99)).isFalse(); a.resize(15); a.resize(15); a.set(14, 30); a.set(14, 30); Loading @@ -71,6 +73,7 @@ public class IntArrayTest { backingArray[2] = 30; backingArray[2] = 30; verify(a, backingArray); verify(a, backingArray); assertThat(a.indexOf(30)).isEqualTo(2); assertThat(a.indexOf(30)).isEqualTo(2); assertThat(a.contains(30)).isTrue(); a.resize(2); a.resize(2); assertThat(backingArray[2]).isEqualTo(0); assertThat(backingArray[2]).isEqualTo(0); Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +3 −2 Original line number Original line Diff line number Diff line Loading @@ -1928,6 +1928,7 @@ public class NotificationManagerService extends SystemService { mConditionProviders.onUserRemoved(userId); mConditionProviders.onUserRemoved(userId); mAssistants.onUserRemoved(userId); mAssistants.onUserRemoved(userId); mHistoryManager.onUserRemoved(userId); mHistoryManager.onUserRemoved(userId); mPreferencesHelper.syncChannelsBypassingDnd(); handleSavePolicyFile(); handleSavePolicyFile(); } else if (action.equals(Intent.ACTION_USER_UNLOCKED)) { } else if (action.equals(Intent.ACTION_USER_UNLOCKED)) { final int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, USER_NULL); final int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, USER_NULL); Loading Loading @@ -2379,6 +2380,7 @@ public class NotificationManagerService extends SystemService { }); }); mPermissionHelper = permissionHelper; mPermissionHelper = permissionHelper; mNotificationChannelLogger = channelLogger; mNotificationChannelLogger = channelLogger; mUserProfiles.updateCache(getContext()); mPreferencesHelper = new PreferencesHelper(getContext(), mPreferencesHelper = new PreferencesHelper(getContext(), mPackageManagerClient, mPackageManagerClient, mRankingHandler, mRankingHandler, Loading @@ -2387,6 +2389,7 @@ public class NotificationManagerService extends SystemService { mPermissionManager, mPermissionManager, mNotificationChannelLogger, mNotificationChannelLogger, mAppOps, mAppOps, mUserProfiles, new SysUiStatsEvent.BuilderFactory(), new SysUiStatsEvent.BuilderFactory(), mShowReviewPermissionsNotification); mShowReviewPermissionsNotification); mRankingHelper = new RankingHelper(getContext(), mRankingHelper = new RankingHelper(getContext(), Loading Loading @@ -2442,8 +2445,6 @@ public class NotificationManagerService extends SystemService { mZenModeHelper.initZenMode(); mZenModeHelper.initZenMode(); mInterruptionFilter = mZenModeHelper.getZenModeListenerInterruptionFilter(); mInterruptionFilter = mZenModeHelper.getZenModeListenerInterruptionFilter(); mUserProfiles.updateCache(getContext()); if (mPackageManagerClient.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) { if (mPackageManagerClient.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) { telephonyManager.listen(new PhoneStateListener() { telephonyManager.listen(new PhoneStateListener() { @Override @Override Loading
services/core/java/com/android/server/notification/PreferencesHelper.java +12 −22 Original line number Original line Diff line number Diff line Loading @@ -38,7 +38,6 @@ import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.Nullable; import android.annotation.UserIdInt; import android.annotation.UserIdInt; import android.app.ActivityManager; import android.app.AppOpsManager; import android.app.AppOpsManager; import android.app.Notification; import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationChannel; Loading @@ -53,7 +52,6 @@ import android.content.pm.ParceledListSlice; import android.content.pm.UserInfo; import android.content.pm.UserInfo; import android.metrics.LogMaker; import android.metrics.LogMaker; import android.net.Uri; import android.net.Uri; import android.os.Binder; import android.os.Build; import android.os.Build; import android.os.Process; import android.os.Process; import android.os.UserHandle; import android.os.UserHandle; Loading Loading @@ -114,7 +112,6 @@ public class PreferencesHelper implements RankingConfig { private static final int XML_VERSION_REVIEW_PERMISSIONS_NOTIFICATION = 4; private static final int XML_VERSION_REVIEW_PERMISSIONS_NOTIFICATION = 4; @VisibleForTesting @VisibleForTesting static final int UNKNOWN_UID = UserHandle.USER_NULL; static final int UNKNOWN_UID = UserHandle.USER_NULL; private static final String NON_BLOCKABLE_CHANNEL_DELIM = ":"; @VisibleForTesting @VisibleForTesting static final int NOTIFICATION_CHANNEL_COUNT_LIMIT = 5000; static final int NOTIFICATION_CHANNEL_COUNT_LIMIT = 5000; Loading Loading @@ -196,6 +193,7 @@ public class PreferencesHelper implements RankingConfig { private final PermissionManager mPermissionManager; private final PermissionManager mPermissionManager; private final NotificationChannelLogger mNotificationChannelLogger; private final NotificationChannelLogger mNotificationChannelLogger; private final AppOpsManager mAppOps; private final AppOpsManager mAppOps; private final ManagedServices.UserProfiles mUserProfiles; private SparseBooleanArray mBadgingEnabled; private SparseBooleanArray mBadgingEnabled; private SparseBooleanArray mBubblesEnabled; private SparseBooleanArray mBubblesEnabled; Loading @@ -204,14 +202,12 @@ public class PreferencesHelper implements RankingConfig { private boolean mIsMediaNotificationFilteringEnabled = DEFAULT_MEDIA_NOTIFICATION_FILTERING; private boolean mIsMediaNotificationFilteringEnabled = DEFAULT_MEDIA_NOTIFICATION_FILTERING; private boolean mCurrentUserHasChannelsBypassingDnd; private boolean mCurrentUserHasChannelsBypassingDnd; private boolean mHideSilentStatusBarIcons = DEFAULT_HIDE_SILENT_STATUS_BAR_ICONS; private boolean mHideSilentStatusBarIcons = DEFAULT_HIDE_SILENT_STATUS_BAR_ICONS; private boolean mShowReviewPermissionsNotification; private final boolean mShowReviewPermissionsNotification; private boolean mAllowInvalidShortcuts = false; public PreferencesHelper(Context context, PackageManager pm, RankingHandler rankingHandler, public PreferencesHelper(Context context, PackageManager pm, RankingHandler rankingHandler, ZenModeHelper zenHelper, PermissionHelper permHelper, PermissionManager permManager, ZenModeHelper zenHelper, PermissionHelper permHelper, PermissionManager permManager, NotificationChannelLogger notificationChannelLogger, NotificationChannelLogger notificationChannelLogger, AppOpsManager appOpsManager, AppOpsManager appOpsManager, ManagedServices.UserProfiles userProfiles, SysUiStatsEvent.BuilderFactory statsEventBuilderFactory, SysUiStatsEvent.BuilderFactory statsEventBuilderFactory, boolean showReviewPermissionsNotification) { boolean showReviewPermissionsNotification) { mContext = context; mContext = context; Loading @@ -222,6 +218,7 @@ public class PreferencesHelper implements RankingConfig { mPm = pm; mPm = pm; mNotificationChannelLogger = notificationChannelLogger; mNotificationChannelLogger = notificationChannelLogger; mAppOps = appOpsManager; mAppOps = appOpsManager; mUserProfiles = userProfiles; mStatsEventBuilderFactory = statsEventBuilderFactory; mStatsEventBuilderFactory = statsEventBuilderFactory; mShowReviewPermissionsNotification = showReviewPermissionsNotification; mShowReviewPermissionsNotification = showReviewPermissionsNotification; Loading Loading @@ -435,7 +432,7 @@ public class PreferencesHelper implements RankingConfig { channel.getConversationId() != null && channel.getConversationId() != null && channel.getConversationId().contains( channel.getConversationId().contains( PLACEHOLDER_CONVERSATION_ID); PLACEHOLDER_CONVERSATION_ID); return mAllowInvalidShortcuts || (!mAllowInvalidShortcuts && !isInvalidShortcutChannel); return !isInvalidShortcutChannel; } } private boolean isDeletionOk(NotificationChannel nc) { private boolean isDeletionOk(NotificationChannel nc) { Loading Loading @@ -1790,8 +1787,9 @@ public class PreferencesHelper implements RankingConfig { * Syncs {@link #mCurrentUserHasChannelsBypassingDnd} with the current user's notification * Syncs {@link #mCurrentUserHasChannelsBypassingDnd} with the current user's notification * policy before updating. Must be called: * policy before updating. Must be called: * <ul> * <ul> * <li>On system init, after channels and DND configurations are loaded.</li> * <li>On system init, after channels and DND configurations are loaded. * <li>When the current user changes, after the corresponding DND config is loaded.</li> * <li>When the current user is switched, after the corresponding DND config is loaded. * <li>If users are removed (the removed user could've been a profile of the current one). * </ul> * </ul> */ */ void syncChannelsBypassingDnd() { void syncChannelsBypassingDnd() { Loading @@ -1805,20 +1803,19 @@ public class PreferencesHelper implements RankingConfig { /** /** * Updates the user's NotificationPolicy based on whether the current userId has channels * Updates the user's NotificationPolicy based on whether the current userId has channels * bypassing DND. It should be called whenever a channel is created, updated, or deleted, or * bypassing DND. It should be called whenever a channel is created, updated, or deleted, or * when the current user is switched. * when the current user (or its profiles) change. */ */ private void updateCurrentUserHasChannelsBypassingDnd(int callingUid, private void updateCurrentUserHasChannelsBypassingDnd(int callingUid, boolean fromSystemOrSystemUi) { boolean fromSystemOrSystemUi) { ArraySet<Pair<String, Integer>> candidatePkgs = new ArraySet<>(); ArraySet<Pair<String, Integer>> candidatePkgs = new ArraySet<>(); final int currentUserId = getCurrentUser(); final IntArray currentUserIds = mUserProfiles.getCurrentProfileIds(); synchronized (mPackagePreferences) { synchronized (mPackagePreferences) { final int numPackagePreferences = mPackagePreferences.size(); final int numPackagePreferences = mPackagePreferences.size(); for (int i = 0; i < numPackagePreferences; i++) { for (int i = 0; i < numPackagePreferences; i++) { final PackagePreferences r = mPackagePreferences.valueAt(i); final PackagePreferences r = mPackagePreferences.valueAt(i); // Package isn't associated with the current userId if (!currentUserIds.contains(UserHandle.getUserId(r.uid))) { if (currentUserId != UserHandle.getUserId(r.uid)) { continue; // Package isn't associated with any profile of the current userId. continue; } } for (NotificationChannel channel : r.channels.values()) { for (NotificationChannel channel : r.channels.values()) { Loading @@ -1842,13 +1839,6 @@ 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) { private boolean channelIsLiveLocked(PackagePreferences pkgPref, NotificationChannel channel) { // Channel is in a group that's blocked // Channel is in a group that's blocked if (isGroupBlocked(pkgPref.pkg, pkgPref.uid, channel.getGroup())) { if (isGroupBlocked(pkgPref.pkg, pkgPref.uid, channel.getGroup())) { Loading
services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java +63 −101 File changed.Preview size limit exceeded, changes collapsed. Show changes