1 /* 2 * Copyright (C) 2024 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.mediaprojection.data.model 18 19 import android.app.ActivityManager.RunningTaskInfo 20 21 /** Represents the state of media projection. */ 22 sealed interface MediaProjectionState { 23 /** There is no media being projected. */ 24 data object NotProjecting : MediaProjectionState 25 26 /** 27 * Media is currently being projected. 28 * 29 * @property hostPackage the package name of the app that is receiving the content of the media 30 * projection (aka which app the phone screen contents are being sent to). 31 * @property hostDeviceName the name of the other device that's receiving the content of the 32 * media projection. Null if the media projection is going to this same device (e.g. another 33 * app is recording the screen). 34 */ 35 sealed class Projecting(open val hostPackage: String, open val hostDeviceName: String?) : 36 MediaProjectionState { 37 /** The entire screen is being projected. */ 38 data class EntireScreen( 39 override val hostPackage: String, 40 override val hostDeviceName: String? = null, 41 ) : Projecting(hostPackage, hostDeviceName) 42 43 /** Only a single task is being projected. */ 44 data class SingleTask( 45 override val hostPackage: String, 46 override val hostDeviceName: String?, 47 val task: RunningTaskInfo, 48 ) : Projecting(hostPackage, hostDeviceName) 49 50 /** The screen is not being projected, only audio is being projected. */ 51 data class NoScreen( 52 override val hostPackage: String, 53 override val hostDeviceName: String? = null, 54 ) : Projecting(hostPackage, hostDeviceName) 55 } 56 } 57