Merge "Prevent dream service finishSelf before it was attached" into rvc-dev am: 2240431010

Change-Id: I799d3f1f53b8df36f575bce3f6102ffc03e143cd
This commit is contained in:
TreeHugger Robot
2020-04-01 03:14:27 +00:00
committed by Automerger Merge Worker

View File

@@ -904,22 +904,27 @@ public class DreamService extends Service implements Window.Callback {
if (!mActivity.isFinishing()) {
// In case the activity is not finished yet, do it now.
mActivity.finishAndRemoveTask();
return;
}
} else if (!mWindowless) {
Slog.w(TAG, "Finish was called before the dream was attached.");
return;
}
if (!mFinished) {
mFinished = true;
if (mFinished) {
return;
}
mFinished = true;
try {
// finishSelf will unbind the dream controller from the dream service. This will
// trigger DreamService.this.onDestroy and DreamService.this will die.
mDreamManager.finishSelf(mDreamToken, true /*immediate*/);
} catch (RemoteException ex) {
// system server died
}
if (mDreamToken == null) {
Slog.w(TAG, "Finish was called before the dream was attached.");
stopSelf();
return;
}
try {
// finishSelf will unbind the dream controller from the dream service. This will
// trigger DreamService.this.onDestroy and DreamService.this will die.
mDreamManager.finishSelf(mDreamToken, true /*immediate*/);
} catch (RemoteException ex) {
// system server died
}
}