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

Unverified Commit 45668069 authored by Danny Baumann's avatar Danny Baumann Committed by Adrian DC
Browse files

Honor option to allow vibration during priority zen mode.

RM-290

Change-Id: Ie48746c913758f5d9fe7dea68bc7d304be82b026
parent 0edda153
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -200,13 +200,14 @@ final class Ringer extends CallsManagerListenerBase {
            // The foreground call is one of incoming calls so play the ringer out loud.
            stopCallWaiting(call);

            if (!shouldRingForContact(foregroundCall.getContactUri())) {
                return;
            }
            boolean[] shouldRingOrVibrate =
                    shouldRingOrVibrateForContact(foregroundCall.getContactUri());
            boolean ringAllowed = shouldRingOrVibrate[0];
            boolean vibrationAllowed = shouldRingOrVibrate[1];

            AudioManager audioManager =
                    (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
            if (audioManager.getStreamVolume(AudioManager.STREAM_RING) >= 0) {
            if (ringAllowed && audioManager.getStreamVolume(AudioManager.STREAM_RING) >= 0) {
                if (mState != STATE_RINGING) {
                    Log.event(call, Log.Events.START_RINGER);
                    mState = STATE_RINGING;
@@ -245,7 +246,7 @@ final class Ringer extends CallsManagerListenerBase {
                Log.v(this, "startRingingOrCallWaiting, skipping because volume is 0");
            }

            if (shouldVibrate(mContext) && !mIsVibrating) {
            if (vibrationAllowed && shouldVibrate(mContext) && !mIsVibrating) {
                mVibrator.vibrate(VIBRATION_PATTERN, VIBRATION_PATTERN_REPEAT,
                        VIBRATION_ATTRIBUTES);
                mIsVibrating = true;
@@ -274,7 +275,7 @@ final class Ringer extends CallsManagerListenerBase {
        }
    }

    private boolean shouldRingForContact(Uri contactUri) {
    private boolean[] shouldRingOrVibrateForContact(Uri contactUri) {
        final NotificationManager manager =
                (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
        final Bundle extras = new Bundle();