1 /*
2  * Copyright (C) 2021 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.flags;
18 
19 import com.android.systemui.R;
20 
21 import java.lang.reflect.Field;
22 import java.util.HashMap;
23 import java.util.Map;
24 
25 /**
26  * List of {@link Flag} objects for use in SystemUI.
27  *
28  * Flag Ids are integers.
29  * Ids must be unique. This is enforced in a unit test.
30  * Ids need not be sequential. Flags can "claim" a chunk of ids for flags in related featurs with
31  * a comment. This is purely for organizational purposes.
32  *
33  * On public release builds, flags will always return their default value. There is no way to
34  * change their value on release builds.
35  *
36  * See {@link FeatureFlagManager} for instructions on flipping the flags via adb.
37  */
38 public class Flags {
39     public static final BooleanFlag TEAMFOOD = new BooleanFlag(1, false);
40 
41     /***************************************/
42     // 100 - notification
43     public static final BooleanFlag NEW_NOTIFICATION_PIPELINE =
44             new BooleanFlag(100, true);
45 
46     public static final BooleanFlag NEW_NOTIFICATION_PIPELINE_RENDERING =
47             new BooleanFlag(101, false);
48 
49     public static final BooleanFlag NOTIFICATION_UPDATES =
50             new BooleanFlag(102, true);
51 
52     /***************************************/
53     // 200 - keyguard/lockscreen
54     public static final BooleanFlag KEYGUARD_LAYOUT =
55             new BooleanFlag(200, true);
56 
57     public static final BooleanFlag LOCKSCREEN_ANIMATIONS =
58             new BooleanFlag(201, true);
59 
60     public static final BooleanFlag NEW_UNLOCK_SWIPE_ANIMATION =
61             new BooleanFlag(202, true);
62 
63     public static final BooleanFlag CHARGING_RIPPLE =
64             new BooleanFlag(203, false, R.bool.flag_charging_ripple);
65 
66     /***************************************/
67     // 300 - power menu
68     public static final BooleanFlag POWER_MENU_LITE =
69             new BooleanFlag(300, true);
70 
71     /***************************************/
72     // 400 - smartspace
73     public static final BooleanFlag SMARTSPACE_DEDUPING =
74             new BooleanFlag(400, true);
75 
76     public static final BooleanFlag SMARTSPACE_SHARED_ELEMENT_TRANSITION_ENABLED =
77             new BooleanFlag(401, false);
78 
79     public static final BooleanFlag SMARTSPACE =
80             new BooleanFlag(402, false, R.bool.flag_smartspace);
81 
82     /***************************************/
83     // 500 - quick settings
84     public static final BooleanFlag NEW_USER_SWITCHER =
85             new BooleanFlag(500, true);
86 
87     public static final BooleanFlag COMBINED_QS_HEADERS =
88             new BooleanFlag(501, false);
89 
90     public static final BooleanFlag PEOPLE_TILE =
91             new BooleanFlag(502, false, R.bool.flag_conversations);
92 
93     /***************************************/
94     // 600- status bar
95     public static final BooleanFlag COMBINED_STATUS_BAR_SIGNAL_ICONS =
96             new BooleanFlag(601, false);
97 
98     /***************************************/
99     // 700 - dialer/calls
100     public static final BooleanFlag ONGOING_CALL_STATUS_BAR_CHIP =
101             new BooleanFlag(700, true);
102 
103     public static final BooleanFlag ONGOING_CALL_IN_IMMERSIVE =
104             new BooleanFlag(701, true);
105 
106     public static final BooleanFlag ONGOING_CALL_IN_IMMERSIVE_CHIP_TAP =
107             new BooleanFlag(702, true);
108 
109     /***************************************/
110     // 800 - general visual/theme
111     public static final BooleanFlag MONET =
112             new BooleanFlag(800, true, R.bool.flag_monet);
113 
114     // Pay no attention to the reflection behind the curtain.
115     // ========================== Curtain ==========================
116     // |                                                           |
117     // |  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  |
118     private static Map<Integer, Flag<?>> sFlagMap;
collectFlags()119     static Map<Integer, Flag<?>> collectFlags() {
120         if (sFlagMap != null) {
121             return sFlagMap;
122         }
123         Map<Integer, Flag<?>> flags = new HashMap<>();
124 
125         Field[] fields = Flags.class.getFields();
126 
127         for (Field field : fields) {
128             Class<?> t = field.getType();
129             if (Flag.class.isAssignableFrom(t)) {
130                 try {
131                     Flag<?> flag = (Flag<?>) field.get(null);
132                     flags.put(flag.getId(), flag);
133                 } catch (IllegalAccessException e) {
134                     // no-op
135                 }
136             }
137         }
138 
139         sFlagMap = flags;
140 
141         return sFlagMap;
142     }
143     // |  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  |
144     // |                                                           |
145     // \_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/\_/
146 
147 }
148