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

Commit c694c977 authored by Automerger Merge Worker's avatar Automerger Merge Worker Committed by Android (Google) Code Review
Browse files

Merge "Merge "[Media TTT] Catch if the sender chip receives an invalid...

Merge "Merge "[Media TTT] Catch if the sender chip receives an invalid constant." into tm-dev am: 47883e85 am: 200b8ea4"
parents 5a8bb1d3 ba738936
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui.media.taptotransfer.sender
import android.app.StatusBarManager
import android.content.Context
import android.media.MediaRoute2Info
import android.util.Log
import android.view.View
import androidx.annotation.StringRes
import com.android.internal.logging.UiEventLogger
@@ -221,7 +222,12 @@ enum class ChipStateSender(
         */
        fun getSenderStateFromId(
            @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
@@ -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
// continue indefinitely).
private const val TRANSFER_TRIGGERED_TIMEOUT_MILLIS = 15000L

private const val TAG = "ChipStateSender"
+11 −0
Original line number Diff line number Diff line
@@ -276,6 +276,17 @@ class MediaTttChipControllerSenderTest : SysuiTestCase() {
        verify(windowManager).removeView(viewCaptor.value)
    }

    @Test
    fun commandQueueCallback_invalidStateParam_noChipShown() {
        commandQueueCallback.updateMediaTapToTransferSenderDisplay(
            100,
            routeInfo,
            null
        )

        verify(windowManager, never()).addView(any(), any())
    }

    @Test
    fun receivesNewStateFromCommandQueue_isLogged() {
        commandQueueCallback.updateMediaTapToTransferSenderDisplay(