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
This commit is contained in:
Hongwei Wang
2020-09-24 15:30:37 -07:00
parent 0e2927e75b
commit e4489b4c29

View File

@@ -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();