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

Commit 4a0bf8a5 authored by Christina Tao's avatar Christina Tao Committed by Automerger Merge Worker
Browse files

Merge "[TTC] Override touch feedback haptic settings" into udc-dev am: 4fac2a56 am: 0aabfbde

parents 9b0626a7 0aabfbde
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ import android.animation.ValueAnimator
import android.content.Context
import android.graphics.Rect
import android.os.PowerManager
import android.os.Process
import android.os.VibrationAttributes
import android.view.Gravity
import android.view.MotionEvent
import android.view.View
@@ -226,7 +228,15 @@ constructor(
        maybeGetAccessibilityFocus(newInfo, currentView)

        // ---- Haptics ----
        newInfo.vibrationEffect?.let { vibratorHelper.vibrate(it) }
        newInfo.vibrationEffect?.let {
            vibratorHelper.vibrate(
                Process.myUid(),
                context.getApplicationContext().getPackageName(),
                it,
                newInfo.windowTitle,
                VIBRATION_ATTRIBUTES,
            )
        }
    }

    private fun maybeGetAccessibilityFocus(info: ChipbarInfo?, view: ViewGroup) {
@@ -352,6 +362,11 @@ constructor(
        val loadingView: View,
        val animator: ObjectAnimator,
    )

    companion object {
        val VIBRATION_ATTRIBUTES: VibrationAttributes =
            VibrationAttributes.createForUsage(VibrationAttributes.USAGE_HARDWARE_FEEDBACK)
    }
}

@IdRes private val INFO_TAG = R.id.tag_chipbar_info
+65 −8
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.content.pm.PackageManager
import android.graphics.drawable.Drawable
import android.media.MediaRoute2Info
import android.os.PowerManager
import android.os.VibrationAttributes
import android.os.VibrationEffect
import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
@@ -210,7 +211,14 @@ class MediaTttSenderCoordinatorTest : SysuiTestCase() {
        assertThat(chipbarView.getErrorIcon().visibility).isEqualTo(View.GONE)
        assertThat(uiEventLoggerFake.eventId(0))
            .isEqualTo(MediaTttSenderUiEvents.MEDIA_TTT_SENDER_ALMOST_CLOSE_TO_START_CAST.id)
        verify(vibratorHelper).vibrate(any<VibrationEffect>())
        verify(vibratorHelper)
            .vibrate(
                any(),
                any(),
                any<VibrationEffect>(),
                any(),
                any<VibrationAttributes>(),
            )
    }

    @Test
@@ -246,7 +254,14 @@ class MediaTttSenderCoordinatorTest : SysuiTestCase() {
        assertThat(chipbarView.getErrorIcon().visibility).isEqualTo(View.GONE)
        assertThat(uiEventLoggerFake.eventId(0))
            .isEqualTo(MediaTttSenderUiEvents.MEDIA_TTT_SENDER_ALMOST_CLOSE_TO_END_CAST.id)
        verify(vibratorHelper).vibrate(any<VibrationEffect>())
        verify(vibratorHelper)
            .vibrate(
                any(),
                any(),
                any<VibrationEffect>(),
                any(),
                any<VibrationAttributes>(),
            )
    }

    @Test
@@ -267,7 +282,14 @@ class MediaTttSenderCoordinatorTest : SysuiTestCase() {
        assertThat(chipbarView.getErrorIcon().visibility).isEqualTo(View.GONE)
        assertThat(uiEventLoggerFake.eventId(0))
            .isEqualTo(MediaTttSenderUiEvents.MEDIA_TTT_SENDER_TRANSFER_TO_RECEIVER_TRIGGERED.id)
        verify(vibratorHelper).vibrate(any<VibrationEffect>())
        verify(vibratorHelper)
            .vibrate(
                any(),
                any(),
                any<VibrationEffect>(),
                any(),
                any<VibrationAttributes>(),
            )
    }

    @Test
@@ -303,7 +325,14 @@ class MediaTttSenderCoordinatorTest : SysuiTestCase() {
        assertThat(chipbarView.getErrorIcon().visibility).isEqualTo(View.GONE)
        assertThat(uiEventLoggerFake.eventId(0))
            .isEqualTo(MediaTttSenderUiEvents.MEDIA_TTT_SENDER_TRANSFER_TO_THIS_DEVICE_TRIGGERED.id)
        verify(vibratorHelper).vibrate(any<VibrationEffect>())
        verify(vibratorHelper)
            .vibrate(
                any(),
                any(),
                any<VibrationEffect>(),
                any(),
                any<VibrationAttributes>(),
            )
    }

    @Test
