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.windowdecor.extension 18 19 import android.app.TaskInfo 20 import android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN 21 import android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW 22 import android.app.WindowConfiguration.WINDOWING_MODE_PINNED 23 import android.view.WindowInsets 24 import android.view.WindowInsetsController.APPEARANCE_LIGHT_CAPTION_BARS 25 import android.view.WindowInsetsController.APPEARANCE_TRANSPARENT_CAPTION_BAR_BACKGROUND 26 27 val TaskInfo.isTransparentCaptionBarAppearance: Boolean 28 get() { 29 val appearance = taskDescription?.topOpaqueSystemBarsAppearance ?: 0 30 return (appearance and APPEARANCE_TRANSPARENT_CAPTION_BAR_BACKGROUND) != 0 31 } 32 33 val TaskInfo.isLightCaptionBarAppearance: Boolean 34 get() { 35 val appearance = taskDescription?.topOpaqueSystemBarsAppearance ?: 0 36 return (appearance and APPEARANCE_LIGHT_CAPTION_BARS) != 0 37 } 38 39 /** Whether the task is in fullscreen windowing mode. */ 40 val TaskInfo.isFullscreen: Boolean 41 get() = windowingMode == WINDOWING_MODE_FULLSCREEN 42 43 /** Whether the task is in pinned windowing mode. */ 44 val TaskInfo.isPinned: Boolean 45 get() = windowingMode == WINDOWING_MODE_PINNED 46 47 /** Whether the task is in multi-window windowing mode. */ 48 val TaskInfo.isMultiWindow: Boolean 49 get() = windowingMode == WINDOWING_MODE_MULTI_WINDOW 50 51 /** Whether the task is requesting immersive mode. */ 52 val TaskInfo.requestingImmersive: Boolean 53 get() { 54 // Considered to be requesting immersive when requesting to hide the status bar. 55 return (requestedVisibleTypes and WindowInsets.Type.statusBars()) == 0 56 } 57