• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 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.launcher3.config;
18 
19 import static com.android.launcher3.uioverrides.flags.FlagsFactory.getDebugFlag;
20 import static com.android.launcher3.uioverrides.flags.FlagsFactory.getReleaseFlag;
21 
22 import android.content.Context;
23 
24 import androidx.annotation.VisibleForTesting;
25 
26 import com.android.launcher3.BuildConfig;
27 import com.android.launcher3.Utilities;
28 
29 import java.util.function.Predicate;
30 import java.util.function.ToIntFunction;
31 
32 /**
33  * Defines a set of flags used to control various launcher behaviors.
34  *
35  * <p>All the flags should be defined here with appropriate default values.
36  */
37 public final class FeatureFlags {
38 
39     public static final String FLAGS_PREF_NAME = "featureFlags";
40 
41     @VisibleForTesting
42     public static Predicate<BooleanFlag> sBooleanReader = f -> f.mCurrentValue;
43     @VisibleForTesting
44     public static ToIntFunction<IntFlag> sIntReader = f -> f.mCurrentValue;
45 
FeatureFlags()46     private FeatureFlags() { }
47 
showFlagTogglerUi(Context context)48     public static boolean showFlagTogglerUi(Context context) {
49         return BuildConfig.IS_DEBUG_DEVICE && Utilities.isDevelopersOptionsEnabled(context);
50     }
51 
52     /**
53      * True when the build has come from Android Studio and is being used for local debugging.
54      * @deprecated Use {@link BuildConfig#IS_STUDIO_BUILD} directly
55      */
56     @Deprecated
57     public static final boolean IS_STUDIO_BUILD = BuildConfig.IS_STUDIO_BUILD;
58 
59     /**
60      * Enable moving the QSB on the 0th screen of the workspace. This is not a configuration feature
61      * and should be modified at a project level.
62      * @deprecated Use {@link BuildConfig#QSB_ON_FIRST_SCREEN} directly
63      */
64     @Deprecated
65     public static final boolean QSB_ON_FIRST_SCREEN = BuildConfig.QSB_ON_FIRST_SCREEN;
66 
67     /**
68      * Feature flag to handle define config changes dynamically instead of killing the process.
69      *
70      *
71      * To add a new flag that can be toggled through the flags UI:
72      *
73      * Declare a new ToggleableFlag below. Give it a unique key (e.g. "QSB_ON_FIRST_SCREEN"),
74      * and set a default value for the flag. This will be the default value on Debug builds.
75      */
76     public static final BooleanFlag ENABLE_INPUT_CONSUMER_REASON_LOGGING = getDebugFlag(270390028,
77             "ENABLE_INPUT_CONSUMER_REASON_LOGGING",
78             true,
79             "Log the reason why an Input Consumer was selected for a gesture.");
80 
81     public static final BooleanFlag ENABLE_GESTURE_ERROR_DETECTION = getDebugFlag(270389990,
82             "ENABLE_GESTURE_ERROR_DETECTION",
83             true,
84             "Analyze gesture events and log detected errors");
85 
86     // When enabled the promise icon is visible in all apps while installation an app.
87     public static final BooleanFlag PROMISE_APPS_IN_ALL_APPS = getDebugFlag(270390012,
88             "PROMISE_APPS_IN_ALL_APPS", false, "Add promise icon in all-apps");
89 
90     public static final BooleanFlag KEYGUARD_ANIMATION = getDebugFlag(270390904,
91             "KEYGUARD_ANIMATION", false, "Enable animation for keyguard going away on wallpaper");
92 
93     public static final BooleanFlag ENABLE_DEVICE_SEARCH = getReleaseFlag(270390907,
94             "ENABLE_DEVICE_SEARCH", true, "Allows on device search in all apps");
95 
96     public static final BooleanFlag ENABLE_FLOATING_SEARCH_BAR =
97             getDebugFlag(270390286, "ENABLE_FLOATING_SEARCH_BAR", false,
98                     "Keep All Apps search bar at the bottom (but above keyboard if open)");
99 
100     public static final BooleanFlag ENABLE_HIDE_HEADER = getReleaseFlag(270390930,
101             "ENABLE_HIDE_HEADER", true, "Hide header on keyboard before typing in all apps");
102 
103     public static final BooleanFlag ENABLE_EXPANDING_PAUSE_WORK_BUTTON = getReleaseFlag(270390779,
104             "ENABLE_EXPANDING_PAUSE_WORK_BUTTON", false,
105             "Expand and collapse pause work button while scrolling");
106 
107     public static final BooleanFlag ENABLE_RECENT_BLOCK = getDebugFlag(270390950,
108             "ENABLE_RECENT_BLOCK", false, "Show recently tapped search target block in zero state");
109 
110     public static final BooleanFlag COLLECT_SEARCH_HISTORY = getReleaseFlag(270391455,
111             "COLLECT_SEARCH_HISTORY", false, "Allow launcher to collect search history for log");
112 
113     public static final BooleanFlag ENABLE_TWOLINE_ALLAPPS = getDebugFlag(270390937,
114             "ENABLE_TWOLINE_ALLAPPS", false, "Enables two line label inside all apps.");
115 
116     public static final BooleanFlag ENABLE_TWOLINE_DEVICESEARCH = getDebugFlag(201388851,
117             "ENABLE_TWOLINE_DEVICESEARCH", false,
118             "Enable two line label for icons with labels on device search.");
119 
120     public static final BooleanFlag ENABLE_DEVICE_SEARCH_PERFORMANCE_LOGGING = getReleaseFlag(
121             270391397, "ENABLE_DEVICE_SEARCH_PERFORMANCE_LOGGING", false,
122             "Allows on device search in all apps logging");
123 
124     public static final BooleanFlag IME_STICKY_SNACKBAR_EDU = getDebugFlag(270391693,
125             "IME_STICKY_SNACKBAR_EDU", true, "Show sticky IME edu in AllApps");
126 
127     public static final BooleanFlag ENABLE_PEOPLE_TILE_PREVIEW = getDebugFlag(270391653,
128             "ENABLE_PEOPLE_TILE_PREVIEW", false,
129             "Experimental: Shows conversation shortcuts on home screen as search results");
130 
131     public static final BooleanFlag FOLDER_NAME_MAJORITY_RANKING = getDebugFlag(270391638,
132             "FOLDER_NAME_MAJORITY_RANKING", true,
133             "Suggests folder names based on majority based ranking.");
134 
135     public static final BooleanFlag INJECT_FALLBACK_APP_CORPUS_RESULTS = getReleaseFlag(270391706,
136             "INJECT_FALLBACK_APP_CORPUS_RESULTS", false,
137             "Inject fallback app corpus result when AiAi fails to return it.");
138 
139     public static final BooleanFlag ASSISTANT_GIVES_LAUNCHER_FOCUS = getDebugFlag(270391641,
140             "ASSISTANT_GIVES_LAUNCHER_FOCUS", false,
141             "Allow Launcher to handle nav bar gestures while Assistant is running over it");
142 
143     public static final BooleanFlag ENABLE_BULK_WORKSPACE_ICON_LOADING = getDebugFlag(270392203,
144             "ENABLE_BULK_WORKSPACE_ICON_LOADING",
145             true,
146             "Enable loading workspace icons in bulk.");
147 
148     public static final BooleanFlag ENABLE_BULK_ALL_APPS_ICON_LOADING = getDebugFlag(270392465,
149             "ENABLE_BULK_ALL_APPS_ICON_LOADING",
150             true,
151             "Enable loading all apps icons in bulk.");
152 
153     public static final BooleanFlag ENABLE_DATABASE_RESTORE = getDebugFlag(270392706,
154             "ENABLE_DATABASE_RESTORE", false,
155             "Enable database restore when new restore session is created");
156 
157     public static final BooleanFlag ENABLE_SMARTSPACE_DISMISS = getDebugFlag(270391664,
158             "ENABLE_SMARTSPACE_DISMISS", true,
159             "Adds a menu option to dismiss the current Enhanced Smartspace card.");
160 
161     public static final BooleanFlag ENABLE_OVERLAY_CONNECTION_OPTIM = getDebugFlag(270392629,
162             "ENABLE_OVERLAY_CONNECTION_OPTIM",
163             false,
164             "Enable optimizing overlay service connection");
165 
166     /**
167      * Enables region sampling for text color: Needs system health assessment before turning on
168      */
169     public static final BooleanFlag ENABLE_REGION_SAMPLING = getDebugFlag(270391669,
170             "ENABLE_REGION_SAMPLING", false,
171             "Enable region sampling to determine color of text on screen.");
172 
173     public static final BooleanFlag ALWAYS_USE_HARDWARE_OPTIMIZATION_FOR_FOLDER_ANIMATIONS =
174             getDebugFlag(270393096,
175                     "ALWAYS_USE_HARDWARE_OPTIMIZATION_FOR_FOLDER_ANIMATIONS", false,
176                     "Always use hardware optimization for folder animations.");
177 
178     public static final BooleanFlag SEPARATE_RECENTS_ACTIVITY = getDebugFlag(270392980,
179             "SEPARATE_RECENTS_ACTIVITY", false,
180             "Uses a separate recents activity instead of using the integrated recents+Launcher UI");
181 
182     public static final BooleanFlag ENABLE_MINIMAL_DEVICE = getDebugFlag(270392984,
183             "ENABLE_MINIMAL_DEVICE", false,
184             "Allow user to toggle minimal device mode in launcher.");
185 
186     public static final BooleanFlag ENABLE_TASKBAR_POPUP_MENU = getDebugFlag(
187             270392477, "ENABLE_TASKBAR_POPUP_MENU", true,
188             "Enables long pressing taskbar icons to show the popup menu.");
189 
190     public static final BooleanFlag ENABLE_TWO_PANEL_HOME = getDebugFlag(270392643,
191             "ENABLE_TWO_PANEL_HOME", true,
192             "Uses two panel on home screen. Only applicable on large screen devices.");
193 
194     public static final BooleanFlag ENABLE_SCRIM_FOR_APP_LAUNCH = getDebugFlag(270393276,
195             "ENABLE_SCRIM_FOR_APP_LAUNCH", false,
196             "Enables scrim during app launch animation.");
197 
198     public static final BooleanFlag ENABLE_ENFORCED_ROUNDED_CORNERS = getReleaseFlag(270393258,
199             "ENABLE_ENFORCED_ROUNDED_CORNERS", true, "Enforce rounded corners on all App Widgets");
200 
201     public static final BooleanFlag NOTIFY_CRASHES = getDebugFlag(
202             270393108, "NOTIFY_CRASHES", false,
203             "Sends a notification whenever launcher encounters an uncaught exception.");
204 
205     public static final BooleanFlag ENABLE_WALLPAPER_SCRIM = getDebugFlag(270393604,
206             "ENABLE_WALLPAPER_SCRIM", false,
207             "Enables scrim over wallpaper for text protection.");
208 
209     public static final BooleanFlag WIDGETS_IN_LAUNCHER_PREVIEW = getDebugFlag(270393268,
210             "WIDGETS_IN_LAUNCHER_PREVIEW", true,
211             "Enables widgets in Launcher preview for the Wallpaper app.");
212 
213     public static final BooleanFlag QUICK_WALLPAPER_PICKER = getDebugFlag(270393112,
214             "QUICK_WALLPAPER_PICKER", true,
215             "Shows quick wallpaper picker in long-press menu");
216 
217     public static final BooleanFlag ENABLE_BACK_SWIPE_HOME_ANIMATION = getDebugFlag(270393426,
218             "ENABLE_BACK_SWIPE_HOME_ANIMATION", true,
219             "Enables home animation to icon when user swipes back.");
220 
221     public static final BooleanFlag ENABLE_ICON_LABEL_AUTO_SCALING = getDebugFlag(270393294,
222             "ENABLE_ICON_LABEL_AUTO_SCALING", true,
223             "Enables scaling/spacing for icon labels to make more characters visible");
224 
225     public static final BooleanFlag ENABLE_ALL_APPS_BUTTON_IN_HOTSEAT = getDebugFlag(270393897,
226             "ENABLE_ALL_APPS_BUTTON_IN_HOTSEAT", false,
227             "Enables displaying the all apps button in the hotseat.");
228 
229     public static final BooleanFlag ENABLE_ALL_APPS_ONE_SEARCH_IN_TASKBAR = getDebugFlag(270393900,
230             "ENABLE_ALL_APPS_ONE_SEARCH_IN_TASKBAR", false,
231             "Enables One Search box in Taskbar All Apps.");
232 
233     public static final BooleanFlag ENABLE_SPLIT_FROM_WORKSPACE = getDebugFlag(270393906,
234             "ENABLE_SPLIT_FROM_WORKSPACE", true,
235             "Enable initiating split screen from workspace.");
236 
237     public static final BooleanFlag ENABLE_SPLIT_FROM_FULLSCREEN_WITH_KEYBOARD_SHORTCUTS =
238             getDebugFlag(270394122, "ENABLE_SPLIT_FROM_FULLSCREEN_SHORTCUT", false,
239                     "Enable splitting from fullscreen app with keyboard shortcuts");
240 
241     public static final BooleanFlag ENABLE_SPLIT_FROM_WORKSPACE_TO_WORKSPACE = getDebugFlag(
242             270393453, "ENABLE_SPLIT_FROM_WORKSPACE_TO_WORKSPACE", false,
243             "Enable initiating split screen from workspace to workspace.");
244 
245     public static final BooleanFlag ENABLE_NEW_MIGRATION_LOGIC = getDebugFlag(270393455,
246             "ENABLE_NEW_MIGRATION_LOGIC", true,
247             "Enable the new grid migration logic, keeping pages when src < dest");
248 
249     public static final BooleanFlag ENABLE_WIDGET_HOST_IN_BACKGROUND = getDebugFlag(270394384,
250             "ENABLE_WIDGET_HOST_IN_BACKGROUND", false,
251             "Enable background widget updates listening for widget holder");
252 
253     public static final BooleanFlag ENABLE_ONE_SEARCH_MOTION = getReleaseFlag(270394223,
254             "ENABLE_ONE_SEARCH_MOTION", true, "Enables animations in OneSearch.");
255 
256     public static final BooleanFlag ENABLE_SEARCH_RESULT_BACKGROUND_DRAWABLES = getReleaseFlag(
257             270394041, "ENABLE_SEARCH_RESULT_BACKGROUND_DRAWABLES", false,
258             "Enable option to replace decorator-based search result backgrounds with drawables");
259 
260     public static final BooleanFlag ENABLE_SEARCH_RESULT_LAUNCH_TRANSITION = getReleaseFlag(
261             270394392, "ENABLE_SEARCH_RESULT_LAUNCH_TRANSITION", false,
262             "Enable option to launch search results using the new view container transitions");
263 
264     public static final BooleanFlag ENABLE_SHOW_KEYBOARD_OPTION_IN_ALL_APPS = getReleaseFlag(
265             270394468, "ENABLE_SHOW_KEYBOARD_OPTION_IN_ALL_APPS", true,
266             "Enable option to show keyboard when going to all-apps");
267 
268     public static final BooleanFlag USE_LOCAL_ICON_OVERRIDES = getDebugFlag(270394973,
269             "USE_LOCAL_ICON_OVERRIDES", true,
270             "Use inbuilt monochrome icons if app doesn't provide one");
271 
272     public static final BooleanFlag ENABLE_DISMISS_PREDICTION_UNDO = getDebugFlag(270394476,
273             "ENABLE_DISMISS_PREDICTION_UNDO", false,
274             "Show an 'Undo' snackbar when users dismiss a predicted hotseat item");
275 
276     public static final BooleanFlag ENABLE_CACHED_WIDGET = getDebugFlag(270395008,
277             "ENABLE_CACHED_WIDGET", true,
278             "Show previously cached widgets as opposed to deferred widget where available");
279 
280     public static final BooleanFlag USE_SEARCH_REQUEST_TIMEOUT_OVERRIDES = getDebugFlag(270395010,
281             "USE_SEARCH_REQUEST_TIMEOUT_OVERRIDES", false,
282             "Use local overrides for search request timeout");
283 
284     public static final BooleanFlag CONTINUOUS_VIEW_TREE_CAPTURE = getDebugFlag(270395171,
285             "CONTINUOUS_VIEW_TREE_CAPTURE", false, "Capture View tree every frame");
286 
287     public static final BooleanFlag FOLDABLE_WORKSPACE_REORDER = getDebugFlag(270395070,
288             "FOLDABLE_WORKSPACE_REORDER", true,
289             "In foldables, when reordering the icons and widgets, is now going to use both sides");
290 
291     public static final BooleanFlag ENABLE_MULTI_DISPLAY_PARTIAL_DEPTH = getDebugFlag(270395073,
292             "ENABLE_MULTI_DISPLAY_PARTIAL_DEPTH", false,
293             "Allow bottom sheet depth to be smaller than 1 for multi-display devices.");
294 
295     public static final BooleanFlag SCROLL_TOP_TO_RESET = getReleaseFlag(
296             270395177, "SCROLL_TOP_TO_RESET", true,
297             "Bring up IME and focus on input when scroll to top if 'Always show keyboard'"
298                     + " is enabled or in prefix state");
299 
300     public static final BooleanFlag ENABLE_MATERIAL_U_POPUP = getDebugFlag(270395516,
301             "ENABLE_MATERIAL_U_POPUP", false, "Switch popup UX to use material U");
302 
303     public static final BooleanFlag ENABLE_SEARCH_UNINSTALLED_APPS = getReleaseFlag(270395269,
304             "ENABLE_SEARCH_UNINSTALLED_APPS", false, "Search uninstalled app results.");
305 
306     public static final BooleanFlag SHOW_HOME_GARDENING = getDebugFlag(270395183,
307             "SHOW_HOME_GARDENING", false,
308             "Show the new home gardening mode");
309 
310     public static final BooleanFlag HOME_GARDENING_WORKSPACE_BUTTONS = getDebugFlag(270395133,
311             "HOME_GARDENING_WORKSPACE_BUTTONS", false,
312             "Change workspace edit buttons to reflect home gardening");
313 
314     public static final BooleanFlag ENABLE_DOWNLOAD_APP_UX_V2 = getReleaseFlag(270395134,
315             "ENABLE_DOWNLOAD_APP_UX_V2", true, "Updates the download app UX"
316                     + " to have better visuals");
317 
318     public static final BooleanFlag ENABLE_DOWNLOAD_APP_UX_V3 = getDebugFlag(270395186,
319             "ENABLE_DOWNLOAD_APP_UX_V3", false, "Updates the download app UX"
320                     + " to have better visuals, improve contrast, and color");
321 
322     public static final BooleanFlag FORCE_PERSISTENT_TASKBAR = getDebugFlag(270395077,
323             "FORCE_PERSISTENT_TASKBAR", false, "Forces taskbar to be persistent, even in gesture"
324                     + " nav mode and when transient taskbar is enabled.");
325 
326     public static final BooleanFlag FOLDABLE_SINGLE_PAGE = getDebugFlag(270395274,
327             "FOLDABLE_SINGLE_PAGE", false,
328             "Use a single page for the workspace");
329 
330     public static final BooleanFlag ENABLE_TRANSIENT_TASKBAR = getDebugFlag(270395798,
331             "ENABLE_TRANSIENT_TASKBAR", true, "Enables transient taskbar.");
332 
333     public static final BooleanFlag SECONDARY_DRAG_N_DROP_TO_PIN = getDebugFlag(270395140,
334             "SECONDARY_DRAG_N_DROP_TO_PIN", false,
335             "Enable dragging and dropping to pin apps within secondary display");
336 
337     public static final BooleanFlag ENABLE_ICON_IN_TEXT_HEADER = getDebugFlag(270395143,
338             "ENABLE_ICON_IN_TEXT_HEADER", false, "Show icon in textheader");
339 
340     public static final BooleanFlag ENABLE_APP_ICON_FOR_INLINE_SHORTCUTS = getDebugFlag(270395087,
341             "ENABLE_APP_ICON_IN_INLINE_SHORTCUTS", false, "Show app icon for inline shortcut");
342 
343     public static final BooleanFlag SHOW_DOT_PAGINATION = getDebugFlag(270395278,
344             "SHOW_DOT_PAGINATION", false, "Enable showing dot pagination in workspace");
345 
346     public static final BooleanFlag LARGE_SCREEN_WIDGET_PICKER = getDebugFlag(270395809,
347             "LARGE_SCREEN_WIDGET_PICKER", false, "Enable new widget picker that takes "
348                     + "advantage of large screen format");
349 
350     public static final BooleanFlag ENABLE_NEW_GESTURE_NAV_TUTORIAL = getDebugFlag(270396257,
351             "ENABLE_NEW_GESTURE_NAV_TUTORIAL", false,
352             "Enable the redesigned gesture navigation tutorial");
353 
354     public static final BooleanFlag ENABLE_LAUNCH_FROM_STAGED_APP = getDebugFlag(270395567,
355             "ENABLE_LAUNCH_FROM_STAGED_APP", true,
356             "Enable the ability to tap a staged app during split select to launch it in full screen"
357     );
358 
359     public static final BooleanFlag ENABLE_PREMIUM_HAPTICS_ALL_APPS = getDebugFlag(270396358,
360             "ENABLE_PREMIUM_HAPTICS_ALL_APPS", false,
361             "Enables haptics opening/closing All apps");
362 
363     public static final BooleanFlag ENABLE_FORCED_MONO_ICON = getDebugFlag(270396209,
364             "ENABLE_FORCED_MONO_ICON", false,
365             "Enable the ability to generate monochromatic icons, if it is not provided by the app"
366     );
367 
368     public static final BooleanFlag ENABLE_TASKBAR_EDU_TOOLTIP = getDebugFlag(270396268,
369             "ENABLE_TASKBAR_EDU_TOOLTIP", true,
370             "Enable the tooltip version of the Taskbar education flow.");
371 
372     public static final BooleanFlag ENABLE_MULTI_INSTANCE = getDebugFlag(270396680,
373             "ENABLE_MULTI_INSTANCE", false,
374             "Enables creation and filtering of multiple task instances in overview");
375 
376     public static final BooleanFlag ENABLE_TASKBAR_PINNING = getDebugFlag(270396583,
377             "ENABLE_TASKBAR_PINNING", false,
378             "Enables taskbar pinning to allow user to switch between transient and persistent "
379                     + "taskbar flavors");
380 
381     public static final BooleanFlag ENABLE_WORKSPACE_LOADING_OPTIMIZATION = getDebugFlag(251502424,
382             "ENABLE_WORKSPACE_LOADING_OPTIMIZATION", false, "load the current workspace screen "
383                     + "visible to the user before the rest rather than loading all of them at once."
384     );
385 
386     public static final BooleanFlag ENABLE_GRID_ONLY_OVERVIEW = getDebugFlag(270397206,
387             "ENABLE_GRID_ONLY_OVERVIEW", false,
388             "Enable a grid-only overview without a focused task.");
389 
390     public static final BooleanFlag RECEIVE_UNFOLD_EVENTS_FROM_SYSUI = getDebugFlag(270397209,
391             "RECEIVE_UNFOLD_EVENTS_FROM_SYSUI", true,
392             "Enables receiving unfold animation events from sysui instead of calculating "
393                     + "them in launcher process using hinge sensor values.");
394 
395     public static final BooleanFlag ENABLE_KEYBOARD_QUICK_SWITCH = getDebugFlag(270396844,
396             "ENABLE_KEYBOARD_QUICK_SWITCH", false,
397             "Enables keyboard quick switching");
398 
399     public static class BooleanFlag {
400 
401         private final boolean mCurrentValue;
402 
BooleanFlag(boolean currentValue)403         public BooleanFlag(boolean currentValue) {
404             mCurrentValue = currentValue;
405         }
406 
get()407         public boolean get() {
408             return sBooleanReader.test(this);
409         }
410     }
411 
412     /**
413      * Class representing an integer flag
414      */
415     public static class IntFlag {
416 
417         private final int mCurrentValue;
418 
IntFlag(int currentValue)419         public IntFlag(int currentValue) {
420             mCurrentValue = currentValue;
421         }
422 
get()423         public int get() {
424             return sIntReader.applyAsInt(this);
425         }
426     }
427 }
428