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 18 19 import android.content.pm.PackageManager 20 import com.android.systemui.util.Utils 21 22 /** Various utility methods related to media projection. */ 23 object MediaProjectionUtils { 24 /** 25 * Returns true iff projecting to the given [packageName] means that we're casting media to a 26 * *different* device (as opposed to sharing media to some application on *this* device). 27 */ packageHasCastingCapabilitiesnull28 fun packageHasCastingCapabilities( 29 packageManager: PackageManager, 30 packageName: String 31 ): Boolean { 32 // The [isHeadlessRemoteDisplayProvider] check approximates whether a projection is to a 33 // different device or the same device, because headless remote display packages are the 34 // only kinds of packages that do cast-to-other-device. This isn't exactly perfect, 35 // because it means that any projection by those headless remote display packages will be 36 // marked as going to a different device, even if that isn't always true. See b/321078669. 37 return Utils.isHeadlessRemoteDisplayProvider(packageManager, packageName) 38 } 39 } 40