From 77954bae4e77ba431a6ae8bb9997d6611c1de308 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Mon, 25 Mar 2024 11:53:17 -0700 Subject: [PATCH] Cleaning up some build configurations > Removing Launcher3Go-without-quickstep > Removing src_ui_overrides to src_no_quickstep > Removing unnecessary code swpa for GO builds Bug: 330920490 Flag: None Test: Presubmit, everything builds Change-Id: I5746dbc7c5a37c1d99d78b55bf2a6adce1a711c9 --- Android.bp | 181 ++++++------------ go/quickstep/res/values/config.xml | 3 + .../res/xml/device_profiles.xml | 0 .../com/android/launcher3/BuildConfig.java | 43 +++++ go/res/values-v26/bools.xml | 22 --- go/res/values/override.xml | 22 --- .../launcher3/model/LauncherBinder.java | 45 ----- .../android/launcher3/model/WidgetsModel.java | 105 ---------- .../launcher3/util/AbsGridOccupancy.java | 56 ------ .../uioverrides/QuickstepWidgetHolder.java | 6 +- src/com/android/launcher3/LauncherModel.java | 4 +- .../graphics/PreviewSurfaceRenderer.java | 4 +- .../launcher3/icons/ShortcutCachingLogic.java | 4 +- .../launcher3/model/BaseLauncherBinder.java | 37 +++- .../android/launcher3/model/BgDataModel.java | 4 +- .../android/launcher3/model/LoaderTask.java | 6 +- .../android/launcher3/model/WidgetsModel.java | 21 +- .../launcher3/provider/RestoreDbTask.java | 4 +- .../launcher3/settings/SettingsActivity.java | 3 +- .../launcher3/shortcuts/ShortcutRequest.java | 12 +- .../android/launcher3/util/GridOccupancy.java | 21 +- .../android/launcher3/util/ShortcutUtil.java | 5 +- .../launcher3/views/ActivityContext.java | 4 +- .../launcher3/views/OptionsPopupView.java | 4 +- .../widget/LauncherWidgetHolder.java | 12 +- .../launcher3/widget/WidgetInflater.kt | 4 +- .../launcher3/widget/WidgetManagerHelper.java | 13 +- .../com/android/launcher3/BuildConfig.java | 5 + .../launcher3/uioverrides/ApiWrapper.java | 0 .../uioverrides/PredictedAppIconInflater.java | 29 +++ .../uioverrides/flags/DeveloperOptionsUI.java | 0 .../uioverrides/flags/FlagsFactory.java | 0 .../plugins/PluginManagerWrapper.java | 0 .../uioverrides/states/AllAppsState.java | 0 .../uioverrides/states/OverviewState.java | 0 .../launcher3/model/LauncherBinder.java | 59 ------ .../launcher3/util/AbsGridOccupancy.java | 55 ------ tests/Android.bp | 14 -- .../android/launcher3/model/LoaderTaskTest.kt | 2 +- 39 files changed, 255 insertions(+), 554 deletions(-) rename go/{ => quickstep}/res/xml/device_profiles.xml (100%) create mode 100644 go/quickstep/src/com/android/launcher3/BuildConfig.java delete mode 100644 go/res/values-v26/bools.xml delete mode 100644 go/res/values/override.xml delete mode 100644 go/src/com/android/launcher3/model/LauncherBinder.java delete mode 100644 go/src/com/android/launcher3/model/WidgetsModel.java delete mode 100644 go/src/com/android/launcher3/util/AbsGridOccupancy.java rename {src_shortcuts_overrides => src}/com/android/launcher3/model/WidgetsModel.java (96%) rename {src_ui_overrides => src_no_quickstep}/com/android/launcher3/uioverrides/ApiWrapper.java (100%) create mode 100644 src_no_quickstep/com/android/launcher3/uioverrides/PredictedAppIconInflater.java rename {src_ui_overrides => src_no_quickstep}/com/android/launcher3/uioverrides/flags/DeveloperOptionsUI.java (100%) rename {src_ui_overrides => src_no_quickstep}/com/android/launcher3/uioverrides/flags/FlagsFactory.java (100%) rename {src_ui_overrides => src_no_quickstep}/com/android/launcher3/uioverrides/plugins/PluginManagerWrapper.java (100%) rename {src_ui_overrides => src_no_quickstep}/com/android/launcher3/uioverrides/states/AllAppsState.java (100%) rename {src_ui_overrides => src_no_quickstep}/com/android/launcher3/uioverrides/states/OverviewState.java (100%) delete mode 100644 src_shortcuts_overrides/com/android/launcher3/model/LauncherBinder.java delete mode 100644 src_shortcuts_overrides/com/android/launcher3/util/AbsGridOccupancy.java diff --git a/Android.bp b/Android.bp index f45394a998..79c1b9fc6d 100644 --- a/Android.bp +++ b/Android.bp @@ -21,6 +21,8 @@ min_launcher3_sdk_version = "30" // Common source files used to build launcher (java and kotlin) // All sources are split so they can be reused in many other libraries/apps in other folders + +// Main Launcher source, excluding the build config filegroup { name: "launcher-src", srcs: [ @@ -29,6 +31,7 @@ filegroup { ], } +// Source code for quickstep build, on top of launcher-src filegroup { name: "launcher-quickstep-src", srcs: [ @@ -37,35 +40,20 @@ filegroup { ], } +// Alternate source when quickstep is not included filegroup { - name: "launcher-go-src", + name: "launcher-src_no_quickstep", srcs: [ - "go/src/**/*.java", - "go/src/**/*.kt", + "src_no_quickstep/**/*.java", + "src_no_quickstep/**/*.kt", ], } +// Default build config for Launcher3 filegroup { - name: "launcher-go-quickstep-src", + name: "launcher-build-config", srcs: [ - "go/quickstep/src/**/*.java", - "go/quickstep/src/**/*.kt", - ], -} - -filegroup { - name: "launcher-src_shortcuts_overrides", - srcs: [ - "src_shortcuts_overrides/**/*.java", - "src_shortcuts_overrides/**/*.kt", - ], -} - -filegroup { - name: "launcher-src_ui_overrides", - srcs: [ - "src_ui_overrides/**/*.java", - "src_ui_overrides/**/*.kt", + "src_build_config/**/*.java", ], } @@ -165,36 +153,16 @@ android_library { "iconloader_base", "view_capture", "animationlib", - ], - manifest: "AndroidManifest-common.xml", - sdk_version: "current", - min_sdk_version: min_launcher3_sdk_version, - lint: { - baseline_filename: "lint-baseline.xml", - }, -} - -// -// Build rule for Launcher3 dependencies lib. -// -android_library { - name: "Launcher3CommonDepsLib", - srcs: ["src_build_config/**/*.java"], - static_libs: [ "SystemUI-statsd", - "Launcher3ResLib", "launcher-testing-shared", - "animationlib", - "kotlinx_coroutines_android", - "kotlinx_coroutines", "com_android_launcher3_flags_lib", "com_android_wm_shell_flags_lib", "android.appwidget.flags-aconfig-java", "com.android.window.flags.window-aconfig-java", ], + manifest: "AndroidManifest-common.xml", sdk_version: "current", min_sdk_version: min_launcher3_sdk_version, - manifest: "AndroidManifest-common.xml", lint: { baseline_filename: "lint-baseline.xml", }, @@ -207,12 +175,12 @@ android_app { name: "Launcher3", static_libs: [ - "Launcher3CommonDepsLib", + "Launcher3ResLib", ], srcs: [ ":launcher-src", - ":launcher-src_shortcuts_overrides", - ":launcher-src_ui_overrides", + ":launcher-src_no_quickstep", + ":launcher-build-config", ], optimize: { @@ -259,24 +227,21 @@ android_library { "lottie", "SystemUISharedLib", "SettingsLibSettingsTheme", - "SystemUI-statsd", - "animationlib", ], manifest: "quickstep/AndroidManifest.xml", min_sdk_version: "current", } -// Library with all the dependencies for building Launcher Go +// Library with all the source code and dependencies for building Launcher Go android_library { - name: "LauncherGoResLib", + name: "Launcher3GoLib", srcs: [ ":launcher-src", ":launcher-quickstep-src", - ":launcher-go-src", - ":launcher-go-quickstep-src", + "go/quickstep/src/**/*.java", + "go/quickstep/src/**/*.kt", ], resource_dirs: [ - "go/res", "go/quickstep/res", ], // Note the ordering here is important when it comes to resource @@ -284,7 +249,6 @@ android_library { // in QuickstepResLib to take precendece, so it should be the final // dependency. See b/205278434 for how this can go wrong. static_libs: [ - "Launcher3CommonDepsLib", "QuickstepResLib", "androidx.room_room-runtime", ], @@ -299,13 +263,13 @@ android_library { use_resource_processor: false, } -// Build rule for Quickstep library +// Library with all the source code and dependencies for building Quickstep android_library { name: "Launcher3QuickStepLib", srcs: [ ":launcher-src", ":launcher-quickstep-src", - ":launcher-src_shortcuts_overrides", + ":launcher-build-config", ], resource_dirs: [], libs: [ @@ -317,10 +281,7 @@ android_library { // dependency. See b/208647810 for how this can go wrong. static_libs: [ "SystemUI-statsd", - "SystemUISharedLib", - "Launcher3CommonDepsLib", "QuickstepResLib", - "animationlib", ], manifest: "quickstep/AndroidManifest.xml", platform_apis: true, @@ -329,49 +290,6 @@ android_library { use_resource_processor: false, } -// Build rule for Launcher3 Go app for Android Go devices. -android_app { - name: "Launcher3Go", - - static_libs: ["Launcher3CommonDepsLib"], - - srcs: [ - ":launcher-src", - ":launcher-go-src", - ":launcher-src_ui_overrides", - ], - - resource_dirs: ["go/res"], - - optimize: { - proguard_flags_files: ["proguard.flags"], - }, - - sdk_version: "current", - min_sdk_version: "current", - target_sdk_version: "current", - privileged: true, - system_ext_specific: true, - overrides: [ - "Home", - "Launcher2", - "Launcher3", - "Launcher3QuickStep", - ], - required: ["privapp_whitelist_com.android.launcher3"], - - additional_manifests: [ - "AndroidManifest.xml", - "AndroidManifest-common.xml", - ], - - manifest: "go/AndroidManifest.xml", - jacoco: { - include_filter: ["com.android.launcher3.*"], - }, - -} - // Build rule for Quickstep app. android_app { name: "Launcher3QuickStep", @@ -408,28 +326,54 @@ android_app { } -// Build rule for Launcher3 Go app with quickstep for Android Go devices. -android_app { - name: "Launcher3QuickStepGo", - static_libs: [ - "SystemUI-statsd", - "SystemUISharedLib", - "LauncherGoResLib", - ], +// Build rule for Launcher3 Go app with quickstep for Android Go devices. +// Note that the following two rules are exactly same, and should +// eventually be merged into a single target +android_app { + name: "Launcher3Go", + + static_libs: ["Launcher3GoLib"], + + platform_apis: true, + min_sdk_version: "current", + target_sdk_version: "current", + + optimize: { + proguard_flags_files: ["proguard.flags"], + enabled: true, + }, + + privileged: true, + system_ext_specific: true, + overrides: [ + "Home", + "Launcher2", + "Launcher3", + "Launcher3QuickStep", + ], + required: ["privapp_whitelist_com.android.launcher3"], + + additional_manifests: [ + "go/AndroidManifest.xml", + "go/AndroidManifest-launcher.xml", + "AndroidManifest-common.xml", + ], + + manifest: "quickstep/AndroidManifest.xml", + jacoco: { + include_filter: ["com.android.launcher3.*"], + }, +} +android_app { + name: "Launcher3QuickStepGo", + + static_libs: ["Launcher3GoLib"], platform_apis: true, min_sdk_version: "current", target_sdk_version: "current", - srcs: [], - - resource_dirs: [ - "go/quickstep/res", - "go/res", - "quickstep/res", - ], - optimize: { proguard_flags_files: ["proguard.flags"], enabled: true, @@ -455,5 +399,4 @@ android_app { jacoco: { include_filter: ["com.android.launcher3.*"], }, - } diff --git a/go/quickstep/res/values/config.xml b/go/quickstep/res/values/config.xml index 796d14db16..147dd96c41 100644 --- a/go/quickstep/res/values/config.xml +++ b/go/quickstep/res/values/config.xml @@ -21,4 +21,7 @@ true com.android.quickstep.TaskOverlayFactoryGo + + + #Intent;action=android.intent.action.DELETE;launchFlags=0x10800000;B.android.intent.extra.RETURN_RESULT=true;end \ No newline at end of file diff --git a/go/res/xml/device_profiles.xml b/go/quickstep/res/xml/device_profiles.xml similarity index 100% rename from go/res/xml/device_profiles.xml rename to go/quickstep/res/xml/device_profiles.xml diff --git a/go/quickstep/src/com/android/launcher3/BuildConfig.java b/go/quickstep/src/com/android/launcher3/BuildConfig.java new file mode 100644 index 0000000000..cfcda39e01 --- /dev/null +++ b/go/quickstep/src/com/android/launcher3/BuildConfig.java @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2018 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; + +public final class BuildConfig { + public static final String APPLICATION_ID = "com.android.launcher3"; + + public static final boolean IS_STUDIO_BUILD = false; + /** + * Flag to state if the QSB is on the first screen and placed on the top, + * this can be overwritten in other launchers with a different value, if needed. + */ + public static final boolean QSB_ON_FIRST_SCREEN = true; + + /** + * Flag to state if the widget on the top of the first screen should be shown. + */ + public static final boolean WIDGET_ON_FIRST_SCREEN = false; + + /** + * Flag to control various developer centric features + */ + public static final boolean IS_DEBUG_DEVICE = false; + + // Flag to control widgets support in Launcher + public static final boolean WIDGETS_ENABLED = false; + // Flag to control notification dots support in Launcher + public static final boolean NOTIFICATION_DOTS_ENABLED = false; +} diff --git a/go/res/values-v26/bools.xml b/go/res/values-v26/bools.xml deleted file mode 100644 index 1584734ff3..0000000000 --- a/go/res/values-v26/bools.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - false - - diff --git a/go/res/values/override.xml b/go/res/values/override.xml deleted file mode 100644 index 268cb980c7..0000000000 --- a/go/res/values/override.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - #Intent;action=android.intent.action.DELETE;launchFlags=0x10800000;B.android.intent.extra.RETURN_RESULT=true;end - \ No newline at end of file diff --git a/go/src/com/android/launcher3/model/LauncherBinder.java b/go/src/com/android/launcher3/model/LauncherBinder.java deleted file mode 100644 index 7a0dce853b..0000000000 --- a/go/src/com/android/launcher3/model/LauncherBinder.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2018 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.model; - -import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; - -import com.android.launcher3.LauncherAppState; -import com.android.launcher3.model.BgDataModel.Callbacks; - -/** - * Binds the results of {@link com.android.launcher3.model.LoaderTask} to the Callbacks objects. - */ -public class LauncherBinder extends BaseLauncherBinder { - - public LauncherBinder(LauncherAppState app, BgDataModel dataModel, - AllAppsList allAppsList, Callbacks[] callbacks) { - super(app, dataModel, allAppsList, callbacks, MAIN_EXECUTOR); - } - - @Override - public void bindDeepShortcuts() { - } - - @Override - public void bindWidgets() { - } - - @Override - public void bindSmartspaceWidget() { - } -} diff --git a/go/src/com/android/launcher3/model/WidgetsModel.java b/go/src/com/android/launcher3/model/WidgetsModel.java deleted file mode 100644 index 3a28444142..0000000000 --- a/go/src/com/android/launcher3/model/WidgetsModel.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (C) 2018 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.model; - -import android.content.ComponentName; -import android.content.Context; -import android.os.UserHandle; - -import androidx.annotation.Nullable; - -import com.android.launcher3.LauncherAppState; -import com.android.launcher3.icons.ComponentWithLabelAndIcon; -import com.android.launcher3.model.data.PackageItemInfo; -import com.android.launcher3.util.PackageUserKey; -import com.android.launcher3.widget.model.WidgetsListBaseEntry; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.function.Predicate; - -/** - * Widgets data model that is used by the adapters of the widget views and controllers. - * - *

