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.wm.shell.desktopmode 18 19 import android.app.Activity 20 import android.app.TaskInfo 21 import android.content.ComponentName 22 import android.os.Bundle 23 import android.view.WindowManager 24 25 /** 26 * A transparent activity used in the desktop mode to show the wallpaper under the freeform windows. 27 * This activity will be running in `FULLSCREEN` windowing mode, which ensures it hides Launcher. 28 * When entering desktop, we would ensure that it's added behind desktop apps and removed when 29 * leaving the desktop mode. 30 * 31 * Note! This activity should NOT interact directly with any other code in the Shell without calling 32 * onto the shell main thread. Activities are always started on the main thread. 33 */ 34 class DesktopWallpaperActivity : Activity() { 35 onCreatenull36 override fun onCreate(savedInstanceState: Bundle?) { 37 super.onCreate(savedInstanceState) 38 window.addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE) 39 } 40 41 companion object { 42 private const val SYSTEM_UI_PACKAGE_NAME = "com.android.systemui" 43 @JvmStatic 44 val wallpaperActivityComponent = 45 ComponentName(SYSTEM_UI_PACKAGE_NAME, DesktopWallpaperActivity::class.java.name) 46 47 @JvmStatic isWallpaperTasknull48 fun isWallpaperTask(taskInfo: TaskInfo) = 49 taskInfo.baseIntent.component?.let(::isWallpaperComponent) ?: false 50 51 @JvmStatic 52 fun isWallpaperComponent(component: ComponentName) = component == wallpaperActivityComponent 53 } 54 } 55