From 60fa64742776632de647e8e85373c887c6e96728 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Mon, 12 Jun 2017 15:30:14 -0700 Subject: [PATCH] Minimal change to ensure events are propagated to the right DividerView. - The RecentsDrawnEvent sent when Recents is first drawn can be racey, if it is sent before the configuration change in Divider is dispatched, then it will be posted for the old DividerView, which prior to ag/2363241 was still sending the correct resize calls (the animation is independent of the view). For now, we register the event handler in Divider, and instead proxy it to the current view when it is posted. Bug: 62528361 Test: go/wm-smoke Test: Play a movie in Play Movies, ensure the activity is resized Change-Id: I665b0c6af55dea0db1916f5b041589bf72da3baf --- .../android/systemui/stackdivider/Divider.java | 15 +++++++++++++++ .../systemui/stackdivider/DividerView.java | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/stackdivider/Divider.java b/packages/SystemUI/src/com/android/systemui/stackdivider/Divider.java index 3b37437bfca00..02329112c6978 100644 --- a/packages/SystemUI/src/com/android/systemui/stackdivider/Divider.java +++ b/packages/SystemUI/src/com/android/systemui/stackdivider/Divider.java @@ -25,6 +25,8 @@ import android.view.View; import com.android.systemui.R; import com.android.systemui.SystemUI; import com.android.systemui.recents.Recents; +import com.android.systemui.recents.events.EventBus; +import com.android.systemui.recents.events.ui.RecentsDrawnEvent; import com.android.systemui.recents.misc.SystemServicesProxy; import static android.content.res.Configuration.ORIENTATION_LANDSCAPE; @@ -56,6 +58,7 @@ public class Divider extends SystemUI { SystemServicesProxy ssp = Recents.getSystemServices(); ssp.registerDockedStackListener(mDockDividerVisibilityListener); mForcedResizableController = new ForcedResizableInfoActivityController(mContext); + EventBus.getDefault().register(this); } @Override @@ -153,6 +156,18 @@ public class Divider extends SystemUI { mWindowManager.setTouchable((mHomeStackResizable || !mMinimized) && !mAdjustedForIme); } + /** + * Workaround for b/62528361, at the time RecentsDrawnEvent is sent, it may happen before a + * configuration change to the Divider, and internally, the event will be posted to the + * subscriber, or DividerView, which has been removed and prevented from resizing. Instead, + * register the event handler here and proxy the event to the current DividerView. + */ + public final void onBusEvent(RecentsDrawnEvent drawnEvent) { + if (mView != null) { + mView.onRecentsDrawn(); + } + } + @Override public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { pw.print(" mVisible="); pw.println(mVisible); diff --git a/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java b/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java index 6dc7870770a5b..7691652a0ebe1 100644 --- a/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java +++ b/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java @@ -1222,7 +1222,7 @@ public class DividerView extends FrameLayout implements OnTouchListener, mSnapAlgorithm.getMiddleTarget()); } - public final void onBusEvent(RecentsDrawnEvent drawnEvent) { + public void onRecentsDrawn() { if (mState.animateAfterRecentsDrawn) { mState.animateAfterRecentsDrawn = false; updateDockSide();