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

Commit ae88e4f2 authored by Yiwen Chen's avatar Yiwen Chen
Browse files

Apply simple vibration pattern when the flag

use_simple_vibration_pattern is true and add AudioAttributes to ramping
ringer vibrate API.

Bug: 120789399
Test: Tested on device
Change-Id: Ib6c4a0834aad2d0ee0f345deeca744f628ce44a6
AOSP: Infeasible lagged behind
parent 4b871be4
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