diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml index 4d6fda980755c..9c4717b4497ef 100644 --- a/core/res/res/values/config.xml +++ b/core/res/res/values/config.xml @@ -745,6 +745,10 @@ + + false + false diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 924b036813a66..a6a0c6e50a858 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -1910,6 +1910,7 @@ + diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index 042ac8c5760e7..6b94f06af7759 100644 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -455,6 +455,7 @@ public class NotificationManagerService extends SystemService { private int mAutoGroupAtCount; private boolean mIsTelevision; private boolean mIsAutomotive; + private boolean mNotificationEffectsEnabledForAutomotive; private MetricsLogger mMetricsLogger; private TriPredicate mAllowedManagedServicePackages; @@ -1525,6 +1526,11 @@ public class NotificationManagerService extends SystemService { mIsAutomotive = isAutomotive; } + @VisibleForTesting + void setNotificationEffectsEnabledForAutomotive(boolean isEnabled) { + mNotificationEffectsEnabledForAutomotive = isEnabled; + } + @VisibleForTesting void setIsTelevision(boolean isTelevision) { mIsTelevision = isTelevision; @@ -1686,6 +1692,8 @@ public class NotificationManagerService extends SystemService { mIsAutomotive = mPackageManagerClient.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE, 0); + mNotificationEffectsEnabledForAutomotive = + resources.getBoolean(R.bool.config_enableServerNotificationEffectsForAutomotive); mPreferencesHelper.lockChannelsForOEM(getContext().getResources().getStringArray( com.android.internal.R.array.config_nonBlockableNotificationPackages)); @@ -5563,6 +5571,9 @@ public class NotificationManagerService extends SystemService { @VisibleForTesting @GuardedBy("mNotificationLock") void buzzBeepBlinkLocked(NotificationRecord record) { + if (mIsAutomotive && !mNotificationEffectsEnabledForAutomotive) { + return; + } boolean buzz = false; boolean beep = false; boolean blink = false; diff --git a/services/tests/uiservicestests/src/com/android/server/notification/BuzzBeepBlinkTest.java b/services/tests/uiservicestests/src/com/android/server/notification/BuzzBeepBlinkTest.java index 6be2c2e8c59ef..6061d51f3d792 100644 --- a/services/tests/uiservicestests/src/com/android/server/notification/BuzzBeepBlinkTest.java +++ b/services/tests/uiservicestests/src/com/android/server/notification/BuzzBeepBlinkTest.java @@ -455,8 +455,23 @@ public class BuzzBeepBlinkTest extends UiServiceTestCase { } @Test - public void testNoBeepForImportanceDefaultInAutomotive() throws Exception { + public void testNoBeepForAutomotiveIfEffectsDisabled() throws Exception { mService.setIsAutomotive(true); + mService.setNotificationEffectsEnabledForAutomotive(false); + + NotificationRecord r = getBeepyNotification(); + r.setSystemImportance(NotificationManager.IMPORTANCE_HIGH); + + mService.buzzBeepBlinkLocked(r); + + verifyNeverBeep(); + assertFalse(r.isInterruptive()); + } + + @Test + public void testNoBeepForImportanceDefaultInAutomotiveIfEffectsEnabled() throws Exception { + mService.setIsAutomotive(true); + mService.setNotificationEffectsEnabledForAutomotive(true); NotificationRecord r = getBeepyNotification(); r.setSystemImportance(NotificationManager.IMPORTANCE_DEFAULT); @@ -468,10 +483,12 @@ public class BuzzBeepBlinkTest extends UiServiceTestCase { } @Test - public void testBeepForImportanceHighInAutomotive() throws Exception { + public void testBeepForImportanceHighInAutomotiveIfEffectsEnabled() throws Exception { mService.setIsAutomotive(true); + mService.setNotificationEffectsEnabledForAutomotive(true); NotificationRecord r = getBeepyNotification(); + r.setSystemImportance(NotificationManager.IMPORTANCE_HIGH); mService.buzzBeepBlinkLocked(r);