Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fb27c2c7 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Do not make sound for notifications <= IMPORTANCE_DEFAULT in Android Auto."

parents ed11f757 963328f5
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -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;
@@ -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;
@@ -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
@@ -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);
+25 −0
Original line number Diff line number Diff line
@@ -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();