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

Commit 3d1ed4a5 authored by Eric Laurent's avatar Eric Laurent Committed by Android (Google) Code Review
Browse files

Merge "NotificationManager: Fix notifications in VoIP call" into qt-r1-dev

parents 6b068a4f 7412abc3
Loading
Loading
Loading
Loading
+18 −6
Original line number Diff line number Diff line
@@ -397,7 +397,7 @@ public class NotificationManagerService extends SystemService {

    // for enabling and disabling notification pulse behavior
    boolean mScreenOn = true;
    protected boolean mInCall = false;
    protected boolean mInCallStateOffHook = false;
    boolean mNotificationPulseEnabled;

    private Uri mInCallNotificationUri;
@@ -1292,7 +1292,7 @@ public class NotificationManagerService extends SystemService {
                mScreenOn = false;
                updateNotificationPulse();
            } else if (action.equals(TelephonyManager.ACTION_PHONE_STATE_CHANGED)) {
                mInCall = TelephonyManager.EXTRA_STATE_OFFHOOK
                mInCallStateOffHook = TelephonyManager.EXTRA_STATE_OFFHOOK
                        .equals(intent.getStringExtra(TelephonyManager.EXTRA_STATE));
                updateNotificationPulse();
            } else if (action.equals(Intent.ACTION_USER_STOPPED)) {
@@ -5710,7 +5710,7 @@ public class NotificationManagerService extends SystemService {
                    }
                    if (DBG) Slog.v(TAG, "Interrupting!");
                    if (hasValidSound) {
                        if (mInCall) {
                        if (isInCall()) {
                            playInCallNotification();
                            beep = true;
                        } else {
@@ -5724,7 +5724,7 @@ public class NotificationManagerService extends SystemService {
                    final boolean ringerModeSilent =
                            mAudioManager.getRingerModeInternal()
                                    == AudioManager.RINGER_MODE_SILENT;
                    if (!mInCall && hasValidVibrate && !ringerModeSilent) {
                    if (!isInCall() && hasValidVibrate && !ringerModeSilent) {
                        buzz = playVibration(record, vibration, hasValidSound);
                        if(buzz) {
                            mVibrateNotificationKey = key;
@@ -5812,7 +5812,7 @@ public class NotificationManagerService extends SystemService {
            return false;
        }
        // not if in call or the screen's on
        if (mInCall || mScreenOn) {
        if (isInCall() || mScreenOn) {
            return false;
        }

@@ -6913,7 +6913,7 @@ public class NotificationManagerService extends SystemService {
        }

        // Don't flash while we are in a call or screen is on
        if (ledNotification == null || mInCall || mScreenOn) {
        if (ledNotification == null || isInCall() || mScreenOn) {
            mNotificationLight.turnOff();
        } else {
            NotificationRecord.Light light = ledNotification.getLight();
@@ -7381,6 +7381,18 @@ public class NotificationManagerService extends SystemService {
        }
    }

    private boolean isInCall() {
        if (mInCallStateOffHook) {
            return true;
        }
        int audioMode = mAudioManager.getMode();
        if (audioMode == AudioManager.MODE_IN_CALL
                || audioMode == AudioManager.MODE_IN_COMMUNICATION) {
            return true;
        }
        return false;
    }

    public class NotificationAssistants extends ManagedServices {
        static final String TAG_ENABLED_NOTIFICATION_ASSISTANTS = "enabled_assistants";

+3 −3
Original line number Diff line number Diff line
@@ -156,7 +156,7 @@ public class BuzzBeepBlinkTest extends UiServiceTestCase {
        mService.setUsageStats(mUsageStats);
        mService.setAccessibilityManager(accessibilityManager);
        mService.mScreenOn = false;
        mService.mInCall = false;
        mService.mInCallStateOffHook = false;
        mService.mNotificationPulseEnabled = true;
    }

@@ -681,7 +681,7 @@ public class BuzzBeepBlinkTest extends UiServiceTestCase {
        mService.buzzBeepBlinkLocked(r);
        Mockito.reset(mRingtonePlayer);

        mService.mInCall = true;
        mService.mInCallStateOffHook = true;
        mService.buzzBeepBlinkLocked(r);

        verify(mService, times(1)).playInCallNotification();
@@ -1137,7 +1137,7 @@ public class BuzzBeepBlinkTest extends UiServiceTestCase {

    @Test
    public void testLightsInCall() {
        mService.mInCall = true;
        mService.mInCallStateOffHook = true;
        NotificationRecord r = getLightsNotification();
        mService.buzzBeepBlinkLocked(r);
        verifyNeverLights();