Merge "Moving flag creation to a separate file" into tm-qpr-dev

This commit is contained in:
Sunny Goyal
2023-02-28 19:18:25 +00:00
committed by Android (Google) Code Review
17 changed files with 367 additions and 397 deletions
@@ -1,51 +0,0 @@
/*
* Copyright (C) 2019 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.uioverrides;
import android.annotation.TargetApi;
import android.os.Build;
import android.provider.DeviceConfig;
import com.android.launcher3.config.FeatureFlags.DebugFlag;
@TargetApi(Build.VERSION_CODES.P)
public class DeviceFlag extends DebugFlag {
public static final String NAMESPACE_LAUNCHER = "launcher";
private final boolean mDefaultValueInCode;
public DeviceFlag(String key, boolean defaultValue, String description) {
super(key, getDeviceValue(key, defaultValue), description);
mDefaultValueInCode = defaultValue;
}
@Override
protected StringBuilder appendProps(StringBuilder src) {
return super.appendProps(src).append(", mDefaultValueInCode=").append(mDefaultValueInCode);
}
@Override
public boolean get() {
// Override this method in order to let Robolectric ShadowDeviceFlag to stub it.
return super.get();
}
protected static boolean getDeviceValue(String key, boolean defaultValue) {
return DeviceConfig.getBoolean(NAMESPACE_LAUNCHER, key, defaultValue);
}
}
@@ -0,0 +1,40 @@
/*
* Copyright (C) 2023 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.uioverrides.flags;
import com.android.launcher3.config.FeatureFlags.BooleanFlag;
class DebugFlag extends BooleanFlag {
public final String key;
public final String description;
public final boolean defaultValue;
boolean mHasBeenChangedAtLeastOnce;
public DebugFlag(String key, String description, boolean defaultValue, boolean currentValue) {
super(currentValue);
this.key = key;
this.defaultValue = defaultValue;
this.description = description;
}
@Override
public String toString() {
return key + ": defaultValue=" + defaultValue + ", mCurrentValue=" + get();
}
}
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.launcher3.settings;
package com.android.launcher3.uioverrides.flags;
import static android.content.Intent.ACTION_PACKAGE_ADDED;
import static android.content.Intent.ACTION_PACKAGE_CHANGED;
@@ -63,7 +63,6 @@ import androidx.preference.SwitchPreference;
import com.android.launcher3.LauncherPrefs;
import com.android.launcher3.R;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.config.FlagTogglerPrefUi;
import com.android.launcher3.secondarydisplay.SecondaryDisplayLauncher;
import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper;
import com.android.launcher3.util.OnboardingPrefs;
@@ -0,0 +1,33 @@
/*
* Copyright (C) 2019 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.uioverrides.flags;
class DeviceFlag extends DebugFlag {
private final boolean mDefaultValueInCode;
public DeviceFlag(String key, String description, boolean defaultValue,
boolean currentValue, boolean defaultValueInCode) {
super(key, description, defaultValue, currentValue);
mDefaultValueInCode = defaultValueInCode;
}
@Override
public String toString() {
return super.toString() + ", mDefaultValueInCode=" + mDefaultValueInCode;
}
}
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.android.launcher3.config;
package com.android.launcher3.uioverrides.flags;
import static com.android.launcher3.config.FeatureFlags.FLAGS_PREF_NAME;
@@ -33,7 +33,7 @@ import androidx.preference.PreferenceGroup;
import androidx.preference.SwitchPreference;
import com.android.launcher3.R;
import com.android.launcher3.config.FeatureFlags.DebugFlag;
import com.android.launcher3.config.FeatureFlags;
/**
* Dev-build only UI allowing developers to toggle flag settings. See {@link FeatureFlags}.
@@ -50,7 +50,7 @@ public final class FlagTogglerPrefUi {
@Override
public void putBoolean(String key, boolean value) {
for (DebugFlag flag : FeatureFlags.getDebugFlags()) {
for (DebugFlag flag : FlagsFactory.getDebugFlags()) {
if (flag.key.equals(key)) {
SharedPreferences prefs = mContext.getSharedPreferences(
FLAGS_PREF_NAME, Context.MODE_PRIVATE);
@@ -71,7 +71,7 @@ public final class FlagTogglerPrefUi {
@Override
public boolean getBoolean(String key, boolean defaultValue) {
for (DebugFlag flag : FeatureFlags.getDebugFlags()) {
for (DebugFlag flag : FlagsFactory.getDebugFlags()) {
if (flag.key.equals(key)) {
return mContext.getSharedPreferences(FLAGS_PREF_NAME, Context.MODE_PRIVATE)
.getBoolean(key, flag.defaultValue);
@@ -93,7 +93,7 @@ public final class FlagTogglerPrefUi {
// flag with a different value than the default. That way, when we flip flags in
// future, engineers will pick up the new value immediately. To accomplish this, we use a
// custom preference data store.
for (DebugFlag flag : FeatureFlags.getDebugFlags()) {
for (DebugFlag flag : FlagsFactory.getDebugFlags()) {
SwitchPreference switchPreference = new SwitchPreference(mContext);
switchPreference.setKey(flag.key);
switchPreference.setDefaultValue(flag.defaultValue);
@@ -149,11 +149,11 @@ public final class FlagTogglerPrefUi {
}
private boolean anyChanged() {
for (DebugFlag flag : FeatureFlags.getDebugFlags()) {
for (DebugFlag flag : FlagsFactory.getDebugFlags()) {
if (getFlagStateFromSharedPrefs(flag) != flag.get()) {
return true;
}
}
return false;
}
}
}
@@ -0,0 +1,124 @@
/*
* Copyright (C) 2023 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.uioverrides.flags;
import static android.app.ActivityThread.currentApplication;
import android.content.Context;
import android.content.SharedPreferences;
import android.provider.DeviceConfig;
import com.android.launcher3.Utilities;
import com.android.launcher3.config.FeatureFlags.BooleanFlag;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* Helper class to create various flags for system build
*/
public class FlagsFactory {
public static final String FLAGS_PREF_NAME = "featureFlags";
public static final String NAMESPACE_LAUNCHER = "launcher";
private static final List<DebugFlag> sDebugFlags = new ArrayList<>();
/**
* Creates a new debug flag
*/
public static BooleanFlag getDebugFlag(
int bugId, String key, boolean defaultValue, String description) {
if (Utilities.IS_DEBUG_DEVICE) {
SharedPreferences prefs = currentApplication()
.getSharedPreferences(FLAGS_PREF_NAME, Context.MODE_PRIVATE);
boolean currentValue = prefs.getBoolean(key, defaultValue);
DebugFlag flag = new DebugFlag(key, description, defaultValue, currentValue);
flag.mHasBeenChangedAtLeastOnce = prefs.contains(key);
sDebugFlags.add(flag);
return flag;
} else {
return new BooleanFlag(defaultValue);
}
}
/**
* Creates a new release flag
*/
public static BooleanFlag getReleaseFlag(
int bugId, String key, boolean defaultValueInCode, String description) {
boolean defaultValue = DeviceConfig.getBoolean(NAMESPACE_LAUNCHER, key, defaultValueInCode);
if (Utilities.IS_DEBUG_DEVICE) {
SharedPreferences prefs = currentApplication()
.getSharedPreferences(FLAGS_PREF_NAME, Context.MODE_PRIVATE);
boolean currentValue = prefs.getBoolean(key, defaultValue);
DebugFlag flag = new DeviceFlag(key, description, defaultValue, currentValue,
defaultValueInCode);
flag.mHasBeenChangedAtLeastOnce = prefs.contains(key);
sDebugFlags.add(flag);
return flag;
} else {
return new BooleanFlag(defaultValue);
}
}
static List<DebugFlag> getDebugFlags() {
if (!Utilities.IS_DEBUG_DEVICE) {
return Collections.emptyList();
}
List<DebugFlag> flags;
synchronized (sDebugFlags) {
flags = new ArrayList<>(sDebugFlags);
}
flags.sort((f1, f2) -> {
// Sort first by any prefs that the user has changed, then alphabetically.
int changeComparison = Boolean.compare(
f2.mHasBeenChangedAtLeastOnce, f1.mHasBeenChangedAtLeastOnce);
return changeComparison != 0
? changeComparison
: f1.key.compareToIgnoreCase(f2.key);
});
return flags;
}
/**
* Dumps the current flags state to the print writer
*/
public static void dump(PrintWriter pw) {
if (!Utilities.IS_DEBUG_DEVICE) {
return;
}
pw.println("DeviceFlags:");
synchronized (sDebugFlags) {
for (DebugFlag flag : sDebugFlags) {
if (flag instanceof DeviceFlag) {
pw.println(" " + flag);
}
}
}
pw.println("DebugFlags:");
synchronized (sDebugFlags) {
for (DebugFlag flag : sDebugFlags) {
if (!(flag instanceof DeviceFlag)) {
pw.println(" " + flag);
}
}
}
}
}
@@ -86,6 +86,7 @@ import com.android.launcher3.testing.shared.ResourceUtils;
import com.android.launcher3.testing.shared.TestProtocol;
import com.android.launcher3.tracing.LauncherTraceProto;
import com.android.launcher3.tracing.TouchInteractionServiceProto;
import com.android.launcher3.uioverrides.flags.FlagsFactory;
import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.OnboardingPrefs;
@@ -1175,7 +1176,7 @@ public class TouchInteractionService extends Service
}
} else {
// Dump everything
FeatureFlags.dump(pw);
FlagsFactory.dump(pw);
if (mDeviceState.isUserUnlocked()) {
PluginManagerWrapper.INSTANCE.get(getBaseContext()).dump(pw);
}
-6
View File
@@ -50,10 +50,4 @@
launcher:logIdOn="615"
launcher:logIdOff="616" />
<androidx.preference.PreferenceScreen
android:key="pref_developer_options"
android:persistent="false"
android:title="@string/developer_options_title"
android:fragment="com.android.launcher3.settings.DeveloperOptionsFragment"/>
</androidx.preference.PreferenceScreen>
@@ -18,7 +18,6 @@ package com.android.launcher3;
import android.content.Context;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.graphics.BitmapCreationCheck;
import com.android.launcher3.graphics.IconShape;
import com.android.launcher3.logging.FileLog;
@@ -37,7 +36,6 @@ public class MainProcessInitializer implements ResourceBasedOverride {
protected void init(Context context) {
FileLog.setDir(context.getApplicationContext().getFilesDir());
FeatureFlags.initialize(context);
IconShape.init(context);
if (BitmapCreationCheck.ENABLED) {
+103 -281
View File
@@ -16,16 +16,13 @@
package com.android.launcher3.config;
import static com.android.launcher3.uioverrides.flags.FlagsFactory.getDebugFlag;
import static com.android.launcher3.uioverrides.flags.FlagsFactory.getReleaseFlag;
import android.content.Context;
import android.content.SharedPreferences;
import com.android.launcher3.BuildConfig;
import com.android.launcher3.Utilities;
import com.android.launcher3.uioverrides.DeviceFlag;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
/**
* Defines a set of flags used to control various launcher behaviors.
@@ -34,12 +31,9 @@ import java.util.List;
*/
public final class FeatureFlags {
private static final List<DebugFlag> sDebugFlags = new ArrayList<>();
public static final String FLAGS_PREF_NAME = "featureFlags";
private FeatureFlags() {
}
private FeatureFlags() { }
public static boolean showFlagTogglerUi(Context context) {
return BuildConfig.IS_DEBUG_DEVICE && Utilities.isDevelopersOptionsEnabled(context);
@@ -69,110 +63,88 @@ public final class FeatureFlags {
* Declare a new ToggleableFlag below. Give it a unique key (e.g. "QSB_ON_FIRST_SCREEN"),
* and set a default value for the flag. This will be the default value on Debug builds.
*/
// b/270390028
public static final BooleanFlag ENABLE_INPUT_CONSUMER_REASON_LOGGING = getDebugFlag(
public static final BooleanFlag ENABLE_INPUT_CONSUMER_REASON_LOGGING = getDebugFlag(270390028,
"ENABLE_INPUT_CONSUMER_REASON_LOGGING",
true,
"Log the reason why an Input Consumer was selected for a gesture.");
// b/270389990
public static final BooleanFlag ENABLE_GESTURE_ERROR_DETECTION = getDebugFlag(
public static final BooleanFlag ENABLE_GESTURE_ERROR_DETECTION = getDebugFlag(270389990,
"ENABLE_GESTURE_ERROR_DETECTION",
true,
"Analyze gesture events and log detected errors");
// When enabled the promise icon is visible in all apps while installation an app.
// b/270390012
public static final BooleanFlag PROMISE_APPS_IN_ALL_APPS = getDebugFlag(
public static final BooleanFlag PROMISE_APPS_IN_ALL_APPS = getDebugFlag(270390012,
"PROMISE_APPS_IN_ALL_APPS", false, "Add promise icon in all-apps");
// b/270390904
public static final BooleanFlag KEYGUARD_ANIMATION = getDebugFlag(
public static final BooleanFlag KEYGUARD_ANIMATION = getDebugFlag(270390904,
"KEYGUARD_ANIMATION", false, "Enable animation for keyguard going away on wallpaper");
// b/270390907
public static final BooleanFlag ENABLE_DEVICE_SEARCH = new DeviceFlag(
public static final BooleanFlag ENABLE_DEVICE_SEARCH = getReleaseFlag(270390907,
"ENABLE_DEVICE_SEARCH", true, "Allows on device search in all apps");
// b/270390286
public static final BooleanFlag ENABLE_FLOATING_SEARCH_BAR =
getDebugFlag("ENABLE_FLOATING_SEARCH_BAR", false,
getDebugFlag(270390286, "ENABLE_FLOATING_SEARCH_BAR", false,
"Keep All Apps search bar at the bottom (but above keyboard if open)");
// b/270390930
public static final BooleanFlag ENABLE_HIDE_HEADER = new DeviceFlag("ENABLE_HIDE_HEADER",
true, "Hide header on keyboard before typing in all apps");
public static final BooleanFlag ENABLE_HIDE_HEADER = getReleaseFlag(270390930,
"ENABLE_HIDE_HEADER", true, "Hide header on keyboard before typing in all apps");
// b/270390779
public static final BooleanFlag ENABLE_EXPANDING_PAUSE_WORK_BUTTON = new DeviceFlag(
public static final BooleanFlag ENABLE_EXPANDING_PAUSE_WORK_BUTTON = getReleaseFlag(270390779,
"ENABLE_EXPANDING_PAUSE_WORK_BUTTON", false,
"Expand and collapse pause work button while scrolling");
// b/270390950
public static final BooleanFlag ENABLE_RECENT_BLOCK = getDebugFlag("ENABLE_RECENT_BLOCK",
false, "Show recently tapped search target block in zero state");
public static final BooleanFlag ENABLE_RECENT_BLOCK = getDebugFlag(270390950,
"ENABLE_RECENT_BLOCK", false, "Show recently tapped search target block in zero state");
// b/270391455
public static final BooleanFlag COLLECT_SEARCH_HISTORY = new DeviceFlag(
public static final BooleanFlag COLLECT_SEARCH_HISTORY = getReleaseFlag(270391455,
"COLLECT_SEARCH_HISTORY", false, "Allow launcher to collect search history for log");
// b/270390937
public static final BooleanFlag ENABLE_TWOLINE_ALLAPPS = getDebugFlag(
public static final BooleanFlag ENABLE_TWOLINE_ALLAPPS = getDebugFlag(270390937,
"ENABLE_TWOLINE_ALLAPPS", false, "Enables two line label inside all apps.");
// b/270391397
public static final BooleanFlag ENABLE_DEVICE_SEARCH_PERFORMANCE_LOGGING = new DeviceFlag(
"ENABLE_DEVICE_SEARCH_PERFORMANCE_LOGGING", false,
public static final BooleanFlag ENABLE_DEVICE_SEARCH_PERFORMANCE_LOGGING = getReleaseFlag(
270391397, "ENABLE_DEVICE_SEARCH_PERFORMANCE_LOGGING", false,
"Allows on device search in all apps logging");
// b/270391693
public static final BooleanFlag IME_STICKY_SNACKBAR_EDU = getDebugFlag(
public static final BooleanFlag IME_STICKY_SNACKBAR_EDU = getDebugFlag(270391693,
"IME_STICKY_SNACKBAR_EDU", true, "Show sticky IME edu in AllApps");
// b/270391653
public static final BooleanFlag ENABLE_PEOPLE_TILE_PREVIEW = getDebugFlag(
public static final BooleanFlag ENABLE_PEOPLE_TILE_PREVIEW = getDebugFlag(270391653,
"ENABLE_PEOPLE_TILE_PREVIEW", false,
"Experimental: Shows conversation shortcuts on home screen as search results");
// b/270391638
public static final BooleanFlag FOLDER_NAME_MAJORITY_RANKING = getDebugFlag(
public static final BooleanFlag FOLDER_NAME_MAJORITY_RANKING = getDebugFlag(270391638,
"FOLDER_NAME_MAJORITY_RANKING", true,
"Suggests folder names based on majority based ranking.");
// b/270391706
public static final BooleanFlag INJECT_FALLBACK_APP_CORPUS_RESULTS = new DeviceFlag(
"INJECT_FALLBACK_APP_CORPUS_RESULTS", false, "Inject "
+ "fallback app corpus result when AiAi fails to return it.");
public static final BooleanFlag INJECT_FALLBACK_APP_CORPUS_RESULTS = getReleaseFlag(270391706,
"INJECT_FALLBACK_APP_CORPUS_RESULTS", false,
"Inject fallback app corpus result when AiAi fails to return it.");
// b/270391641
public static final BooleanFlag ASSISTANT_GIVES_LAUNCHER_FOCUS = getDebugFlag(
public static final BooleanFlag ASSISTANT_GIVES_LAUNCHER_FOCUS = getDebugFlag(270391641,
"ASSISTANT_GIVES_LAUNCHER_FOCUS", false,
"Allow Launcher to handle nav bar gestures while Assistant is running over it");
// b/270392203
public static final BooleanFlag ENABLE_BULK_WORKSPACE_ICON_LOADING = getDebugFlag(
public static final BooleanFlag ENABLE_BULK_WORKSPACE_ICON_LOADING = getDebugFlag(270392203,
"ENABLE_BULK_WORKSPACE_ICON_LOADING",
true,
"Enable loading workspace icons in bulk.");
// b/270392465
public static final BooleanFlag ENABLE_BULK_ALL_APPS_ICON_LOADING = getDebugFlag(
public static final BooleanFlag ENABLE_BULK_ALL_APPS_ICON_LOADING = getDebugFlag(270392465,
"ENABLE_BULK_ALL_APPS_ICON_LOADING",
true,
"Enable loading all apps icons in bulk.");
// b/270392706
public static final BooleanFlag ENABLE_DATABASE_RESTORE = getDebugFlag(
public static final BooleanFlag ENABLE_DATABASE_RESTORE = getDebugFlag(270392706,
"ENABLE_DATABASE_RESTORE", false,
"Enable database restore when new restore session is created");
// b/270391664
public static final BooleanFlag ENABLE_SMARTSPACE_DISMISS = getDebugFlag(
public static final BooleanFlag ENABLE_SMARTSPACE_DISMISS = getDebugFlag(270391664,
"ENABLE_SMARTSPACE_DISMISS", true,
"Adds a menu option to dismiss the current Enhanced Smartspace card.");
// b/270392629
public static final BooleanFlag ENABLE_OVERLAY_CONNECTION_OPTIM = getDebugFlag(
public static final BooleanFlag ENABLE_OVERLAY_CONNECTION_OPTIM = getDebugFlag(270392629,
"ENABLE_OVERLAY_CONNECTION_OPTIM",
false,
"Enable optimizing overlay service connection");
@@ -180,402 +152,252 @@ public final class FeatureFlags {
/**
* Enables region sampling for text color: Needs system health assessment before turning on
*/
// b/270391669
public static final BooleanFlag ENABLE_REGION_SAMPLING = getDebugFlag(
public static final BooleanFlag ENABLE_REGION_SAMPLING = getDebugFlag(270391669,
"ENABLE_REGION_SAMPLING", false,
"Enable region sampling to determine color of text on screen.");
// b/270393096
public static final BooleanFlag ALWAYS_USE_HARDWARE_OPTIMIZATION_FOR_FOLDER_ANIMATIONS =
getDebugFlag(
getDebugFlag(270393096,
"ALWAYS_USE_HARDWARE_OPTIMIZATION_FOR_FOLDER_ANIMATIONS", false,
"Always use hardware optimization for folder animations.");
// b/270392980
public static final BooleanFlag SEPARATE_RECENTS_ACTIVITY = getDebugFlag(
public static final BooleanFlag SEPARATE_RECENTS_ACTIVITY = getDebugFlag(270392980,
"SEPARATE_RECENTS_ACTIVITY", false,
"Uses a separate recents activity instead of using the integrated recents+Launcher UI");
// b/270392984
public static final BooleanFlag ENABLE_MINIMAL_DEVICE = getDebugFlag(
public static final BooleanFlag ENABLE_MINIMAL_DEVICE = getDebugFlag(270392984,
"ENABLE_MINIMAL_DEVICE", false,
"Allow user to toggle minimal device mode in launcher.");
// b/270392477
public static final BooleanFlag ENABLE_TASKBAR_POPUP_MENU = getDebugFlag(
"ENABLE_TASKBAR_POPUP_MENU", true, "Enables long pressing taskbar icons to show the"
+ " popup menu.");
270392477, "ENABLE_TASKBAR_POPUP_MENU", true,
"Enables long pressing taskbar icons to show the popup menu.");
// b/270392643
public static final BooleanFlag ENABLE_TWO_PANEL_HOME = getDebugFlag(
public static final BooleanFlag ENABLE_TWO_PANEL_HOME = getDebugFlag(270392643,
"ENABLE_TWO_PANEL_HOME", true,
"Uses two panel on home screen. Only applicable on large screen devices.");
// b/270393276
public static final BooleanFlag ENABLE_SCRIM_FOR_APP_LAUNCH = getDebugFlag(
public static final BooleanFlag ENABLE_SCRIM_FOR_APP_LAUNCH = getDebugFlag(270393276,
"ENABLE_SCRIM_FOR_APP_LAUNCH", false,
"Enables scrim during app launch animation.");
// b/270393258
public static final BooleanFlag ENABLE_ENFORCED_ROUNDED_CORNERS = new DeviceFlag(
public static final BooleanFlag ENABLE_ENFORCED_ROUNDED_CORNERS = getReleaseFlag(270393258,
"ENABLE_ENFORCED_ROUNDED_CORNERS", true, "Enforce rounded corners on all App Widgets");
// b/270393108
public static final BooleanFlag NOTIFY_CRASHES = getDebugFlag("NOTIFY_CRASHES", false,
public static final BooleanFlag NOTIFY_CRASHES = getDebugFlag(
270393108, "NOTIFY_CRASHES", false,
"Sends a notification whenever launcher encounters an uncaught exception.");
// b/270393604
public static final BooleanFlag ENABLE_WALLPAPER_SCRIM = getDebugFlag(
public static final BooleanFlag ENABLE_WALLPAPER_SCRIM = getDebugFlag(270393604,
"ENABLE_WALLPAPER_SCRIM", false,
"Enables scrim over wallpaper for text protection.");
// b/270393268
public static final BooleanFlag WIDGETS_IN_LAUNCHER_PREVIEW = getDebugFlag(
public static final BooleanFlag WIDGETS_IN_LAUNCHER_PREVIEW = getDebugFlag(270393268,
"WIDGETS_IN_LAUNCHER_PREVIEW", true,
"Enables widgets in Launcher preview for the Wallpaper app.");
// b/270393112
public static final BooleanFlag QUICK_WALLPAPER_PICKER = getDebugFlag(
public static final BooleanFlag QUICK_WALLPAPER_PICKER = getDebugFlag(270393112,
"QUICK_WALLPAPER_PICKER", true,
"Shows quick wallpaper picker in long-press menu");
// b/270393426
public static final BooleanFlag ENABLE_BACK_SWIPE_HOME_ANIMATION = getDebugFlag(
public static final BooleanFlag ENABLE_BACK_SWIPE_HOME_ANIMATION = getDebugFlag(270393426,
"ENABLE_BACK_SWIPE_HOME_ANIMATION", true,
"Enables home animation to icon when user swipes back.");
// b/270393294
public static final BooleanFlag ENABLE_ICON_LABEL_AUTO_SCALING = getDebugFlag(
public static final BooleanFlag ENABLE_ICON_LABEL_AUTO_SCALING = getDebugFlag(270393294,
"ENABLE_ICON_LABEL_AUTO_SCALING", true,
"Enables scaling/spacing for icon labels to make more characters visible");
// b/270393897
public static final BooleanFlag ENABLE_ALL_APPS_BUTTON_IN_HOTSEAT = getDebugFlag(
public static final BooleanFlag ENABLE_ALL_APPS_BUTTON_IN_HOTSEAT = getDebugFlag(270393897,
"ENABLE_ALL_APPS_BUTTON_IN_HOTSEAT", false,
"Enables displaying the all apps button in the hotseat.");
// b/270393900
public static final BooleanFlag ENABLE_ALL_APPS_ONE_SEARCH_IN_TASKBAR = getDebugFlag(
public static final BooleanFlag ENABLE_ALL_APPS_ONE_SEARCH_IN_TASKBAR = getDebugFlag(270393900,
"ENABLE_ALL_APPS_ONE_SEARCH_IN_TASKBAR", false,
"Enables One Search box in Taskbar All Apps.");
// b/270393449
public static final BooleanFlag ENABLE_TASKBAR_IN_OVERVIEW = getDebugFlag(
public static final BooleanFlag ENABLE_TASKBAR_IN_OVERVIEW = getDebugFlag(270393449,
"ENABLE_TASKBAR_IN_OVERVIEW", true,
"Enables accessing the system Taskbar in overview.");
// b/270393906
public static final BooleanFlag ENABLE_SPLIT_FROM_WORKSPACE = getDebugFlag(
public static final BooleanFlag ENABLE_SPLIT_FROM_WORKSPACE = getDebugFlag(270393906,
"ENABLE_SPLIT_FROM_WORKSPACE", true,
"Enable initiating split screen from workspace.");
// b/270394122
public static final BooleanFlag ENABLE_SPLIT_FROM_FULLSCREEN_WITH_KEYBOARD_SHORTCUTS =
getDebugFlag("ENABLE_SPLIT_FROM_FULLSCREEN_SHORTCUT", false,
getDebugFlag(270394122, "ENABLE_SPLIT_FROM_FULLSCREEN_SHORTCUT", false,
"Enable splitting from fullscreen app with keyboard shortcuts");
// b/270393453
public static final BooleanFlag ENABLE_SPLIT_FROM_WORKSPACE_TO_WORKSPACE = getDebugFlag(
"ENABLE_SPLIT_FROM_WORKSPACE_TO_WORKSPACE", false,
270393453, "ENABLE_SPLIT_FROM_WORKSPACE_TO_WORKSPACE", false,
"Enable initiating split screen from workspace to workspace.");
// b/270393455
public static final BooleanFlag ENABLE_NEW_MIGRATION_LOGIC = getDebugFlag(
public static final BooleanFlag ENABLE_NEW_MIGRATION_LOGIC = getDebugFlag(270393455,
"ENABLE_NEW_MIGRATION_LOGIC", true,
"Enable the new grid migration logic, keeping pages when src < dest");
// b/270394384
public static final BooleanFlag ENABLE_WIDGET_HOST_IN_BACKGROUND = getDebugFlag(
public static final BooleanFlag ENABLE_WIDGET_HOST_IN_BACKGROUND = getDebugFlag(270394384,
"ENABLE_WIDGET_HOST_IN_BACKGROUND", false,
"Enable background widget updates listening for widget holder");
// b/270394223
public static final BooleanFlag ENABLE_ONE_SEARCH_MOTION = new DeviceFlag(
public static final BooleanFlag ENABLE_ONE_SEARCH_MOTION = getReleaseFlag(270394223,
"ENABLE_ONE_SEARCH_MOTION", true, "Enables animations in OneSearch.");
// b/270394041
public static final BooleanFlag ENABLE_SEARCH_RESULT_BACKGROUND_DRAWABLES = new DeviceFlag(
"ENABLE_SEARCH_RESULT_BACKGROUND_DRAWABLES", false,
public static final BooleanFlag ENABLE_SEARCH_RESULT_BACKGROUND_DRAWABLES = getReleaseFlag(
270394041, "ENABLE_SEARCH_RESULT_BACKGROUND_DRAWABLES", false,
"Enable option to replace decorator-based search result backgrounds with drawables");
// b/270394392
public static final BooleanFlag ENABLE_SEARCH_RESULT_LAUNCH_TRANSITION = new DeviceFlag(
"ENABLE_SEARCH_RESULT_LAUNCH_TRANSITION", false,
public static final BooleanFlag ENABLE_SEARCH_RESULT_LAUNCH_TRANSITION = getReleaseFlag(
270394392, "ENABLE_SEARCH_RESULT_LAUNCH_TRANSITION", false,
"Enable option to launch search results using the new view container transitions");
// b/270394225
public static final BooleanFlag TWO_PREDICTED_ROWS_ALL_APPS_SEARCH = new DeviceFlag(
public static final BooleanFlag TWO_PREDICTED_ROWS_ALL_APPS_SEARCH = getReleaseFlag(270394225,
"TWO_PREDICTED_ROWS_ALL_APPS_SEARCH", false,
"Use 2 rows of app predictions in All Apps search zero-state");
// b/270394468
public static final BooleanFlag ENABLE_SHOW_KEYBOARD_OPTION_IN_ALL_APPS = new DeviceFlag(
"ENABLE_SHOW_KEYBOARD_OPTION_IN_ALL_APPS", true,
public static final BooleanFlag ENABLE_SHOW_KEYBOARD_OPTION_IN_ALL_APPS = getReleaseFlag(
270394468, "ENABLE_SHOW_KEYBOARD_OPTION_IN_ALL_APPS", true,
"Enable option to show keyboard when going to all-apps");
// b/270394973
public static final BooleanFlag USE_LOCAL_ICON_OVERRIDES = getDebugFlag(
public static final BooleanFlag USE_LOCAL_ICON_OVERRIDES = getDebugFlag(270394973,
"USE_LOCAL_ICON_OVERRIDES", true,
"Use inbuilt monochrome icons if app doesn't provide one");
// b/270394476
public static final BooleanFlag ENABLE_DISMISS_PREDICTION_UNDO = getDebugFlag(
public static final BooleanFlag ENABLE_DISMISS_PREDICTION_UNDO = getDebugFlag(270394476,
"ENABLE_DISMISS_PREDICTION_UNDO", false,
"Show an 'Undo' snackbar when users dismiss a predicted hotseat item");
// b/270395008
public static final BooleanFlag ENABLE_CACHED_WIDGET = getDebugFlag(
public static final BooleanFlag ENABLE_CACHED_WIDGET = getDebugFlag(270395008,
"ENABLE_CACHED_WIDGET", true,
"Show previously cached widgets as opposed to deferred widget where available");
// b/270395010
public static final BooleanFlag USE_SEARCH_REQUEST_TIMEOUT_OVERRIDES = getDebugFlag(
public static final BooleanFlag USE_SEARCH_REQUEST_TIMEOUT_OVERRIDES = getDebugFlag(270395010,
"USE_SEARCH_REQUEST_TIMEOUT_OVERRIDES", false,
"Use local overrides for search request timeout");
// b/270395171
public static final BooleanFlag CONTINUOUS_VIEW_TREE_CAPTURE = getDebugFlag(
public static final BooleanFlag CONTINUOUS_VIEW_TREE_CAPTURE = getDebugFlag(270395171,
"CONTINUOUS_VIEW_TREE_CAPTURE", false, "Capture View tree every frame");
// b/270395070
public static final BooleanFlag FOLDABLE_WORKSPACE_REORDER = getDebugFlag(
public static final BooleanFlag FOLDABLE_WORKSPACE_REORDER = getDebugFlag(270395070,
"FOLDABLE_WORKSPACE_REORDER", true,
"In foldables, when reordering the icons and widgets, is now going to use both sides");
// b/270395073
public static final BooleanFlag ENABLE_MULTI_DISPLAY_PARTIAL_DEPTH = getDebugFlag(
public static final BooleanFlag ENABLE_MULTI_DISPLAY_PARTIAL_DEPTH = getDebugFlag(270395073,
"ENABLE_MULTI_DISPLAY_PARTIAL_DEPTH", false,
"Allow bottom sheet depth to be smaller than 1 for multi-display devices.");
// b/270395177
public static final BooleanFlag SCROLL_TOP_TO_RESET = new DeviceFlag(
"SCROLL_TOP_TO_RESET", true, "Bring up IME and focus on "
+ "input when scroll to top if 'Always show keyboard' is enabled or in prefix state");
public static final BooleanFlag SCROLL_TOP_TO_RESET = getReleaseFlag(
270395177, "SCROLL_TOP_TO_RESET", true,
"Bring up IME and focus on input when scroll to top if 'Always show keyboard'"
+ " is enabled or in prefix state");
// b/270395516
public static final BooleanFlag ENABLE_MATERIAL_U_POPUP = getDebugFlag(
public static final BooleanFlag ENABLE_MATERIAL_U_POPUP = getDebugFlag(270395516,
"ENABLE_MATERIAL_U_POPUP", false, "Switch popup UX to use material U");
// b/270395269
public static final BooleanFlag ENABLE_SEARCH_UNINSTALLED_APPS = new DeviceFlag(
public static final BooleanFlag ENABLE_SEARCH_UNINSTALLED_APPS = getReleaseFlag(270395269,
"ENABLE_SEARCH_UNINSTALLED_APPS", false, "Search uninstalled app results.");
// b/270395183
public static final BooleanFlag SHOW_HOME_GARDENING = getDebugFlag(
public static final BooleanFlag SHOW_HOME_GARDENING = getDebugFlag(270395183,
"SHOW_HOME_GARDENING", false,
"Show the new home gardening mode");
// b/270395133
public static final BooleanFlag HOME_GARDENING_WORKSPACE_BUTTONS = getDebugFlag(
public static final BooleanFlag HOME_GARDENING_WORKSPACE_BUTTONS = getDebugFlag(270395133,
"HOME_GARDENING_WORKSPACE_BUTTONS", false,
"Change workspace edit buttons to reflect home gardening");
// b/270395134
public static final BooleanFlag ENABLE_DOWNLOAD_APP_UX_V2 = new DeviceFlag(
public static final BooleanFlag ENABLE_DOWNLOAD_APP_UX_V2 = getReleaseFlag(270395134,
"ENABLE_DOWNLOAD_APP_UX_V2", true, "Updates the download app UX"
+ " to have better visuals");
// b/270395186
public static final BooleanFlag ENABLE_DOWNLOAD_APP_UX_V3 = getDebugFlag(
public static final BooleanFlag ENABLE_DOWNLOAD_APP_UX_V3 = getDebugFlag(270395186,
"ENABLE_DOWNLOAD_APP_UX_V3", false, "Updates the download app UX"
+ " to have better visuals, improve contrast, and color");
+ " to have better visuals, improve contrast, and color");
// b/270395077
public static final BooleanFlag FORCE_PERSISTENT_TASKBAR = getDebugFlag(
public static final BooleanFlag FORCE_PERSISTENT_TASKBAR = getDebugFlag(270395077,
"FORCE_PERSISTENT_TASKBAR", false, "Forces taskbar to be persistent, even in gesture"
+ " nav mode and when transient taskbar is enabled.");
// b/270395274
public static final BooleanFlag FOLDABLE_SINGLE_PAGE = getDebugFlag(
public static final BooleanFlag FOLDABLE_SINGLE_PAGE = getDebugFlag(270395274,
"FOLDABLE_SINGLE_PAGE", false,
"Use a single page for the workspace");
// b/270395798
public static final BooleanFlag ENABLE_TRANSIENT_TASKBAR = getDebugFlag(
public static final BooleanFlag ENABLE_TRANSIENT_TASKBAR = getDebugFlag(270395798,
"ENABLE_TRANSIENT_TASKBAR", true, "Enables transient taskbar.");
// b/270395140
public static final BooleanFlag SECONDARY_DRAG_N_DROP_TO_PIN = getDebugFlag(
public static final BooleanFlag SECONDARY_DRAG_N_DROP_TO_PIN = getDebugFlag(270395140,
"SECONDARY_DRAG_N_DROP_TO_PIN", false,
"Enable dragging and dropping to pin apps within secondary display");
// b/270395143
public static final BooleanFlag ENABLE_ICON_IN_TEXT_HEADER = getDebugFlag(
public static final BooleanFlag ENABLE_ICON_IN_TEXT_HEADER = getDebugFlag(270395143,
"ENABLE_ICON_IN_TEXT_HEADER", false, "Show icon in textheader");
// b/270395087
public static final BooleanFlag ENABLE_APP_ICON_FOR_INLINE_SHORTCUTS = getDebugFlag(
public static final BooleanFlag ENABLE_APP_ICON_FOR_INLINE_SHORTCUTS = getDebugFlag(270395087,
"ENABLE_APP_ICON_IN_INLINE_SHORTCUTS", false, "Show app icon for inline shortcut");
// b/270395278
public static final BooleanFlag SHOW_DOT_PAGINATION = getDebugFlag(
public static final BooleanFlag SHOW_DOT_PAGINATION = getDebugFlag(270395278,
"SHOW_DOT_PAGINATION", false, "Enable showing dot pagination in workspace");
// b/270395809
public static final BooleanFlag LARGE_SCREEN_WIDGET_PICKER = getDebugFlag(
public static final BooleanFlag LARGE_SCREEN_WIDGET_PICKER = getDebugFlag(270395809,
"LARGE_SCREEN_WIDGET_PICKER", false, "Enable new widget picker that takes "
+ "advantage of large screen format");
// b/270396257
public static final BooleanFlag ENABLE_NEW_GESTURE_NAV_TUTORIAL = getDebugFlag(
public static final BooleanFlag ENABLE_NEW_GESTURE_NAV_TUTORIAL = getDebugFlag(270396257,
"ENABLE_NEW_GESTURE_NAV_TUTORIAL", false,
"Enable the redesigned gesture navigation tutorial");
// b/270395567
public static final BooleanFlag ENABLE_LAUNCH_FROM_STAGED_APP = getDebugFlag(
public static final BooleanFlag ENABLE_LAUNCH_FROM_STAGED_APP = getDebugFlag(270395567,
"ENABLE_LAUNCH_FROM_STAGED_APP", true,
"Enable the ability to tap a staged app during split select to launch it in full screen"
);
// b/270396358
public static final BooleanFlag ENABLE_HAPTICS_ALL_APPS = getDebugFlag(
public static final BooleanFlag ENABLE_HAPTICS_ALL_APPS = getDebugFlag(270396358,
"ENABLE_HAPTICS_ALL_APPS", false, "Enables haptics opening/closing All apps");
// b/270396209
public static final BooleanFlag ENABLE_FORCED_MONO_ICON = getDebugFlag(
public static final BooleanFlag ENABLE_FORCED_MONO_ICON = getDebugFlag(270396209,
"ENABLE_FORCED_MONO_ICON", false,
"Enable the ability to generate monochromatic icons, if it is not provided by the app"
);
// b/270396364
public static final BooleanFlag ENABLE_DREAM_TRANSITION = getDebugFlag(
public static final BooleanFlag ENABLE_DREAM_TRANSITION = getDebugFlag(270396364,
"ENABLE_DREAM_TRANSITION", true,
"Enable the launcher transition when the device enters a dream");
// b/270396268
public static final BooleanFlag ENABLE_TASKBAR_EDU_TOOLTIP = getDebugFlag(
public static final BooleanFlag ENABLE_TASKBAR_EDU_TOOLTIP = getDebugFlag(270396268,
"ENABLE_TASKBAR_EDU_TOOLTIP", true,
"Enable the tooltip version of the Taskbar education flow.");
// b/270396680
public static final BooleanFlag ENABLE_MULTI_INSTANCE = getDebugFlag(
public static final BooleanFlag ENABLE_MULTI_INSTANCE = getDebugFlag(270396680,
"ENABLE_MULTI_INSTANCE", false,
"Enables creation and filtering of multiple task instances in overview");
// b/270396583
public static final BooleanFlag ENABLE_TASKBAR_PINNING = getDebugFlag(
public static final BooleanFlag ENABLE_TASKBAR_PINNING = getDebugFlag(270396583,
"ENABLE_TASKBAR_PINNING", false,
"Enables taskbar pinning to allow user to switch between transient and persistent "
+ "taskbar flavors");
// b/270397206
public static final BooleanFlag ENABLE_GRID_ONLY_OVERVIEW = getDebugFlag(
public static final BooleanFlag ENABLE_GRID_ONLY_OVERVIEW = getDebugFlag(270397206,
"ENABLE_GRID_ONLY_OVERVIEW", false,
"Enable a grid-only overview without a focused task.");
// b/270397209
public static final BooleanFlag RECEIVE_UNFOLD_EVENTS_FROM_SYSUI = getDebugFlag(
public static final BooleanFlag RECEIVE_UNFOLD_EVENTS_FROM_SYSUI = getDebugFlag(270397209,
"RECEIVE_UNFOLD_EVENTS_FROM_SYSUI", true,
"Enables receiving unfold animation events from sysui instead of calculating "
+ "them in launcher process using hinge sensor values.");
// b/270396844
public static final BooleanFlag ENABLE_KEYBOARD_QUICK_SWITCH = getDebugFlag(
public static final BooleanFlag ENABLE_KEYBOARD_QUICK_SWITCH = getDebugFlag(270396844,
"ENABLE_KEYBOARD_QUICK_SWITCH", false,
"Enables keyboard quick switching");
public static void initialize(Context context) {
synchronized (sDebugFlags) {
for (DebugFlag flag : sDebugFlags) {
flag.initialize(context);
}
sDebugFlags.sort((f1, f2) -> {
// Sort first by any prefs that the user has changed, then alphabetically.
int changeComparison = Boolean.compare(f2.mHasBeenChangedAtLeastOnce,
f1.mHasBeenChangedAtLeastOnce);
return changeComparison != 0
? changeComparison
: f1.key.compareToIgnoreCase(f2.key);
});
}
}
static List<DebugFlag> getDebugFlags() {
synchronized (sDebugFlags) {
return new ArrayList<>(sDebugFlags);
}
}
public static void dump(PrintWriter pw) {
pw.println("DeviceFlags:");
synchronized (sDebugFlags) {
for (DebugFlag flag : sDebugFlags) {
if (flag instanceof DeviceFlag) {
pw.println(" " + flag.toString());
}
}
}
pw.println("DebugFlags:");
synchronized (sDebugFlags) {
for (DebugFlag flag : sDebugFlags) {
if (!(flag instanceof DeviceFlag)) {
pw.println(" " + flag.toString());
}
}
}
}
public static class BooleanFlag {
public final String key;
public final boolean defaultValue;
private final boolean mCurrentValue;
public BooleanFlag(String key, boolean defaultValue) {
this.key = key;
this.defaultValue = defaultValue;
public BooleanFlag(boolean currentValue) {
mCurrentValue = currentValue;
}
public boolean get() {
return defaultValue;
}
@Override
public String toString() {
return appendProps(new StringBuilder()).toString();
}
protected StringBuilder appendProps(StringBuilder src) {
return src.append(key).append(", defaultValue=").append(defaultValue);
}
}
public static class DebugFlag extends BooleanFlag {
public final String description;
protected boolean mHasBeenChangedAtLeastOnce;
protected boolean mCurrentValue;
public DebugFlag(String key, boolean defaultValue, String description) {
super(key, defaultValue);
this.description = description;
mCurrentValue = this.defaultValue;
synchronized (sDebugFlags) {
sDebugFlags.add(this);
}
}
@Override
public boolean get() {
return mCurrentValue;
}
public void initialize(Context context) {
SharedPreferences prefs =
context.getSharedPreferences(FLAGS_PREF_NAME, Context.MODE_PRIVATE);
mHasBeenChangedAtLeastOnce = prefs.contains(key);
mCurrentValue = prefs.getBoolean(key, defaultValue);
}
@Override
protected StringBuilder appendProps(StringBuilder src) {
return super.appendProps(src).append(", mCurrentValue=").append(mCurrentValue);
}
}
private static BooleanFlag getDebugFlag(String key, boolean defaultValue, String description) {
return Utilities.IS_DEBUG_DEVICE
? new DebugFlag(key, defaultValue, description)
: new BooleanFlag(key, defaultValue);
}
}
@@ -52,6 +52,7 @@ import com.android.launcher3.Utilities;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.model.WidgetsModel;
import com.android.launcher3.states.RotationHelper;
import com.android.launcher3.uioverrides.flags.DeveloperOptionsFragment;
import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper;
import com.android.launcher3.util.DisplayController;
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 The Android Open Source Project
* Copyright (C) 2023 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.
@@ -13,14 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.launcher3.uioverrides.flags;
package com.android.launcher3.uioverrides;
import com.android.launcher3.config.FeatureFlags.DebugFlag;
public class DeviceFlag extends DebugFlag {
public DeviceFlag(String key, boolean defaultValue, String description) {
super(key, defaultValue, description);
}
/**
* Place holder class for developer options.
*/
public class DeveloperOptionsFragment {
}
@@ -0,0 +1,49 @@
/*
* Copyright (C) 2023 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.uioverrides.flags;
import com.android.launcher3.config.FeatureFlags.BooleanFlag;
import java.io.PrintWriter;
/**
* Helper class to create various flags for launcher build. The base implementation does
* not provide any flagging system, and simply replies with the default value.
*/
public class FlagsFactory {
/**
* Creates a new debug flag
*/
public static BooleanFlag getDebugFlag(
int bugId, String key, boolean defaultValue, String description) {
return new BooleanFlag(defaultValue);
}
/**
* Creates a new debug flag
*/
public static BooleanFlag getReleaseFlag(
int bugId, String key, boolean defaultValueInCode, String description) {
return new BooleanFlag(defaultValueInCode);
}
/**
* Dumps the current flags state to the print writer
*/
public static void dump(PrintWriter pw) { }
}
@@ -33,7 +33,6 @@ import com.android.launcher3.pm.UserCache
import com.android.launcher3.provider.LauncherDbUtils
import com.android.launcher3.util.LauncherModelHelper
import com.android.launcher3.util.LauncherModelHelper.*
import com.android.launcher3.util.TestUtil
import com.google.common.truth.Truth.assertThat
import org.junit.After
import org.junit.Before
@@ -619,8 +618,6 @@ class GridSizeMigrationUtilTest {
assertThat(locMap[testPackage3]).isEqualTo(1)
assertThat(locMap[testPackage4]).isEqualTo(1)
assertThat(locMap[testPackage5]).isEqualTo(2)
disableNewMigrationLogic()
}
/**
@@ -685,7 +682,6 @@ class GridSizeMigrationUtilTest {
assertThat(locMap[testPackage3]).isEqualTo(0)
assertThat(locMap[testPackage4]).isEqualTo(0)
assertThat(locMap[testPackage5]).isEqualTo(0)
disableNewMigrationLogic()
}
/** Migrating from a larger grid to a smaller, we reflow from page 0 */
@@ -746,19 +742,9 @@ class GridSizeMigrationUtilTest {
assertThat(locMap[testPackage3]).isEqualTo(0)
assertThat(locMap[testPackage4]).isEqualTo(0)
assertThat(locMap[testPackage5]).isEqualTo(0)
disableNewMigrationLogic()
}
private fun enableNewMigrationLogic(srcGridSize: String) {
LauncherPrefs.get(context).putSync(WORKSPACE_SIZE.to(srcGridSize))
TestUtil.overrideBooleanFlagValue(context,
FeatureFlags.ENABLE_NEW_MIGRATION_LOGIC, true);
FeatureFlags.initialize(context)
}
private fun disableNewMigrationLogic() {
TestUtil.overrideBooleanFlagValue(context,
FeatureFlags.ENABLE_NEW_MIGRATION_LOGIC, false);
}
}
@@ -21,7 +21,6 @@ import static android.view.MotionEvent.ACTION_DOWN;
import static com.google.common.truth.Truth.assertThat;
import android.content.Context;
import android.content.Intent;
import android.graphics.Point;
import android.os.SystemClock;
@@ -34,11 +33,8 @@ import androidx.test.uiautomator.By;
import androidx.test.uiautomator.UiObject2;
import androidx.test.uiautomator.Until;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.tapl.LauncherInstrumentation;
import com.android.launcher3.ui.AbstractLauncherUiTest;
import com.android.launcher3.util.LauncherModelHelper;
import com.android.launcher3.util.TestUtil;
import org.junit.After;
import org.junit.Ignore;
@@ -278,9 +274,6 @@ public final class SecondaryDisplayLauncherTest extends AbstractLauncherUiTest {
}
private void setDragNDropFlag(Boolean status) {
Context context = new LauncherModelHelper().sandboxContext;
TestUtil.overrideBooleanFlagValue(
context, FeatureFlags.SECONDARY_DRAG_N_DROP_TO_PIN, status);
startSecondaryDisplayActivity();
}
}
@@ -50,6 +50,7 @@ import androidx.test.espresso.intent.Intents;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.android.launcher3.R;
import com.android.launcher3.uioverrides.flags.DeveloperOptionsFragment;
import com.android.systemui.shared.plugins.PluginPrefs;
import org.junit.After;
@@ -19,18 +19,14 @@ import static androidx.test.InstrumentationRegistry.getContext;
import static androidx.test.InstrumentationRegistry.getInstrumentation;
import static androidx.test.InstrumentationRegistry.getTargetContext;
import android.content.Context;
import android.content.pm.LauncherApps;
import android.content.res.Resources;
import android.os.Handler;
import android.os.Looper;
import android.os.UserHandle;
import androidx.annotation.VisibleForTesting;
import androidx.test.uiautomator.UiDevice;
import com.android.launcher3.config.FeatureFlags;
import org.junit.Assert;
import java.io.FileOutputStream;
@@ -72,18 +68,6 @@ public class TestUtil {
}
}
@VisibleForTesting
// Override feature flag, mainly to be used ONLY in tests
public static void overrideBooleanFlagValue(
Context context, FeatureFlags.BooleanFlag flagToOverride,
boolean bool) {
context.getSharedPreferences(FeatureFlags.FLAGS_PREF_NAME, Context.MODE_PRIVATE)
.edit()
.putBoolean(flagToOverride.key, bool)
.commit();
FeatureFlags.initialize(context);
}
public static void uninstallDummyApp() throws IOException {
UiDevice.getInstance(getInstrumentation()).executeShellCommand(
"pm uninstall " + DUMMY_PACKAGE);