Loading services/core/java/com/android/server/notification/NotificationManagerService.java +12 −1 Original line number Diff line number Diff line Loading @@ -428,6 +428,7 @@ public class NotificationManagerService extends SystemService { private GroupHelper mGroupHelper; private int mAutoGroupAtCount; private boolean mIsTelevision; private boolean mIsAutomotive; private MetricsLogger mMetricsLogger; private Predicate<String> mAllowedManagedServicePackages; Loading Loading @@ -1387,6 +1388,11 @@ public class NotificationManagerService extends SystemService { mRankingHandler = rankingHandler; } @VisibleForTesting void setIsAutomotive(boolean isAutomotive) { mIsAutomotive = isAutomotive; } @VisibleForTesting void setIsTelevision(boolean isTelevision) { mIsTelevision = isTelevision; Loading Loading @@ -1543,6 +1549,9 @@ public class NotificationManagerService extends SystemService { mIsTelevision = mPackageManagerClient.hasSystemFeature(FEATURE_LEANBACK) || mPackageManagerClient.hasSystemFeature(FEATURE_TELEVISION); mIsAutomotive = mPackageManagerClient.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE, 0); } @Override Loading Loading @@ -5131,7 +5140,9 @@ public class NotificationManagerService extends SystemService { // Should this notification make noise, vibe, or use the LED? final boolean aboveThreshold = record.getImportance() >= NotificationManager.IMPORTANCE_DEFAULT; mIsAutomotive ? record.getImportance() > NotificationManager.IMPORTANCE_DEFAULT : record.getImportance() >= NotificationManager.IMPORTANCE_DEFAULT; // Remember if this notification already owns the notification channels. boolean wasBeep = key != null && key.equals(mSoundNotificationKey); Loading services/tests/uiservicestests/src/com/android/server/notification/BuzzBeepBlinkTest.java +25 −0 Original line number Diff line number Diff line Loading @@ -455,6 +455,31 @@ public class BuzzBeepBlinkTest extends UiServiceTestCase { assertFalse(r.getAudiblyAlerted()); } @Test public void testNoBeepForImportanceDefaultInAutomotive() throws Exception { mService.setIsAutomotive(true); NotificationRecord r = getBeepyNotification(); r.setSystemImportance(NotificationManager.IMPORTANCE_DEFAULT); mService.buzzBeepBlinkLocked(r); verifyNeverBeep(); assertFalse(r.isInterruptive()); } @Test public void testBeepForImportanceHighInAutomotive() throws Exception { mService.setIsAutomotive(true); NotificationRecord r = getBeepyNotification(); mService.buzzBeepBlinkLocked(r); verifyBeepLooped(); assertTrue(r.isInterruptive()); } @Test public void testNoInterruptionForMin() throws Exception { NotificationRecord r = getBeepyNotification(); Loading Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +12 −1 Original line number Diff line number Diff line Loading @@ -428,6 +428,7 @@ public class NotificationManagerService extends SystemService { private GroupHelper mGroupHelper; private int mAutoGroupAtCount; private boolean mIsTelevision; private boolean mIsAutomotive; private MetricsLogger mMetricsLogger; private Predicate<String> mAllowedManagedServicePackages; Loading Loading @@ -1387,6 +1388,11 @@ public class NotificationManagerService extends SystemService { mRankingHandler = rankingHandler; } @VisibleForTesting void setIsAutomotive(boolean isAutomotive) { mIsAutomotive = isAutomotive; } @VisibleForTesting void setIsTelevision(boolean isTelevision) { mIsTelevision = isTelevision; Loading Loading @@ -1543,6 +1549,9 @@ public class NotificationManagerService extends SystemService { mIsTelevision = mPackageManagerClient.hasSystemFeature(FEATURE_LEANBACK) || mPackageManagerClient.hasSystemFeature(FEATURE_TELEVISION); mIsAutomotive = mPackageManagerClient.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE, 0); } @Override Loading Loading @@ -5131,7 +5140,9 @@ public class NotificationManagerService extends SystemService { // Should this notification make noise, vibe, or use the LED? final boolean aboveThreshold = record.getImportance() >= NotificationManager.IMPORTANCE_DEFAULT; mIsAutomotive ? record.getImportance() > NotificationManager.IMPORTANCE_DEFAULT : record.getImportance() >= NotificationManager.IMPORTANCE_DEFAULT; // Remember if this notification already owns the notification channels. boolean wasBeep = key != null && key.equals(mSoundNotificationKey); Loading
services/tests/uiservicestests/src/com/android/server/notification/BuzzBeepBlinkTest.java +25 −0 Original line number Diff line number Diff line Loading @@ -455,6 +455,31 @@ public class BuzzBeepBlinkTest extends UiServiceTestCase { assertFalse(r.getAudiblyAlerted()); } @Test public void testNoBeepForImportanceDefaultInAutomotive() throws Exception { mService.setIsAutomotive(true); NotificationRecord r = getBeepyNotification(); r.setSystemImportance(NotificationManager.IMPORTANCE_DEFAULT); mService.buzzBeepBlinkLocked(r); verifyNeverBeep(); assertFalse(r.isInterruptive()); } @Test public void testBeepForImportanceHighInAutomotive() throws Exception { mService.setIsAutomotive(true); NotificationRecord r = getBeepyNotification(); mService.buzzBeepBlinkLocked(r); verifyBeepLooped(); assertTrue(r.isInterruptive()); } @Test public void testNoInterruptionForMin() throws Exception { NotificationRecord r = getBeepyNotification(); Loading