From 46c86784475f69d7464676b1fbde411e5ce95807 Mon Sep 17 00:00:00 2001 From: Selim Cinek Date: Fri, 18 Feb 2022 14:24:39 +0100 Subject: [PATCH 01/11] Passing in the launch cookie for widget broadcast trampolines The launch cookie can now be transfered via the broadcast Fixes: 220290671 Test: add Photos widget, return properly to widget Change-Id: Ibfe9e5232317837f3111459212a4b016b5828ef4 --- .../launcher3/BaseQuickstepLauncher.java | 28 ++++++++++++++----- .../QuickstepInteractionHandler.java | 14 ++++++---- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java index af4f49d324..367c390a92 100644 --- a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java @@ -41,6 +41,7 @@ import android.hardware.SensorManager; import android.hardware.devicestate.DeviceStateManager; import android.os.Bundle; import android.os.CancellationSignal; +import android.os.IBinder; import android.view.Display; import android.view.View; import android.view.WindowInsets; @@ -533,11 +534,26 @@ public abstract class BaseQuickstepLauncher extends Launcher } /** - * Adds a new launch cookie for the activity launch of the given {@param info} if supported. + * Adds a new launch cookie for the activity launch if supported. + * + * @param info the item info for the launch + * @param opts the options to set the launchCookie on. */ public void addLaunchCookie(ItemInfo info, ActivityOptions opts) { + IBinder launchCookie = getLaunchCookie(info); + if (launchCookie != null) { + opts.setLaunchCookie(launchCookie); + } + } + + /** + * Return a new launch cookie for the activity launch if supported. + * + * @param info the item info for the launch + */ + public IBinder getLaunchCookie(ItemInfo info) { if (info == null) { - return; + return null; } switch (info.container) { case LauncherSettings.Favorites.CONTAINER_DESKTOP: @@ -551,8 +567,7 @@ public abstract class BaseQuickstepLauncher extends Launcher break; } // Reset any existing launch cookies associated with the cookie - opts.setLaunchCookie(ObjectWrapper.wrap(NO_MATCHING_ID)); - return; + return ObjectWrapper.wrap(NO_MATCHING_ID); } switch (info.itemType) { case LauncherSettings.Favorites.ITEM_TYPE_APPLICATION: @@ -563,10 +578,9 @@ public abstract class BaseQuickstepLauncher extends Launcher break; default: // Reset any existing launch cookies associated with the cookie - opts.setLaunchCookie(ObjectWrapper.wrap(NO_MATCHING_ID)); - return; + return ObjectWrapper.wrap(NO_MATCHING_ID); } - opts.setLaunchCookie(ObjectWrapper.wrap(new Integer(info.id))); + return ObjectWrapper.wrap(new Integer(info.id)); } public void setHintUserWillBeActive() { diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepInteractionHandler.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepInteractionHandler.java index c058aa7bba..be7535a90e 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepInteractionHandler.java +++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepInteractionHandler.java @@ -21,6 +21,7 @@ import android.app.ActivityOptions; import android.app.ActivityTaskManager; import android.app.PendingIntent; import android.content.Intent; +import android.os.IBinder; import android.os.RemoteException; import android.util.Log; import android.util.Pair; @@ -58,6 +59,12 @@ class QuickstepInteractionHandler implements RemoteViews.InteractionHandler { Pair options = remoteResponse.getLaunchOptions(view); ActivityOptionsWrapper activityOptions = mLauncher.getAppTransitionManager() .getActivityLaunchOptions(hostView); + Object itemInfo = hostView.getTag(); + IBinder launchCookie = null; + if (itemInfo instanceof ItemInfo) { + launchCookie = mLauncher.getLaunchCookie((ItemInfo) itemInfo); + activityOptions.options.setLaunchCookie(launchCookie); + } if (Utilities.ATLEAST_S && !pendingIntent.isActivity()) { // In the event this pending intent eventually launches an activity, i.e. a trampoline, // use the Quickstep transition animation. @@ -65,17 +72,14 @@ class QuickstepInteractionHandler implements RemoteViews.InteractionHandler { ActivityTaskManager.getService() .registerRemoteAnimationForNextActivityStart( pendingIntent.getCreatorPackage(), - activityOptions.options.getRemoteAnimationAdapter()); + activityOptions.options.getRemoteAnimationAdapter(), + launchCookie); } catch (RemoteException e) { // Do nothing. } } activityOptions.options.setPendingIntentLaunchFlags(Intent.FLAG_ACTIVITY_NEW_TASK); activityOptions.options.setSplashScreenStyle(SplashScreen.SPLASH_SCREEN_STYLE_EMPTY); - Object itemInfo = hostView.getTag(); - if (itemInfo instanceof ItemInfo) { - mLauncher.addLaunchCookie((ItemInfo) itemInfo, activityOptions.options); - } options = Pair.create(options.first, activityOptions.options); if (pendingIntent.isActivity()) { logAppLaunch(itemInfo); From 871759483b8e134c6d88db3fa61cf2f6c2043a01 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Wed, 16 Feb 2022 06:43:55 +0000 Subject: [PATCH 02/11] 1b/ Replace removed shared lib calls with direct calls Bug: 219861883 Test: Builds Change-Id: I7831d0de14286c9fa39fed59b168535e0a70d94d --- .../statehandlers/DepthController.java | 6 +++--- .../taskbar/TaskbarDragController.java | 18 ++++++++---------- ...skbarShortcutMenuAccessibilityDelegate.java | 4 +--- .../quickstep/QuickstepProcessInitializer.java | 6 +++--- .../com/android/quickstep/TaskIconCache.java | 12 ++++++++++-- .../android/quickstep/TaskShortcutFactory.java | 3 +-- .../src/com/android/quickstep/ViewUtils.java | 2 -- 7 files changed, 26 insertions(+), 25 deletions(-) diff --git a/quickstep/src/com/android/launcher3/statehandlers/DepthController.java b/quickstep/src/com/android/launcher3/statehandlers/DepthController.java index d54b9e774b..3b02599ada 100644 --- a/quickstep/src/com/android/launcher3/statehandlers/DepthController.java +++ b/quickstep/src/com/android/launcher3/statehandlers/DepthController.java @@ -23,6 +23,7 @@ import static com.android.launcher3.states.StateAnimationConfig.SKIP_DEPTH_CONTR import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; +import android.app.WallpaperManager; import android.os.IBinder; import android.os.SystemProperties; import android.util.FloatProperty; @@ -42,7 +43,6 @@ import com.android.launcher3.anim.PendingAnimation; import com.android.launcher3.statemanager.StateManager.StateHandler; import com.android.launcher3.states.StateAnimationConfig; import com.android.systemui.shared.system.BlurUtils; -import com.android.systemui.shared.system.WallpaperManagerCompat; import java.io.PrintWriter; import java.util.function.Consumer; @@ -127,7 +127,7 @@ public class DepthController implements StateHandler, */ private int mMaxBlurRadius; private boolean mCrossWindowBlursEnabled; - private WallpaperManagerCompat mWallpaperManager; + private WallpaperManager mWallpaperManager; private SurfaceControl mSurface; /** * How visible the -1 overlay is, from 0 to 1. @@ -168,7 +168,7 @@ public class DepthController implements StateHandler, private void ensureDependencies() { if (mWallpaperManager == null) { mMaxBlurRadius = mLauncher.getResources().getInteger(R.integer.max_depth_blur_radius); - mWallpaperManager = new WallpaperManagerCompat(mLauncher); + mWallpaperManager = mLauncher.getSystemService(WallpaperManager.class); } if (mLauncher.getRootView() != null && mOnAttachListener == null) { diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java index c9f7f7e528..12b11959e8 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java @@ -66,8 +66,6 @@ import com.android.launcher3.shortcuts.DeepShortcutView; import com.android.launcher3.shortcuts.ShortcutDragPreviewProvider; import com.android.launcher3.util.LauncherBindableItemsContainer; import com.android.systemui.shared.recents.model.Task; -import com.android.systemui.shared.system.ClipDescriptionCompat; -import com.android.systemui.shared.system.LauncherAppsCompat; import java.io.PrintWriter; import java.util.Arrays; @@ -314,13 +312,13 @@ public class TaskbarDragController extends DragController im clipDescription = new ClipDescription(item.title, new String[] { item.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT - ? ClipDescriptionCompat.MIMETYPE_APPLICATION_SHORTCUT - : ClipDescriptionCompat.MIMETYPE_APPLICATION_ACTIVITY + ? ClipDescription.MIMETYPE_APPLICATION_SHORTCUT + : ClipDescription.MIMETYPE_APPLICATION_ACTIVITY }); intent = new Intent(); if (item.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) { String deepShortcutId = ((WorkspaceItemInfo) item).getDeepShortcutId(); - intent.putExtra(ClipDescriptionCompat.EXTRA_PENDING_INTENT, + intent.putExtra(ClipDescription.EXTRA_PENDING_INTENT, launcherApps.getShortcutIntent( item.getIntent().getPackage(), deepShortcutId, @@ -329,19 +327,19 @@ public class TaskbarDragController extends DragController im intent.putExtra(Intent.EXTRA_PACKAGE_NAME, item.getIntent().getPackage()); intent.putExtra(Intent.EXTRA_SHORTCUT_ID, deepShortcutId); } else { - intent.putExtra(ClipDescriptionCompat.EXTRA_PENDING_INTENT, - LauncherAppsCompat.getMainActivityLaunchIntent(launcherApps, - item.getIntent().getComponent(), null, item.user)); + intent.putExtra(ClipDescription.EXTRA_PENDING_INTENT, + launcherApps.getMainActivityLaunchIntent(item.getIntent().getComponent(), + null, item.user)); } intent.putExtra(Intent.EXTRA_USER, item.user); } else if (tag instanceof Task) { Task task = (Task) tag; clipDescription = new ClipDescription(task.titleDescription, new String[] { - ClipDescriptionCompat.MIMETYPE_APPLICATION_TASK + ClipDescription.MIMETYPE_APPLICATION_TASK }); intent = new Intent(); - intent.putExtra(ClipDescriptionCompat.EXTRA_TASK_ID, task.key.id); + intent.putExtra(Intent.EXTRA_TASK_ID, task.key.id); intent.putExtra(Intent.EXTRA_USER, UserHandle.of(task.key.userId)); } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarShortcutMenuAccessibilityDelegate.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarShortcutMenuAccessibilityDelegate.java index 158958217f..f131595126 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarShortcutMenuAccessibilityDelegate.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarShortcutMenuAccessibilityDelegate.java @@ -35,7 +35,6 @@ import com.android.launcher3.model.data.WorkspaceItemInfo; import com.android.launcher3.notification.NotificationListener; import com.android.launcher3.util.ShortcutUtil; import com.android.quickstep.SystemUiProxy; -import com.android.systemui.shared.system.LauncherAppsCompat; import java.util.List; @@ -94,8 +93,7 @@ public class TaskbarShortcutMenuAccessibilityDelegate info.user); } else { SystemUiProxy.INSTANCE.get(mContext).startIntent( - LauncherAppsCompat.getMainActivityLaunchIntent( - mLauncherApps, + mLauncherApps.getMainActivityLaunchIntent( item.getIntent().getComponent(), /* startActivityOptions= */null, item.user), diff --git a/quickstep/src/com/android/quickstep/QuickstepProcessInitializer.java b/quickstep/src/com/android/quickstep/QuickstepProcessInitializer.java index 678372cf24..55210200e0 100644 --- a/quickstep/src/com/android/quickstep/QuickstepProcessInitializer.java +++ b/quickstep/src/com/android/quickstep/QuickstepProcessInitializer.java @@ -23,11 +23,11 @@ import android.os.Build; import android.os.RemoteException; import android.os.UserManager; import android.util.Log; +import android.view.ThreadedRenderer; import com.android.launcher3.BuildConfig; import com.android.launcher3.MainProcessInitializer; import com.android.systemui.shared.system.InteractionJankMonitorWrapper; -import com.android.systemui.shared.system.ThreadedRendererCompat; @SuppressWarnings("unused") @TargetApi(Build.VERSION_CODES.R) @@ -60,8 +60,8 @@ public class QuickstepProcessInitializer extends MainProcessInitializer { super.init(context); // Elevate GPU priority for Quickstep and Remote animations. - ThreadedRendererCompat.setContextPriority( - ThreadedRendererCompat.EGL_CONTEXT_PRIORITY_HIGH_IMG); + ThreadedRenderer.setContextPriority( + ThreadedRenderer.EGL_CONTEXT_PRIORITY_HIGH_IMG); // Enable binder tracing on system server for calls originating from Launcher try { diff --git a/quickstep/src/com/android/quickstep/TaskIconCache.java b/quickstep/src/com/android/quickstep/TaskIconCache.java index 6c71da9a0e..300f085b2a 100644 --- a/quickstep/src/com/android/quickstep/TaskIconCache.java +++ b/quickstep/src/com/android/quickstep/TaskIconCache.java @@ -18,6 +18,7 @@ package com.android.quickstep; import static com.android.launcher3.uioverrides.QuickstepLauncher.GO_LOW_RAM_RECENTS_ENABLED; import static com.android.launcher3.util.DisplayController.CHANGE_DENSITY; +import android.app.ActivityManager; import android.app.ActivityManager.TaskDescription; import android.content.Context; import android.content.pm.ActivityInfo; @@ -48,7 +49,6 @@ import com.android.quickstep.util.TaskKeyLruCache; import com.android.systemui.shared.recents.model.Task; import com.android.systemui.shared.recents.model.Task.TaskKey; import com.android.systemui.shared.system.PackageManagerWrapper; -import com.android.systemui.shared.system.TaskDescriptionCompat; import java.util.concurrent.Executor; import java.util.function.Consumer; @@ -154,7 +154,7 @@ public class TaskIconCache implements DisplayInfoChangeListener { // Load icon // TODO: Load icon resource (b/143363444) - Bitmap icon = TaskDescriptionCompat.getIcon(desc, key.userId); + Bitmap icon = getIcon(desc, key.userId); if (icon != null) { entry.icon = getBitmapInfo( new BitmapDrawable(mContext.getResources(), icon), @@ -193,6 +193,14 @@ public class TaskIconCache implements DisplayInfoChangeListener { return entry; } + private Bitmap getIcon(ActivityManager.TaskDescription desc, int userId) { + if (desc.getInMemoryIcon() != null) { + return desc.getInMemoryIcon(); + } + return ActivityManager.TaskDescription.loadTaskDescriptionIcon( + desc.getIconFilename(), userId); + } + private String getBadgedContentDescription(ActivityInfo info, int userId, TaskDescription td) { PackageManager pm = mContext.getPackageManager(); String taskLabel = td == null ? null : Utilities.trim(td.getLabel()); diff --git a/quickstep/src/com/android/quickstep/TaskShortcutFactory.java b/quickstep/src/com/android/quickstep/TaskShortcutFactory.java index ecb30e52f1..e731b79a80 100644 --- a/quickstep/src/com/android/quickstep/TaskShortcutFactory.java +++ b/quickstep/src/com/android/quickstep/TaskShortcutFactory.java @@ -258,9 +258,8 @@ public interface TaskShortcutFactory { @Override protected ActivityOptions makeLaunchOptions(Activity activity) { - final ActivityCompat act = new ActivityCompat(activity); final int navBarPosition = WindowManagerWrapper.getInstance().getNavBarPosition( - act.getDisplayId()); + activity.getDisplayId()); if (navBarPosition == WindowManagerWrapper.NAV_BAR_POS_INVALID) { return null; } diff --git a/quickstep/src/com/android/quickstep/ViewUtils.java b/quickstep/src/com/android/quickstep/ViewUtils.java index e290be8e33..ab26d15284 100644 --- a/quickstep/src/com/android/quickstep/ViewUtils.java +++ b/quickstep/src/com/android/quickstep/ViewUtils.java @@ -21,10 +21,8 @@ import android.view.View; import android.view.ViewRootImpl; import com.android.launcher3.Utilities; -import com.android.systemui.shared.system.ViewRootImplCompat; import java.util.function.BooleanSupplier; -import java.util.function.LongConsumer; /** * Utility class for helpful methods related to {@link View} objects. From d68872426c43b36051652ece6a194c7e53d2180a Mon Sep 17 00:00:00 2001 From: Hyunyoung Song Date: Wed, 23 Feb 2022 23:00:49 -0800 Subject: [PATCH 03/11] Change the all apps atomic transition duration to 150 ms Test: manual TL;DR;; this value is used for tap on qsb all apps container atomic transition. 320 is value that used to be used in R when all apps travel distance used to be entire window height. In S, we reduced the travel distance to 1/3 of the height. Change-Id: Ib66f8a4408fd77350c31c5b894d9f8b2c889159f --- .../com/android/launcher3/uioverrides/states/AllAppsState.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java b/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java index 4583fc3f5e..cd14b3f75c 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java +++ b/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java @@ -38,7 +38,7 @@ public class AllAppsState extends LauncherState { @Override public int getTransitionDuration(Context context) { - return 320; + return 150; } @Override From f2f302bcf6d1625e173e4608ccc4e51b2b53927c Mon Sep 17 00:00:00 2001 From: Adam Cohen Date: Thu, 24 Feb 2022 08:24:26 -0800 Subject: [PATCH 04/11] Fix DnD logic for determining current drag screen / panel => we want to use the extremum of finger location and object center for snapping to a new screen (max when snapping to right, min when snapping to left) => when selecting a panel within the current screen, we want to rely strictly on the object center to determine selection; there is plenty of space to be consistent here, and extremum logic could cause thrashing back and forth with no page movement. Test: Manual. See videos in b/221104663. On two-panel and one-panel test dragging a widget between different screens with different starting positions of where the widget goes down. Bug 221104663 Change-Id: I8f0f13f07b753752087a90c4bacb76cfbf7aa5bf --- src/com/android/launcher3/Workspace.java | 30 ++++++++++++++++-------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index b3f5c0334f..df97d2fd06 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -2484,21 +2484,27 @@ public class Workspace extends PagedView } } + // Note, centerX represents the center of the object that is being dragged, visually. d.x + // represents the location of the finger within the dragged item. + float touchX; + float touchY = d.y; + + // Go through the pages and check if the dragged item is inside one of them. This block + // is responsible for determining whether we need to snap to a different screen. int nextPage = getNextPage(); - IntSet pageIndexesToVerify = IntSet.wrap(nextPage - 1, nextPage + 1); - if (isTwoPanelEnabled()) { - // If two panel is enabled, users can also drag items to nextPage + 2 - pageIndexesToVerify.add(nextPage + 2); - } - - int touchX = (int) Math.min(centerX, d.x); - int touchY = d.y; - - // Go through the pages and check if the dragged item is inside one of them + IntSet pageIndexesToVerify = IntSet.wrap(nextPage - 1, nextPage + + (isTwoPanelEnabled() ? 2 : 1)); for (int pageIndex : pageIndexesToVerify) { if (layout != null || isPageInTransition()) { break; } + + // When deciding whether to perform a page switch, we need to consider the most extreme + // X coordinate between the finger location and the center of the object being dragged. + // This is either the max or the min of the two depending on whether dragging to the + // left / right, respectively. + touchX = ((((pageIndex < nextPage) && !mIsRtl) || pageIndex > nextPage && mIsRtl) + ? Math.min(d.x, centerX) : Math.max(d.x, centerX)); layout = verifyInsidePage(pageIndex, touchX, touchY); } @@ -2507,12 +2513,16 @@ public class Workspace extends PagedView // on one panel just choose the current page. if (layout == null && nextPage >= 0 && nextPage < getPageCount()) { if (isTwoPanelEnabled()) { + // When determining which panel to use within a single screen, we always use + // the centroid of the object rather than the finger. + touchX = centerX; nextPage = getScreenCenter(getScrollX()) > touchX ? (mIsRtl ? nextPage + 1 : nextPage) // left side : (mIsRtl ? nextPage : nextPage + 1); // right side } layout = (CellLayout) getChildAt(nextPage); } + if (layout != mDragTargetLayout) { setCurrentDropLayout(layout); setCurrentDragOverlappingLayout(layout); From e479619836b1abf874ab25bdfb2402bf84ed0f56 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Fri, 25 Feb 2022 06:41:45 +0000 Subject: [PATCH 05/11] Just return an empty list if the system returns null Bug: 206648922 Test: Presubmit (unable to reproduce this) Change-Id: I04a4759a1c237513ab314ece4acd542e1407edb1 --- quickstep/src/com/android/quickstep/SystemUiProxy.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/quickstep/src/com/android/quickstep/SystemUiProxy.java b/quickstep/src/com/android/quickstep/SystemUiProxy.java index d28796c89e..8b00f45426 100644 --- a/quickstep/src/com/android/quickstep/SystemUiProxy.java +++ b/quickstep/src/com/android/quickstep/SystemUiProxy.java @@ -816,8 +816,12 @@ public class SystemUiProxy implements ISystemUiProxy, public ArrayList getRecentTasks(int numTasks, int userId) { if (mRecentTasks != null) { try { - return new ArrayList<>(Arrays.asList(mRecentTasks.getRecentTasks(numTasks, - RECENT_IGNORE_UNAVAILABLE, userId))); + final GroupedRecentTaskInfo[] rawTasks = mRecentTasks.getRecentTasks(numTasks, + RECENT_IGNORE_UNAVAILABLE, userId); + if (rawTasks == null) { + return new ArrayList<>(); + } + return new ArrayList<>(Arrays.asList(rawTasks)); } catch (RemoteException e) { Log.w(TAG, "Failed call getRecentTasks", e); } From 410c75a44276302d3ce1513cf09eba58a3d7bb88 Mon Sep 17 00:00:00 2001 From: Luca Zuccarini Date: Mon, 14 Feb 2022 13:12:05 +0000 Subject: [PATCH 06/11] Ensure that the Hotseat respects the margins of the QSB. Before this change they were ignored by onMeasure(), so that the QSB couldn't rely on margins for its positioning. Bug: 217477426 Test: manual Change-Id: Ifecd3d40ea584273b7857d19b25a90dbafe1c656 --- src/com/android/launcher3/Hotseat.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java index cb0cc113b0..e1680fc7e7 100644 --- a/src/com/android/launcher3/Hotseat.java +++ b/src/com/android/launcher3/Hotseat.java @@ -173,9 +173,15 @@ public class Hotseat extends CellLayout implements Insettable { protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); - int width = mActivity.getDeviceProfile().isQsbInline - ? mActivity.getDeviceProfile().qsbWidth - : getShortcutsAndWidgets().getMeasuredWidth(); + int width; + if (mActivity.getDeviceProfile().isQsbInline) { + width = mActivity.getDeviceProfile().qsbWidth; + } else { + MarginLayoutParams qsbParams = (MarginLayoutParams) mQsb.getLayoutParams(); + width = getShortcutsAndWidgets().getMeasuredWidth() + - qsbParams.getMarginStart() + - qsbParams.getMarginEnd(); + } mQsb.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(mQsbHeight, MeasureSpec.EXACTLY)); From 890e4a75c305c41fcb77e41d57a8abf133f2d021 Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Fri, 25 Feb 2022 11:38:01 +0000 Subject: [PATCH 07/11] Dump DeviceProfile in TouchInteractionService dumpsys - So DeviceProfile dumpsys will be available in bugreports, useful for debugging - Only dump DeviceProfile in createdOverviewActivity if it's non-null Fix: 221395133 Test: adb shell dumpsys activity service com.google.android.apps.nexuslauncher/com.android.quickstep.TouchInteractionService Change-Id: Iaf7b7abd25771814be6cb918e96e042d1085debb --- .../src/com/android/quickstep/TouchInteractionService.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java index 2ed75b5c98..fc5f34df9a 100644 --- a/quickstep/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java @@ -959,6 +959,9 @@ public class TouchInteractionService extends Service pw.println("ProtoTrace:"); pw.println(" file=" + ProtoTracer.INSTANCE.get(this).getTraceFile()); mTaskbarManager.dumpLogs("", pw); + if (createdOverviewActivity != null) { + createdOverviewActivity.getDeviceProfile().dump("", pw); + } } } From 20f1328b9671c46f7c0afeb59ec83c6c4883f235 Mon Sep 17 00:00:00 2001 From: Shikha Malhotra Date: Thu, 24 Feb 2022 13:30:57 +0000 Subject: [PATCH 08/11] Top row of first workspace screen occupied only when QSB is placed at the top. This CL facilitates making the Feature Flag QSB_ON_FIRST_SCREEN as false for LauncherLilyGoogle to make sure that that the top row on the first screen is not blocked for QSB. Hinging it on BuildConfig allows it be overwritten in LauncherLilyGoogle. Bug: 208136186 Bug: 188511548 Test: Manually tested that top row of the first screen is not occupied and does not clear the shortcuts after a power cycle for LauncherLilyGoogle. Change-Id: I9113e2e2f2c0a160a2e1caf0ef3c5f86c6ec54b8 --- Android.bp | 15 +++++++++++++++ .../android/launcher3/config/FeatureFlags.java | 2 +- .../com/android/launcher3/BuildConfig.java | 9 +++++++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/Android.bp b/Android.bp index f5a38b4e6f..1c7c448948 100644 --- a/Android.bp +++ b/Android.bp @@ -224,6 +224,21 @@ filegroup { ], } +// Common source files used to build go launcher +filegroup { + name: "launcher-go-src-no-build-config", + srcs: [ + "src/**/*.java", + "src/**/*.kt", + "quickstep/src/**/*.java", + "quickstep/src/**/*.kt", + "go/src/**/*.java", + "go/src/**/*.kt", + "go/quickstep/src/**/*.java", + "go/quickstep/src/**/*.kt", + ], +} + // Proguard files for Launcher3 filegroup { name: "launcher-proguard-rules", diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java index 8b2184d8fe..b9054fe985 100644 --- a/src/com/android/launcher3/config/FeatureFlags.java +++ b/src/com/android/launcher3/config/FeatureFlags.java @@ -52,7 +52,7 @@ public final class FeatureFlags { * Enable moving the QSB on the 0th screen of the workspace. This is not a configuration feature * and should be modified at a project level. */ - public static final boolean QSB_ON_FIRST_SCREEN = true; + public static final boolean QSB_ON_FIRST_SCREEN = BuildConfig.QSB_ON_FIRST_SCREEN; /** * Feature flag to handle define config changes dynamically instead of killing the process. diff --git a/src_build_config/com/android/launcher3/BuildConfig.java b/src_build_config/com/android/launcher3/BuildConfig.java index 49aadf61ff..9a81d3f54c 100644 --- a/src_build_config/com/android/launcher3/BuildConfig.java +++ b/src_build_config/com/android/launcher3/BuildConfig.java @@ -17,6 +17,11 @@ package com.android.launcher3; public final class BuildConfig { - public static final String APPLICATION_ID = "com.android.launcher3"; - public static final boolean DEBUG = false; + public static final String APPLICATION_ID = "com.android.launcher3"; + public static final boolean DEBUG = 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; } From 01fb0032465d2c67f37d32b20cc149e40b6146c1 Mon Sep 17 00:00:00 2001 From: Pierre Barbier de Reuille Date: Fri, 25 Feb 2022 14:41:24 +0000 Subject: [PATCH 09/11] Removing the Sunshine team from OWNERS. We switched back to Digital Wellbeing. Test: n/a Change-Id: I98375788f66d3659cac3256f10cd8cd2bc19025e --- OWNERS | 7 ------- 1 file changed, 7 deletions(-) diff --git a/OWNERS b/OWNERS index 05fa502b34..f3fafe77a0 100644 --- a/OWNERS +++ b/OWNERS @@ -7,13 +7,6 @@ alexchau@google.com andraskloczl@google.com patmanning@google.com -petrcermak@google.com -pbdr@google.com -kideckel@google.com -stevenckng@google.com -ydixit@google.com -boadway@google.com -alinazaidi@google.com adamcohen@google.com hyunyoungs@google.com mrcasey@google.com From c4240fd4295bfa1f073003b92ac701771a0c3e7c Mon Sep 17 00:00:00 2001 From: Schneider Victor-tulias Date: Fri, 25 Feb 2022 10:06:18 -0800 Subject: [PATCH 10/11] Remove old logs associated to b/200572078 b/200572078 is no longer reproducing. Removing old logs and closing the bug Fixed: 200572078 Test: remote tests Change-Id: I7100ec33d5c92fc951b82f4118184453a388d772 --- src/com/android/launcher3/Launcher.java | 8 -------- src/com/android/launcher3/LauncherModel.java | 6 ------ .../android/launcher3/model/BaseLoaderResults.java | 13 ------------- src/com/android/launcher3/model/ModelUtils.java | 5 ----- src/com/android/launcher3/testing/TestProtocol.java | 1 - 5 files changed, 33 deletions(-) diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 8fb2f53ec6..e2bce00fcc 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -2173,10 +2173,6 @@ public class Launcher extends StatefulActivity implements Launche IntSet result = new IntSet(); if (visibleIds.isEmpty()) { - if (TestProtocol.sDebugTracing) { - Log.d(TestProtocol.NULL_INT_SET, "getPagesToBindSynchronously (1): " - + result); - } return result; } for (int id : orderedScreenIds.toArray()) { @@ -2197,10 +2193,6 @@ public class Launcher extends StatefulActivity implements Launche // pages being hidden in single panel. result.add(pairId); } - if (TestProtocol.sDebugTracing) { - Log.d(TestProtocol.NULL_INT_SET, "getPagesToBindSynchronously (2): " - + result); - } return result; } diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java index 8646849c2c..2d7fcb12fa 100644 --- a/src/com/android/launcher3/LauncherModel.java +++ b/src/com/android/launcher3/LauncherModel.java @@ -357,12 +357,6 @@ public class LauncherModel extends LauncherApps.Callback implements InstallSessi public void addCallbacks(Callbacks callbacks) { Preconditions.assertUIThread(); synchronized (mCallbacksList) { - if (TestProtocol.sDebugTracing) { - Log.d(TestProtocol.NULL_INT_SET, "addCallbacks pointer: " - + callbacks - + ", name: " - + callbacks.getClass().getName(), new Exception()); - } mCallbacksList.add(callbacks); } } diff --git a/src/com/android/launcher3/model/BaseLoaderResults.java b/src/com/android/launcher3/model/BaseLoaderResults.java index 5b278ab4cf..db417a7e5e 100644 --- a/src/com/android/launcher3/model/BaseLoaderResults.java +++ b/src/com/android/launcher3/model/BaseLoaderResults.java @@ -32,7 +32,6 @@ 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.testing.TestProtocol; import com.android.launcher3.util.IntArray; import com.android.launcher3.util.IntSet; import com.android.launcher3.util.LooperExecutor; @@ -174,20 +173,8 @@ public abstract class BaseLoaderResults { ArrayList currentAppWidgets = new ArrayList<>(); ArrayList otherAppWidgets = new ArrayList<>(); - if (TestProtocol.sDebugTracing) { - Log.d(TestProtocol.NULL_INT_SET, "bind (1) currentScreenIds: " - + currentScreenIds - + ", pointer: " - + mCallbacks - + ", name: " - + mCallbacks.getClass().getName()); - } filterCurrentWorkspaceItems(currentScreenIds, mWorkspaceItems, currentWorkspaceItems, otherWorkspaceItems); - if (TestProtocol.sDebugTracing) { - Log.d(TestProtocol.NULL_INT_SET, "bind (2) currentScreenIds: " - + currentScreenIds); - } filterCurrentWorkspaceItems(currentScreenIds, mAppWidgets, currentAppWidgets, otherAppWidgets); final InvariantDeviceProfile idp = mApp.getInvariantDeviceProfile(); diff --git a/src/com/android/launcher3/model/ModelUtils.java b/src/com/android/launcher3/model/ModelUtils.java index ef5eef1e43..58aa9e591f 100644 --- a/src/com/android/launcher3/model/ModelUtils.java +++ b/src/com/android/launcher3/model/ModelUtils.java @@ -31,7 +31,6 @@ import com.android.launcher3.icons.BitmapInfo; import com.android.launcher3.icons.LauncherIcons; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.WorkspaceItemInfo; -import com.android.launcher3.testing.TestProtocol; import com.android.launcher3.util.IntArray; import com.android.launcher3.util.IntSet; @@ -67,10 +66,6 @@ public class ModelUtils { (lhs, rhs) -> Integer.compare(lhs.container, rhs.container)); for (T info : allWorkspaceItems) { if (info.container == LauncherSettings.Favorites.CONTAINER_DESKTOP) { - if (TestProtocol.sDebugTracing) { - Log.d(TestProtocol.NULL_INT_SET, "filterCurrentWorkspaceItems: " - + currentScreenIds); - } if (currentScreenIds.contains(info.screenId)) { currentScreenItems.add(info); itemsOnScreen.add(info.id); diff --git a/src/com/android/launcher3/testing/TestProtocol.java b/src/com/android/launcher3/testing/TestProtocol.java index fc18ada958..11a585fffb 100644 --- a/src/com/android/launcher3/testing/TestProtocol.java +++ b/src/com/android/launcher3/testing/TestProtocol.java @@ -127,7 +127,6 @@ public final class TestProtocol { public static final String PERMANENT_DIAG_TAG = "TaplTarget"; public static final String TASK_VIEW_ID_CRASH = "b/195430732"; public static final String NO_DROP_TARGET = "b/195031154"; - public static final String NULL_INT_SET = "b/200572078"; public static final String MISSING_PROMISE_ICON = "b/202985412"; public static final String LAUNCHER_NOT_INITIALIZED = "b/215233405"; } From bcec90b08161f24d955ae2fabe6867643943d261 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Thu, 24 Feb 2022 14:21:44 -0800 Subject: [PATCH 11/11] Adding tests for themed icons support in Launcher Bug: 205772453 Test: Presubmit Change-Id: I2fc8cade8e103e5a7b3aa7349c870e613929464c --- tests/AndroidManifest-common.xml | 9 ++ tests/res/drawable/test_theme_icon.xml | 29 ++++ .../ui/workspace/ThemeIconsTest.java | 128 ++++++++++++++++++ 3 files changed, 166 insertions(+) create mode 100644 tests/res/drawable/test_theme_icon.xml create mode 100644 tests/src/com/android/launcher3/ui/workspace/ThemeIconsTest.java diff --git a/tests/AndroidManifest-common.xml b/tests/AndroidManifest-common.xml index e44c172081..b4cd773435 100644 --- a/tests/AndroidManifest-common.xml +++ b/tests/AndroidManifest-common.xml @@ -267,6 +267,15 @@ + + + + + + + + + + + + + + + + + + diff --git a/tests/src/com/android/launcher3/ui/workspace/ThemeIconsTest.java b/tests/src/com/android/launcher3/ui/workspace/ThemeIconsTest.java new file mode 100644 index 0000000000..e66810cc3d --- /dev/null +++ b/tests/src/com/android/launcher3/ui/workspace/ThemeIconsTest.java @@ -0,0 +1,128 @@ +/* + * 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.ui.workspace; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import android.content.ContentProviderClient; +import android.content.ContentResolver; +import android.content.ContentValues; +import android.net.Uri; +import android.view.View; +import android.view.ViewGroup; + +import androidx.test.filters.LargeTest; + +import com.android.launcher3.BubbleTextView; +import com.android.launcher3.icons.ThemedIconDrawable; +import com.android.launcher3.tapl.HomeAllApps; +import com.android.launcher3.tapl.HomeAppIcon; +import com.android.launcher3.ui.AbstractLauncherUiTest; +import com.android.launcher3.ui.TaplTestsLauncher3; + +import org.junit.Test; + +import java.util.ArrayDeque; +import java.util.Queue; + +/** + * Tests for theme icon support in Launcher + * + * Note running these tests will clear the workspace on the device. + */ +@LargeTest +public class ThemeIconsTest extends AbstractLauncherUiTest { + + private static final String APP_NAME = "ThemeIconTestActivity"; + + @Test + public void testIconWithoutTheme() throws Exception { + setThemeEnabled(false); + TaplTestsLauncher3.initialize(this); + + HomeAllApps allApps = mLauncher.getWorkspace().switchToAllApps(); + allApps.freeze(); + + try { + HomeAppIcon icon = allApps.getAppIcon(APP_NAME); + executeOnLauncher(l -> verifyIconTheme(l.getAppsView(), false)); + icon.dragToWorkspace(false, false); + executeOnLauncher(l -> verifyIconTheme(l.getWorkspace(), false)); + } finally { + allApps.unfreeze(); + } + } + + @Test + public void testIconWithTheme() throws Exception { + setThemeEnabled(true); + TaplTestsLauncher3.initialize(this); + + HomeAllApps allApps = mLauncher.getWorkspace().switchToAllApps(); + allApps.freeze(); + + try { + HomeAppIcon icon = allApps.getAppIcon(APP_NAME); + executeOnLauncher(l -> verifyIconTheme(l.getAppsView(), false)); + icon.dragToWorkspace(false, false); + executeOnLauncher(l -> verifyIconTheme(l.getWorkspace(), true)); + } finally { + allApps.unfreeze(); + } + } + + private void verifyIconTheme(ViewGroup parent, boolean isThemed) { + // Find the app icon + Queue viewQueue = new ArrayDeque<>(); + viewQueue.add(parent); + BubbleTextView icon = null; + while (!viewQueue.isEmpty()) { + View view = viewQueue.poll(); + if (view instanceof ViewGroup) { + parent = (ViewGroup) view; + for (int i = parent.getChildCount() - 1; i >= 0; i--) { + viewQueue.add(parent.getChildAt(i)); + } + } else if (view instanceof BubbleTextView) { + BubbleTextView btv = (BubbleTextView) view; + if (APP_NAME.equals(btv.getText())) { + icon = btv; + break; + } + } + } + + assertNotNull(icon.getIcon()); + assertEquals(isThemed, icon.getIcon() instanceof ThemedIconDrawable); + } + + private void setThemeEnabled(boolean isEnabled) throws Exception { + Uri uri = new Uri.Builder() + .scheme(ContentResolver.SCHEME_CONTENT) + .authority(mTargetPackage + ".grid_control") + .appendPath("set_icon_themed") + .build(); + ContentValues values = new ContentValues(); + values.put("boolean_value", isEnabled); + try (ContentProviderClient client = mTargetContext.getContentResolver() + .acquireContentProviderClient(uri)) { + int result = client.update(uri, values, null); + assertTrue(result > 0); + } + } +}