1 /* 2 * Copyright (C) 2025 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.quickstep.util 18 19 import android.app.TaskInfo 20 import android.content.ComponentName 21 import android.content.res.Resources 22 import android.window.DesktopExperienceFlags 23 import com.android.systemui.shared.recents.model.Task 24 25 class DesksUtils { 26 companion object { 27 val sysUiPackage = 28 Resources.getSystem().getString(com.android.internal.R.string.config_systemUi) 29 30 @JvmStatic areMultiDesksFlagsEnablednull31 fun areMultiDesksFlagsEnabled() = 32 DesktopExperienceFlags.ENABLE_MULTIPLE_DESKTOPS_BACKEND.isTrue && 33 DesktopExperienceFlags.ENABLE_MULTIPLE_DESKTOPS_FRONTEND.isTrue 34 35 /** Returns true if this [task] contains the [DesktopWallpaperActivity]. */ 36 @JvmStatic 37 fun isDesktopWallpaperTask(task: Task) = 38 task.key.component?.let(::isDesktopWallpaperComponent) == true 39 40 @JvmStatic 41 fun isDesktopWallpaperTask(taskInfo: TaskInfo): Boolean { 42 // TODO: b/403118101 - In some launcher tests, there is a task with baseIntent set to 43 // null. Remove this check after finding out how that task is created. 44 if (taskInfo.baseIntent == null) return false 45 return taskInfo.baseIntent.component?.let(::isDesktopWallpaperComponent) == true 46 } 47 48 @JvmStatic isDesktopWallpaperComponentnull49 fun isDesktopWallpaperComponent(component: ComponentName) = 50 component.className.contains("DesktopWallpaperActivity") && 51 component.packageName.contains(sysUiPackage) 52 } 53 } 54