From f6264d2387151da5a902c9646cb3476dbf28544e Mon Sep 17 00:00:00 2001 From: Nicolo' Mazzucato Date: Thu, 14 Sep 2023 12:22:43 +0000 Subject: [PATCH] Preload overview after unfold Before this change, the configChange was processed when launcher becomes visible. However, this happened during animations (e.g. swipe to home after unfold to app). With this change, the onConfigChange received by TIS (so, it's received also if the activity is not visible), is used to preload overview, moving a ~100ms block to unfold instead of during the animation. Bug: 294352799 Test: recorded a perfetto trace and checked jank decrease Change-Id: I35a7036887cc9ea490f27d5ccd47fe423775350b Merged-In: I35a7036887cc9ea490f27d5ccd47fe423775350b (cherry picked from commit 11ce5f85c90b5caea3d0fea9d1ede09479fd587a) --- .../android/quickstep/TouchInteractionService.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java index c1680de1b3..b12d1c65c5 100644 --- a/quickstep/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java @@ -28,6 +28,7 @@ import static com.android.launcher3.MotionEventsUtils.isTrackpadMotionEvent; import static com.android.launcher3.MotionEventsUtils.isTrackpadMultiFingerSwipe; import static com.android.launcher3.config.FeatureFlags.ENABLE_TRACKPAD_GESTURE; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; +import static com.android.launcher3.util.window.WindowManagerProxy.MIN_TABLET_WIDTH; import static com.android.quickstep.GestureState.DEFAULT_STATE; import static com.android.quickstep.GestureState.TrackpadGestureType.getTrackpadGestureType; import static com.android.quickstep.InputConsumer.TYPE_CURSOR_HOVER; @@ -68,6 +69,7 @@ import android.os.Bundle; import android.os.IBinder; import android.os.Looper; import android.os.SystemClock; +import android.os.Trace; import android.util.Log; import android.view.Choreographer; import android.view.InputDevice; @@ -1210,7 +1212,9 @@ public class TouchInteractionService extends Service { } private void preloadOverview(boolean fromInit) { + Trace.beginSection("preloadOverview(fromInit=" + fromInit + ")"); preloadOverview(fromInit, false); + Trace.endSection(); } private void preloadOverview(boolean fromInit, boolean forSUWAllSet) { @@ -1260,7 +1264,10 @@ public class TouchInteractionService extends Service { // We only care about the existing background activity. return; } - if (mOverviewComponentObserver.canHandleConfigChanges(activity.getComponentName(), + Configuration oldConfig = activity.getResources().getConfiguration(); + boolean isFoldUnfold = isTablet(oldConfig) != isTablet(newConfig); + if (!isFoldUnfold && mOverviewComponentObserver.canHandleConfigChanges( + activity.getComponentName(), activity.getResources().getConfiguration().diff(newConfig))) { // Since navBar gestural height are different between portrait and landscape, // can handle orientation changes and refresh navigation gestural region through @@ -1275,6 +1282,10 @@ public class TouchInteractionService extends Service { preloadOverview(false /* fromInit */); } + private static boolean isTablet(Configuration config) { + return config.smallestScreenWidthDp >= MIN_TABLET_WIDTH; + } + @Override protected void dump(FileDescriptor fd, PrintWriter pw, String[] rawArgs) { // Dump everything