Merge "[TTC] Override touch feedback haptic settings" into udc-dev am: 4fac2a56a3
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23118760 Change-Id: Iaa6221f3a245aca09a36516b3914d486d019bccd Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -21,6 +21,8 @@ import android.animation.ValueAnimator
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.Rect
|
import android.graphics.Rect
|
||||||
import android.os.PowerManager
|
import android.os.PowerManager
|
||||||
|
import android.os.Process
|
||||||
|
import android.os.VibrationAttributes
|
||||||
import android.view.Gravity
|
import android.view.Gravity
|
||||||
import android.view.MotionEvent
|
import android.view.MotionEvent
|
||||||
import android.view.View
|
import android.view.View
|
||||||
@@ -226,7 +228,15 @@ constructor(
|
|||||||
maybeGetAccessibilityFocus(newInfo, currentView)
|
maybeGetAccessibilityFocus(newInfo, currentView)
|
||||||
|
|
||||||
// ---- Haptics ----
|
// ---- 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) {
|
private fun maybeGetAccessibilityFocus(info: ChipbarInfo?, view: ViewGroup) {
|
||||||
@@ -352,6 +362,11 @@ constructor(
|
|||||||
val loadingView: View,
|
val loadingView: View,
|
||||||
val animator: ObjectAnimator,
|
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
|
@IdRes private val INFO_TAG = R.id.tag_chipbar_info
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import android.content.pm.PackageManager
|
|||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.media.MediaRoute2Info
|
import android.media.MediaRoute2Info
|
||||||
import android.os.PowerManager
|
import android.os.PowerManager
|
||||||
|
import android.os.VibrationAttributes
|
||||||
import android.os.VibrationEffect
|
import android.os.VibrationEffect
|
||||||
import android.testing.AndroidTestingRunner
|
import android.testing.AndroidTestingRunner
|
||||||
import android.testing.TestableLooper
|
import android.testing.TestableLooper
|
||||||
@@ -210,7 +211,14 @@ class MediaTttSenderCoordinatorTest : SysuiTestCase() {
|
|||||||
assertThat(chipbarView.getErrorIcon().visibility).isEqualTo(View.GONE)
|
assertThat(chipbarView.getErrorIcon().visibility).isEqualTo(View.GONE)
|
||||||
assertThat(uiEventLoggerFake.eventId(0))
|
assertThat(uiEventLoggerFake.eventId(0))
|
||||||
.isEqualTo(MediaTttSenderUiEvents.MEDIA_TTT_SENDER_ALMOST_CLOSE_TO_START_CAST.id)
|
.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
|
@Test
|
||||||
@@ -246,7 +254,14 @@ class MediaTttSenderCoordinatorTest : SysuiTestCase() {
|
|||||||
assertThat(chipbarView.getErrorIcon().visibility).isEqualTo(View.GONE)
|
assertThat(chipbarView.getErrorIcon().visibility).isEqualTo(View.GONE)
|
||||||
assertThat(uiEventLoggerFake.eventId(0))
|
assertThat(uiEventLoggerFake.eventId(0))
|
||||||
.isEqualTo(MediaTttSenderUiEvents.MEDIA_TTT_SENDER_ALMOST_CLOSE_TO_END_CAST.id)
|
.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
|
@Test
|
||||||
@@ -267,7 +282,14 @@ class MediaTttSenderCoordinatorTest : SysuiTestCase() {
|
|||||||
assertThat(chipbarView.getErrorIcon().visibility).isEqualTo(View.GONE)
|
assertThat(chipbarView.getErrorIcon().visibility).isEqualTo(View.GONE)
|
||||||
assertThat(uiEventLoggerFake.eventId(0))
|
assertThat(uiEventLoggerFake.eventId(0))
|
||||||
.isEqualTo(MediaTttSenderUiEvents.MEDIA_TTT_SENDER_TRANSFER_TO_RECEIVER_TRIGGERED.id)
|
.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
|
@Test
|
||||||
@@ -303,7 +325,14 @@ class MediaTttSenderCoordinatorTest : SysuiTestCase() {
|
|||||||
assertThat(chipbarView.getErrorIcon().visibility).isEqualTo(View.GONE)
|
assertThat(chipbarView.getErrorIcon().visibility).isEqualTo(View.GONE)
|
||||||
assertThat(uiEventLoggerFake.eventId(0))
|
assertThat(uiEventLoggerFake.eventId(0))
|
||||||
.isEqualTo(MediaTttSenderUiEvents.MEDIA_TTT_SENDER_TRANSFER_TO_THIS_DEVICE_TRIGGERED.id)
|
.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
|
@Test
|
||||||
@@ -326,7 +355,14 @@ class MediaTttSenderCoordinatorTest : SysuiTestCase() {
|
|||||||
// Event index 1 since initially displaying the triggered chip would also log an event.
|
// Event index 1 since initially displaying the triggered chip would also log an event.
|
||||||
assertThat(uiEventLoggerFake.eventId(1))
|
assertThat(uiEventLoggerFake.eventId(1))
|
||||||
.isEqualTo(MediaTttSenderUiEvents.MEDIA_TTT_SENDER_TRANSFER_TO_RECEIVER_SUCCEEDED.id)
|
.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
|
@Test
|
||||||
@@ -403,7 +439,14 @@ class MediaTttSenderCoordinatorTest : SysuiTestCase() {
|
|||||||
// Event index 1 since initially displaying the triggered chip would also log an event.
|
// Event index 1 since initially displaying the triggered chip would also log an event.
|
||||||
assertThat(uiEventLoggerFake.eventId(1))
|
assertThat(uiEventLoggerFake.eventId(1))
|
||||||
.isEqualTo(MediaTttSenderUiEvents.MEDIA_TTT_SENDER_TRANSFER_TO_THIS_DEVICE_SUCCEEDED.id)
|
.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
|
@Test
|
||||||
@@ -483,7 +526,14 @@ class MediaTttSenderCoordinatorTest : SysuiTestCase() {
|
|||||||
// Event index 1 since initially displaying the triggered chip would also log an event.
|
// Event index 1 since initially displaying the triggered chip would also log an event.
|
||||||
assertThat(uiEventLoggerFake.eventId(1))
|
assertThat(uiEventLoggerFake.eventId(1))
|
||||||
.isEqualTo(MediaTttSenderUiEvents.MEDIA_TTT_SENDER_TRANSFER_TO_RECEIVER_FAILED.id)
|
.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
|
@Test
|
||||||
@@ -511,7 +561,14 @@ class MediaTttSenderCoordinatorTest : SysuiTestCase() {
|
|||||||
// Event index 1 since initially displaying the triggered chip would also log an event.
|
// Event index 1 since initially displaying the triggered chip would also log an event.
|
||||||
assertThat(uiEventLoggerFake.eventId(1))
|
assertThat(uiEventLoggerFake.eventId(1))
|
||||||
.isEqualTo(MediaTttSenderUiEvents.MEDIA_TTT_SENDER_TRANSFER_TO_THIS_DEVICE_FAILED.id)
|
.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
|
@Test
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
package com.android.systemui.temporarydisplay.chipbar
|
package com.android.systemui.temporarydisplay.chipbar
|
||||||
|
|
||||||
import android.os.PowerManager
|
import android.os.PowerManager
|
||||||
|
import android.os.VibrationAttributes
|
||||||
import android.os.VibrationEffect
|
import android.os.VibrationEffect
|
||||||
import android.testing.AndroidTestingRunner
|
import android.testing.AndroidTestingRunner
|
||||||
import android.testing.TestableLooper
|
import android.testing.TestableLooper
|
||||||
@@ -461,7 +462,7 @@ class ChipbarCoordinatorTest : SysuiTestCase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun displayView_vibrationEffect_doubleClickEffect() {
|
fun displayView_vibrationEffect_doubleClickEffectWithHardwareFeedback() {
|
||||||
underTest.displayView(
|
underTest.displayView(
|
||||||
createChipbarInfo(
|
createChipbarInfo(
|
||||||
Icon.Resource(R.id.check_box, null),
|
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. */
|
/** Regression test for b/266119467. */
|
||||||
|
|||||||
Reference in New Issue
Block a user