• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 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.server.wm;
18 
19 import android.app.AppGlobals;
20 import android.content.pm.PackageManager;
21 
22 import com.android.window.flags.Flags;
23 
24 /**
25  * Utility class to read the flags used in the WindowManager server.
26  *
27  * It is not very cheap to read trunk stable flag, so having a centralized place to cache the flag
28  * values in the system server side.
29  *
30  * Flags should be defined in `core.java.android.window.flags` to allow access from client side.
31  *
32  * To override flag:
33  *   adb shell device_config put [namespace] [package].[name] [true/false]
34  *   adb reboot
35  *
36  * To access in wm:
37  *   {@link WindowManagerService#mFlags}
38  *
39  * Notes:
40  *   The system may use flags at anytime, so changing flags will only take effect after device
41  *   reboot. Otherwise, it may result unexpected behavior, such as broken transition.
42  *   When a flag needs to be read from both the server side and the client side, changing the flag
43  *   value will result difference in server and client until device reboot.
44  */
45 class WindowManagerFlags {
46 
47     /* Start Available Flags */
48 
49     final boolean mWallpaperOffsetAsync = Flags.wallpaperOffsetAsync();
50 
51     final boolean mAllowsScreenSizeDecoupledFromStatusBarAndCutout =
52             Flags.allowsScreenSizeDecoupledFromStatusBarAndCutout();
53 
54     final boolean mInsetsDecoupledConfiguration = Flags.insetsDecoupledConfiguration();
55 
56     final boolean mRespectNonTopVisibleFixedOrientation =
57             Flags.respectNonTopVisibleFixedOrientation();
58 
59     final boolean mEnsureWallpaperInTransitions;
60 
61     final boolean mAodTransition = Flags.aodTransition();
62 
63     /* End Available Flags */
64 
WindowManagerFlags()65     WindowManagerFlags() {
66         boolean isWatch;
67         try {
68             isWatch = AppGlobals.getPackageManager().hasSystemFeature(
69                         PackageManager.FEATURE_WATCH, 0 /* version */);
70         } catch (Throwable e) {
71             isWatch = false;
72         }
73         /*
74          * Wallpaper enablement is separated on Wear vs Phone as the latter appears to still exhibit
75          * regressions when enabled (for example b/353870983). These don't exist on Wear likely
76          * due to differences in SysUI/transition implementations. Wear enablement is required for
77          * 25Q2 while phone doesn't have as pressing a constraint and will wait to resolve any
78          * outstanding issues prior to roll-out.
79          */
80         mEnsureWallpaperInTransitions = (isWatch && Flags.ensureWallpaperInWearTransitions())
81                 || Flags.ensureWallpaperInTransitions();
82     }
83 }
84