From 3d34f947849846e2f68baa9901095c244313107b Mon Sep 17 00:00:00 2001 From: Adam Bookatz Date: Tue, 30 Nov 2021 00:18:38 +0000 Subject: [PATCH] Revert "Fix issue with Shell listeners being unbound if SysUI is restarted" This reverts commit 34e384d2e1a381e1b18e7da90227fb61b2e75172. Reason for revert: Multiuser performance (b/208276322) Change-Id: Icd27ab3095c446895360f8e2faa7f9c92ab2cf01 Bug: 208276322 --- .../android/quickstep/RecentTasksList.java | 21 ------ .../com/android/quickstep/RecentsModel.java | 6 -- .../com/android/quickstep/SystemUiProxy.java | 72 +++++++++++-------- .../quickstep/TouchInteractionService.java | 1 - 4 files changed, 41 insertions(+), 59 deletions(-) diff --git a/quickstep/src/com/android/quickstep/RecentTasksList.java b/quickstep/src/com/android/quickstep/RecentTasksList.java index 097850fd6f..c5f4a53877 100644 --- a/quickstep/src/com/android/quickstep/RecentTasksList.java +++ b/quickstep/src/com/android/quickstep/RecentTasksList.java @@ -36,7 +36,6 @@ import com.android.wm.shell.recents.IRecentTasksListener; import com.android.wm.shell.util.GroupedRecentTaskInfo; import com.android.wm.shell.util.StagedSplitBounds; -import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; import java.util.function.Consumer; @@ -220,26 +219,6 @@ public class RecentTasksList { return newTasks; } - public void dump(String prefix, PrintWriter writer) { - writer.println(prefix + "RecentTasksList:"); - writer.println(prefix + " mChangeId=" + mChangeId); - writer.println(prefix + " mResultsUi=[id=" + mResultsUi.mRequestId + ", tasks="); - for (GroupTask task : mResultsUi) { - writer.println(prefix + " t1=" + task.task1.key.id - + " t2=" + (task.hasMultipleTasks() ? task.task2.key.id : "-1")); - } - writer.println(prefix + " ]"); - int currentUserId = Process.myUserHandle().getIdentifier(); - ArrayList rawTasks = - mSysUiProxy.getRecentTasks(Integer.MAX_VALUE, currentUserId); - writer.println(prefix + " rawTasks=["); - for (GroupedRecentTaskInfo task : rawTasks) { - writer.println(prefix + " t1=" + task.mTaskInfo1.taskId - + " t2=" + (task.mTaskInfo2 != null ? task.mTaskInfo2.taskId : "-1")); - } - writer.println(prefix + " ]"); - } - private static class TaskLoadResult extends ArrayList { final int mRequestId; diff --git a/quickstep/src/com/android/quickstep/RecentsModel.java b/quickstep/src/com/android/quickstep/RecentsModel.java index 5d77a6e916..e539a8c7c4 100644 --- a/quickstep/src/com/android/quickstep/RecentsModel.java +++ b/quickstep/src/com/android/quickstep/RecentsModel.java @@ -43,7 +43,6 @@ import com.android.systemui.shared.system.KeyguardManagerCompat; import com.android.systemui.shared.system.TaskStackChangeListener; import com.android.systemui.shared.system.TaskStackChangeListeners; -import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import java.util.concurrent.Executor; @@ -221,11 +220,6 @@ public class RecentsModel extends TaskStackChangeListener implements IconChangeL mThumbnailChangeListeners.remove(listener); } - public void dump(String prefix, PrintWriter writer) { - writer.println(prefix + "RecentsModel:"); - mTaskList.dump(" ", writer); - } - /** * Listener for receiving various task properties changes */ diff --git a/quickstep/src/com/android/quickstep/SystemUiProxy.java b/quickstep/src/com/android/quickstep/SystemUiProxy.java index c8abd14d22..68b7558cf2 100644 --- a/quickstep/src/com/android/quickstep/SystemUiProxy.java +++ b/quickstep/src/com/android/quickstep/SystemUiProxy.java @@ -83,16 +83,14 @@ public class SystemUiProxy implements ISystemUiProxy, MAIN_EXECUTOR.execute(() -> clearProxy()); }; - // Save the listeners passed into the proxy since OverviewProxyService may not have been bound - // yet, and we'll need to set/register these listeners with SysUI when they do. Note that it is - // up to the caller to clear the listeners to prevent leaks as these can be held indefinitely - // in case SysUI needs to rebind. - private IPipAnimationListener mPipAnimationListener; - private ISplitScreenListener mSplitScreenListener; - private IStartingWindowListener mStartingWindowListener; - private ISmartspaceCallback mSmartspaceCallback; - private IRecentTasksListener mRecentTasksListener; - private final ArrayList mRemoteTransitions = new ArrayList<>(); + // Save the listeners passed into the proxy since when set/register these listeners, + // setProxy may not have been called, eg. OverviewProxyService is not connected yet. + private IPipAnimationListener mPendingPipAnimationListener; + private ISplitScreenListener mPendingSplitScreenListener; + private IStartingWindowListener mPendingStartingWindowListener; + private ISmartspaceCallback mPendingSmartspaceCallback; + private IRecentTasksListener mPendingRecentTasksListener; + private final ArrayList mPendingRemoteTransitions = new ArrayList<>(); // Used to dedupe calls to SystemUI private int mLastShelfHeight; @@ -169,23 +167,29 @@ public class SystemUiProxy implements ISystemUiProxy, mRecentTasks = recentTasks; linkToDeath(); // re-attach the listeners once missing due to setProxy has not been initialized yet. - if (mPipAnimationListener != null && mPip != null) { - setPinnedStackAnimationListener(mPipAnimationListener); + if (mPendingPipAnimationListener != null && mPip != null) { + setPinnedStackAnimationListener(mPendingPipAnimationListener); + mPendingPipAnimationListener = null; } - if (mSplitScreenListener != null && mSplitScreen != null) { - registerSplitScreenListener(mSplitScreenListener); + if (mPendingSplitScreenListener != null && mSplitScreen != null) { + registerSplitScreenListener(mPendingSplitScreenListener); + mPendingSplitScreenListener = null; } - if (mStartingWindowListener != null && mStartingWindow != null) { - setStartingWindowListener(mStartingWindowListener); + if (mPendingStartingWindowListener != null && mStartingWindow != null) { + setStartingWindowListener(mPendingStartingWindowListener); + mPendingStartingWindowListener = null; } - if (mSmartspaceCallback != null && mSmartspaceTransitionController != null) { - setSmartspaceCallback(mSmartspaceCallback); + if (mPendingSmartspaceCallback != null && mSmartspaceTransitionController != null) { + setSmartspaceCallback(mPendingSmartspaceCallback); + mPendingSmartspaceCallback = null; } - for (int i = mRemoteTransitions.size() - 1; i >= 0; --i) { - registerRemoteTransition(mRemoteTransitions.get(i)); + for (int i = mPendingRemoteTransitions.size() - 1; i >= 0; --i) { + registerRemoteTransition(mPendingRemoteTransitions.get(i)); } - if (mRecentTasksListener != null && mRecentTasks != null) { - registerRecentTasksListener(mRecentTasksListener); + mPendingRemoteTransitions.clear(); + if (mPendingRecentTasksListener != null && mRecentTasks != null) { + registerRecentTasksListener(mPendingRecentTasksListener); + mPendingRecentTasksListener = null; } if (mPendingSetNavButtonAlpha != null) { @@ -509,8 +513,9 @@ public class SystemUiProxy implements ISystemUiProxy, } catch (RemoteException e) { Log.w(TAG, "Failed call setPinnedStackAnimationListener", e); } + } else { + mPendingPipAnimationListener = listener; } - mPipAnimationListener = listener; } public Rect startSwipePipToHome(ComponentName componentName, ActivityInfo activityInfo, @@ -548,8 +553,9 @@ public class SystemUiProxy implements ISystemUiProxy, } catch (RemoteException e) { Log.w(TAG, "Failed call registerSplitScreenListener"); } + } else { + mPendingSplitScreenListener = listener; } - mSplitScreenListener = listener; } public void unregisterSplitScreenListener(ISplitScreenListener listener) { @@ -560,7 +566,7 @@ public class SystemUiProxy implements ISystemUiProxy, Log.w(TAG, "Failed call unregisterSplitScreenListener"); } } - mSplitScreenListener = null; + mPendingSplitScreenListener = null; } /** Start multiple tasks in split-screen simultaneously. */ @@ -681,8 +687,9 @@ public class SystemUiProxy implements ISystemUiProxy, } catch (RemoteException e) { Log.w(TAG, "Failed call registerRemoteTransition"); } + } else { + mPendingRemoteTransitions.add(remoteTransition); } - mRemoteTransitions.add(remoteTransition); } public void unregisterRemoteTransition(RemoteTransitionCompat remoteTransition) { @@ -693,7 +700,7 @@ public class SystemUiProxy implements ISystemUiProxy, Log.w(TAG, "Failed call registerRemoteTransition"); } } - mRemoteTransitions.remove(remoteTransition); + mPendingRemoteTransitions.remove(remoteTransition); } // @@ -710,8 +717,9 @@ public class SystemUiProxy implements ISystemUiProxy, } catch (RemoteException e) { Log.w(TAG, "Failed call setStartingWindowListener", e); } + } else { + mPendingStartingWindowListener = listener; } - mStartingWindowListener = listener; } // @@ -725,8 +733,9 @@ public class SystemUiProxy implements ISystemUiProxy, } catch (RemoteException e) { Log.w(TAG, "Failed call setStartingWindowListener", e); } + } else { + mPendingSmartspaceCallback = callback; } - mSmartspaceCallback = callback; } // @@ -740,8 +749,9 @@ public class SystemUiProxy implements ISystemUiProxy, } catch (RemoteException e) { Log.w(TAG, "Failed call registerRecentTasksListener", e); } + } else { + mPendingRecentTasksListener = listener; } - mRecentTasksListener = listener; } public void unregisterRecentTasksListener(IRecentTasksListener listener) { @@ -752,7 +762,7 @@ public class SystemUiProxy implements ISystemUiProxy, Log.w(TAG, "Failed call unregisterRecentTasksListener"); } } - mRecentTasksListener = null; + mPendingRecentTasksListener = null; } public ArrayList getRecentTasks(int numTasks, int userId) { diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java index 30dce61422..bda5a3044c 100644 --- a/quickstep/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java @@ -976,7 +976,6 @@ public class TouchInteractionService extends Service pw.println(" resumed=" + resumed); pw.println(" mConsumer=" + mConsumer.getName()); ActiveGestureLog.INSTANCE.dump("", pw); - RecentsModel.INSTANCE.get(this).dump("", pw); pw.println("ProtoTrace:"); pw.println(" file=" + ProtoTracer.INSTANCE.get(this).getTraceFile()); }