@@ -326,7 +355,14 @@ class MediaTttSenderCoordinatorTest : SysuiTestCase() {
        // Event index 1 since initially displaying the triggered chip would also log an event.
        assertThat(uiEventLoggerFake.eventId(1))
            .isEqualTo(MediaTttSenderUiEvents.MEDIA_TTT_SENDER_TRANSFER_TO_RECEIVER_SUCCEEDED.id)
        verify(vibratorHelper, never()).vibrate(any<VibrationEffect>())
        verify(vibratorHelper, never())
            .vibrate(
                any(),
                any(),
                any<VibrationEffect>(),
                any(),
                any<VibrationAttributes>(),
            )
    }

    @Test
@@ -403,7 +439,14 @@ class MediaTttSenderCoordinatorTest : SysuiTestCase() {
        // Event index 1 since initially displaying the triggered chip would also log an event.
        assertThat(uiEventLoggerFake.eventId(1))
            .isEqualTo(MediaTttSenderUiEvents.MEDIA_TTT_SENDER_TRANSFER_TO_THIS_DEVICE_SUCCEEDED.id)
        verify(vibratorHelper, never()).vibrate(any<VibrationEffect>())
        verify(vibratorHelper, never())
            .vibrate(
                any(),
                any(),
                any<VibrationEffect>(),
                any(),
                any<VibrationAttributes>(),
            )
    }

    @Test
@@ -483,7 +526,14 @@ class MediaTttSenderCoordinatorTest : SysuiTestCase() {
        // Event index 1 since initially displaying the triggered chip would also log an event.
        assertThat(uiEventLoggerFake.eventId(1))
            .isEqualTo(MediaTttSenderUiEvents.MEDIA_TTT_SENDER_TRANSFER_TO_RECEIVER_FAILED.id)
        verify(vibratorHelper).vibrate(any<VibrationEffect>())
        verify(vibratorHelper)
            .vibrate(
                any(),
                any(),
                any<VibrationEffect>(),
                any(),
                any<VibrationAttributes>(),
            )
    }

    @Test
@@ -511,7 +561,14 @@ class MediaTttSenderCoordinatorTest : SysuiTestCase() {
        // Event index 1 since initially displaying the triggered chip would also log an event.
        assertThat(uiEventLoggerFake.eventId(1))
            .isEqualTo(MediaTttSenderUiEvents.MEDIA_TTT_SENDER_TRANSFER_TO_THIS_DEVICE_FAILED.id)
        verify(vibratorHelper).vibrate(any<VibrationEffect>())
        verify(vibratorHelper)
            .vibrate(
                any(),
                any(),
                any<VibrationEffect>(),
                any(),
                any<VibrationAttributes>(),
            )
    }

    @Test
+10 −2
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.temporarydisplay.chipbar

import android.os.PowerManager
import android.os.VibrationAttributes
import android.os.VibrationEffect
import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
@@ -461,7 +462,7 @@ class ChipbarCoordinatorTest : SysuiTestCase() {
    }

    @Test
    fun displayView_vibrationEffect_doubleClickEffect() {
    fun displayView_vibrationEffect_doubleClickEffectWithHardwareFeedback() {
        underTest.displayView(
            createChipbarInfo(
                Icon.Resource(R.id.check_box, null),
@@ -471,7 +472,14 @@ class ChipbarCoordinatorTest : SysuiTestCase() {
            )
        )

        verify(vibratorHelper).vibrate(VibrationEffect.get(VibrationEffect.EFFECT_DOUBLE_CLICK))
        verify(vibratorHelper)
            .vibrate(
                any(),
                any(),
                eq(VibrationEffect.get(VibrationEffect.EFFECT_DOUBLE_CLICK)),
                any(),
                eq(VibrationAttributes.createForUsage(VibrationAttributes.USAGE_HARDWARE_FEEDBACK)),
            )
    }

    /** Regression test for b/266119467. */