1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.systemui.qs.tiles.base.actions 18 19 import android.app.PendingIntent 20 import android.content.Intent 21 import com.android.systemui.animation.Expandable 22 23 /** 24 * Fake implementation of [QSTileIntentUserInputHandler] interface. Consider using this alongside 25 * [QSTileIntentUserInputHandlerSubject]. 26 */ 27 class FakeQSTileIntentUserInputHandler : QSTileIntentUserInputHandler { 28 29 val handledInputs: List<Input> 30 get() = mutableInputs 31 32 private val mutableInputs = mutableListOf<Input>() 33 handlenull34 override fun handle( 35 expandable: Expandable?, 36 intent: Intent, 37 handleDismissShadeShowOverLockScreenWhenLocked: Boolean 38 ) { 39 mutableInputs.add(Input.Intent(expandable, intent)) 40 } 41 handlenull42 override fun handle( 43 expandable: Expandable?, 44 pendingIntent: PendingIntent, 45 requestLaunchingDefaultActivity: Boolean 46 ) { 47 mutableInputs.add( 48 Input.PendingIntent(expandable, pendingIntent, requestLaunchingDefaultActivity) 49 ) 50 } 51 52 sealed interface Input { 53 data class Intent(val expandable: Expandable?, val intent: android.content.Intent) : Input 54 data class PendingIntent( 55 val expandable: Expandable?, 56 val pendingIntent: android.app.PendingIntent, 57 val requestLaunchingDefaultActivity: Boolean 58 ) : Input 59 } 60 } 61 62 val FakeQSTileIntentUserInputHandler.intentInputs <lambda>null63 get() = handledInputs.mapNotNull { it as? FakeQSTileIntentUserInputHandler.Input.Intent } 64 val FakeQSTileIntentUserInputHandler.pendingIntentInputs <lambda>null65 get() = handledInputs.mapNotNull { it as? FakeQSTileIntentUserInputHandler.Input.PendingIntent } 66