Loading packages/SystemUI/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinator.kt +16 −1 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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) { Loading Loading @@ -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 Loading packages/SystemUI/tests/src/com/android/systemui/media/taptotransfer/sender/MediaTttSenderCoordinatorTest.kt +65 −8 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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 Loading Loading @@ -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 Loading @@ -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 Loading Loading @@ -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 Loading @@ -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 Loading Loading @@ -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 Loading Loading @@ -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 Loading Loading @@ -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 Loading packages/SystemUI/tests/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinatorTest.kt +10 −2 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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), Loading @@ -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. */ Loading Loading
packages/SystemUI/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinator.kt +16 −1 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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) { Loading Loading @@ -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 Loading
packages/SystemUI/tests/src/com/android/systemui/media/taptotransfer/sender/MediaTttSenderCoordinatorTest.kt +65 −8 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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 Loading Loading @@ -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 Loading @@ -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 Loading Loading @@ -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 Loading @@ -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 Loading Loading @@ -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 Loading Loading @@ -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 Loading Loading @@ -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 Loading
packages/SystemUI/tests/src/com/android/systemui/temporarydisplay/chipbar/ChipbarCoordinatorTest.kt +10 −2 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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), Loading @@ -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. */ Loading