From 3b3537e0a18844b479f9585eb9589c61d9418665 Mon Sep 17 00:00:00 2001 From: Tiger Huang Date: Mon, 10 Feb 2020 18:12:04 +0800 Subject: [PATCH] Make sure the control target has a control The CL only allows a target to be the control target if the insets source provider has a control. This prevents the arrays in InsetsStateController.mControlTargetTypeMap contains a type which doesn't have a control. If an insets source provider haven't had a window yet while we are updating control for target, we let the target be the pending control target, and then use it to update again while the provider get the window. Bug: 149121559 Test: Manual test Change-Id: I3c63e892f870f4daca667106d935e05423dfece8 --- .../java/com/android/server/wm/InsetsSourceProvider.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/wm/InsetsSourceProvider.java b/services/core/java/com/android/server/wm/InsetsSourceProvider.java index 798665972a338..0d3f6b98f4836 100644 --- a/services/core/java/com/android/server/wm/InsetsSourceProvider.java +++ b/services/core/java/com/android/server/wm/InsetsSourceProvider.java @@ -59,6 +59,7 @@ class InsetsSourceProvider { private final InsetsSourceControl mFakeControl; private @Nullable InsetsSourceControl mControl; private @Nullable InsetsControlTarget mControlTarget; + private @Nullable InsetsControlTarget mPendingControlTarget; private @Nullable InsetsControlTarget mFakeControlTarget; private @Nullable ControlAdapter mAdapter; @@ -140,8 +141,9 @@ class InsetsSourceProvider { mSource.setVisibleFrame(null); } else if (mControllable) { mWin.setControllableInsetProvider(this); - if (mControlTarget != null) { - updateControlForTarget(mControlTarget, true /* force */); + if (mPendingControlTarget != null) { + updateControlForTarget(mPendingControlTarget, true /* force */); + mPendingControlTarget = null; } } } @@ -245,7 +247,7 @@ class InsetsSourceProvider { setWindow(null, null, null); } if (mWin == null) { - mControlTarget = target; + mPendingControlTarget = target; return; } if (target == mControlTarget && !force) {