• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.shade
18 
19 import android.content.Context
20 import android.graphics.PixelFormat
21 import android.os.Binder
22 import android.view.Gravity
23 import android.view.ViewGroup
24 import android.view.WindowManager.LayoutParams
25 import com.android.systemui.scene.shared.flag.SceneContainerFlag
26 
27 object ShadeWindowLayoutParams {
28     /**
29      * Creates [LayoutParams] for the shade window.
30      *
31      * This is extracted to a single place as those layout params will be used by several places:
32      * - When sysui starts, and the shade is added the first time
33      * - When the shade moves to a different window (e.g. while an external display is connected)
34      */
createnull35     fun create(context: Context): LayoutParams {
36         return LayoutParams(
37                 ViewGroup.LayoutParams.MATCH_PARENT,
38                 ViewGroup.LayoutParams.MATCH_PARENT,
39                 LayoutParams.TYPE_NOTIFICATION_SHADE,
40                 LayoutParams.FLAG_NOT_FOCUSABLE or
41                     LayoutParams.FLAG_TOUCHABLE_WHEN_WAKING or
42                     LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH or
43                     LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS,
44                 // Now that the notification shade encompasses the sliding panel and its
45                 // translucent backdrop, the entire thing is made TRANSLUCENT and is
46                 // hardware-accelerated.
47                 PixelFormat.TRANSLUCENT,
48             )
49             .apply {
50                 token = Binder()
51                 gravity = Gravity.TOP
52                 fitInsetsTypes = 0
53                 title = "NotificationShade"
54                 packageName = context.packageName
55                 layoutInDisplayCutoutMode = LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS
56                 privateFlags = privateFlags or LayoutParams.PRIVATE_FLAG_OPTIMIZE_MEASURE
57                 if (SceneContainerFlag.isEnabled) {
58                     // This prevents the appearance and disappearance of the software keyboard (also
59                     // known as the "IME") from scrolling/panning the window to make room for the
60                     // keyboard.
61                     //
62                     // The scene container logic does its own adjustment and animation when the IME
63                     // appears or disappears.
64                     softInputMode = LayoutParams.SOFT_INPUT_ADJUST_NOTHING
65                 }
66             }
67     }
68 }
69