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

Commit 0eb9e816 authored by Yiwen Chen's avatar Yiwen Chen Committed by Android (Google) Code Review
Browse files

Merge "Apply simple vibration pattern when the flag...

Merge "Apply simple vibration pattern when the flag use_simple_vibration_pattern is true and add AudioAttributes to ramping ringer vibrate API."
parents 930f8062 ae88e4f2
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -355,7 +355,7 @@ public class Ringer {
                    && mSystemSettingsUtil.enableRampingRingerFromDeviceConfig()
                    && isRingerAudible) {
                Log.i(this, "start vibration for ramping ringer.");
                mVibrator.vibrate(effect);
                mVibrator.vibrate(effect, VIBRATION_ATTRIBUTES);
                mIsVibrating = true;
            } else {
                Log.i(this, "start normal vibration.");
@@ -373,11 +373,22 @@ public class Ringer {
        }
        List<Long> rampingRingerVibrationPatternList = new ArrayList<>();
        List<Integer> rampingRingerVibrationAmplitudeList = new ArrayList<>();
        long[] rampingRingerPulsePattern;
        int[] rampingRingerPulseAmplitude;
        if (mContext.getResources().getBoolean(R.bool.use_simple_vibration_pattern)) {
            rampingRingerPulsePattern = SIMPLE_VIBRATION_PATTERN;
            rampingRingerPulseAmplitude = SIMPLE_VIBRATION_AMPLITUDE;
            Log.i(this, "Start vibration for ramping ringer with simple vibration pattern.");
        } else {
            rampingRingerPulsePattern = PULSE_RAMPING_PATTERN;
            rampingRingerPulseAmplitude = PULSE_RAMPING_AMPLITUDE;
            Log.i(this, "Start vibration for ramping ringer with normal vibration pattern.");
        }
        while (vibrationSeconds > 0) {
            rampingRingerVibrationPatternList.addAll(
                Arrays.stream(PULSE_RAMPING_PATTERN).boxed().collect(Collectors.toList()));
                Arrays.stream(rampingRingerPulsePattern).boxed().collect(Collectors.toList()));
            rampingRingerVibrationAmplitudeList.addAll(
                Arrays.stream(PULSE_RAMPING_AMPLITUDE).boxed().collect(Collectors.toList()));
                Arrays.stream(rampingRingerPulseAmplitude).boxed().collect(Collectors.toList()));
            vibrationSeconds -= 2;
        }
        // remove the last second of pause