Loading services/core/java/com/android/server/notification/NotificationManagerService.java +6 −1 Original line number Diff line number Diff line Loading @@ -1515,6 +1515,11 @@ public class NotificationManagerService extends SystemService { mRankingHandler = rankingHandler; } @VisibleForTesting void setZenHelper(ZenModeHelper zenHelper) { mZenModeHelper = zenHelper; } @VisibleForTesting void setIsAutomotive(boolean isAutomotive) { mIsAutomotive = isAutomotive; Loading Loading @@ -3563,7 +3568,7 @@ public class NotificationManagerService extends SystemService { return; } boolean accessAllowed = false; String[] packages = getContext().getPackageManager().getPackagesForUid(uid); String[] packages = mPackageManagerClient.getPackagesForUid(uid); final int packageCount = packages.length; for (int i = 0; i < packageCount; i++) { if (mConditionProviders.isPackageOrComponentAllowed( Loading services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +13 −2 Original line number Diff line number Diff line Loading @@ -348,6 +348,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { when(mPackageManagerClient.hasSystemFeature(FEATURE_WATCH)).thenReturn(false); when(mUgmInternal.newUriPermissionOwner(anyString())).thenReturn(mPermOwner); when(mPackageManager.getPackagesForUid(mUid)).thenReturn(new String[]{PKG}); when(mPackageManagerClient.getPackagesForUid(anyInt())).thenReturn(new String[]{PKG}); // write to a test file; the system file isn't readable from tests mFile = new File(mContext.getCacheDir(), "test.xml"); Loading Loading @@ -4948,6 +4949,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { assertEquals(1, mService.getNotificationRecordCount()); } @Test public void testGetAllowedAssistantAdjustments() throws Exception { List<String> capabilities = mBinderService.getAllowedAssistantAdjustments(null); assertNotNull(capabilities); Loading @@ -4962,8 +4964,11 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { } } @Test public void testAdjustRestrictedKey() throws Exception { NotificationRecord r = generateNotificationRecord(mTestNotificationChannel); mService.addNotification(r); when(mAssistants.isSameUser(any(), anyInt())).thenReturn(true); when(mAssistants.isAdjustmentAllowed(KEY_IMPORTANCE)).thenReturn(true); when(mAssistants.isAdjustmentAllowed(KEY_USER_SENTIMENT)).thenReturn(false); Loading @@ -4981,8 +4986,12 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { assertEquals(USER_SENTIMENT_NEUTRAL, r.getUserSentiment()); } @Test public void testAutomaticZenRuleValidation_policyFilterAgreement() throws Exception { ComponentName owner = mock(ComponentName.class); when(mConditionProviders.isPackageOrComponentAllowed(anyString(), anyInt())) .thenReturn(true); mService.setZenHelper(mock(ZenModeHelper.class)); ComponentName owner = new ComponentName(mContext, this.getClass()); ZenPolicy zenPolicy = new ZenPolicy.Builder().allowAlarms(true).build(); boolean isEnabled = true; AutomaticZenRule rule = new AutomaticZenRule("test", owner, owner, mock(Uri.class), Loading @@ -4990,7 +4999,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { try { mBinderService.addAutomaticZenRule(rule); fail("Zen policy only aplies to priority only mode"); fail("Zen policy only applies to priority only mode"); } catch (IllegalArgumentException e) { // yay } Loading @@ -5004,6 +5013,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { mBinderService.addAutomaticZenRule(rule); } @Test public void testAreNotificationsEnabledForPackage_crossUser() throws Exception { try { mBinderService.areNotificationsEnabledForPackage(mContext.getPackageName(), Loading @@ -5020,6 +5030,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { mUid + UserHandle.PER_USER_RANGE); } @Test public void testAreBubblesAllowedForPackage_crossUser() throws Exception { try { mBinderService.areBubblesAllowedForPackage(mContext.getPackageName(), Loading Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +6 −1 Original line number Diff line number Diff line Loading @@ -1515,6 +1515,11 @@ public class NotificationManagerService extends SystemService { mRankingHandler = rankingHandler; } @VisibleForTesting void setZenHelper(ZenModeHelper zenHelper) { mZenModeHelper = zenHelper; } @VisibleForTesting void setIsAutomotive(boolean isAutomotive) { mIsAutomotive = isAutomotive; Loading Loading @@ -3563,7 +3568,7 @@ public class NotificationManagerService extends SystemService { return; } boolean accessAllowed = false; String[] packages = getContext().getPackageManager().getPackagesForUid(uid); String[] packages = mPackageManagerClient.getPackagesForUid(uid); final int packageCount = packages.length; for (int i = 0; i < packageCount; i++) { if (mConditionProviders.isPackageOrComponentAllowed( Loading
services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +13 −2 Original line number Diff line number Diff line Loading @@ -348,6 +348,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { when(mPackageManagerClient.hasSystemFeature(FEATURE_WATCH)).thenReturn(false); when(mUgmInternal.newUriPermissionOwner(anyString())).thenReturn(mPermOwner); when(mPackageManager.getPackagesForUid(mUid)).thenReturn(new String[]{PKG}); when(mPackageManagerClient.getPackagesForUid(anyInt())).thenReturn(new String[]{PKG}); // write to a test file; the system file isn't readable from tests mFile = new File(mContext.getCacheDir(), "test.xml"); Loading Loading @@ -4948,6 +4949,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { assertEquals(1, mService.getNotificationRecordCount()); } @Test public void testGetAllowedAssistantAdjustments() throws Exception { List<String> capabilities = mBinderService.getAllowedAssistantAdjustments(null); assertNotNull(capabilities); Loading @@ -4962,8 +4964,11 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { } } @Test public void testAdjustRestrictedKey() throws Exception { NotificationRecord r = generateNotificationRecord(mTestNotificationChannel); mService.addNotification(r); when(mAssistants.isSameUser(any(), anyInt())).thenReturn(true); when(mAssistants.isAdjustmentAllowed(KEY_IMPORTANCE)).thenReturn(true); when(mAssistants.isAdjustmentAllowed(KEY_USER_SENTIMENT)).thenReturn(false); Loading @@ -4981,8 +4986,12 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { assertEquals(USER_SENTIMENT_NEUTRAL, r.getUserSentiment()); } @Test public void testAutomaticZenRuleValidation_policyFilterAgreement() throws Exception { ComponentName owner = mock(ComponentName.class); when(mConditionProviders.isPackageOrComponentAllowed(anyString(), anyInt())) .thenReturn(true); mService.setZenHelper(mock(ZenModeHelper.class)); ComponentName owner = new ComponentName(mContext, this.getClass()); ZenPolicy zenPolicy = new ZenPolicy.Builder().allowAlarms(true).build(); boolean isEnabled = true; AutomaticZenRule rule = new AutomaticZenRule("test", owner, owner, mock(Uri.class), Loading @@ -4990,7 +4999,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { try { mBinderService.addAutomaticZenRule(rule); fail("Zen policy only aplies to priority only mode"); fail("Zen policy only applies to priority only mode"); } catch (IllegalArgumentException e) { // yay } Loading @@ -5004,6 +5013,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { mBinderService.addAutomaticZenRule(rule); } @Test public void testAreNotificationsEnabledForPackage_crossUser() throws Exception { try { mBinderService.areNotificationsEnabledForPackage(mContext.getPackageName(), Loading @@ -5020,6 +5030,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { mUid + UserHandle.PER_USER_RANGE); } @Test public void testAreBubblesAllowedForPackage_crossUser() throws Exception { try { mBinderService.areBubblesAllowedForPackage(mContext.getPackageName(), Loading