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

Commit 45e18615 authored by Yiwen Chen's avatar Yiwen Chen
Browse files

Consistent vibration for ramping ringer on P4

On P4 devices, we currently can only do audio-coupled haptics with
ramping ringer. This cl fixes the bug. It gives us option to play normal
vibration with ramping ringer on P4 so that we can have consistent
function across all Pixel devices.

Bug:143305848
Test: tested on all Pixel devices.
Change-Id: I3e50fbeb8878b9620b7807ba53a650e38a3280ad
parent 5d22d5a4
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -224,10 +224,11 @@ public class AsyncRingtonePlayer {
                // can know whether to trigger the vibrator.
                if (mHapticsFuture != null && !mHapticsFuture.isDone()) {
                    boolean hasHaptics = factory.hasHapticChannels(mRingtone);

                    Log.i(this, "handlePlay: hasHaptics=%b, isVibrationEnabled=%b", hasHaptics,
                            isVibrationEnabled);
                    if (hasHaptics) {
                    SystemSettingsUtil systemSettingsUtil = new SystemSettingsUtil();
                    if (hasHaptics && (volumeShaperConfig == null
                            || systemSettingsUtil.enableAudioCoupledVibrationForRampingRinger())) {
                        AudioAttributes attributes = mRingtone.getAudioAttributes();
                        Log.d(this, "handlePlay: %s haptic channel",
                                (isVibrationEnabled ? "unmuting" : "muting"));
+6 −1
Original line number Diff line number Diff line
@@ -332,6 +332,12 @@ public class Ringer {
                            isUsingAudioCoupledHaptics, mIsHapticPlaybackSupportedByDevice);
                    maybeStartVibration(foregroundCall, shouldRingForContact, effect,
                            isVibratorEnabled, isRingerAudible);
                } else if (mSystemSettingsUtil.applyRampingRinger(mContext)
                           && mSystemSettingsUtil.enableRampingRingerFromDeviceConfig()
                           && !mSystemSettingsUtil.enableAudioCoupledVibrationForRampingRinger()) {
                    Log.i(this, "startRinging: apply ramping ringer vibration");
                    maybeStartVibration(foregroundCall, shouldRingForContact, effect,
                            isVibratorEnabled, isRingerAudible);
                } else {
                    Log.addEvent(foregroundCall, LogUtils.Events.SKIP_VIBRATION,
                            "using audio-coupled haptics");
@@ -354,7 +360,6 @@ public class Ringer {

    private void maybeStartVibration(Call foregroundCall, boolean shouldRingForContact,
        VibrationEffect effect, boolean isVibrationEnabled, boolean isRingerAudible) {

        if (isVibrationEnabled
                && !mIsVibrating && shouldRingForContact) {
            if (mSystemSettingsUtil.applyRampingRinger(mContext)