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

Commit 571afb3b authored by Julia Reynolds's avatar Julia Reynolds Committed by Android (Google) Code Review
Browse files

Merge "Actually use listener hints?" into pi-dev

parents de18a38e 9aee2841
Loading
Loading
Loading
Loading
+19 −0
Original line number Original line Diff line number Diff line
@@ -1248,6 +1248,11 @@ public class NotificationManagerService extends SystemService {
        mAudioManager = audioMananger;
        mAudioManager = audioMananger;
    }
    }


    @VisibleForTesting
    void setHints(int hints) {
        mListenerHints = hints;
    }

    @VisibleForTesting
    @VisibleForTesting
    void setVibrator(Vibrator vibrator) {
    void setVibrator(Vibrator vibrator) {
        mVibrator = vibrator;
        mVibrator = vibrator;
@@ -3689,6 +3694,20 @@ public class NotificationManagerService extends SystemService {
        if ((mListenerHints & HINT_HOST_DISABLE_EFFECTS) != 0) {
        if ((mListenerHints & HINT_HOST_DISABLE_EFFECTS) != 0) {
            return "listenerHints";
            return "listenerHints";
        }
        }
        if (record != null && record.getAudioAttributes() != null) {
            if ((mListenerHints & HINT_HOST_DISABLE_NOTIFICATION_EFFECTS) != 0) {
                if (record.getAudioAttributes().getUsage()
                        != AudioAttributes.USAGE_VOICE_COMMUNICATION) {
                    return "listenerNoti";
                }
            }
            if ((mListenerHints & HINT_HOST_DISABLE_CALL_EFFECTS) != 0) {
                if (record.getAudioAttributes().getUsage()
                        == AudioAttributes.USAGE_VOICE_COMMUNICATION) {
                    return "listenerCall";
                }
            }
        }
        if (mCallState != TelephonyManager.CALL_STATE_IDLE && !mZenModeHelper.isCall(record)) {
        if (mCallState != TelephonyManager.CALL_STATE_IDLE && !mZenModeHelper.isCall(record)) {
            return "callState";
            return "callState";
        }
        }
+7 −11
Original line number Original line Diff line number Diff line
@@ -58,6 +58,7 @@ import android.os.UserHandle;
import android.os.VibrationEffect;
import android.os.VibrationEffect;
import android.os.Vibrator;
import android.os.Vibrator;
import android.provider.Settings;
import android.provider.Settings;
import android.service.notification.NotificationListenerService;
import android.service.notification.StatusBarNotification;
import android.service.notification.StatusBarNotification;
import android.support.test.runner.AndroidJUnit4;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.SmallTest;
import android.test.suitebuilder.annotation.SmallTest;
@@ -112,7 +113,7 @@ public class BuzzBeepBlinkTest extends UiServiceTestCase {
    private static final Uri CUSTOM_SOUND = Settings.System.DEFAULT_ALARM_ALERT_URI;
    private static final Uri CUSTOM_SOUND = Settings.System.DEFAULT_ALARM_ALERT_URI;
    private static final AudioAttributes CUSTOM_ATTRIBUTES = new AudioAttributes.Builder()
    private static final AudioAttributes CUSTOM_ATTRIBUTES = new AudioAttributes.Builder()
            .setContentType(AudioAttributes.CONTENT_TYPE_UNKNOWN)
            .setContentType(AudioAttributes.CONTENT_TYPE_UNKNOWN)
            .setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE)
            .setUsage(AudioAttributes.USAGE_VOICE_COMMUNICATION)
            .build();
            .build();
    private static final int CUSTOM_LIGHT_COLOR = Color.BLACK;
    private static final int CUSTOM_LIGHT_COLOR = Color.BLACK;
    private static final int CUSTOM_LIGHT_ON = 10000;
    private static final int CUSTOM_LIGHT_ON = 10000;
@@ -230,11 +231,11 @@ public class BuzzBeepBlinkTest extends UiServiceTestCase {
                false /* noisy */, false /* buzzy*/, true /* lights */);
                false /* noisy */, false /* buzzy*/, true /* lights */);
    }
    }


    private NotificationRecord getCustomLightsNotification() {
    private NotificationRecord getCallRecord(int id, boolean insistent) {
        return getNotificationRecord(mId, false /* insistent */, true /* once */,
        return getNotificationRecord(id, false, false /* once */, true /* noisy */,
                false /* noisy */, true /* buzzy*/, true /* lights */,
                false /* buzzy */, false /* lights */, false /* default vib */,
                true /* defaultVibration */, true /* defaultSound */, false /* defaultLights */,
                false /* default sound */, false /* default lights */, "",
                null, Notification.GROUP_ALERT_ALL, false);
                Notification.GROUP_ALERT_ALL, false);
    }
    }


    private NotificationRecord getNotificationRecord(int id, boolean insistent, boolean once,
    private NotificationRecord getNotificationRecord(int id, boolean insistent, boolean once,
@@ -344,11 +345,6 @@ public class BuzzBeepBlinkTest extends UiServiceTestCase {
                eq(false), (AudioAttributes) anyObject());
                eq(false), (AudioAttributes) anyObject());
    }
    }


    private void verifyCustomBeep() throws RemoteException {
        verify(mRingtonePlayer, times(1)).playAsync(eq(CUSTOM_SOUND), (UserHandle) anyObject(),
                eq(false), (AudioAttributes) anyObject());
    }

    private void verifyNeverStopAudio() throws RemoteException {
    private void verifyNeverStopAudio() throws RemoteException {
        verify(mRingtonePlayer, never()).stopAsync();
        verify(mRingtonePlayer, never()).stopAsync();
    }
    }