2017-07-24 01:02:38 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2017 The Android Open Source Project
|
|
|
|
|
*
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
|
*
|
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
*
|
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
|
* limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
package com.android.launcher3.config;
|
|
|
|
|
|
2018-10-12 14:14:16 -04:00
|
|
|
import android.content.Context;
|
|
|
|
|
|
2019-09-11 16:51:50 -07:00
|
|
|
import com.android.launcher3.BuildConfig;
|
2019-08-26 14:36:02 -07:00
|
|
|
import com.android.launcher3.Utilities;
|
2020-01-21 11:59:19 -08:00
|
|
|
import com.android.launcher3.uioverrides.DeviceFlag;
|
2019-08-26 14:36:02 -07:00
|
|
|
|
2020-02-12 16:17:28 -08:00
|
|
|
import java.io.PrintWriter;
|
2018-10-12 14:14:16 -04:00
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
2017-07-24 01:02:38 -07:00
|
|
|
/**
|
|
|
|
|
* Defines a set of flags used to control various launcher behaviors.
|
|
|
|
|
*
|
2018-10-03 13:32:01 -04:00
|
|
|
* <p>All the flags should be defined here with appropriate default values.
|
2017-07-24 01:02:38 -07:00
|
|
|
*/
|
2019-09-11 16:51:50 -07:00
|
|
|
public final class FeatureFlags {
|
2017-07-24 01:02:38 -07:00
|
|
|
|
2020-01-21 11:59:19 -08:00
|
|
|
private static final List<DebugFlag> sDebugFlags = new ArrayList<>();
|
2018-10-12 14:14:16 -04:00
|
|
|
|
2020-01-21 11:59:19 -08:00
|
|
|
public static final String FLAGS_PREF_NAME = "featureFlags";
|
2018-10-03 13:32:01 -04:00
|
|
|
|
2019-09-11 16:51:50 -07:00
|
|
|
private FeatureFlags() { }
|
2018-10-12 14:14:16 -04:00
|
|
|
|
2018-10-22 16:31:28 -04:00
|
|
|
public static boolean showFlagTogglerUi(Context context) {
|
2019-05-15 14:01:30 -07:00
|
|
|
return Utilities.IS_DEBUG_DEVICE && Utilities.isDevelopersOptionsEnabled(context);
|
2018-10-03 13:32:01 -04:00
|
|
|
}
|
2017-07-24 01:02:38 -07:00
|
|
|
|
2020-02-14 14:15:13 -08:00
|
|
|
/**
|
|
|
|
|
* True when the build has come from Android Studio and is being used for local debugging.
|
|
|
|
|
*/
|
|
|
|
|
public static final boolean IS_STUDIO_BUILD = BuildConfig.DEBUG;
|
2019-09-11 16:51:50 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Enable moving the QSB on the 0th screen of the workspace. This is not a configuration feature
|
|
|
|
|
* and should be modified at a project level.
|
|
|
|
|
*/
|
|
|
|
|
public static final boolean QSB_ON_FIRST_SCREEN = true;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Feature flag to handle define config changes dynamically instead of killing the process.
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* To add a new flag that can be toggled through the flags UI:
|
|
|
|
|
*
|
2019-12-03 12:00:44 -08:00
|
|
|
* Declare a new ToggleableFlag below. Give it a unique key (e.g. "QSB_ON_FIRST_SCREEN"),
|
2019-09-11 16:51:50 -07:00
|
|
|
* and set a default value for the flag. This will be the default value on Debug builds.
|
|
|
|
|
*/
|
2017-07-24 01:02:38 -07:00
|
|
|
// When enabled the promise icon is visible in all apps while installation an app.
|
2020-01-21 11:59:19 -08:00
|
|
|
public static final BooleanFlag PROMISE_APPS_IN_ALL_APPS = getDebugFlag(
|
2019-09-11 16:51:50 -07:00
|
|
|
"PROMISE_APPS_IN_ALL_APPS", false, "Add promise icon in all-apps");
|
2017-07-24 01:02:38 -07:00
|
|
|
|
2019-08-19 13:32:09 -07:00
|
|
|
// When enabled a promise icon is added to the home screen when install session is active.
|
2020-01-21 11:59:19 -08:00
|
|
|
public static final BooleanFlag PROMISE_APPS_NEW_INSTALLS = getDebugFlag(
|
|
|
|
|
"PROMISE_APPS_NEW_INSTALLS", true,
|
|
|
|
|
"Adds a promise icon to the home screen for new install sessions.");
|
2019-08-19 13:32:09 -07:00
|
|
|
|
2020-01-21 11:59:19 -08:00
|
|
|
public static final BooleanFlag APPLY_CONFIG_AT_RUNTIME = getDebugFlag(
|
2018-12-04 15:43:16 -08:00
|
|
|
"APPLY_CONFIG_AT_RUNTIME", true, "Apply display changes dynamically");
|
2018-10-12 11:42:33 -07:00
|
|
|
|
2020-01-21 11:59:19 -08:00
|
|
|
public static final BooleanFlag QUICKSTEP_SPRINGS = getDebugFlag(
|
|
|
|
|
"QUICKSTEP_SPRINGS", true, "Enable springs for quickstep animations");
|
2020-01-07 11:22:51 -08:00
|
|
|
|
2020-01-21 11:59:19 -08:00
|
|
|
public static final BooleanFlag UNSTABLE_SPRINGS = getDebugFlag(
|
|
|
|
|
"UNSTABLE_SPRINGS", false, "Enable unstable springs for quickstep animations");
|
2019-01-08 16:01:57 -08:00
|
|
|
|
2020-01-21 11:59:19 -08:00
|
|
|
public static final BooleanFlag ADAPTIVE_ICON_WINDOW_ANIM = getDebugFlag(
|
|
|
|
|
"ADAPTIVE_ICON_WINDOW_ANIM", true, "Use adaptive icons for window animations.");
|
2019-02-19 15:34:41 -08:00
|
|
|
|
2020-01-21 11:59:19 -08:00
|
|
|
public static final BooleanFlag ENABLE_QUICKSTEP_LIVE_TILE = getDebugFlag(
|
2018-10-29 16:08:29 -04:00
|
|
|
"ENABLE_QUICKSTEP_LIVE_TILE", false, "Enable live tile in Quickstep overview");
|
|
|
|
|
|
2020-01-21 11:59:19 -08:00
|
|
|
public static final BooleanFlag ENABLE_HINTS_IN_OVERVIEW = getDebugFlag(
|
|
|
|
|
"ENABLE_HINTS_IN_OVERVIEW", false, "Show chip hints and gleams on the overview screen");
|
2019-02-11 13:07:04 -05:00
|
|
|
|
2020-01-21 11:59:19 -08:00
|
|
|
public static final BooleanFlag FAKE_LANDSCAPE_UI = getDebugFlag(
|
|
|
|
|
"FAKE_LANDSCAPE_UI", false, "Rotate launcher UI instead of using transposed layout");
|
2019-04-30 12:04:37 -07:00
|
|
|
|
2020-01-21 11:59:19 -08:00
|
|
|
public static final BooleanFlag FOLDER_NAME_SUGGEST = getDebugFlag(
|
2020-02-12 13:25:45 -08:00
|
|
|
"FOLDER_NAME_SUGGEST", true, "Suggests folder names instead of blank text.");
|
2019-10-10 23:11:12 -07:00
|
|
|
|
2020-01-21 11:59:19 -08:00
|
|
|
public static final BooleanFlag APP_SEARCH_IMPROVEMENTS = new DeviceFlag(
|
2019-08-08 12:22:26 -07:00
|
|
|
"APP_SEARCH_IMPROVEMENTS", false,
|
|
|
|
|
"Adds localized title and keyword search and ranking");
|
|
|
|
|
|
2020-02-12 17:00:59 -08:00
|
|
|
public static final BooleanFlag ENABLE_PREDICTION_DISMISS = new DeviceFlag(
|
2020-03-04 15:43:15 -08:00
|
|
|
"ENABLE_PREDICTION_DISMISS", true, "Allow option to dimiss apps from predicted list");
|
2019-08-09 16:16:06 -07:00
|
|
|
|
2020-01-21 11:59:19 -08:00
|
|
|
public static final BooleanFlag ENABLE_QUICK_CAPTURE_GESTURE = getDebugFlag(
|
2019-12-20 14:24:10 -05:00
|
|
|
"ENABLE_QUICK_CAPTURE_GESTURE", true, "Swipe from right to left to quick capture");
|
2019-08-09 16:16:06 -07:00
|
|
|
|
2020-03-03 17:20:42 -05:00
|
|
|
public static final BooleanFlag FORCE_LOCAL_OVERSCROLL_PLUGIN = getDebugFlag(
|
|
|
|
|
"FORCE_LOCAL_OVERSCROLL_PLUGIN", false,
|
|
|
|
|
"Use a launcher-provided OverscrollPlugin if available");
|
|
|
|
|
|
2020-01-21 11:59:19 -08:00
|
|
|
public static final BooleanFlag ASSISTANT_GIVES_LAUNCHER_FOCUS = getDebugFlag(
|
2019-10-17 11:59:53 -07:00
|
|
|
"ASSISTANT_GIVES_LAUNCHER_FOCUS", false,
|
|
|
|
|
"Allow Launcher to handle nav bar gestures while Assistant is running over it");
|
|
|
|
|
|
2020-02-12 17:00:59 -08:00
|
|
|
public static final BooleanFlag ENABLE_HYBRID_HOTSEAT = new DeviceFlag(
|
2019-10-21 02:02:40 -07:00
|
|
|
"ENABLE_HYBRID_HOTSEAT", false, "Fill gaps in hotseat with predicted apps");
|
|
|
|
|
|
2020-02-25 18:47:54 -08:00
|
|
|
public static final BooleanFlag HOTSEAT_MIGRATE_NEW_PAGE = new DeviceFlag(
|
|
|
|
|
"HOTSEAT_MIGRATE_NEW_PAGE", true,
|
|
|
|
|
"Migrates hotseat to a new workspace page instead of same page");
|
|
|
|
|
|
2020-01-21 11:59:19 -08:00
|
|
|
public static final BooleanFlag ENABLE_DEEP_SHORTCUT_ICON_CACHE = getDebugFlag(
|
2019-10-23 17:47:28 +00:00
|
|
|
"ENABLE_DEEP_SHORTCUT_ICON_CACHE", true, "R/W deep shortcut in IconCache");
|
|
|
|
|
|
2020-01-27 13:44:06 -08:00
|
|
|
public static final BooleanFlag MULTI_DB_GRID_MIRATION_ALGO = getDebugFlag(
|
|
|
|
|
"MULTI_DB_GRID_MIRATION_ALGO", false, "Use the multi-db grid migration algorithm");
|
|
|
|
|
|
2020-01-21 11:59:19 -08:00
|
|
|
public static final BooleanFlag ENABLE_LAUNCHER_PREVIEW_IN_GRID_PICKER = getDebugFlag(
|
2020-03-02 15:21:53 -08:00
|
|
|
"ENABLE_LAUNCHER_PREVIEW_IN_GRID_PICKER", true,
|
2019-11-29 21:47:29 -08:00
|
|
|
"Show launcher preview in grid picker");
|
|
|
|
|
|
2020-01-21 11:59:19 -08:00
|
|
|
public static final BooleanFlag ENABLE_OVERVIEW_ACTIONS = getDebugFlag(
|
2020-02-19 14:52:10 -08:00
|
|
|
"ENABLE_OVERVIEW_ACTIONS", true, "Show app actions instead of the shelf in Overview."
|
2019-11-04 16:23:51 -08:00
|
|
|
+ " As part of this decoupling, also distinguish swipe up from nav bar vs above it.");
|
2019-12-02 14:30:55 -08:00
|
|
|
|
2020-01-21 11:59:19 -08:00
|
|
|
public static final BooleanFlag ENABLE_DATABASE_RESTORE = getDebugFlag(
|
2019-12-10 14:56:34 -08:00
|
|
|
"ENABLE_DATABASE_RESTORE", true,
|
|
|
|
|
"Enable database restore when new restore session is created");
|
|
|
|
|
|
2020-01-21 23:28:07 -08:00
|
|
|
public static final BooleanFlag ENABLE_UNIVERSAL_SMARTSPACE = getDebugFlag(
|
2020-01-17 12:01:26 -08:00
|
|
|
"ENABLE_UNIVERSAL_SMARTSPACE", false,
|
|
|
|
|
"Replace Smartspace with a version rendered by System UI.");
|
|
|
|
|
|
2020-02-20 12:03:39 -08:00
|
|
|
public static final BooleanFlag ENABLE_LSQ_VELOCITY_PROVIDER = getDebugFlag(
|
|
|
|
|
"ENABLE_LSQ_VELOCITY_PROVIDER", false,
|
|
|
|
|
"Use Least Square algorithm for motion pause detection.");
|
|
|
|
|
|
2020-02-12 14:40:05 -08:00
|
|
|
public static final BooleanFlag ALWAYS_USE_HARDWARE_OPTIMIZATION_FOR_FOLDER_ANIMATIONS =
|
|
|
|
|
getDebugFlag(
|
|
|
|
|
"ALWAYS_USE_HARDWARE_OPTIMIZATION_FOR_FOLDER_ANIMATIONS", false,
|
|
|
|
|
"Always use hardware optimization for folder animations.");
|
|
|
|
|
|
2018-10-12 14:14:16 -04:00
|
|
|
public static void initialize(Context context) {
|
2020-01-21 11:59:19 -08:00
|
|
|
synchronized (sDebugFlags) {
|
|
|
|
|
for (DebugFlag flag : sDebugFlags) {
|
|
|
|
|
flag.initialize(context);
|
2018-10-12 14:14:16 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-21 11:59:19 -08:00
|
|
|
static List<DebugFlag> getDebugFlags() {
|
|
|
|
|
synchronized (sDebugFlags) {
|
|
|
|
|
return new ArrayList<>(sDebugFlags);
|
2018-10-12 14:14:16 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-12 16:17:28 -08:00
|
|
|
public static void dump(PrintWriter pw) {
|
|
|
|
|
pw.println("FeatureFlags:");
|
|
|
|
|
synchronized (sDebugFlags) {
|
|
|
|
|
for (DebugFlag flag : sDebugFlags) {
|
|
|
|
|
pw.println(" " + flag.key + "=" + flag.get());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-21 11:59:19 -08:00
|
|
|
public static class BooleanFlag {
|
2018-10-12 14:14:16 -04:00
|
|
|
|
2020-01-21 11:59:19 -08:00
|
|
|
public final String key;
|
|
|
|
|
public boolean defaultValue;
|
2018-11-08 11:30:14 -05:00
|
|
|
|
2020-01-21 11:59:19 -08:00
|
|
|
public BooleanFlag(String key, boolean defaultValue) {
|
|
|
|
|
this.key = key;
|
|
|
|
|
this.defaultValue = defaultValue;
|
2018-10-12 14:14:16 -04:00
|
|
|
}
|
2019-08-13 15:57:15 -07:00
|
|
|
|
2020-01-21 11:59:19 -08:00
|
|
|
public boolean get() {
|
|
|
|
|
return defaultValue;
|
2018-11-04 11:39:08 -05:00
|
|
|
}
|
|
|
|
|
|
2020-01-21 11:59:19 -08:00
|
|
|
@Override
|
|
|
|
|
public String toString() {
|
|
|
|
|
return appendProps(new StringBuilder()
|
|
|
|
|
.append(getClass().getSimpleName()).append('{'))
|
|
|
|
|
.append('}').toString();
|
2018-11-04 11:39:08 -05:00
|
|
|
}
|
|
|
|
|
|
2020-01-21 11:59:19 -08:00
|
|
|
protected StringBuilder appendProps(StringBuilder src) {
|
|
|
|
|
return src.append("key=").append(key).append(", defaultValue=").append(defaultValue);
|
2018-11-04 11:39:08 -05:00
|
|
|
}
|
2018-10-12 14:14:16 -04:00
|
|
|
|
2020-01-21 11:59:19 -08:00
|
|
|
public void addChangeListener(Context context, Runnable r) { }
|
|
|
|
|
}
|
2018-10-12 14:14:16 -04:00
|
|
|
|
2020-01-21 11:59:19 -08:00
|
|
|
public static class DebugFlag extends BooleanFlag {
|
2018-10-12 14:14:16 -04:00
|
|
|
|
2020-01-21 11:59:19 -08:00
|
|
|
public final String description;
|
|
|
|
|
private boolean mCurrentValue;
|
|
|
|
|
|
|
|
|
|
public DebugFlag(String key, boolean defaultValue, String description) {
|
|
|
|
|
super(key, defaultValue);
|
|
|
|
|
this.description = description;
|
|
|
|
|
mCurrentValue = this.defaultValue;
|
|
|
|
|
synchronized (sDebugFlags) {
|
|
|
|
|
sDebugFlags.add(this);
|
|
|
|
|
}
|
2018-10-12 14:14:16 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2020-01-21 11:59:19 -08:00
|
|
|
public boolean get() {
|
|
|
|
|
return mCurrentValue;
|
2018-10-12 14:14:16 -04:00
|
|
|
}
|
|
|
|
|
|
2020-01-21 11:59:19 -08:00
|
|
|
public void initialize(Context context) {
|
|
|
|
|
mCurrentValue = context.getSharedPreferences(FLAGS_PREF_NAME, Context.MODE_PRIVATE)
|
|
|
|
|
.getBoolean(key, defaultValue);
|
2018-10-12 14:14:16 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2020-01-21 11:59:19 -08:00
|
|
|
protected StringBuilder appendProps(StringBuilder src) {
|
|
|
|
|
return super.appendProps(src).append(", mCurrentValue=").append(mCurrentValue)
|
|
|
|
|
.append(", description=").append(description);
|
2018-10-12 14:14:16 -04:00
|
|
|
}
|
|
|
|
|
}
|
2020-01-21 11:59:19 -08:00
|
|
|
|
|
|
|
|
private static BooleanFlag getDebugFlag(String key, boolean defaultValue, String description) {
|
|
|
|
|
return Utilities.IS_DEBUG_DEVICE
|
|
|
|
|
? new DebugFlag(key, defaultValue, description)
|
|
|
|
|
: new BooleanFlag(key, defaultValue);
|
|
|
|
|
}
|
2017-07-24 01:02:38 -07:00
|
|
|
}
|