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

Commit 4883dc64 authored by yw.bae's avatar yw.bae Committed by Angela Wang
Browse files

Call AccessibilityManager.startFlashNotificationEvent method in...


Call AccessibilityManager.startFlashNotificationEvent method in NotificationManagerService to implement Flash Notification for Notification.

Bug: 237628564
Test: atest BuzzBeepBlinkTest
Change-Id: Ib790ceaa0d181ba9ab0654ab09e34da819350d26
Signed-off-by: default avataryw.bae <yw.bae@samsung.corp-partner.google.com>
Signed-off-by: default avatarAngela Wang <angelala@google.com>
parent b0994ef7
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -7978,6 +7978,13 @@ public class NotificationManagerService extends SystemService {
                            }
                        }
                    }
                    // Try to start flash notification event whenever an audible and non-suppressed
                    // notification is received
                    mAccessibilityManager.startFlashNotificationEvent(getContext(),
                            AccessibilityManager.FLASH_REASON_NOTIFICATION,
                            record.getSbn().getPackageName());
                } else if ((record.getFlags() & Notification.FLAG_INSISTENT) != 0) {
                    hasValidSound = false;
                }
+59 −0
Original line number Diff line number Diff line
@@ -1870,6 +1870,65 @@ public class BuzzBeepBlinkTest extends UiServiceTestCase {
        verifyVibrate(1);
    }

    @Test
    public void testStartFlashNotificationEvent_receiveBeepyNotification() throws Exception {
        NotificationRecord r = getBeepyNotification();

        mService.buzzBeepBlinkLocked(r);

        verifyBeepUnlooped();
        verifyNeverVibrate();
        verify(mAccessibilityService).startFlashNotificationEvent(any(), anyInt(),
                eq(r.getSbn().getPackageName()));
        assertTrue(r.isInterruptive());
        assertNotEquals(-1, r.getLastAudiblyAlertedMs());
    }

    @Test
    public void testStartFlashNotificationEvent_receiveBuzzyNotification() throws Exception {
        NotificationRecord r = getBuzzyNotification();

        mService.buzzBeepBlinkLocked(r);

        verifyNeverBeep();
        verifyVibrate();
        verify(mAccessibilityService).startFlashNotificationEvent(any(), anyInt(),
                eq(r.getSbn().getPackageName()));
        assertTrue(r.isInterruptive());
        assertNotEquals(-1, r.getLastAudiblyAlertedMs());
    }

    @Test
    public void testStartFlashNotificationEvent_receiveBuzzyBeepyNotification() throws Exception {
        NotificationRecord r = getBuzzyBeepyNotification();

        mService.buzzBeepBlinkLocked(r);

        verifyBeepUnlooped();
        verifyDelayedVibrate(r.getVibration());
        verify(mAccessibilityService).startFlashNotificationEvent(any(), anyInt(),
                eq(r.getSbn().getPackageName()));
        assertTrue(r.isInterruptive());
        assertNotEquals(-1, r.getLastAudiblyAlertedMs());
    }

    @Test
    public void testStartFlashNotificationEvent_receiveBuzzyBeepyNotification_ringerModeSilent()
            throws Exception {
        NotificationRecord r = getBuzzyBeepyNotification();
        when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_SILENT);
        when(mAudioManager.getStreamVolume(anyInt())).thenReturn(0);

        mService.buzzBeepBlinkLocked(r);

        verifyNeverBeep();
        verifyNeverVibrate();
        verify(mAccessibilityService).startFlashNotificationEvent(any(), anyInt(),
                eq(r.getSbn().getPackageName()));
        assertFalse(r.isInterruptive());
        assertEquals(-1, r.getLastAudiblyAlertedMs());
    }

    static class VibrateRepeatMatcher implements ArgumentMatcher<VibrationEffect> {
        private final int mRepeatIndex;