[ActivityManager] Fix NPE when start activity

Cherry picked from aosp.

Fixes bug 18593457.

Symptom:
NPE occurs in line 1184 (resultStack.sendActivityResultLocked)
because resultStack is null.

Root cause:
When starting activity with FLAG_ACTIVITY_FORWARD_RESULT flag,
the resultRecord could be updated, but the resultStack is not
updated as well. In that case, the resultStack is still be
null. The exception will occurs if the activity is not
granted to launch due to permission denied.

Solution:
Update resultStack when resultRecord updates.

Change-Id: I91634e4f713c2e8dbd1a71f358a8fd9beed83ec7
This commit is contained in:
louis_chang
2014-08-01 10:09:08 +08:00
committed by Craig Mautner
parent 932c332147
commit cd5d198d7e

View File

@@ -1314,7 +1314,6 @@ public final class ActivityStackSupervisor implements DisplayListener {
}
}
}
ActivityStack resultStack = resultRecord == null ? null : resultRecord.task.stack;
final int launchFlags = intent.getFlags();
@@ -1391,6 +1390,8 @@ public final class ActivityStackSupervisor implements DisplayListener {
}
}
final ActivityStack resultStack = resultRecord == null ? null : resultRecord.task.stack;
if (err != ActivityManager.START_SUCCESS) {
if (resultRecord != null) {
resultStack.sendActivityResultLocked(-1,