Prevent dream service finishSelf before it was attached

Bring back stopSelf logic to prevent dream service finishSelf before any
token attached.

Fix: 150818348
Test: manual test, won't throw exp while leaving dream service.
Merged-In: I31bb4f32013b9fa0aa2263b94117060e4d3a7341
Change-Id: I31bb4f32013b9fa0aa2263b94117060e4d3a7341
This commit is contained in:
Jerry Chang
2020-03-10 10:21:27 +08:00
parent 97a8c8a153
commit b050ab8a78

View File

@@ -906,15 +906,21 @@ public class DreamService extends Service implements Window.Callback {
if (!mActivity.isFinishing()) { if (!mActivity.isFinishing()) {
// In case the activity is not finished yet, do it now. // In case the activity is not finished yet, do it now.
mActivity.finishAndRemoveTask(); mActivity.finishAndRemoveTask();
}
return; return;
} }
} else if (!mWindowless) {
Slog.w(TAG, "Finish was called before the dream was attached.");
}
if (!mFinished) { if (mFinished) {
return;
}
mFinished = true; mFinished = true;
if (mDreamToken == null) {
Slog.w(TAG, "Finish was called before the dream was attached.");
stopSelf();
return;
}
try { try {
// finishSelf will unbind the dream controller from the dream service. This will // finishSelf will unbind the dream controller from the dream service. This will
// trigger DreamService.this.onDestroy and DreamService.this will die. // trigger DreamService.this.onDestroy and DreamService.this will die.
@@ -923,7 +929,6 @@ public class DreamService extends Service implements Window.Callback {
// system server died // system server died
} }
} }
}
/** /**
* Wakes the dream up gently. * Wakes the dream up gently.