Merge "[Media TTT] Catch if the sender chip receives an invalid constant." into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
47883e857a
@@ -19,6 +19,7 @@ package com.android.systemui.media.taptotransfer.sender
|
|||||||
import android.app.StatusBarManager
|
import android.app.StatusBarManager
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.media.MediaRoute2Info
|
import android.media.MediaRoute2Info
|
||||||
|
import android.util.Log
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import com.android.internal.logging.UiEventLogger
|
import com.android.internal.logging.UiEventLogger
|
||||||
@@ -221,7 +222,12 @@ enum class ChipStateSender(
|
|||||||
*/
|
*/
|
||||||
fun getSenderStateFromId(
|
fun getSenderStateFromId(
|
||||||
@StatusBarManager.MediaTransferSenderState displayState: Int,
|
@StatusBarManager.MediaTransferSenderState displayState: Int,
|
||||||
): ChipStateSender = values().first { it.stateInt == displayState }
|
): ChipStateSender? = try {
|
||||||
|
values().first { it.stateInt == displayState }
|
||||||
|
} catch (e: NoSuchElementException) {
|
||||||
|
Log.e(TAG, "Could not find requested state $displayState", e)
|
||||||
|
null
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the state int from [StatusBarManager] associated with the given sender state
|
* Returns the state int from [StatusBarManager] associated with the given sender state
|
||||||
@@ -238,3 +244,5 @@ enum class ChipStateSender(
|
|||||||
// process and we should keep the user informed about it as long as possible (but don't allow it to
|
// process and we should keep the user informed about it as long as possible (but don't allow it to
|
||||||
// continue indefinitely).
|
// continue indefinitely).
|
||||||
private const val TRANSFER_TRIGGERED_TIMEOUT_MILLIS = 15000L
|
private const val TRANSFER_TRIGGERED_TIMEOUT_MILLIS = 15000L
|
||||||
|
|
||||||
|
private const val TAG = "ChipStateSender"
|
||||||
|
|||||||
@@ -276,6 +276,17 @@ class MediaTttChipControllerSenderTest : SysuiTestCase() {
|
|||||||
verify(windowManager).removeView(viewCaptor.value)
|
verify(windowManager).removeView(viewCaptor.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun commandQueueCallback_invalidStateParam_noChipShown() {
|
||||||
|
commandQueueCallback.updateMediaTapToTransferSenderDisplay(
|
||||||
|
100,
|
||||||
|
routeInfo,
|
||||||
|
null
|
||||||
|
)
|
||||||
|
|
||||||
|
verify(windowManager, never()).addView(any(), any())
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun receivesNewStateFromCommandQueue_isLogged() {
|
fun receivesNewStateFromCommandQueue_isLogged() {
|
||||||
commandQueueCallback.updateMediaTapToTransferSenderDisplay(
|
commandQueueCallback.updateMediaTapToTransferSenderDisplay(
|
||||||
|
|||||||
Reference in New Issue
Block a user