From 40ff08495b2918c450dfbd93f4785aff1ae7b28c Mon Sep 17 00:00:00 2001 From: Jerry Chang Date: Fri, 29 Jul 2022 16:14:38 +0000 Subject: [PATCH 1/5] Integrate split pair cold launch transition with shell transition Fix: 222163803 Test: enabled shell transition, cold launch a split pair from overview has proper transition. Change-Id: Ia5398d24baa64bc98a04e839f6d1247c7c7aabeb --- .../com/android/quickstep/TaskViewUtils.java | 34 +++++++++++++++++-- .../util/SplitSelectStateController.java | 5 +-- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/quickstep/src/com/android/quickstep/TaskViewUtils.java b/quickstep/src/com/android/quickstep/TaskViewUtils.java index a0305688af..89de95aa17 100644 --- a/quickstep/src/com/android/quickstep/TaskViewUtils.java +++ b/quickstep/src/com/android/quickstep/TaskViewUtils.java @@ -391,10 +391,39 @@ public final class TaskViewUtils { * device is considered in multiWindowMode and things like insets and stuff change * and calculations have to be adjusted in the animations for that */ - public static void composeRecentsSplitLaunchAnimator(int initialTaskId, - @Nullable PendingIntent initialTaskPendingIntent, int secondTaskId, + public static void composeRecentsSplitLaunchAnimator(GroupedTaskView launchingTaskView, + @NonNull StateManager stateManager, @Nullable DepthController depthController, + int initialTaskId, @Nullable PendingIntent initialTaskPendingIntent, int secondTaskId, @NonNull TransitionInfo transitionInfo, SurfaceControl.Transaction t, @NonNull Runnable finishCallback) { + if (launchingTaskView != null) { + AnimatorSet animatorSet = new AnimatorSet(); + animatorSet.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + finishCallback.run(); + } + }); + + final RemoteAnimationTargetCompat[] appTargets = + RemoteAnimationTargetCompat.wrapApps(transitionInfo, t, null /* leashMap */); + final RemoteAnimationTargetCompat[] wallpaperTargets = + RemoteAnimationTargetCompat.wrapNonApps( + transitionInfo, true /* wallpapers */, t, null /* leashMap */); + final RemoteAnimationTargetCompat[] nonAppTargets = + RemoteAnimationTargetCompat.wrapNonApps( + transitionInfo, false /* wallpapers */, t, null /* leashMap */); + final RecentsView recentsView = launchingTaskView.getRecentsView(); + composeRecentsLaunchAnimator(animatorSet, launchingTaskView, + appTargets, wallpaperTargets, nonAppTargets, + true, stateManager, + recentsView, depthController); + + t.apply(); + animatorSet.start(); + return; + } + // TODO: consider initialTaskPendingIntent TransitionInfo.Change splitRoot1 = null; TransitionInfo.Change splitRoot2 = null; @@ -682,6 +711,7 @@ public final class TaskViewUtils { public void onAnimationStart(Animator animation) { if (shown) { for (SurfaceControl leash : auxiliarySurfaces) { + t.setLayer(leash, Integer.MAX_VALUE); t.setAlpha(leash, 0); t.show(leash); } diff --git a/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java b/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java index e89c842b5f..da5c4f76a8 100644 --- a/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java +++ b/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java @@ -242,8 +242,9 @@ public class SplitSelectStateController { @Override public void startAnimation(@NonNull IBinder transition, @NonNull TransitionInfo info, @NonNull SurfaceControl.Transaction t, @NonNull Runnable finishCallback) { - TaskViewUtils.composeRecentsSplitLaunchAnimator(mInitialTaskId, - mInitialTaskPendingIntent, mSecondTaskId, info, t, () -> { + TaskViewUtils.composeRecentsSplitLaunchAnimator(mLaunchingTaskView, mStateManager, + mDepthController, mInitialTaskId, mInitialTaskPendingIntent, mSecondTaskId, + info, t, () -> { finishCallback.run(); if (mSuccessCallback != null) { mSuccessCallback.accept(true); From c3ecf392e3c9a52996ebac672e8832dea9551f4c Mon Sep 17 00:00:00 2001 From: Sebastian Franco Date: Tue, 9 Aug 2022 11:18:28 -0700 Subject: [PATCH 2/5] Adding 4x4 roerder widget test Fix: 241000659 Test: atest ReorderWidgets Change-Id: I7dea2fbc676710798187b50d27b63ced9910a43b --- .../celllayout/testcases/FullReorderCase.java | 33 ++++++++++--- .../testcases/MoveOutReorderCase.java | 33 +++++++++---- .../celllayout/testcases/PushReorderCase.java | 48 +++++++++++-------- .../testcases/SimpleReorderCase.java | 36 +++++++++----- 4 files changed, 103 insertions(+), 47 deletions(-) diff --git a/tests/src/com/android/launcher3/celllayout/testcases/FullReorderCase.java b/tests/src/com/android/launcher3/celllayout/testcases/FullReorderCase.java index ff03a50fbc..1326389ab7 100644 --- a/tests/src/com/android/launcher3/celllayout/testcases/FullReorderCase.java +++ b/tests/src/com/android/launcher3/celllayout/testcases/FullReorderCase.java @@ -20,46 +20,65 @@ import android.graphics.Point; import java.util.Map; public class FullReorderCase { + + /** 5x5 Test + **/ private static final String START_BOARD_STR_5x5 = "" + "xxxxx\n" + "222mm\n" + "222mm\n" + "ad111\n" + "bc111"; - private static final Point MOVE_TO_5x5 = new Point(0, 4); - private static final String END_BOARD_STR_5x5 = "" + "xxxxx\n" + "222ad\n" + "222bc\n" + "mm111\n" + "mm111"; - private static final ReorderTestCase TEST_CASE_5x5 = new ReorderTestCase(START_BOARD_STR_5x5, MOVE_TO_5x5, END_BOARD_STR_5x5); + /** 6x5 Test + **/ private static final String START_BOARD_STR_6x5 = "" + "xxxxxx\n" + "2222mm\n" + "2222mm\n" + "ad1111\n" + "bc1111"; - private static final Point MOVE_TO_6x5 = new Point(0, 4); - private static final String END_BOARD_STR_6x5 = "" + "xxxxxx\n" + "2222ad\n" + "2222bc\n" + "mm1111\n" + "mm1111"; - private static final ReorderTestCase TEST_CASE_6x5 = new ReorderTestCase(START_BOARD_STR_6x5, MOVE_TO_6x5, END_BOARD_STR_6x5); + /** 4x4 Test + **/ + private static final String START_BOARD_STR_4x4 = "" + + "xxxx\n" + + "22mm\n" + + "admm\n" + + "bc11"; + private static final Point MOVE_TO_4x4 = new Point(0, 3); + private static final String END_BOARD_STR_4x4 = "" + + "xxxx\n" + + "22ad\n" + + "mmbc\n" + + "mm11"; + + private static final ReorderTestCase TEST_CASE_4x4 = new ReorderTestCase(START_BOARD_STR_4x4, + MOVE_TO_4x4, + END_BOARD_STR_4x4); + public static final Map TEST_BY_GRID_SIZE = - Map.of(new Point(5, 5), TEST_CASE_5x5, new Point(6, 5), TEST_CASE_6x5); + Map.of(new Point(5, 5), TEST_CASE_5x5, + new Point(6, 5), TEST_CASE_6x5, + new Point(4, 4), TEST_CASE_4x4); } diff --git a/tests/src/com/android/launcher3/celllayout/testcases/MoveOutReorderCase.java b/tests/src/com/android/launcher3/celllayout/testcases/MoveOutReorderCase.java index 32bf05a52c..1701390268 100644 --- a/tests/src/com/android/launcher3/celllayout/testcases/MoveOutReorderCase.java +++ b/tests/src/com/android/launcher3/celllayout/testcases/MoveOutReorderCase.java @@ -20,47 +20,64 @@ import android.graphics.Point; import java.util.Map; public class MoveOutReorderCase { + + /** 5x5 Test + **/ private static final String START_BOARD_STR_5x5 = "" + "xxxxx\n" + "34-m-\n" + "35111\n" + "32111\n" + "32111"; - private static final Point MOVE_TO_5x5 = new Point(1, 2); - private static final String END_BOARD_STR_5x5 = "" + "xxxxx\n" + "345--\n" + "3m111\n" + "32111\n" + "32111"; - private static final ReorderTestCase TEST_CASE_5x5 = new ReorderTestCase(START_BOARD_STR_5x5, MOVE_TO_5x5, END_BOARD_STR_5x5); - + /** 6x5 Test + **/ private static final String START_BOARD_STR_6x5 = "" + "xxxxxx\n" + "34-m--\n" + "351111\n" + "321111\n" + "321111"; - private static final Point MOVE_TO_6x5 = new Point(1, 2); - private static final String END_BOARD_STR_6x5 = "" + "xxxxxx\n" + "345---\n" + "3m1111\n" + "321111\n" + "321111"; - private static final ReorderTestCase TEST_CASE_6x5 = new ReorderTestCase(START_BOARD_STR_6x5, MOVE_TO_6x5, END_BOARD_STR_6x5); + /** 4x4 Test + **/ + private static final String START_BOARD_STR_4x4 = "" + + "xxxx\n" + + "34-m\n" + + "3511\n" + + "3211"; + private static final Point MOVE_TO_4x4 = new Point(1, 2); + private static final String END_BOARD_STR_4x4 = "" + + "xxxx\n" + + "345-\n" + + "3m11\n" + + "3211"; + private static final ReorderTestCase TEST_CASE_4x4 = new ReorderTestCase(START_BOARD_STR_4x4, + MOVE_TO_4x4, + END_BOARD_STR_4x4); + public static final Map TEST_BY_GRID_SIZE = - Map.of(new Point(5, 5), TEST_CASE_5x5, new Point(6, 5), TEST_CASE_6x5); + Map.of(new Point(5, 5), TEST_CASE_5x5, + new Point(6, 5), TEST_CASE_6x5, + new Point(4, 4), TEST_CASE_4x4); } diff --git a/tests/src/com/android/launcher3/celllayout/testcases/PushReorderCase.java b/tests/src/com/android/launcher3/celllayout/testcases/PushReorderCase.java index b386946176..bb8d5e9631 100644 --- a/tests/src/com/android/launcher3/celllayout/testcases/PushReorderCase.java +++ b/tests/src/com/android/launcher3/celllayout/testcases/PushReorderCase.java @@ -17,60 +17,68 @@ package com.android.launcher3.celllayout.testcases; import android.graphics.Point; -import com.android.launcher3.celllayout.CellLayoutBoard; - import java.util.Map; public class PushReorderCase { + + /** 5x5 Test + **/ private static final String START_BOARD_STR_5x5 = "" + "xxxxx\n" + "222m-\n" + "--111\n" + "--333\n" + "-----"; - private static final CellLayoutBoard START_BOARD_5x5 = CellLayoutBoard.boardFromString( - START_BOARD_STR_5x5); - private static final Point MOVE_TO_5x5 = new Point(2, 1); - private static final String END_BOARD_STR_5x5 = "" + "xxxxx\n" + "--m--\n" + "222--\n" + "--111\n" + "--333"; - private static final CellLayoutBoard END_BOARD_5x5 = CellLayoutBoard.boardFromString( + private static final ReorderTestCase TEST_CASE_5x5 = new ReorderTestCase(START_BOARD_STR_5x5, + MOVE_TO_5x5, END_BOARD_STR_5x5); - private static final ReorderTestCase TEST_CASE_5x5 = new ReorderTestCase(START_BOARD_5x5, - MOVE_TO_5x5, - END_BOARD_5x5); - + /** 6x5 Test + **/ private static final String START_BOARD_STR_6x5 = "" + "xxxxxx\n" + "2222m-\n" + "--111-\n" + "--333-\n" + "------"; - private static final CellLayoutBoard START_BOARD_6x5 = CellLayoutBoard.boardFromString( - START_BOARD_STR_6x5); - private static final Point MOVE_TO_6x5 = new Point(2, 1); - private static final String END_BOARD_STR_6x5 = "" + "xxxxxx\n" + "--m---\n" + "2222--\n" + "--111-\n" + "--333-"; - private static final CellLayoutBoard END_BOARD_6x5 = CellLayoutBoard.boardFromString( + private static final ReorderTestCase TEST_CASE_6x5 = new ReorderTestCase(START_BOARD_STR_6x5, + MOVE_TO_6x5, END_BOARD_STR_6x5); - private static final ReorderTestCase TEST_CASE_6x5 = new ReorderTestCase(START_BOARD_6x5, - MOVE_TO_6x5, - END_BOARD_6x5); + /** 4x4 Test + **/ + private static final String START_BOARD_STR_4x4 = "" + + "xxxx\n" + + "222m\n" + + "-111\n" + + "----"; + private static final Point MOVE_TO_4x4 = new Point(2, 1); + private static final String END_BOARD_STR_4x4 = "" + + "xxxx\n" + + "--m-\n" + + "222-\n" + + "-111"; + private static final ReorderTestCase TEST_CASE_4x4 = new ReorderTestCase(START_BOARD_STR_4x4, + MOVE_TO_4x4, + END_BOARD_STR_4x4); public static final Map TEST_BY_GRID_SIZE = - Map.of(new Point(5, 5), TEST_CASE_5x5, new Point(6, 5), TEST_CASE_6x5); + Map.of(new Point(5, 5), TEST_CASE_5x5, + new Point(6, 5), TEST_CASE_6x5, + new Point(4, 4), TEST_CASE_4x4); } diff --git a/tests/src/com/android/launcher3/celllayout/testcases/SimpleReorderCase.java b/tests/src/com/android/launcher3/celllayout/testcases/SimpleReorderCase.java index 57e1398bd2..30269a0f5d 100644 --- a/tests/src/com/android/launcher3/celllayout/testcases/SimpleReorderCase.java +++ b/tests/src/com/android/launcher3/celllayout/testcases/SimpleReorderCase.java @@ -17,35 +17,47 @@ package com.android.launcher3.celllayout.testcases; import android.graphics.Point; -import com.android.launcher3.celllayout.CellLayoutBoard; - import java.util.Map; public class SimpleReorderCase { - private static final String START_BOARD_STR = "" + + /** 5x5 Test + **/ + private static final String START_BOARD_STR_5x5 = "" + "xxxxx\n" + "--mm-\n" + "--mm-\n" + "-----\n" + "-----"; - private static final CellLayoutBoard START_BOARD_5x5 = CellLayoutBoard.boardFromString( - START_BOARD_STR); - private static final Point MOVE_TO_5x5 = new Point(4, 4); - private static final String END_BOARD_STR_5x5 = "" + "xxxxx\n" + "-----\n" + "-----\n" + "---mm\n" + "---mm"; - private static final CellLayoutBoard END_BOARD_5x5 = CellLayoutBoard.boardFromString( + private static final ReorderTestCase TEST_CASE_5x5 = new ReorderTestCase(START_BOARD_STR_5x5, + MOVE_TO_5x5, END_BOARD_STR_5x5); - private static final ReorderTestCase TEST_CASE_5x5 = new ReorderTestCase(START_BOARD_5x5, - MOVE_TO_5x5, - END_BOARD_5x5); + /** 4x4 Test + **/ + private static final String START_BOARD_STR_4x4 = "" + + "xxxx\n" + + "--mm\n" + + "--mm\n" + + "----"; + private static final Point MOVE_TO_4x4 = new Point(3, 3); + private static final String END_BOARD_STR_4x4 = "" + + "xxxx\n" + + "----\n" + + "--mm\n" + + "--mm"; + private static final ReorderTestCase TEST_CASE_4x4 = new ReorderTestCase(START_BOARD_STR_4x4, + MOVE_TO_4x4, + END_BOARD_STR_4x4); public static final Map TEST_BY_GRID_SIZE = - Map.of(new Point(5, 5), TEST_CASE_5x5); + Map.of(new Point(5, 5), TEST_CASE_5x5, + new Point(4, 4), TEST_CASE_4x4); } From 1fb075de3b6c41a748ea0abc0baaf20890cad18d Mon Sep 17 00:00:00 2001 From: Thales Lima Date: Wed, 10 Aug 2022 10:47:50 +0100 Subject: [PATCH 3/5] Tune display options for non-default display sizes Fix: 241382721 Test: manual Change-Id: I05379c359dabad6931ee897455aa847a7a9b470c --- res/values/attrs.xml | 2 ++ src/com/android/launcher3/InvariantDeviceProfile.java | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/res/values/attrs.xml b/res/values/attrs.xml index 28d094b138..df1ca14de2 100644 --- a/res/values/attrs.xml +++ b/res/values/attrs.xml @@ -281,6 +281,8 @@ + + diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java index 21eba00ee2..cf2a3f8474 100644 --- a/src/com/android/launcher3/InvariantDeviceProfile.java +++ b/src/com/android/launcher3/InvariantDeviceProfile.java @@ -1004,7 +1004,9 @@ public class InvariantDeviceProfile { allAppsIconSizes[INDEX_DEFAULT] = a.getFloat( R.styleable.ProfileDisplayOption_allAppsIconSize, iconSizes[INDEX_DEFAULT]); - allAppsIconSizes[INDEX_LANDSCAPE] = allAppsIconSizes[INDEX_DEFAULT]; + allAppsIconSizes[INDEX_LANDSCAPE] = a.getFloat( + R.styleable.ProfileDisplayOption_allAppsIconSizeLandscape, + iconSizes[INDEX_DEFAULT]); allAppsIconSizes[INDEX_TWO_PANEL_PORTRAIT] = a.getFloat( R.styleable.ProfileDisplayOption_allAppsIconSizeTwoPanelPortrait, allAppsIconSizes[INDEX_DEFAULT]); From 360ec033aca0acb706f3e3693dfd319690ef7f24 Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Wed, 10 Aug 2022 16:11:42 +0100 Subject: [PATCH 4/5] Use WindowManagerProxy.getRotation to determine if rotation has changed - Follow-up of http://ag/19559863 as Config diff on windowConfiguration does not work on 3P Launcher, so diff WindowManagerProxy.getRotation instead - Also centralized Configuration diff logic into StatefulActivity Bug: 240730723 Test: manual on 90/180 degree rotation in Launcher, RecentsActivity and 3P Launcher Change-Id: Ib368ed5d749841a6873a03e2644608ff68885922 --- .../launcher3/BaseQuickstepLauncher.java | 18 --------- .../android/quickstep/RecentsActivity.java | 37 ++----------------- src/com/android/launcher3/Launcher.java | 25 +++---------- .../statemanager/StatefulActivity.java | 34 ++++++++++++++++- 4 files changed, 41 insertions(+), 73 deletions(-) diff --git a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java index 1ffa8891fd..c2e8658401 100644 --- a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java @@ -15,9 +15,6 @@ */ package com.android.launcher3; -import static android.app.WindowConfiguration.WINDOW_CONFIG_ROTATION; -import static android.content.pm.ActivityInfo.CONFIG_WINDOW_CONFIGURATION; - import static com.android.launcher3.AbstractFloatingView.TYPE_ALL; import static com.android.launcher3.AbstractFloatingView.TYPE_HIDE_BACK_BUTTON; import static com.android.launcher3.LauncherState.FLAG_HIDE_BACK_BUTTON; @@ -46,7 +43,6 @@ import android.app.ActivityOptions; import android.content.Context; import android.content.Intent; import android.content.IntentSender; -import android.content.res.Configuration; import android.hardware.SensorManager; import android.hardware.devicestate.DeviceStateManager; import android.os.Bundle; @@ -653,20 +649,6 @@ public abstract class BaseQuickstepLauncher extends Launcher { } } - @Override - protected boolean compareConfiguration(Configuration oldConfig, Configuration newConfig) { - int diff = newConfig.diff(oldConfig); - if ((diff & CONFIG_WINDOW_CONFIGURATION) != 0) { - long windowDiff = - newConfig.windowConfiguration.diff(oldConfig.windowConfiguration, false); - if ((windowDiff & WINDOW_CONFIG_ROTATION) != 0) { - return true; - } - } - - return super.compareConfiguration(oldConfig, newConfig); - } - @Override public void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args) { super.dump(prefix, fd, writer, args); diff --git a/quickstep/src/com/android/quickstep/RecentsActivity.java b/quickstep/src/com/android/quickstep/RecentsActivity.java index 1a966e2516..3e3a43178c 100644 --- a/quickstep/src/com/android/quickstep/RecentsActivity.java +++ b/quickstep/src/com/android/quickstep/RecentsActivity.java @@ -15,11 +15,6 @@ */ package com.android.quickstep; -import static android.app.WindowConfiguration.WINDOW_CONFIG_ROTATION; -import static android.content.pm.ActivityInfo.CONFIG_ORIENTATION; -import static android.content.pm.ActivityInfo.CONFIG_SCREEN_SIZE; -import static android.content.pm.ActivityInfo.CONFIG_WINDOW_CONFIGURATION; - import static com.android.launcher3.QuickstepTransitionManager.RECENTS_LAUNCH_DURATION; import static com.android.launcher3.QuickstepTransitionManager.STATUS_BAR_TRANSITION_DURATION; import static com.android.launcher3.QuickstepTransitionManager.STATUS_BAR_TRANSITION_PRE_DELAY; @@ -112,8 +107,6 @@ public final class RecentsActivity extends StatefulActivity { private @Nullable TaskbarManager mTaskbarManager; private @Nullable FallbackTaskbarUIController mTaskbarUIController; - private Configuration mOldConfig; - private StateManager mStateManager; // Strong refs to runners which are cleared when the activity is destroyed @@ -165,7 +158,7 @@ public final class RecentsActivity extends StatefulActivity { @Override public void onMultiWindowModeChanged(boolean isInMultiWindowMode, Configuration newConfig) { - onHandleConfigChanged(); + onHandleConfigurationChanged(); super.onMultiWindowModeChanged(isInMultiWindowMode, newConfig); } @@ -175,11 +168,8 @@ public final class RecentsActivity extends StatefulActivity { ACTIVITY_TRACKER.handleNewIntent(this); } - /** - * Logic for when device configuration changes (rotation, screen size change, multi-window, - * etc.) - */ - protected void onHandleConfigChanged() { + @Override + protected void onHandleConfigurationChanged() { initDeviceProfile(); AbstractFloatingView.closeOpenViews(this, true, @@ -340,7 +330,6 @@ public final class RecentsActivity extends StatefulActivity { mStateManager = new StateManager<>(this, RecentsState.BG_LAUNCHER); - mOldConfig = new Configuration(getResources().getConfiguration()); initDeviceProfile(); setupViews(); @@ -349,26 +338,6 @@ public final class RecentsActivity extends StatefulActivity { ACTIVITY_TRACKER.handleCreate(this); } - @Override - public void handleConfigurationChanged(Configuration newConfig) { - if (compareConfiguration(mOldConfig, newConfig)) { - onHandleConfigChanged(); - } - mOldConfig.setTo(newConfig); - super.handleConfigurationChanged(newConfig); - } - - private boolean compareConfiguration(Configuration oldConfig, Configuration newConfig) { - int diff = newConfig.diff(oldConfig); - if ((diff & CONFIG_WINDOW_CONFIGURATION) != 0) { - long windowDiff = - newConfig.windowConfiguration.diff(oldConfig.windowConfiguration, false); - return (windowDiff & WINDOW_CONFIG_ROTATION) != 0; - } - - return (diff & (CONFIG_ORIENTATION | CONFIG_SCREEN_SIZE)) != 0; - } - @Override public void onStateSetEnd(RecentsState state) { super.onStateSetEnd(state); diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 03ff146edf..e55321b2bf 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -18,8 +18,6 @@ package com.android.launcher3; import static android.app.PendingIntent.FLAG_IMMUTABLE; import static android.app.PendingIntent.FLAG_UPDATE_CURRENT; -import static android.content.pm.ActivityInfo.CONFIG_ORIENTATION; -import static android.content.pm.ActivityInfo.CONFIG_SCREEN_SIZE; import static android.content.pm.ActivityInfo.CONFIG_UI_MODE; import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_NO; import static android.view.accessibility.AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED; @@ -310,8 +308,6 @@ public class Launcher extends StatefulActivity private static final FloatProperty HOTSEAT_WIDGET_SCALE = HOTSEAT_SCALE_PROPERTY_FACTORY.get(SCALE_INDEX_WIDGET_TRANSITION); - private Configuration mOldConfig; - @Thunk Workspace mWorkspace; @Thunk @@ -466,7 +462,6 @@ public class Launcher extends StatefulActivity super.onCreate(savedInstanceState); LauncherAppState app = LauncherAppState.getInstance(this); - mOldConfig = new Configuration(getResources().getConfiguration()); mModel = app.getModel(); mRotationHelper = new RotationHelper(this); @@ -614,21 +609,6 @@ public class Launcher extends StatefulActivity dispatchDeviceProfileChanged(); } - @Override - public void handleConfigurationChanged(Configuration newConfig) { - if (compareConfiguration(mOldConfig, newConfig)) { - onIdpChanged(false); - } - - mOldConfig.setTo(newConfig); - super.handleConfigurationChanged(newConfig); - } - - protected boolean compareConfiguration(Configuration oldConfig, Configuration newConfig) { - int diff = newConfig.diff(oldConfig); - return (diff & (CONFIG_ORIENTATION | CONFIG_SCREEN_SIZE)) != 0; - } - /** * Initializes the drag controller. */ @@ -638,6 +618,11 @@ public class Launcher extends StatefulActivity @Override public void onIdpChanged(boolean modelPropertiesChanged) { + onHandleConfigurationChanged(); + } + + @Override + protected void onHandleConfigurationChanged() { if (!initDeviceProfile(mDeviceProfile.inv)) { return; } diff --git a/src/com/android/launcher3/statemanager/StatefulActivity.java b/src/com/android/launcher3/statemanager/StatefulActivity.java index eea90919ba..2a890c3d1f 100644 --- a/src/com/android/launcher3/statemanager/StatefulActivity.java +++ b/src/com/android/launcher3/statemanager/StatefulActivity.java @@ -15,10 +15,14 @@ */ package com.android.launcher3.statemanager; +import static android.content.pm.ActivityInfo.CONFIG_ORIENTATION; +import static android.content.pm.ActivityInfo.CONFIG_SCREEN_SIZE; + import static com.android.launcher3.LauncherState.FLAG_CLOSE_POPUPS; import static com.android.launcher3.LauncherState.FLAG_NON_INTERACTIVE; import android.content.res.Configuration; +import android.os.Bundle; import android.os.Handler; import android.view.LayoutInflater; import android.view.View; @@ -31,6 +35,7 @@ import com.android.launcher3.LauncherRootView; import com.android.launcher3.Utilities; import com.android.launcher3.statemanager.StateManager.AtomicAnimationFactory; import com.android.launcher3.statemanager.StateManager.StateHandler; +import com.android.launcher3.util.window.WindowManagerProxy; import com.android.launcher3.views.BaseDragLayer; import java.util.List; @@ -48,6 +53,17 @@ public abstract class StatefulActivity> private LauncherRootView mRootView; + protected Configuration mOldConfig; + private int mOldRotation; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + mOldConfig = new Configuration(getResources().getConfiguration()); + mOldRotation = WindowManagerProxy.INSTANCE.get(this).getRotation(this); + } + /** * Create handlers to control the property changes for this activity */ @@ -198,5 +214,21 @@ public abstract class StatefulActivity> * Handles configuration change when system calls {@link #onConfigurationChanged}, or on other * situations that configuration might change. */ - public void handleConfigurationChanged(Configuration newConfig) {} + public void handleConfigurationChanged(Configuration newConfig) { + int diff = newConfig.diff(mOldConfig); + int rotation = WindowManagerProxy.INSTANCE.get(this).getRotation(this); + if ((diff & (CONFIG_ORIENTATION | CONFIG_SCREEN_SIZE)) != 0 + || rotation != mOldRotation) { + onHandleConfigurationChanged(); + } + + mOldConfig.setTo(newConfig); + mOldRotation = rotation; + } + + /** + * Logic for when device configuration changes (rotation, screen size change, multi-window, + * etc.) + */ + protected abstract void onHandleConfigurationChanged(); } From e7bf15932baac168403af6e42ca57e1d008d9b84 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Tue, 9 Aug 2022 19:12:54 +0000 Subject: [PATCH 5/5] Force finish pending frame drawn callback once launcher is stopped - In rare cases, we may schedule to update the taskview with a screenshot but Launcher will not finish calling back because the activity is stopped (can be the result of the animation cancelling back to the app), which prevents Launcher from scheduling any frames and properly decrementing the frame count. Bug: 202776119 Test: Launch an app with sharesheet, swipe up and verify that screenshot callbacks Change-Id: I6b7e121fd5d9ef27ef5cccca060a4ff819fe9acc --- .../src/com/android/quickstep/ViewUtils.java | 39 +++++++++++++++++-- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/quickstep/src/com/android/quickstep/ViewUtils.java b/quickstep/src/com/android/quickstep/ViewUtils.java index 1fef544e3e..1bb95b97f9 100644 --- a/quickstep/src/com/android/quickstep/ViewUtils.java +++ b/quickstep/src/com/android/quickstep/ViewUtils.java @@ -17,6 +17,7 @@ package com.android.quickstep; import android.graphics.HardwareRenderer; import android.os.Handler; +import android.view.SurfaceControl; import android.view.View; import android.view.ViewRootImpl; @@ -45,22 +46,42 @@ public class ViewUtils { return new FrameHandler(view, onFinishRunnable, canceled).schedule(); } - private static class FrameHandler implements HardwareRenderer.FrameDrawingCallback { + private static class FrameHandler implements HardwareRenderer.FrameDrawingCallback, + ViewRootImpl.SurfaceChangedCallback { final ViewRootImpl mViewRoot; final Runnable mFinishCallback; final BooleanSupplier mCancelled; final Handler mHandler; + boolean mFinished; int mDeferFrameCount = 1; FrameHandler(View view, Runnable finishCallback, BooleanSupplier cancelled) { mViewRoot = view.getViewRootImpl(); + mViewRoot.addSurfaceChangedCallback(this); mFinishCallback = finishCallback; mCancelled = cancelled; mHandler = new Handler(); } + @Override + public void surfaceCreated(SurfaceControl.Transaction t) { + // Do nothing + } + + @Override + public void surfaceReplaced(SurfaceControl.Transaction t) { + // Do nothing + } + + @Override + public void surfaceDestroyed() { + // If the root view is detached, then the app won't get any scheduled frames so we need + // to force-run any pending callbacks + finish(); + } + @Override public void onFrameDraw(long frame) { Utilities.postAsyncCallback(mHandler, this::onFrame); @@ -77,9 +98,7 @@ public class ViewUtils { return; } - if (mFinishCallback != null) { - mFinishCallback.run(); - } + finish(); } private boolean schedule() { @@ -90,5 +109,17 @@ public class ViewUtils { } return false; } + + private void finish() { + if (mFinished) { + return; + } + mFinished = true; + mDeferFrameCount = 0; + if (mFinishCallback != null) { + mFinishCallback.run(); + } + mViewRoot.removeSurfaceChangedCallback(this); + } } }