Fix NPE when calling recreate in onCreate

ActivityClientRecord#activity is assigned after calling
Activity#onCreate. A use case is that the app uses
support library to set night mode in onCreate.

Bug: 195418295
Test: Invoke Activity#recreate() in Activity#onCreate.
Change-Id: I6319cd6ee94fc2603979da47303963d04168db04
This commit is contained in:
Riddle Hsu
2021-08-04 10:13:13 +08:00
parent 15fd1a115c
commit 6c675a3a48

View File

@@ -5654,8 +5654,8 @@ public final class ActivityThread extends ClientTransactionHandler
*/
private void scheduleRelaunchActivityIfPossible(@NonNull ActivityClientRecord r,
boolean preserveWindow) {
if (r.activity.mFinished || r.token instanceof Binder) {
// Do not schedule relaunch if the activity is finishing or not a local object (e.g.
if ((r.activity != null && r.activity.mFinished) || r.token instanceof Binder) {
// Do not schedule relaunch if the activity is finishing or is a local object (e.g.
// created by ActivtiyGroup that server side doesn't recognize it).
return;
}