From b7b176808c6dd8eabee65a6f60c38b079f526056 Mon Sep 17 00:00:00 2001 From: Alexander Koskovich Date: Wed, 4 Nov 2020 16:51:30 -0700 Subject: [PATCH 001/376] Launcher3: Allow changing app suggestion settings Change-Id: Ib077324ba6676a1b8e143b26c14bf0b6eb258d28 Signed-off-by: Pranav Vashi Signed-off-by: str-br Signed-off-by: Pranav Vashi --- res/values/cr_strings.xml | 4 ++++ res/xml/launcher_misc_preferences.xml | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/res/values/cr_strings.xml b/res/values/cr_strings.xml index 2a46e45745..a7974582ba 100644 --- a/res/values/cr_strings.xml +++ b/res/values/cr_strings.xml @@ -77,4 +77,8 @@ Turn on work apps Your work apps cannot send you notifications, use your battery, or access your location Your work apps cannot receive phone calls or text messages, send you notifications, use your battery, or access your location + + + Suggestions + For All Apps & Home screen suggestions diff --git a/res/xml/launcher_misc_preferences.xml b/res/xml/launcher_misc_preferences.xml index 045f091bba..9053598b4c 100644 --- a/res/xml/launcher_misc_preferences.xml +++ b/res/xml/launcher_misc_preferences.xml @@ -29,4 +29,12 @@ launcher:logIdOff="616" launcher:iconSpaceReserved="false" /> + + + + From ee16816c9819fb8889e497f4bc9520c416a490bb Mon Sep 17 00:00:00 2001 From: Filippo Date: Fri, 23 Sep 2022 21:43:33 +0800 Subject: [PATCH 002/376] Launcher3: Hide app suggestion entry if DPS not available Such entry isn't able to find its hook in our GApp-less builds since we don't include Pixel vendor in them. Change-Id: Ib68200ef38d6d1fdcff0418afcd65039921b72a7 Signed-off-by: Pranav Vashi --- .../android/launcher3/settings/SettingsMisc.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/com/android/launcher3/settings/SettingsMisc.java b/src/com/android/launcher3/settings/SettingsMisc.java index 615ff4a255..38f43608d0 100644 --- a/src/com/android/launcher3/settings/SettingsMisc.java +++ b/src/com/android/launcher3/settings/SettingsMisc.java @@ -27,8 +27,10 @@ import static com.android.launcher3.states.RotationHelper.ALLOW_ROTATION_PREFERENCE_KEY; import android.app.Activity; +import android.content.Context; import android.content.Intent; import android.content.pm.ActivityInfo; +import android.content.pm.PackageManager; import android.net.Uri; import android.os.Bundle; import android.provider.Settings; @@ -74,6 +76,9 @@ public class SettingsMisc extends CollapsingToolbarBaseActivity public static final String FIXED_LANDSCAPE_MODE = "pref_fixed_landscape_mode"; + private static final String SUGGESTIONS_KEY = "pref_suggestions"; + protected static final String DPS_PACKAGE = "com.google.android.as"; + public static final String EXTRA_FRAGMENT_ARGS = ":settings:fragment_args"; // Intent extra to indicate the pref-key to highlighted when opening the settings activity @@ -324,10 +329,21 @@ protected boolean initPreference(Preference preference) { } ); return !info.isTablet(info.realBounds); + case SUGGESTIONS_KEY: + // Show if Device Personalization Services is present. + return isDPSEnabled(getContext()); } return true; } + public static boolean isDPSEnabled(Context context) { + try { + return context.getPackageManager().getApplicationInfo(DPS_PACKAGE, 0).enabled; + } catch (PackageManager.NameNotFoundException e) { + return false; + } + } + @Override public void onResume() { super.onResume(); From ddd9b7b9fffef085b44173730ab4c17ab356ffbd Mon Sep 17 00:00:00 2001 From: minaripenguin Date: Sat, 1 Apr 2023 19:29:53 +0800 Subject: [PATCH 003/376] Launcher3: Migrate deprecated getColor to one with Theme Signed-off-by: minaripenguin Signed-off-by: Pranav Vashi --- .../src/com/android/quickstep/views/TaskMenuViewWithArrow.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quickstep/src/com/android/quickstep/views/TaskMenuViewWithArrow.kt b/quickstep/src/com/android/quickstep/views/TaskMenuViewWithArrow.kt index 8644748973..33c8c60c9f 100644 --- a/quickstep/src/com/android/quickstep/views/TaskMenuViewWithArrow.kt +++ b/quickstep/src/com/android/quickstep/views/TaskMenuViewWithArrow.kt @@ -198,7 +198,7 @@ class TaskMenuViewWithArrow : ArrowPopup where T : RecentsViewContainer, T // Add the spaces between items val divider = ShapeDrawable(RectShape()) - divider.paint.color = resources.getColor(android.R.color.transparent) + divider.paint.color = resources.getColor(android.R.color.transparent, /* theme= */ null) val dividerSpacing = resources.getDimension(R.dimen.task_menu_spacing).toInt() optionLayout.showDividers = SHOW_DIVIDER_MIDDLE From 342016d4a4d6e0581df9399e996a558c0ce4d200 Mon Sep 17 00:00:00 2001 From: Peter Njeim Date: Sun, 12 Dec 2021 18:28:32 -0400 Subject: [PATCH 004/376] Launcher3: Add WallpaperManager check to support WSA Signed-off-by: Pranav Vashi --- src/com/android/launcher3/Workspace.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index addcb684aa..78ecb3e11f 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -1427,7 +1427,9 @@ protected void setWallpaperDimension() { @Override public void run() { final Point size = LauncherAppState.getIDP(getContext()).defaultWallpaperSize; - if (size.x != mWallpaperManager.getDesiredMinimumWidth() + if (!mWallpaperManager.isWallpaperSupported()) { + mWallpaperManager.suggestDesiredDimensions(0, 0); + } else if (size.x != mWallpaperManager.getDesiredMinimumWidth() || size.y != mWallpaperManager.getDesiredMinimumHeight()) { mWallpaperManager.suggestDesiredDimensions(size.x, size.y); } From 7367a84bbf6e791f6bacbb61ac9941541b9cc855 Mon Sep 17 00:00:00 2001 From: Saul Henriquez Date: Thu, 21 Oct 2021 20:30:27 -0600 Subject: [PATCH 005/376] Launcher3: Allow widgets to have 1 row as minimum size Signed-off-by: Saul Henriquez --- .../launcher3/widget/LauncherAppWidgetProviderInfo.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/android/launcher3/widget/LauncherAppWidgetProviderInfo.java b/src/com/android/launcher3/widget/LauncherAppWidgetProviderInfo.java index cc66c1c341..26a08ff585 100644 --- a/src/com/android/launcher3/widget/LauncherAppWidgetProviderInfo.java +++ b/src/com/android/launcher3/widget/LauncherAppWidgetProviderInfo.java @@ -103,7 +103,7 @@ protected LauncherAppWidgetProviderInfo(Parcel in) { public void initSpans(Context context, InvariantDeviceProfile idp) { mPM = context.getApplicationContext().getPackageManager(); int minSpanX = 0; - int minSpanY = 0; + int minSpanY = 1; int maxSpanX = idp.numColumns; int maxSpanY = idp.numRows; int spanX = 0; @@ -125,7 +125,7 @@ public void initSpans(Context context, InvariantDeviceProfile idp) { getSpanX(widgetPadding, minResizeWidth, dp.getWorkspaceIconProfile().getCellLayoutBorderSpacePx().x, cellSize.x)); - minSpanY = Math.max(minSpanY, + minSpanY = Math.min(minSpanY, getSpanY(widgetPadding, minResizeHeight, dp.getWorkspaceIconProfile().getCellLayoutBorderSpacePx().y, cellSize.y)); From 431732737f5378a503e35e0fc87ee820471cd8f4 Mon Sep 17 00:00:00 2001 From: MrSluffy Date: Tue, 19 Dec 2023 10:34:02 +0800 Subject: [PATCH 006/376] Launcher3: Add null check for BaseDragLayer @neobuddy89: Squash separate fixes. Fixes: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getScrollX()' on a null object reference at com.android.launcher3.Utilities.mapCoordInSelfToDescendant(Utilities.java:335) at com.android.launcher3.Workspace.updateIsBeingDraggedOnTouchDown(Workspace.java:1236) at com.android.launcher3.PagedView.onInterceptTouchEvent(PagedView.java:1081) at com.android.launcher3.Workspace.onInterceptTouchEvent(Workspace.java:1168) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2652) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3120) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2744) at com.android.launcher3.views.BaseDragLayer.dispatchTouchEvent(BaseDragLayer.java:303) at com.android.launcher3.dragndrop.DragLayer.dispatchTouchEvent(DragLayer.java:225) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3120) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2744) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3120) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2744) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3120) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2744) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3120) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2744) at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:535) at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1925) at android.app.Activity.dispatchTouchEvent(Activity.java:4298) at com.android.launcher3.Launcher.dispatchTouchEvent(Launcher.java:2189) at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:493) at android.view.View.dispatchPointerEvent(View.java:14884) at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:6595) at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:6396) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5874) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5931) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:5897) at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:6062) at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:5905) at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:6119) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5878) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5931) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:5897) at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:5905) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5878) at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:8891) at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:8807) at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:8776) at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:9027) at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:266) at android.os.MessageQueue.nativePollOnce(Native Method) at android.os.MessageQueue.next(MessageQueue.java:342) at android.os.Looper.loopOnce(Looper.java:182) at android.os.Looper.loop(Looper.java:357) at android.app.ActivityThread.main(ActivityThread.java:8089) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1026) Signed-off-by: Pranav Vashi --- src/com/android/launcher3/views/BaseDragLayer.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/com/android/launcher3/views/BaseDragLayer.java b/src/com/android/launcher3/views/BaseDragLayer.java index 38406620f0..916c0cf734 100644 --- a/src/com/android/launcher3/views/BaseDragLayer.java +++ b/src/com/android/launcher3/views/BaseDragLayer.java @@ -461,8 +461,10 @@ public void mapCoordInSelfToDescendant(View descendant, float[] coord) { public void mapCoordInSelfToDescendant(View descendant, int[] coord) { mTmpXY[0] = coord[0]; mTmpXY[1] = coord[1]; - Utilities.mapCoordInSelfToDescendant(descendant, this, mTmpXY); - Utilities.roundArray(mTmpXY, coord); + if (descendant != null) { + Utilities.mapCoordInSelfToDescendant(descendant, this, mTmpXY); + Utilities.roundArray(mTmpXY, coord); + } } public void getViewRectRelativeToSelf(View v, Rect r) { From a89afae7607d36a0008010722491356bd35be26d Mon Sep 17 00:00:00 2001 From: hundeva Date: Sat, 12 Oct 2019 07:33:14 +0000 Subject: [PATCH 007/376] Launcher3: Add restart action for toggling settings Squashed: From: elpaablo Date: Wed, 17 Mar 2021 11:11:29 +0000 Subject: [PATCH 094/300] Launcher3: Move restart check to home page It's just a flag check. And avoids having to implement a listener for the home key (and still miss home gesture). Also, restarting the launcher when navigating to previous settings page doesn't seem right. This way, the launcher is restarted once, if needed, when user goes back to home page, which is where the changes are visible, anyway. Signed-off-by: Pranav Vashi @neobuddy89: Updated for Android 15 and Android 16. Co-authored-by: Pranav Vashi Signed-off-by: Pranav Vashi --- src/com/android/launcher3/Launcher.java | 2 ++ src/com/android/launcher3/LauncherAppState.kt | 13 +++++++++++++ src/com/android/launcher3/Utilities.java | 14 ++++++++++++++ .../launcher3/util/DaggerSingletonObject.java | 19 ++++++++++++++++++- 4 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index e82551305e..8242b6dca2 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -1212,6 +1212,8 @@ protected void onResume() { DragView.removeAllViews(this); TraceHelper.INSTANCE.endSection(); + + LauncherAppState.INSTANCE.executeIfCreated(app -> app.checkIfRestartNeeded()); } @Override diff --git a/src/com/android/launcher3/LauncherAppState.kt b/src/com/android/launcher3/LauncherAppState.kt index ff84c3c863..5b27f07a59 100644 --- a/src/com/android/launcher3/LauncherAppState.kt +++ b/src/com/android/launcher3/LauncherAppState.kt @@ -36,7 +36,20 @@ constructor( @Named("SAFE_MODE") val isSafeModeEnabled: Boolean, ) { + fun setNeedsRestart() { + needsRestart = true + } + + fun checkIfRestartNeeded() { + // we destroyed Settings activity with the back button + // so we force a restart now if needed without waiting for home button press + if (needsRestart) { + Utilities.restart(context) + } + } + companion object { + @JvmField var needsRestart: Boolean = false @JvmField var INSTANCE = DaggerSingletonObject { it.launcherAppState } diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index 72a1ea7b8a..cbf6b37bcb 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -112,6 +112,8 @@ import java.util.function.Predicate; import java.util.stream.Collectors; +import static com.android.launcher3.util.Executors.MODEL_EXECUTOR; + /** * Various utilities shared amongst the Launcher's classes. */ @@ -137,6 +139,8 @@ public final class Utilities { public static final boolean ATLEAST_V = Build.VERSION.SDK_INT >= VERSION_CODES.VANILLA_ICE_CREAM; + private static final long WAIT_BEFORE_RESTART = 250; + /** * Set on a motion event dispatched from the nav bar. See {@link MotionEvent#setEdgeFlags(int)}. */ @@ -1021,6 +1025,16 @@ public static void debugLog(String tag, String message) { } } + public static void restart(final Context context) { + MODEL_EXECUTOR.execute(() -> { + try { + Thread.sleep(WAIT_BEFORE_RESTART); + } catch (Exception ignored) { + } + android.os.Process.killProcess(android.os.Process.myPid()); + }); + } + /** * Returns whether mouse interaction changes intended for the desktop form factor should be * enabled. diff --git a/src/com/android/launcher3/util/DaggerSingletonObject.java b/src/com/android/launcher3/util/DaggerSingletonObject.java index a4bd30a193..6d49340fb2 100644 --- a/src/com/android/launcher3/util/DaggerSingletonObject.java +++ b/src/com/android/launcher3/util/DaggerSingletonObject.java @@ -21,6 +21,7 @@ import com.android.launcher3.dagger.LauncherAppComponent; import com.android.launcher3.dagger.LauncherComponentProvider; +import java.util.function.Consumer; import java.util.function.Function; /** @@ -30,12 +31,28 @@ public class DaggerSingletonObject { private final Function mFunction; + private T mValue; public DaggerSingletonObject(Function function) { mFunction = function; } public T get(Context context) { - return mFunction.apply(LauncherComponentProvider.get(context)); + mValue = mFunction.apply(LauncherComponentProvider.get(context)); + return mValue; + } + + /** + * Executes the callback is the value is already created + * @return true if the callback was executed, false otherwise + */ + public boolean executeIfCreated(Consumer callback) { + T v = mValue; + if (v != null) { + callback.accept(v); + return true; + } else { + return false; + } } } From 4f2326d19752d4837c186e969af37b13aeb96b50 Mon Sep 17 00:00:00 2001 From: Pranav Vashi Date: Sun, 6 Feb 2022 02:39:35 +0530 Subject: [PATCH 008/376] Launcher3: Restart launcher on google app change * Refreshes google elements in home screen. Signed-off-by: Pranav Vashi --- .../launcher3/model/tasks/PackageUpdatedTask.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/com/android/launcher3/model/tasks/PackageUpdatedTask.java b/src/com/android/launcher3/model/tasks/PackageUpdatedTask.java index c4400995fe..135d4376aa 100644 --- a/src/com/android/launcher3/model/tasks/PackageUpdatedTask.java +++ b/src/com/android/launcher3/model/tasks/PackageUpdatedTask.java @@ -36,6 +36,7 @@ import com.android.launcher3.Flags; import com.android.launcher3.LauncherModel.ModelUpdateTask; import com.android.launcher3.LauncherSettings.Favorites; +import com.android.launcher3.Utilities; import com.android.launcher3.icons.IconCache; import com.android.launcher3.logging.FileLog; import com.android.launcher3.model.AllAppsList; @@ -97,11 +98,15 @@ public void execute(@NonNull ModelTaskController taskController, @NonNull BgData final FlagOp flagOp = FlagOp.NO_OP.removeFlag(FLAG_DISABLED_NOT_AVAILABLE); final HashSet removedComponents = new HashSet<>(); final HashMap> activitiesLists = new HashMap<>(); + boolean needsRestart = false; for (String packageName : mPackages) { iconCache.updateIconsForPkg(packageName, mUser); activitiesLists.put( packageName, appsList.updatePackage(context, packageName, mUser, removedComponents)); + if (isTargetPackage(packageName)) { + needsRestart = true; + } } taskController.bindApplicationsIfNeeded(); @@ -306,6 +311,10 @@ public void execute(@NonNull ModelTaskController taskController, @NonNull BgData } taskController.bindUpdatedWidgets(dataModel); } + + if (needsRestart) { + Utilities.restart(context); + } } /** @@ -338,4 +347,8 @@ private boolean shouldRemoveRestoredShortcut(WorkspaceItemInfo itemInfo) { && !itemInfo.isArchived() && itemInfo.itemType == ITEM_TYPE_DEEP_SHORTCUT; } + + private boolean isTargetPackage(String packageName) { + return packageName.equals(Utilities.GSA_PACKAGE); + } } From 7eea2867d11a60d6cb914cda01e9744e27d10bcc Mon Sep 17 00:00:00 2001 From: elpaablo Date: Tue, 19 Apr 2022 13:22:35 +0100 Subject: [PATCH 009/376] Launcher3: Add a preference to manually restart the launcher Signed-off-by: Dmitrii Signed-off-by: Pranav Vashi --- res/values/cr_strings.xml | 4 +++ res/xml/launcher_misc_preferences.xml | 7 +++- .../preference/RestartPreference.java | 35 +++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 src/com/android/launcher3/settings/preference/RestartPreference.java diff --git a/res/values/cr_strings.xml b/res/values/cr_strings.xml index a7974582ba..2c65db95d0 100644 --- a/res/values/cr_strings.xml +++ b/res/values/cr_strings.xml @@ -81,4 +81,8 @@ Suggestions For All Apps & Home screen suggestions + + + Restart + Restart the launcher manually to apply any pending settings diff --git a/res/xml/launcher_misc_preferences.xml b/res/xml/launcher_misc_preferences.xml index 9053598b4c..1f6c451982 100644 --- a/res/xml/launcher_misc_preferences.xml +++ b/res/xml/launcher_misc_preferences.xml @@ -36,5 +36,10 @@ android:summary="@string/suggestion_pref_screen_desc"> - + + + diff --git a/src/com/android/launcher3/settings/preference/RestartPreference.java b/src/com/android/launcher3/settings/preference/RestartPreference.java new file mode 100644 index 0000000000..a560656bc6 --- /dev/null +++ b/src/com/android/launcher3/settings/preference/RestartPreference.java @@ -0,0 +1,35 @@ +package com.android.launcher3.settings.preference; + +import android.content.Context; +import android.content.Intent; +import android.util.AttributeSet; +import com.android.launcher3.Utilities; + +import androidx.preference.Preference; + +public class RestartPreference extends Preference { + + + public RestartPreference( + Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { + super(context, attrs, defStyleAttr, defStyleRes); + } + + public RestartPreference(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + + public RestartPreference(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public RestartPreference(Context context) { + super(context); + } + + @Override + protected void onClick() { + super.onClick(); + Utilities.restart(getContext()); + } +} From efc71a0e8560c3d74461087269b5859030fc7e45 Mon Sep 17 00:00:00 2001 From: minaripenguin Date: Tue, 18 Apr 2023 11:45:07 +0800 Subject: [PATCH 010/376] Launcher3: Show a toast when restarting the launcher * Some users were reporting the launcher restart after config change as bug. Show a toast to let the user know its intended. Signed-off-by: minaripenguin [@neobuddy89: Update strings.] Signed-off-by: Pranav Vashi --- res/values/cr_strings.xml | 3 +++ src/com/android/launcher3/LauncherAppState.kt | 2 ++ src/com/android/launcher3/model/tasks/PackageUpdatedTask.java | 3 +++ .../launcher3/settings/preference/RestartPreference.java | 3 +++ 4 files changed, 11 insertions(+) diff --git a/res/values/cr_strings.xml b/res/values/cr_strings.xml index 2c65db95d0..fa86ee0322 100644 --- a/res/values/cr_strings.xml +++ b/res/values/cr_strings.xml @@ -85,4 +85,7 @@ Restart Restart the launcher manually to apply any pending settings + Restarting launcher... + Restarting launcher to apply changes... + Restarting launcher to update launcher components... diff --git a/src/com/android/launcher3/LauncherAppState.kt b/src/com/android/launcher3/LauncherAppState.kt index 5b27f07a59..ea8deece30 100644 --- a/src/com/android/launcher3/LauncherAppState.kt +++ b/src/com/android/launcher3/LauncherAppState.kt @@ -16,6 +16,7 @@ package com.android.launcher3 import android.content.Context +import android.widget.Toast; import com.android.launcher3.dagger.ApplicationContext import com.android.launcher3.icons.IconCache import com.android.launcher3.icons.LauncherIconProvider @@ -44,6 +45,7 @@ constructor( // we destroyed Settings activity with the back button // so we force a restart now if needed without waiting for home button press if (needsRestart) { + Toast.makeText(context, R.string.restarting_launcher_changes, Toast.LENGTH_SHORT).show(); Utilities.restart(context) } } diff --git a/src/com/android/launcher3/model/tasks/PackageUpdatedTask.java b/src/com/android/launcher3/model/tasks/PackageUpdatedTask.java index 135d4376aa..1d82141159 100644 --- a/src/com/android/launcher3/model/tasks/PackageUpdatedTask.java +++ b/src/com/android/launcher3/model/tasks/PackageUpdatedTask.java @@ -29,6 +29,7 @@ import android.content.pm.LauncherApps; import android.content.pm.ShortcutInfo; import android.os.UserHandle; +import android.widget.Toast; import android.util.Log; import androidx.annotation.NonNull; @@ -36,6 +37,7 @@ import com.android.launcher3.Flags; import com.android.launcher3.LauncherModel.ModelUpdateTask; import com.android.launcher3.LauncherSettings.Favorites; +import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.icons.IconCache; import com.android.launcher3.logging.FileLog; @@ -313,6 +315,7 @@ public void execute(@NonNull ModelTaskController taskController, @NonNull BgData } if (needsRestart) { + Toast.makeText(context, R.string.updating_launcher_components, Toast.LENGTH_SHORT).show(); Utilities.restart(context); } } diff --git a/src/com/android/launcher3/settings/preference/RestartPreference.java b/src/com/android/launcher3/settings/preference/RestartPreference.java index a560656bc6..4c2a0c5f92 100644 --- a/src/com/android/launcher3/settings/preference/RestartPreference.java +++ b/src/com/android/launcher3/settings/preference/RestartPreference.java @@ -3,6 +3,8 @@ import android.content.Context; import android.content.Intent; import android.util.AttributeSet; +import android.widget.Toast; +import com.android.launcher3.R; import com.android.launcher3.Utilities; import androidx.preference.Preference; @@ -30,6 +32,7 @@ public RestartPreference(Context context) { @Override protected void onClick() { super.onClick(); + Toast.makeText(getContext(), R.string.restarting_launcher, Toast.LENGTH_SHORT).show(); Utilities.restart(getContext()); } } From d28da7ae3d9462261f89bae51b47ea1b2395383f Mon Sep 17 00:00:00 2001 From: Adithya R Date: Sat, 8 Feb 2025 23:34:07 +0100 Subject: [PATCH 011/376] Launcher3: Improve restart logic - Use main executor - Use System.exit() instead of killProcess() - Reduce wait period Change-Id: Ibc27b412153110eada13b850b7dfcf32d00a0f2b Signed-off-by: Pranav Vashi --- src/com/android/launcher3/LauncherAppState.kt | 2 +- src/com/android/launcher3/Utilities.java | 16 ++++++---------- .../model/tasks/PackageUpdatedTask.java | 2 +- .../settings/preference/RestartPreference.java | 2 +- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/com/android/launcher3/LauncherAppState.kt b/src/com/android/launcher3/LauncherAppState.kt index ea8deece30..3f7269fbbd 100644 --- a/src/com/android/launcher3/LauncherAppState.kt +++ b/src/com/android/launcher3/LauncherAppState.kt @@ -46,7 +46,7 @@ constructor( // so we force a restart now if needed without waiting for home button press if (needsRestart) { Toast.makeText(context, R.string.restarting_launcher_changes, Toast.LENGTH_SHORT).show(); - Utilities.restart(context) + Utilities.restart() } } diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index cbf6b37bcb..548c0ee9c0 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -112,7 +112,7 @@ import java.util.function.Predicate; import java.util.stream.Collectors; -import static com.android.launcher3.util.Executors.MODEL_EXECUTOR; +import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; /** * Various utilities shared amongst the Launcher's classes. @@ -139,7 +139,7 @@ public final class Utilities { public static final boolean ATLEAST_V = Build.VERSION.SDK_INT >= VERSION_CODES.VANILLA_ICE_CREAM; - private static final long WAIT_BEFORE_RESTART = 250; + private static final long WAIT_BEFORE_RESTART = 100; // ms /** * Set on a motion event dispatched from the nav bar. See {@link MotionEvent#setEdgeFlags(int)}. @@ -1025,14 +1025,10 @@ public static void debugLog(String tag, String message) { } } - public static void restart(final Context context) { - MODEL_EXECUTOR.execute(() -> { - try { - Thread.sleep(WAIT_BEFORE_RESTART); - } catch (Exception ignored) { - } - android.os.Process.killProcess(android.os.Process.myPid()); - }); + public static void restart() { + MAIN_EXECUTOR.getHandler().postDelayed(() -> { + System.exit(0); + }, WAIT_BEFORE_RESTART); } /** diff --git a/src/com/android/launcher3/model/tasks/PackageUpdatedTask.java b/src/com/android/launcher3/model/tasks/PackageUpdatedTask.java index 1d82141159..180e5de530 100644 --- a/src/com/android/launcher3/model/tasks/PackageUpdatedTask.java +++ b/src/com/android/launcher3/model/tasks/PackageUpdatedTask.java @@ -316,7 +316,7 @@ public void execute(@NonNull ModelTaskController taskController, @NonNull BgData if (needsRestart) { Toast.makeText(context, R.string.updating_launcher_components, Toast.LENGTH_SHORT).show(); - Utilities.restart(context); + Utilities.restart(); } } diff --git a/src/com/android/launcher3/settings/preference/RestartPreference.java b/src/com/android/launcher3/settings/preference/RestartPreference.java index 4c2a0c5f92..6c14f3a05b 100644 --- a/src/com/android/launcher3/settings/preference/RestartPreference.java +++ b/src/com/android/launcher3/settings/preference/RestartPreference.java @@ -33,6 +33,6 @@ public RestartPreference(Context context) { protected void onClick() { super.onClick(); Toast.makeText(getContext(), R.string.restarting_launcher, Toast.LENGTH_SHORT).show(); - Utilities.restart(getContext()); + Utilities.restart(); } } From 25334026a0b4b5da66ee86a3c718944e0a74d89d Mon Sep 17 00:00:00 2001 From: rmp22 <195054967+rmp22@users.noreply.github.com> Date: Thu, 12 Jun 2025 07:43:03 +0800 Subject: [PATCH 012/376] Launcher3: Improve restart logic issue https://github.com/AxionAOSP/issue_tracker/issues/46 Change-Id: Ie89c528621ffc44a7d6d0b4680d427c43823f77b Co-authored-by: Pranav Vashi Signed-off-by: rmp22 <195054967+rmp22@users.noreply.github.com> Signed-off-by: Pranav Vashi --- .../android/quickstep/util/RecentsAtomicAnimationFactory.kt | 4 ++++ src/com/android/launcher3/Launcher.java | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/quickstep/src/com/android/quickstep/util/RecentsAtomicAnimationFactory.kt b/quickstep/src/com/android/quickstep/util/RecentsAtomicAnimationFactory.kt index 7de827e1f5..c5cf7d7979 100644 --- a/quickstep/src/com/android/quickstep/util/RecentsAtomicAnimationFactory.kt +++ b/quickstep/src/com/android/quickstep/util/RecentsAtomicAnimationFactory.kt @@ -34,6 +34,7 @@ import com.android.app.animation.Interpolators.LINEAR import com.android.app.animation.Interpolators.OVERSHOOT_0_75 import com.android.app.animation.Interpolators.OVERSHOOT_1_2 import com.android.app.animation.Interpolators.clampToProgress +import com.android.launcher3.LauncherAppState import com.android.launcher3.LauncherState.ALL_APPS import com.android.launcher3.LauncherState.HINT_STATE import com.android.launcher3.LauncherState.HINT_STATE_TWO_BUTTON @@ -195,6 +196,9 @@ CONTAINER : StatefulContainer { val isPinnedTaskbar = TaskbarFeatureEvaluator.INSTANCE.get(container).isPinned val isThreeButton = (DisplayController.getNavigationMode(container) == NavigationMode.THREE_BUTTONS) + if (toState == NORMAL) { + LauncherAppState.INSTANCE.executeIfCreated(LauncherAppState::checkIfRestartNeeded) + } if ((fromState == OVERVIEW || fromState == OVERVIEW_SPLIT_SELECT) && toState == NORMAL) { applyOverviewToHomeAnimConfig( fromState, diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 8242b6dca2..e82551305e 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -1212,8 +1212,6 @@ protected void onResume() { DragView.removeAllViews(this); TraceHelper.INSTANCE.endSection(); - - LauncherAppState.INSTANCE.executeIfCreated(app -> app.checkIfRestartNeeded()); } @Override From cc2455dfa6b2dffbd02ff42d3b4aebeb9df9af2b Mon Sep 17 00:00:00 2001 From: Pranav Vashi Date: Sun, 27 Jul 2025 19:25:56 +0530 Subject: [PATCH 013/376] Launcher3: Debounce restart calls Signed-off-by: Pranav Vashi --- src/com/android/launcher3/Utilities.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index 548c0ee9c0..306887a696 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -139,7 +139,9 @@ public final class Utilities { public static final boolean ATLEAST_V = Build.VERSION.SDK_INT >= VERSION_CODES.VANILLA_ICE_CREAM; - private static final long WAIT_BEFORE_RESTART = 100; // ms + private static final long WAIT_BEFORE_RESTART = 300; // ms + private static final Object sRestartLock = new Object(); + private static boolean sRestartScheduled = false; /** * Set on a motion event dispatched from the nav bar. See {@link MotionEvent#setEdgeFlags(int)}. @@ -1026,6 +1028,13 @@ public static void debugLog(String tag, String message) { } public static void restart() { + synchronized (sRestartLock) { + if (sRestartScheduled) { + return; + } + sRestartScheduled = true; + } + MAIN_EXECUTOR.getHandler().postDelayed(() -> { System.exit(0); }, WAIT_BEFORE_RESTART); From 4999cf333e556481db63eeda5c0a6f033fa32344 Mon Sep 17 00:00:00 2001 From: Thecrazyskull Date: Fri, 10 Feb 2017 09:38:50 -0500 Subject: [PATCH 014/376] Launcher3: Double tap on home screen to turn off screen Co-authored-by: Hikari-no-Tenshi Change-Id: I554c005d5e523aca0842c78a353686e86af1a7f2 Signed-off-by: Pranav Vashi --- AndroidManifest-common.xml | 1 + res/values/cr_strings.xml | 4 ++++ res/xml/launcher_home_screen_preferences.xml | 8 ++++++++ src/com/android/launcher3/LauncherPrefs.kt | 1 + .../launcher3/touch/WorkspaceTouchListener.java | 14 ++++++++++++++ 5 files changed, 28 insertions(+) diff --git a/AndroidManifest-common.xml b/AndroidManifest-common.xml index ad598818e1..3ae6aea714 100644 --- a/AndroidManifest-common.xml +++ b/AndroidManifest-common.xml @@ -32,6 +32,7 @@ --> + diff --git a/res/values/cr_strings.xml b/res/values/cr_strings.xml index fa86ee0322..9381c585a7 100644 --- a/res/values/cr_strings.xml +++ b/res/values/cr_strings.xml @@ -88,4 +88,8 @@ Restarting launcher... Restarting launcher to apply changes... Restarting launcher to update launcher components... + + + Tap to sleep + Double-tap an empty area in the home screen to turn off the display diff --git a/res/xml/launcher_home_screen_preferences.xml b/res/xml/launcher_home_screen_preferences.xml index 265ec21da1..4617e9410f 100644 --- a/res/xml/launcher_home_screen_preferences.xml +++ b/res/xml/launcher_home_screen_preferences.xml @@ -41,6 +41,14 @@ launcher:logIdOff="614" launcher:iconSpaceReserved="false" /> + + workspace) { @@ -82,6 +86,7 @@ public WorkspaceTouchListener(Launcher launcher, Workspace workspace) { // Use twice the touch slop as we are looking for long press which is more // likely to cause movement. mTouchSlop = 2 * ViewConfiguration.get(launcher).getScaledTouchSlop(); + mPowerManager = workspace.getContext().getSystemService(PowerManager.class); mGestureDetector = new GestureDetector(workspace.getContext(), this); } @@ -222,4 +227,13 @@ private void maybeShowMenu() { } } } + + @Override + public boolean onDoubleTap(MotionEvent event) { + if (LauncherPrefs.SLEEP_GESTURE.get(mWorkspace.getContext())) { + mPowerManager.goToSleep(event.getEventTime()); + return true; + } + return false; + } } From e4a6ae1df34c9b6a35691ba3dd8f0c3cfdbc67b6 Mon Sep 17 00:00:00 2001 From: LordShenron Date: Sun, 2 Apr 2023 20:16:50 +0800 Subject: [PATCH 015/376] Launcher3: Vibrate on double tap to sleep [HELLBOY017: Make it optional] Signed-off-by: LordShenron Signed-off-by: Pranav Vashi --- res/values/cr_strings.xml | 2 ++ res/xml/launcher_home_screen_preferences.xml | 9 +++++++++ src/com/android/launcher3/LauncherPrefs.kt | 1 + .../android/launcher3/touch/WorkspaceTouchListener.java | 7 ++++++- 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/res/values/cr_strings.xml b/res/values/cr_strings.xml index 9381c585a7..3204286462 100644 --- a/res/values/cr_strings.xml +++ b/res/values/cr_strings.xml @@ -92,4 +92,6 @@ Tap to sleep Double-tap an empty area in the home screen to turn off the display + Vibrate on tap to sleep + Provide haptic feedback on double-tap to sleep gesture diff --git a/res/xml/launcher_home_screen_preferences.xml b/res/xml/launcher_home_screen_preferences.xml index 4617e9410f..e88f56cff9 100644 --- a/res/xml/launcher_home_screen_preferences.xml +++ b/res/xml/launcher_home_screen_preferences.xml @@ -49,6 +49,15 @@ android:persistent="true" launcher:iconSpaceReserved="false" /> + + Date: Fri, 7 Nov 2025 06:23:02 +0530 Subject: [PATCH 016/376] Launcher3: Remove D2S vibrate if not supported Signed-off-by: Pranav Vashi --- res/xml/launcher_home_screen_preferences.xml | 1 + .../android/launcher3/settings/SettingsHomescreen.java | 10 ++++++++++ src/com/android/launcher3/util/VibratorWrapper.java | 6 +++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/res/xml/launcher_home_screen_preferences.xml b/res/xml/launcher_home_screen_preferences.xml index e88f56cff9..7150b705b3 100644 --- a/res/xml/launcher_home_screen_preferences.xml +++ b/res/xml/launcher_home_screen_preferences.xml @@ -20,6 +20,7 @@ xmlns:settings="http://schemas.android.com/apk/res/com.android.launcher3"> settingsCache.register(HAPTIC_FEEDBACK_URI, mHapticChangeListener)); @@ -105,6 +105,10 @@ public void vibrate(VibrationEffect vibrationEffect) { } } + public boolean hasVibrator() { + return mHasVibrator; + } + /** * Vibrates with a single primitive, if supported, or use a fallback effect instead. This only * vibrates if haptic feedback is available and enabled. From 65bde28f3682eec241ee8946f4cdeefa1f621935 Mon Sep 17 00:00:00 2001 From: jhonboy121 Date: Tue, 15 Mar 2022 18:55:35 +0530 Subject: [PATCH 017/376] Launcher3: Show clear all button in recents overview idoybh (YAAP): Keep rightmost neobuddy89: Updated for A15 QPR2 Signed-off-by: Pranav Vashi --- quickstep/res/drawable/ic_clear_all.xml | 19 +++++++++++++++++++ .../res/layout/overview_actions_container.xml | 13 +++++++++++-- .../states/BackgroundAppState.java | 1 - .../uioverrides/states/OverviewState.java | 4 ++-- .../android/quickstep/TaskOverlayFactory.java | 15 +++++++++++++++ .../quickstep/views/OverviewActionsView.java | 5 ++++- .../android/quickstep/views/RecentsView.java | 4 ++++ 7 files changed, 55 insertions(+), 6 deletions(-) create mode 100644 quickstep/res/drawable/ic_clear_all.xml diff --git a/quickstep/res/drawable/ic_clear_all.xml b/quickstep/res/drawable/ic_clear_all.xml new file mode 100644 index 0000000000..00e8fd42a3 --- /dev/null +++ b/quickstep/res/drawable/ic_clear_all.xml @@ -0,0 +1,19 @@ + + + + + \ No newline at end of file diff --git a/quickstep/res/layout/overview_actions_container.xml b/quickstep/res/layout/overview_actions_container.xml index ce54028256..c90bc0a06a 100644 --- a/quickstep/res/layout/overview_actions_container.xml +++ b/quickstep/res/layout/overview_actions_container.xml @@ -34,6 +34,7 @@ android:id="@+id/action_screenshot" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:layout_marginHorizontal="6dp" android:drawableStart="@drawable/ic_screenshot" android:text="@string/action_screenshot" /> @@ -41,10 +42,18 @@ android:id="@+id/action_split" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginStart="@dimen/overview_actions_button_spacing" + android:layout_marginHorizontal="6dp" android:text="@string/action_split" android:visibility="gone" /> +