The widgets and shortcuts are organized using package name as its index. - */ -public class WidgetsModel { - - // True is the widget support is disabled. - public static final boolean GO_DISABLE_WIDGETS = true; - public static final boolean GO_DISABLE_NOTIFICATION_DOTS = true; - - private static final ArrayList EMPTY_WIDGET_LIST = new ArrayList<>(); - - /** - * Returns a list of {@link WidgetsListBaseEntry} filtered using given widget item filter. All - * {@link WidgetItem}s in a single row are sorted (based on label and user), but the overall - * list of {@link WidgetsListBaseEntry}s is not sorted. - * - * @see com.android.launcher3.widget.picker.WidgetsListAdapter#setWidgets(List) - */ - public synchronized ArrayList getFilteredWidgetsListForPicker( - Context context, - Predicate widgetItemFilter) { - return EMPTY_WIDGET_LIST; - } - - /** - * Returns a list of {@link WidgetsListBaseEntry}. All {@link WidgetItem} in a single row are - * sorted (based on label and user), but the overall list of {@link WidgetsListBaseEntry}s is - * not sorted. This list is sorted at the UI when using - * {@link com.android.launcher3.widget.picker.WidgetsDiffReporter} - * - * @see com.android.launcher3.widget.picker.WidgetsListAdapter#setWidgets(List) - */ - public synchronized ArrayList getWidgetsListForPicker(Context context) { - return EMPTY_WIDGET_LIST; - } - - /** Returns a mapping of packages to their widgets without static shortcuts. */ - public synchronized Map> getAllWidgetsWithoutShortcuts() { - return Map.of(); - } - - /** - * @param packageUser If null, all widgets and shortcuts are updated and returned, otherwise - * only widgets and shortcuts associated with the package/user are. - */ - public List update(LauncherAppState app, - @Nullable PackageUserKey packageUser) { - return Collections.emptyList(); - } - - - public void onPackageIconsUpdated(Set packageNames, UserHandle user, - LauncherAppState app) { - } - - public WidgetItem getWidgetProviderInfoByProviderName( - ComponentName providerName, UserHandle user) { - return null; - } - - /** Returns {@link PackageItemInfo} of a pending widget. */ - public static PackageItemInfo newPendingItemInfo( - Context context, ComponentName provider, UserHandle userHandle) { - return new PackageItemInfo(provider.getPackageName(), userHandle); - } -} diff --git a/go/src/com/android/launcher3/util/AbsGridOccupancy.java b/go/src/com/android/launcher3/util/AbsGridOccupancy.java deleted file mode 100644 index 4a46bd193f..0000000000 --- a/go/src/com/android/launcher3/util/AbsGridOccupancy.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2022 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.util; - -/** - * Defines method to find the next vacant cell on a grid. - * This uses the default top-down, left-right approach and can be over-written through - * code swaps in different launchers. - */ -public abstract class AbsGridOccupancy { - - /** - * Find the first vacant cell, if there is one. - * - * @param vacantOut Holds the x and y coordinate of the vacant cell - * @param spanX Horizontal cell span. - * @param spanY Vertical cell span. - * - * @return true if a vacant cell was found - */ - protected boolean findVacantCell(int[] vacantOut, boolean[][] cells, int countX, int countY, - int spanX, int spanY) { - for (int y = 0; (y + spanY) <= countY; y++) { - for (int x = 0; (x + spanX) <= countX; x++) { - boolean available = !cells[x][y]; - out: - for (int i = x; i < x + spanX; i++) { - for (int j = y; j < y + spanY; j++) { - available = available && !cells[i][j]; - if (!available) break out; - } - } - if (available) { - vacantOut[0] = x; - vacantOut[1] = y; - return true; - } - } - } - return false; - } -} diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepWidgetHolder.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepWidgetHolder.java index 23e2622f1a..01d5ff0e15 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepWidgetHolder.java +++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepWidgetHolder.java @@ -15,6 +15,7 @@ */ package com.android.launcher3.uioverrides; +import static com.android.launcher3.BuildConfig.WIDGETS_ENABLED; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; @@ -32,7 +33,6 @@ import androidx.annotation.Nullable; import androidx.annotation.UiThread; import com.android.launcher3.config.FeatureFlags; -import com.android.launcher3.model.WidgetsModel; import com.android.launcher3.util.IntSet; import com.android.launcher3.util.SafeCloseable; import com.android.launcher3.widget.LauncherAppWidgetHostView; @@ -101,7 +101,7 @@ public final class QuickstepWidgetHolder extends LauncherWidgetHolder { new ArrayList<>(h.mProviderChangedListeners).forEach( ProviderChangedListener::notifyWidgetProvidersChanged))), UI_HELPER_EXECUTOR.getLooper()); - if (!WidgetsModel.GO_DISABLE_WIDGETS) { + if (WIDGETS_ENABLED) { sWidgetHost.startListening(); } } @@ -195,7 +195,7 @@ public final class QuickstepWidgetHolder extends LauncherWidgetHolder { */ @Override public void stopListening() { - if (WidgetsModel.GO_DISABLE_WIDGETS) { + if (!WIDGETS_ENABLED) { return; } diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java index be01d633bc..7fdfd726f9 100644 --- a/src/com/android/launcher3/LauncherModel.java +++ b/src/com/android/launcher3/LauncherModel.java @@ -47,12 +47,12 @@ import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.icons.IconCache; import com.android.launcher3.model.AddWorkspaceItemsTask; import com.android.launcher3.model.AllAppsList; +import com.android.launcher3.model.BaseLauncherBinder; import com.android.launcher3.model.BaseModelUpdateTask; import com.android.launcher3.model.BgDataModel; import com.android.launcher3.model.BgDataModel.Callbacks; import com.android.launcher3.model.CacheDataUpdatedTask; import com.android.launcher3.model.ItemInstallQueue; -import com.android.launcher3.model.LauncherBinder; import com.android.launcher3.model.LoaderTask; import com.android.launcher3.model.ModelDbController; import com.android.launcher3.model.ModelDelegate; @@ -365,7 +365,7 @@ public class LauncherModel implements InstallSessionTracker.Callback { MAIN_EXECUTOR.execute(cb::clearPendingBinds); } - LauncherBinder launcherBinder = new LauncherBinder( + BaseLauncherBinder launcherBinder = new BaseLauncherBinder( mApp, mBgDataModel, mBgAllAppsList, callbacksList); if (bindDirectly) { // Divide the set of loaded items into those that we are binding synchronously, diff --git a/src/com/android/launcher3/graphics/PreviewSurfaceRenderer.java b/src/com/android/launcher3/graphics/PreviewSurfaceRenderer.java index fe327d01e3..addd0727e8 100644 --- a/src/com/android/launcher3/graphics/PreviewSurfaceRenderer.java +++ b/src/com/android/launcher3/graphics/PreviewSurfaceRenderer.java @@ -50,10 +50,10 @@ import com.android.launcher3.LauncherAppState; import com.android.launcher3.LauncherSettings; import com.android.launcher3.Workspace; import com.android.launcher3.graphics.LauncherPreviewRenderer.PreviewContext; +import com.android.launcher3.model.BaseLauncherBinder; import com.android.launcher3.model.BgDataModel; import com.android.launcher3.model.BgDataModel.Callbacks; import com.android.launcher3.model.GridSizeMigrationUtil; -import com.android.launcher3.model.LauncherBinder; import com.android.launcher3.model.LoaderTask; import com.android.launcher3.model.ModelDbController; import com.android.launcher3.provider.LauncherDbUtils; @@ -244,7 +244,7 @@ public class PreviewSurfaceRenderer { /* bgAllAppsList= */ null, bgModel, LauncherAppState.getInstance(previewContext).getModel().getModelDelegate(), - new LauncherBinder(LauncherAppState.getInstance(previewContext), bgModel, + new BaseLauncherBinder(LauncherAppState.getInstance(previewContext), bgModel, /* bgAllAppsList= */ null, new Callbacks[0])) { @Override diff --git a/src/com/android/launcher3/icons/ShortcutCachingLogic.java b/src/com/android/launcher3/icons/ShortcutCachingLogic.java index 17915394ae..f40eda6c2d 100644 --- a/src/com/android/launcher3/icons/ShortcutCachingLogic.java +++ b/src/com/android/launcher3/icons/ShortcutCachingLogic.java @@ -16,7 +16,7 @@ package com.android.launcher3.icons; -import static com.android.launcher3.model.WidgetsModel.GO_DISABLE_WIDGETS; +import static com.android.launcher3.BuildConfig.WIDGETS_ENABLED; import android.content.ComponentName; import android.content.Context; @@ -101,7 +101,7 @@ public class ShortcutCachingLogic implements CachingLogic { * Launcher specific checks */ public static Drawable getIcon(Context context, ShortcutInfo shortcutInfo, int density) { - if (GO_DISABLE_WIDGETS) { + if (!WIDGETS_ENABLED) { return null; } try { diff --git a/src/com/android/launcher3/model/BaseLauncherBinder.java b/src/com/android/launcher3/model/BaseLauncherBinder.java index 966b6a6264..41dbe4e7eb 100644 --- a/src/com/android/launcher3/model/BaseLauncherBinder.java +++ b/src/com/android/launcher3/model/BaseLauncherBinder.java @@ -16,6 +16,7 @@ package com.android.launcher3.model; +import static com.android.launcher3.BuildConfig.WIDGETS_ENABLED; import static com.android.launcher3.Flags.enableWorkspaceInflation; import static com.android.launcher3.config.FeatureFlags.ENABLE_SMARTSPACE_REMOVAL; import static com.android.launcher3.model.ItemInstallQueue.FLAG_LOADER_RUNNING; @@ -43,6 +44,7 @@ import com.android.launcher3.model.BgDataModel.FixedContainerItems; import com.android.launcher3.model.data.AppInfo; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.LauncherAppWidgetInfo; +import com.android.launcher3.util.ComponentKey; import com.android.launcher3.util.IntArray; import com.android.launcher3.util.IntSet; import com.android.launcher3.util.ItemInflater; @@ -50,10 +52,12 @@ import com.android.launcher3.util.LooperExecutor; import com.android.launcher3.util.LooperIdleLock; import com.android.launcher3.util.PackageUserKey; import com.android.launcher3.util.RunnableList; +import com.android.launcher3.widget.model.WidgetsListBaseEntry; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -65,7 +69,7 @@ import java.util.stream.Collectors; /** * Binds the results of {@link com.android.launcher3.model.LoaderTask} to the Callbacks objects. */ -public abstract class BaseLauncherBinder { +public class BaseLauncherBinder { protected static final String TAG = "LauncherBinder"; private static final int ITEMS_CHUNK = 6; // batch size for the workspace icons @@ -81,8 +85,8 @@ public abstract class BaseLauncherBinder { private int mMyBindingId; public BaseLauncherBinder(LauncherAppState app, BgDataModel dataModel, - AllAppsList allAppsList, Callbacks[] callbacksList, LooperExecutor uiExecutor) { - mUiExecutor = uiExecutor; + AllAppsList allAppsList, Callbacks[] callbacksList) { + mUiExecutor = MAIN_EXECUTOR; mApp = app; mBgDataModel = dataModel; mBgAllAppsList = allAppsList; @@ -158,7 +162,16 @@ public abstract class BaseLauncherBinder { /** * BindDeepShortcuts is abstract because it is a no-op for the go launcher. */ - public abstract void bindDeepShortcuts(); + public void bindDeepShortcuts() { + if (!WIDGETS_ENABLED) { + return; + } + final HashMap shortcutMapCopy; + synchronized (mBgDataModel) { + shortcutMapCopy = new HashMap<>(mBgDataModel.deepShortcutMap); + } + executeCallbacksTask(c -> c.bindDeepShortcutMap(shortcutMapCopy), mUiExecutor); + } /** * Binds the all apps results from LoaderTask to the callbacks UX. @@ -178,12 +191,24 @@ public abstract class BaseLauncherBinder { /** * bindWidgets is abstract because it is a no-op for the go launcher. */ - public abstract void bindWidgets(); + public void bindWidgets() { + if (!WIDGETS_ENABLED) { + return; + } + final List widgets = + mBgDataModel.widgetsModel.getWidgetsListForPicker(mApp.getContext()); + executeCallbacksTask(c -> c.bindAllWidgets(widgets), mUiExecutor); + } /** * bindWidgets is abstract because it is a no-op for the go launcher. */ - public abstract void bindSmartspaceWidget(); + public void bindSmartspaceWidget() { + if (!WIDGETS_ENABLED) { + return; + } + executeCallbacksTask(c -> c.bindSmartspaceWidget(), mUiExecutor); + } /** * Sorts the set of items by hotseat, workspace (spatially from top to bottom, left to right) diff --git a/src/com/android/launcher3/model/BgDataModel.java b/src/com/android/launcher3/model/BgDataModel.java index 8579d1d682..0e1c8f4c66 100644 --- a/src/com/android/launcher3/model/BgDataModel.java +++ b/src/com/android/launcher3/model/BgDataModel.java @@ -18,9 +18,9 @@ package com.android.launcher3.model; import static android.content.pm.LauncherApps.ShortcutQuery.FLAG_GET_KEY_FIELDS_ONLY; import static com.android.launcher3.BuildConfig.QSB_ON_FIRST_SCREEN; +import static com.android.launcher3.BuildConfig.WIDGETS_ENABLED; import static com.android.launcher3.config.FeatureFlags.ENABLE_SMARTSPACE_REMOVAL; import static com.android.launcher3.config.FeatureFlags.shouldShowFirstPageWidget; -import static com.android.launcher3.model.WidgetsModel.GO_DISABLE_WIDGETS; import static com.android.launcher3.shortcuts.ShortcutRequest.PINNED; import static java.util.stream.Collectors.groupingBy; @@ -305,7 +305,7 @@ public class BgDataModel { * shortcuts and unpinning any extra shortcuts. */ public synchronized void updateShortcutPinnedState(Context context, UserHandle user) { - if (GO_DISABLE_WIDGETS) { + if (!WIDGETS_ENABLED) { return; } diff --git a/src/com/android/launcher3/model/LoaderTask.java b/src/com/android/launcher3/model/LoaderTask.java index 17cef900ec..f3d04b75bb 100644 --- a/src/com/android/launcher3/model/LoaderTask.java +++ b/src/com/android/launcher3/model/LoaderTask.java @@ -132,7 +132,7 @@ public class LoaderTask implements Runnable { private FirstScreenBroadcast mFirstScreenBroadcast; @NonNull - private final LauncherBinder mLauncherBinder; + private final BaseLauncherBinder mLauncherBinder; private final LauncherApps mLauncherApps; private final UserManager mUserManager; @@ -153,13 +153,13 @@ public class LoaderTask implements Runnable { private String mDbName; public LoaderTask(@NonNull LauncherAppState app, AllAppsList bgAllAppsList, BgDataModel bgModel, - ModelDelegate modelDelegate, @NonNull LauncherBinder launcherBinder) { + ModelDelegate modelDelegate, @NonNull BaseLauncherBinder launcherBinder) { this(app, bgAllAppsList, bgModel, modelDelegate, launcherBinder, new UserManagerState()); } @VisibleForTesting LoaderTask(@NonNull LauncherAppState app, AllAppsList bgAllAppsList, BgDataModel bgModel, - ModelDelegate modelDelegate, @NonNull LauncherBinder launcherBinder, + ModelDelegate modelDelegate, @NonNull BaseLauncherBinder launcherBinder, UserManagerState userManagerState) { mApp = app; mBgAllAppsList = bgAllAppsList; diff --git a/src_shortcuts_overrides/com/android/launcher3/model/WidgetsModel.java b/src/com/android/launcher3/model/WidgetsModel.java similarity index 96% rename from src_shortcuts_overrides/com/android/launcher3/model/WidgetsModel.java rename to src/com/android/launcher3/model/WidgetsModel.java index 8b983fc391..91ce5eabf5 100644 --- a/src_shortcuts_overrides/com/android/launcher3/model/WidgetsModel.java +++ b/src/com/android/launcher3/model/WidgetsModel.java @@ -3,6 +3,7 @@ package com.android.launcher3.model; import static android.appwidget.AppWidgetProviderInfo.WIDGET_FEATURE_HIDE_FROM_PICKER; +import static com.android.launcher3.BuildConfig.WIDGETS_ENABLED; import static com.android.launcher3.pm.ShortcutConfigActivityInfo.queryList; import static com.android.launcher3.widget.WidgetSections.NO_CATEGORY; @@ -44,6 +45,7 @@ import com.android.launcher3.widget.model.WidgetsListHeaderEntry; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -59,10 +61,6 @@ import java.util.function.Predicate; */ public class WidgetsModel { - // True is the widget support is disabled. - public static final boolean GO_DISABLE_WIDGETS = false; - public static final boolean GO_DISABLE_NOTIFICATION_DOTS = false; - private static final String TAG = "WidgetsModel"; private static final boolean DEBUG = false; @@ -79,6 +77,9 @@ public class WidgetsModel { public synchronized ArrayList getFilteredWidgetsListForPicker( Context context, Predicate widgetItemFilter) { + if (!WIDGETS_ENABLED) { + return new ArrayList<>(); + } ArrayList result = new ArrayList<>(); AlphabeticIndexCompat indexer = new AlphabeticIndexCompat(context); @@ -111,6 +112,9 @@ public class WidgetsModel { /** Returns a mapping of packages to their widgets without static shortcuts. */ public synchronized Map> getAllWidgetsWithoutShortcuts() { + if (!WIDGETS_ENABLED) { + return Collections.emptyMap(); + } Map> packagesToWidgets = new HashMap<>(); mWidgetsList.forEach((packageItemInfo, widgetsAndShortcuts) -> { List widgets = widgetsAndShortcuts.stream() @@ -131,6 +135,9 @@ public class WidgetsModel { */ public List update( LauncherAppState app, @Nullable PackageUserKey packageUser) { + if (!WIDGETS_ENABLED) { + return Collections.emptyList(); + } Preconditions.assertWorkerThread(); Context context = app.getContext(); @@ -207,6 +214,9 @@ public class WidgetsModel { public void onPackageIconsUpdated(Set packageNames, UserHandle user, LauncherAppState app) { + if (!WIDGETS_ENABLED) { + return; + } WidgetManagerHelper widgetManager = new WidgetManagerHelper(app.getContext()); for (Entry> entry : mWidgetsList.entrySet()) { if (packageNames.contains(entry.getKey().packageName)) { @@ -231,6 +241,9 @@ public class WidgetsModel { public WidgetItem getWidgetProviderInfoByProviderName( ComponentName providerName, UserHandle user) { + if (!WIDGETS_ENABLED) { + return null; + } List widgetsList = mWidgetsList.get( new PackageItemInfo(providerName.getPackageName(), user)); if (widgetsList == null) { diff --git a/src/com/android/launcher3/provider/RestoreDbTask.java b/src/com/android/launcher3/provider/RestoreDbTask.java index 756153e5c4..9f2b10f198 100644 --- a/src/com/android/launcher3/provider/RestoreDbTask.java +++ b/src/com/android/launcher3/provider/RestoreDbTask.java @@ -18,6 +18,7 @@ package com.android.launcher3.provider; import static android.os.Process.myUserHandle; +import static com.android.launcher3.BuildConfig.WIDGETS_ENABLED; import static com.android.launcher3.Flags.enableLauncherBrMetricsFixed; import static com.android.launcher3.InvariantDeviceProfile.TYPE_MULTI_DISPLAY; import static com.android.launcher3.LauncherPrefs.APP_WIDGET_IDS; @@ -64,7 +65,6 @@ import com.android.launcher3.logging.FileLog; import com.android.launcher3.model.DeviceGridState; import com.android.launcher3.model.LoaderTask; import com.android.launcher3.model.ModelDbController; -import com.android.launcher3.model.WidgetsModel; import com.android.launcher3.model.data.AppInfo; import com.android.launcher3.model.data.LauncherAppWidgetInfo; import com.android.launcher3.model.data.WorkspaceItemInfo; @@ -428,7 +428,7 @@ public class RestoreDbTask { private void restoreAppWidgetIds(Context context, ModelDbController controller, LauncherRestoreEventLogger launcherRestoreEventLogger, int[] oldWidgetIds, int[] newWidgetIds, @NonNull AppWidgetHost host) { - if (WidgetsModel.GO_DISABLE_WIDGETS) { + if (!WIDGETS_ENABLED) { FileLog.e(TAG, "Skipping widget ID remap as widgets not supported"); host.deleteHost(); launcherRestoreEventLogger.logFavoritesItemsRestoreFailed(Favorites.ITEM_TYPE_APPWIDGET, diff --git a/src/com/android/launcher3/settings/SettingsActivity.java b/src/com/android/launcher3/settings/SettingsActivity.java index a5f9c2a53f..c10d85eccd 100644 --- a/src/com/android/launcher3/settings/SettingsActivity.java +++ b/src/com/android/launcher3/settings/SettingsActivity.java @@ -52,7 +52,6 @@ import androidx.recyclerview.widget.RecyclerView; import com.android.launcher3.BuildConfig; import com.android.launcher3.LauncherFiles; import com.android.launcher3.R; -import com.android.launcher3.model.WidgetsModel; import com.android.launcher3.states.RotationHelper; import com.android.launcher3.uioverrides.flags.DeveloperOptionsUI; import com.android.launcher3.util.DisplayController; @@ -238,7 +237,7 @@ public class SettingsActivity extends FragmentActivity protected boolean initPreference(Preference preference) { switch (preference.getKey()) { case NOTIFICATION_DOTS_PREFERENCE_KEY: - return !WidgetsModel.GO_DISABLE_NOTIFICATION_DOTS; + return BuildConfig.NOTIFICATION_DOTS_ENABLED; case ALLOW_ROTATION_PREFERENCE_KEY: DisplayController.Info info = diff --git a/src/com/android/launcher3/shortcuts/ShortcutRequest.java b/src/com/android/launcher3/shortcuts/ShortcutRequest.java index 21efceb0fd..015d54dd85 100644 --- a/src/com/android/launcher3/shortcuts/ShortcutRequest.java +++ b/src/com/android/launcher3/shortcuts/ShortcutRequest.java @@ -16,7 +16,7 @@ package com.android.launcher3.shortcuts; -import static com.android.launcher3.model.WidgetsModel.GO_DISABLE_WIDGETS; +import static com.android.launcher3.BuildConfig.WIDGETS_ENABLED; import android.content.ComponentName; import android.content.Context; @@ -47,7 +47,7 @@ public class ShortcutRequest { | ShortcutQuery.FLAG_MATCH_MANIFEST; public static final int PINNED = ShortcutQuery.FLAG_MATCH_PINNED; - private final ShortcutQuery mQuery = GO_DISABLE_WIDGETS ? null : new ShortcutQuery(); + private final ShortcutQuery mQuery = !WIDGETS_ENABLED ? null : new ShortcutQuery(); private final Context mContext; private final UserHandle mUserHandle; @@ -74,7 +74,7 @@ public class ShortcutRequest { * @return A list of ShortcutInfo's associated with the given package. */ public ShortcutRequest forPackage(String packageName, @Nullable List shortcutIds) { - if (!GO_DISABLE_WIDGETS && packageName != null) { + if (WIDGETS_ENABLED && packageName != null) { mQuery.setPackage(packageName); mQuery.setShortcutIds(shortcutIds); } @@ -82,7 +82,7 @@ public class ShortcutRequest { } public ShortcutRequest withContainer(@Nullable ComponentName activity) { - if (!GO_DISABLE_WIDGETS) { + if (WIDGETS_ENABLED) { if (activity == null) { mFailed = true; } else { @@ -93,7 +93,7 @@ public class ShortcutRequest { } public QueryResult query(int flags) { - if (GO_DISABLE_WIDGETS || mFailed) { + if (!WIDGETS_ENABLED || mFailed) { return QueryResult.DEFAULT; } mQuery.setQueryFlags(flags); @@ -109,7 +109,7 @@ public class ShortcutRequest { public static class QueryResult extends ArrayList { - static final QueryResult DEFAULT = new QueryResult(GO_DISABLE_WIDGETS); + static final QueryResult DEFAULT = new QueryResult(!WIDGETS_ENABLED); private final boolean mWasSuccess; diff --git a/src/com/android/launcher3/util/GridOccupancy.java b/src/com/android/launcher3/util/GridOccupancy.java index 43e486c7ab..f248e58ef3 100644 --- a/src/com/android/launcher3/util/GridOccupancy.java +++ b/src/com/android/launcher3/util/GridOccupancy.java @@ -7,7 +7,7 @@ import com.android.launcher3.model.data.ItemInfo; /** * Utility object to manage the occupancy in a grid. */ -public class GridOccupancy extends AbsGridOccupancy { +public class GridOccupancy { private final int mCountX; private final int mCountY; @@ -30,7 +30,24 @@ public class GridOccupancy extends AbsGridOccupancy { * @return true if a vacant cell was found */ public boolean findVacantCell(int[] vacantOut, int spanX, int spanY) { - return super.findVacantCell(vacantOut, cells, mCountX, mCountY, spanX, spanY); + for (int y = 0; (y + spanY) <= mCountY; y++) { + for (int x = 0; (x + spanX) <= mCountX; x++) { + boolean available = !cells[x][y]; + out: + for (int i = x; i < x + spanX; i++) { + for (int j = y; j < y + spanY; j++) { + available = available && !cells[i][j]; + if (!available) break out; + } + } + if (available) { + vacantOut[0] = x; + vacantOut[1] = y; + return true; + } + } + } + return false; } public void copyTo(GridOccupancy dest) { diff --git a/src/com/android/launcher3/util/ShortcutUtil.java b/src/com/android/launcher3/util/ShortcutUtil.java index 91cf835287..07b7941036 100644 --- a/src/com/android/launcher3/util/ShortcutUtil.java +++ b/src/com/android/launcher3/util/ShortcutUtil.java @@ -15,9 +15,10 @@ */ package com.android.launcher3.util; +import static com.android.launcher3.BuildConfig.WIDGETS_ENABLED; + import com.android.launcher3.LauncherSettings; import com.android.launcher3.Utilities; -import com.android.launcher3.model.WidgetsModel; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.WorkspaceItemInfo; import com.android.launcher3.shortcuts.ShortcutKey; @@ -34,7 +35,7 @@ public class ShortcutUtil { * Returns true when we should show depp shortcuts in shortcut menu for the item. */ public static boolean supportsDeepShortcuts(ItemInfo info) { - return isActive(info) && isApp(info) && !WidgetsModel.GO_DISABLE_WIDGETS; + return isActive(info) && isApp(info) && !!WIDGETS_ENABLED; } /** diff --git a/src/com/android/launcher3/views/ActivityContext.java b/src/com/android/launcher3/views/ActivityContext.java index 31f5d6541a..bf43a229f3 100644 --- a/src/com/android/launcher3/views/ActivityContext.java +++ b/src/com/android/launcher3/views/ActivityContext.java @@ -17,12 +17,12 @@ package com.android.launcher3.views; import static android.window.SplashScreen.SPLASH_SCREEN_STYLE_SOLID_COLOR; +import static com.android.launcher3.BuildConfig.WIDGETS_ENABLED; import static com.android.launcher3.LauncherSettings.Animation.DEFAULT_NO_ICON; import static com.android.launcher3.Utilities.allowBGLaunch; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_KEYBOARD_CLOSED; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_APP_LAUNCH_PENDING_INTENT; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_APP_LAUNCH_TAP; -import static com.android.launcher3.model.WidgetsModel.GO_DISABLE_WIDGETS; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; @@ -389,7 +389,7 @@ public interface ActivityContext { boolean isShortcut = (item instanceof WorkspaceItemInfo) && item.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT && !((WorkspaceItemInfo) item).isPromise(); - if (isShortcut && GO_DISABLE_WIDGETS) { + if (isShortcut && !WIDGETS_ENABLED) { return null; } ActivityOptionsWrapper options = v != null ? getActivityLaunchOptions(v, item) diff --git a/src/com/android/launcher3/views/OptionsPopupView.java b/src/com/android/launcher3/views/OptionsPopupView.java index 5cdad03116..62eed5c545 100644 --- a/src/com/android/launcher3/views/OptionsPopupView.java +++ b/src/com/android/launcher3/views/OptionsPopupView.java @@ -17,6 +17,7 @@ package com.android.launcher3.views; import static androidx.core.content.ContextCompat.getColorStateList; +import static com.android.launcher3.BuildConfig.WIDGETS_ENABLED; import static com.android.launcher3.LauncherState.EDIT_MODE; import static com.android.launcher3.config.FeatureFlags.MULTI_SELECT_EDIT_MODE; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.IGNORE; @@ -47,7 +48,6 @@ import com.android.launcher3.LauncherSettings; import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.logging.StatsLogManager.EventEnum; -import com.android.launcher3.model.WidgetsModel; import com.android.launcher3.model.data.WorkspaceItemInfo; import com.android.launcher3.popup.ArrowPopup; import com.android.launcher3.shortcuts.DeepShortcutView; @@ -207,7 +207,7 @@ public class OptionsPopupView extends Arrow R.drawable.ic_palette, IGNORE, OptionsPopupView::startWallpaperPicker)); - if (!WidgetsModel.GO_DISABLE_WIDGETS) { + if (WIDGETS_ENABLED) { options.add(new OptionItem(launcher, R.string.widget_button_text, R.drawable.ic_widget, diff --git a/src/com/android/launcher3/widget/LauncherWidgetHolder.java b/src/com/android/launcher3/widget/LauncherWidgetHolder.java index 0fb4e097be..a5e22c5899 100644 --- a/src/com/android/launcher3/widget/LauncherWidgetHolder.java +++ b/src/com/android/launcher3/widget/LauncherWidgetHolder.java @@ -17,6 +17,7 @@ package com.android.launcher3.widget; import static android.app.Activity.RESULT_CANCELED; +import static com.android.launcher3.BuildConfig.WIDGETS_ENABLED; import static com.android.launcher3.Flags.enableWorkspaceInflation; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import static com.android.launcher3.widget.LauncherAppWidgetProviderInfo.fromProviderInfo; @@ -40,7 +41,6 @@ import com.android.launcher3.BaseActivity; import com.android.launcher3.BaseDraggingActivity; import com.android.launcher3.R; import com.android.launcher3.Utilities; -import com.android.launcher3.model.WidgetsModel; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.testing.TestLogging; import com.android.launcher3.testing.shared.TestProtocol; @@ -100,7 +100,7 @@ public class LauncherWidgetHolder { * Starts listening to the widget updates from the server side */ public void startListening() { - if (WidgetsModel.GO_DISABLE_WIDGETS) { + if (!WIDGETS_ENABLED) { return; } @@ -177,7 +177,7 @@ public class LauncherWidgetHolder { * @return The allocated app widget id if allocation is successful, returns -1 otherwise */ public int allocateAppWidgetId() { - if (WidgetsModel.GO_DISABLE_WIDGETS) { + if (!WIDGETS_ENABLED) { return AppWidgetManager.INVALID_APPWIDGET_ID; } @@ -210,7 +210,7 @@ public class LauncherWidgetHolder { */ public void startConfigActivity(@NonNull BaseDraggingActivity activity, int widgetId, int requestCode) { - if (WidgetsModel.GO_DISABLE_WIDGETS) { + if (!WIDGETS_ENABLED) { sendActionCancelled(activity, requestCode); return; } @@ -261,7 +261,7 @@ public class LauncherWidgetHolder { */ public void startBindFlow(@NonNull BaseActivity activity, int appWidgetId, @NonNull AppWidgetProviderInfo info, int requestCode) { - if (WidgetsModel.GO_DISABLE_WIDGETS) { + if (!WIDGETS_ENABLED) { sendActionCancelled(activity, requestCode); return; } @@ -279,7 +279,7 @@ public class LauncherWidgetHolder { * Stop the host from listening to the widget updates */ public void stopListening() { - if (WidgetsModel.GO_DISABLE_WIDGETS) { + if (!WIDGETS_ENABLED) { return; } mWidgetHost.stopListening(); diff --git a/src/com/android/launcher3/widget/WidgetInflater.kt b/src/com/android/launcher3/widget/WidgetInflater.kt index dd50b71cb1..271c9c298e 100644 --- a/src/com/android/launcher3/widget/WidgetInflater.kt +++ b/src/com/android/launcher3/widget/WidgetInflater.kt @@ -17,11 +17,11 @@ package com.android.launcher3.widget import android.content.Context +import com.android.launcher3.BuildConfig import com.android.launcher3.Launcher import com.android.launcher3.LauncherAppState import com.android.launcher3.backuprestore.LauncherRestoreEventLogger.RestoreError import com.android.launcher3.logging.FileLog -import com.android.launcher3.model.WidgetsModel import com.android.launcher3.model.data.LauncherAppWidgetInfo import com.android.launcher3.qsb.QsbContainerView @@ -55,7 +55,7 @@ class WidgetInflater(private val context: Context) { // The widget id is not valid. Try to find the widget based on the provider info. appWidgetInfo = widgetHelper.findProvider(item.providerName, item.user) if (appWidgetInfo == null) { - if (WidgetsModel.GO_DISABLE_WIDGETS) { + if (!BuildConfig.WIDGETS_ENABLED) { removalReason = "widgets are disabled on go device." logReason = RestoreError.WIDGETS_DISABLED } else { diff --git a/src/com/android/launcher3/widget/WidgetManagerHelper.java b/src/com/android/launcher3/widget/WidgetManagerHelper.java index ba7e0754a9..d293d15f38 100644 --- a/src/com/android/launcher3/widget/WidgetManagerHelper.java +++ b/src/com/android/launcher3/widget/WidgetManagerHelper.java @@ -16,6 +16,8 @@ package com.android.launcher3.widget; +import static com.android.launcher3.BuildConfig.WIDGETS_ENABLED; + import android.annotation.TargetApi; import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetProviderInfo; @@ -31,7 +33,6 @@ import androidx.annotation.Nullable; import androidx.annotation.RequiresApi; import com.android.launcher3.logging.FileLog; -import com.android.launcher3.model.WidgetsModel; import com.android.launcher3.model.data.LauncherAppWidgetInfo; import com.android.launcher3.pm.UserCache; import com.android.launcher3.util.PackageUserKey; @@ -87,7 +88,7 @@ public class WidgetManagerHelper { */ @TargetApi(Build.VERSION_CODES.O) public List getAllProviders(@Nullable PackageUserKey packageUser) { - if (WidgetsModel.GO_DISABLE_WIDGETS) { + if (!WIDGETS_ENABLED) { return Collections.emptyList(); } @@ -112,7 +113,7 @@ public class WidgetManagerHelper { */ public boolean bindAppWidgetIdIfAllowed(int appWidgetId, AppWidgetProviderInfo info, Bundle options) { - if (WidgetsModel.GO_DISABLE_WIDGETS) { + if (!WIDGETS_ENABLED) { return false; } if (appWidgetId <= LauncherAppWidgetInfo.CUSTOM_WIDGET_ID) { @@ -123,7 +124,7 @@ public class WidgetManagerHelper { } public LauncherAppWidgetProviderInfo findProvider(ComponentName provider, UserHandle user) { - if (WidgetsModel.GO_DISABLE_WIDGETS) { + if (!WIDGETS_ENABLED) { return null; } for (AppWidgetProviderInfo info : @@ -139,8 +140,8 @@ public class WidgetManagerHelper { * Returns if a AppWidgetProvider has marked a widget restored */ public boolean isAppWidgetRestored(int appWidgetId) { - return !WidgetsModel.GO_DISABLE_WIDGETS && mAppWidgetManager.getAppWidgetOptions( - appWidgetId).getBoolean(WIDGET_OPTION_RESTORE_COMPLETED); + return WIDGETS_ENABLED && mAppWidgetManager.getAppWidgetOptions(appWidgetId) + .getBoolean(WIDGET_OPTION_RESTORE_COMPLETED); } diff --git a/src_build_config/com/android/launcher3/BuildConfig.java b/src_build_config/com/android/launcher3/BuildConfig.java index 3841969e9d..6d4f56d655 100644 --- a/src_build_config/com/android/launcher3/BuildConfig.java +++ b/src_build_config/com/android/launcher3/BuildConfig.java @@ -35,4 +35,9 @@ public final class BuildConfig { * Flag to control various developer centric features */ public static final boolean IS_DEBUG_DEVICE = false; + + // Flag to control widgets support in Launcher + public static final boolean WIDGETS_ENABLED = true; + // Flag to control notification dots support in Launcher + public static final boolean NOTIFICATION_DOTS_ENABLED = true; } diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/ApiWrapper.java b/src_no_quickstep/com/android/launcher3/uioverrides/ApiWrapper.java similarity index 100% rename from src_ui_overrides/com/android/launcher3/uioverrides/ApiWrapper.java rename to src_no_quickstep/com/android/launcher3/uioverrides/ApiWrapper.java diff --git a/src_no_quickstep/com/android/launcher3/uioverrides/PredictedAppIconInflater.java b/src_no_quickstep/com/android/launcher3/uioverrides/PredictedAppIconInflater.java new file mode 100644 index 0000000000..4893c1740e --- /dev/null +++ b/src_no_quickstep/com/android/launcher3/uioverrides/PredictedAppIconInflater.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2020 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.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import com.android.launcher3.model.data.WorkspaceItemInfo; + +/** A util class that inflates a predicted app icon */ +public class PredictedAppIconInflater { + public static View inflate(LayoutInflater inflater, ViewGroup parent, WorkspaceItemInfo info) { + return null; + } +} diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/flags/DeveloperOptionsUI.java b/src_no_quickstep/com/android/launcher3/uioverrides/flags/DeveloperOptionsUI.java similarity index 100% rename from src_ui_overrides/com/android/launcher3/uioverrides/flags/DeveloperOptionsUI.java rename to src_no_quickstep/com/android/launcher3/uioverrides/flags/DeveloperOptionsUI.java diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/flags/FlagsFactory.java b/src_no_quickstep/com/android/launcher3/uioverrides/flags/FlagsFactory.java similarity index 100% rename from src_ui_overrides/com/android/launcher3/uioverrides/flags/FlagsFactory.java rename to src_no_quickstep/com/android/launcher3/uioverrides/flags/FlagsFactory.java diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/plugins/PluginManagerWrapper.java b/src_no_quickstep/com/android/launcher3/uioverrides/plugins/PluginManagerWrapper.java similarity index 100% rename from src_ui_overrides/com/android/launcher3/uioverrides/plugins/PluginManagerWrapper.java rename to src_no_quickstep/com/android/launcher3/uioverrides/plugins/PluginManagerWrapper.java diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/states/AllAppsState.java b/src_no_quickstep/com/android/launcher3/uioverrides/states/AllAppsState.java similarity index 100% rename from src_ui_overrides/com/android/launcher3/uioverrides/states/AllAppsState.java rename to src_no_quickstep/com/android/launcher3/uioverrides/states/AllAppsState.java diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/states/OverviewState.java b/src_no_quickstep/com/android/launcher3/uioverrides/states/OverviewState.java similarity index 100% rename from src_ui_overrides/com/android/launcher3/uioverrides/states/OverviewState.java rename to src_no_quickstep/com/android/launcher3/uioverrides/states/OverviewState.java diff --git a/src_shortcuts_overrides/com/android/launcher3/model/LauncherBinder.java b/src_shortcuts_overrides/com/android/launcher3/model/LauncherBinder.java deleted file mode 100644 index 7e73ab5fbb..0000000000 --- a/src_shortcuts_overrides/com/android/launcher3/model/LauncherBinder.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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.model; - -import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; - -import com.android.launcher3.LauncherAppState; -import com.android.launcher3.model.BgDataModel.Callbacks; -import com.android.launcher3.util.ComponentKey; -import com.android.launcher3.widget.model.WidgetsListBaseEntry; - -import java.util.HashMap; -import java.util.List; - -/** - * Binds the results of {@link com.android.launcher3.model.LoaderTask} to the Callbacks objects. - */ -public class LauncherBinder extends BaseLauncherBinder { - - public LauncherBinder(LauncherAppState app, BgDataModel dataModel, - AllAppsList allAppsList, Callbacks[] callbacks) { - super(app, dataModel, allAppsList, callbacks, MAIN_EXECUTOR); - } - - @Override - public void bindDeepShortcuts() { - final HashMap shortcutMapCopy; - synchronized (mBgDataModel) { - shortcutMapCopy = new HashMap<>(mBgDataModel.deepShortcutMap); - } - executeCallbacksTask(c -> c.bindDeepShortcutMap(shortcutMapCopy), mUiExecutor); - } - - @Override - public void bindWidgets() { - final List widgets = - mBgDataModel.widgetsModel.getWidgetsListForPicker(mApp.getContext()); - executeCallbacksTask(c -> c.bindAllWidgets(widgets), mUiExecutor); - } - - @Override - public void bindSmartspaceWidget() { - executeCallbacksTask(c -> c.bindSmartspaceWidget(), mUiExecutor); - } -} diff --git a/src_shortcuts_overrides/com/android/launcher3/util/AbsGridOccupancy.java b/src_shortcuts_overrides/com/android/launcher3/util/AbsGridOccupancy.java deleted file mode 100644 index 968b281787..0000000000 --- a/src_shortcuts_overrides/com/android/launcher3/util/AbsGridOccupancy.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2022 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.util; - -/** - * Defines method to find the next vacant cell on a grid. - * This uses the default top-down, left-right approach and can be over-written through - * code swaps in different launchers. - */ -public abstract class AbsGridOccupancy { - /** - * Find the first vacant cell, if there is one. - * - * @param vacantOut Holds the x and y coordinate of the vacant cell - * @param spanX Horizontal cell span. - * @param spanY Vertical cell span. - * - * @return true if a vacant cell was found - */ - protected boolean findVacantCell(int[] vacantOut, boolean[][] cells, int countX, int countY, - int spanX, int spanY) { - for (int y = 0; (y + spanY) <= countY; y++) { - for (int x = 0; (x + spanX) <= countX; x++) { - boolean available = !cells[x][y]; - out: - for (int i = x; i < x + spanX; i++) { - for (int j = y; j < y + spanY; j++) { - available = available && !cells[i][j]; - if (!available) break out; - } - } - if (available) { - vacantOut[0] = x; - vacantOut[1] = y; - return true; - } - } - } - return false; - } -} diff --git a/tests/Android.bp b/tests/Android.bp index eeafdba855..c1d41802cc 100644 --- a/tests/Android.bp +++ b/tests/Android.bp @@ -168,20 +168,6 @@ filegroup { ], } -android_library { - name: "Launcher3Lib", - srcs: [ - ":launcher-src", - ":launcher-src_shortcuts_overrides", - ":launcher-src_ui_overrides", - ], - static_libs: [ - "Launcher3CommonDepsLib", - ], - // TODO(b/319712088): re-enable use_resource_processor - use_resource_processor: false, -} - android_robolectric_test { enabled: true, name: "Launcher3RoboTests", diff --git a/tests/src/com/android/launcher3/model/LoaderTaskTest.kt b/tests/src/com/android/launcher3/model/LoaderTaskTest.kt index e2ca31f22b..bbe8265bc3 100644 --- a/tests/src/com/android/launcher3/model/LoaderTaskTest.kt +++ b/tests/src/com/android/launcher3/model/LoaderTaskTest.kt @@ -46,7 +46,7 @@ class LoaderTaskTest { @Mock private lateinit var app: LauncherAppState @Mock private lateinit var bgAllAppsList: AllAppsList @Mock private lateinit var modelDelegate: ModelDelegate - @Mock private lateinit var launcherBinder: LauncherBinder + @Mock private lateinit var launcherBinder: BaseLauncherBinder @Mock private lateinit var launcherModel: LauncherModel @Mock private lateinit var transaction: LoaderTransaction @Mock private lateinit var iconCache: IconCache