From e4489b4c296df842eac4b9a8d54a3d4dc53f9033 Mon Sep 17 00:00:00 2001 From: Hongwei Wang Date: Thu, 24 Sep 2020 15:30:37 -0700 Subject: [PATCH] Bail early if mToken.asBinder() not found Not able to reproduce what's in the original bug report, this null check is added as a safe guard. A possible scenario is PipTaskOrganizer#exitPip is called twice and there is a race condition that the first applySyncTransaction is not ready yet and leave the internal state as it was, the second call tries to get configuration and it is null, which leads to a NPE. This is a counterpart of ag/12674237 Bug: 169360509 Test: N/A Change-Id: Ife3281178f341a4118820b6e511afdab56f9ff11 --- .../src/com/android/systemui/pip/PipTaskOrganizer.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/pip/PipTaskOrganizer.java b/packages/SystemUI/src/com/android/systemui/pip/PipTaskOrganizer.java index 6cc0cd879d71a..42817c262dcdd 100644 --- a/packages/SystemUI/src/com/android/systemui/pip/PipTaskOrganizer.java +++ b/packages/SystemUI/src/com/android/systemui/pip/PipTaskOrganizer.java @@ -327,9 +327,13 @@ public class PipTaskOrganizer extends TaskOrganizer implements ShellTaskOrganize return; } + final Configuration initialConfig = mInitialState.remove(mToken.asBinder()); + if (initialConfig == null) { + Log.wtf(TAG, "Token not in record, this should not happen mToken=" + mToken); + return; + } mPipUiEventLoggerLogger.log( PipUiEventLogger.PipUiEventEnum.PICTURE_IN_PICTURE_EXPAND_TO_FULLSCREEN); - final Configuration initialConfig = mInitialState.remove(mToken.asBinder()); final boolean orientationDiffers = initialConfig.windowConfiguration.getRotation() != mPipBoundsHandler.getDisplayRotation(); final WindowContainerTransaction wct = new WindowContainerTransaction();