Merge "[Media TTT] Use a default name if blank string is given" into tm-qpr-dev am: fdb815d735

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20870164

Change-Id: Iceef83128e73c6297553668e9ec253d2f2e40e40
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Michael Mikhail
2023-01-10 21:03:10 +00:00
committed by Automerger Merge Worker
3 changed files with 45 additions and 1 deletions

View File

@@ -2366,6 +2366,8 @@
<string name="media_transfer_failed">Something went wrong. Try again.</string> <string name="media_transfer_failed">Something went wrong. Try again.</string>
<!-- Text to indicate that a media transfer is currently in-progress, aka loading. [CHAR LIMIT=NONE] --> <!-- Text to indicate that a media transfer is currently in-progress, aka loading. [CHAR LIMIT=NONE] -->
<string name="media_transfer_loading">Loading</string> <string name="media_transfer_loading">Loading</string>
<!-- Default name of the device. [CHAR LIMIT=30] -->
<string name="media_ttt_default_device_type">tablet</string>
<!-- Error message indicating that a control timed out while waiting for an update [CHAR_LIMIT=30] --> <!-- Error message indicating that a control timed out while waiting for an update [CHAR_LIMIT=30] -->
<string name="controls_error_timeout">Inactive, check app</string> <string name="controls_error_timeout">Inactive, check app</string>

View File

@@ -150,7 +150,12 @@ constructor(
logger: MediaTttLogger<ChipbarInfo>, logger: MediaTttLogger<ChipbarInfo>,
): ChipbarInfo { ): ChipbarInfo {
val packageName = routeInfo.clientPackageName val packageName = routeInfo.clientPackageName
val otherDeviceName = routeInfo.name.toString() val otherDeviceName =
if (routeInfo.name.isBlank()) {
context.getString(R.string.media_ttt_default_device_type)
} else {
routeInfo.name.toString()
}
return ChipbarInfo( return ChipbarInfo(
// Display the app's icon as the start icon // Display the app's icon as the start icon

View File

@@ -205,6 +205,21 @@ class MediaTttSenderCoordinatorTest : SysuiTestCase() {
verify(vibratorHelper).vibrate(any<VibrationEffect>()) verify(vibratorHelper).vibrate(any<VibrationEffect>())
} }
@Test
fun commandQueueCallback_almostCloseToStartCast_deviceNameBlank_showsDefaultDeviceName() {
commandQueueCallback.updateMediaTapToTransferSenderDisplay(
StatusBarManager.MEDIA_TRANSFER_SENDER_STATE_ALMOST_CLOSE_TO_START_CAST,
routeInfoWithBlankDeviceName,
null,
)
val chipbarView = getChipbarView()
assertThat(chipbarView.getChipText())
.contains(context.getString(R.string.media_ttt_default_device_type))
assertThat(chipbarView.getChipText())
.isNotEqualTo(ChipStateSender.ALMOST_CLOSE_TO_START_CAST.getExpectedStateText())
}
@Test @Test
fun commandQueueCallback_almostCloseToEndCast_triggersCorrectChip() { fun commandQueueCallback_almostCloseToEndCast_triggersCorrectChip() {
commandQueueCallback.updateMediaTapToTransferSenderDisplay( commandQueueCallback.updateMediaTapToTransferSenderDisplay(
@@ -247,6 +262,21 @@ class MediaTttSenderCoordinatorTest : SysuiTestCase() {
verify(vibratorHelper).vibrate(any<VibrationEffect>()) verify(vibratorHelper).vibrate(any<VibrationEffect>())
} }
@Test
fun commandQueueCallback_transferToReceiverTriggered_deviceNameBlank_showsDefaultDeviceName() {
commandQueueCallback.updateMediaTapToTransferSenderDisplay(
StatusBarManager.MEDIA_TRANSFER_SENDER_STATE_TRANSFER_TO_RECEIVER_TRIGGERED,
routeInfoWithBlankDeviceName,
null,
)
val chipbarView = getChipbarView()
assertThat(chipbarView.getChipText())
.contains(context.getString(R.string.media_ttt_default_device_type))
assertThat(chipbarView.getChipText())
.isNotEqualTo(ChipStateSender.TRANSFER_TO_RECEIVER_TRIGGERED.getExpectedStateText())
}
@Test @Test
fun commandQueueCallback_transferToThisDeviceTriggered_triggersCorrectChip() { fun commandQueueCallback_transferToThisDeviceTriggered_triggersCorrectChip() {
commandQueueCallback.updateMediaTapToTransferSenderDisplay( commandQueueCallback.updateMediaTapToTransferSenderDisplay(
@@ -934,6 +964,7 @@ class MediaTttSenderCoordinatorTest : SysuiTestCase() {
private const val APP_NAME = "Fake app name" private const val APP_NAME = "Fake app name"
private const val OTHER_DEVICE_NAME = "My Tablet" private const val OTHER_DEVICE_NAME = "My Tablet"
private const val BLANK_DEVICE_NAME = " "
private const val PACKAGE_NAME = "com.android.systemui" private const val PACKAGE_NAME = "com.android.systemui"
private const val TIMEOUT = 10000 private const val TIMEOUT = 10000
@@ -942,3 +973,9 @@ private val routeInfo =
.addFeature("feature") .addFeature("feature")
.setClientPackageName(PACKAGE_NAME) .setClientPackageName(PACKAGE_NAME)
.build() .build()
private val routeInfoWithBlankDeviceName =
MediaRoute2Info.Builder("id", BLANK_DEVICE_NAME)
.addFeature("feature")
.setClientPackageName(PACKAGE_NAME)
.build()