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

Commit 1b023b9b authored by Wilson Wu's avatar Wilson Wu
Browse files

Use classic vibration when ramping ringer

CL[1] added a logic to not mute haptic channel
for customization when ramping ringer enabled.

Remove the logic to keep audio-coupled ringtone
keep classic vibration for ramping ringer as legacy
behavior.

[1]: I3dab1edc3a5d7a64a65d6350a99ad9517d999f2b

Flag: android.media.audio.enable_ringtone_haptics_customization
Bug: 394231980
Test: atest RingerTest
Change-Id: I96c4c11136c4f6e9e9ecb4f75079afcb99d37606
parent 3bd3bd0f
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -433,11 +433,6 @@ public class Ringer {
                    && isVibratorEnabled) {
                Log.i(this, "Muted haptic channels since audio coupled ramping ringer is disabled");
                hapticChannelsMuted = true;
                if (useCustomVibration(foregroundCall)) {
                    Log.i(this,
                            "Not muted haptic channel for customization when apply ramping ringer");
                    hapticChannelsMuted = false;
                }
            } else if (hapticChannelsMuted) {
                Log.i(this,
                        "Muted haptic channels isVibratorEnabled=%s, hapticPlaybackSupported=%s",
+0 −32
Original line number Diff line number Diff line
@@ -888,38 +888,6 @@ public class RingerTest extends TelecomTestCase {
        }
    }

    @SmallTest
    @Test
    @EnableFlags(Flags.FLAG_ENABLE_RINGTONE_HAPTICS_CUSTOMIZATION)
    public void testNotMuteHapticChannelWithRampingRinger() throws Exception {
        final Context context = ApplicationProvider.getApplicationContext();
        Uri defaultRingtoneUri = RingtoneManager.getActualDefaultRingtoneUri(context,
                RingtoneManager.TYPE_RINGTONE);
        assumeNotNull(defaultRingtoneUri);
        Uri FAKE_RINGTONE_VIBRATION_URI = defaultRingtoneUri.buildUpon().appendQueryParameter(
                        VIBRATION_PARAM, FAKE_VIBRATION_URI.toString()).build();
        mComponentContextFixture.putBooleanResource(
                com.android.internal.R.bool.config_ringtoneVibrationSettingsSupported, true);
        ArgumentCaptor<Boolean> muteHapticChannelCaptor = ArgumentCaptor.forClass(Boolean.class);
        try {
            RingtoneManager.setActualDefaultRingtoneUri(context, RingtoneManager.TYPE_RINGTONE,
                    FAKE_RINGTONE_VIBRATION_URI);
            createRingerUnderTest(); // Needed after mock the config.
            mRingerUnderTest.startCallWaiting(mockCall1);
            ensureRingerIsAudible();
            enableRampingRinger();
            enableVibrationWhenRinging();
            assertTrue(startRingingAndWaitForAsync(mockCall2, false));
            verify(mockRingtoneFactory, atLeastOnce()).getRingtone(any(Call.class),
                    nullable(VolumeShaper.Configuration.class), muteHapticChannelCaptor.capture());
            assertFalse(muteHapticChannelCaptor.getValue());
        } finally {
            // Restore the default ringtone Uri
            RingtoneManager.setActualDefaultRingtoneUri(context, RingtoneManager.TYPE_RINGTONE,
                    defaultRingtoneUri);
        }
    }

    /**
     * Call startRinging and wait for its effects to have played out, to allow reliable assertions
     * after it. The effects are generally "start playing ringtone" and "start vibration" - not