diff options
author | riddle_hsu <riddle_hsu@htc.com> | 2015-06-05 16:38:38 +0800 |
---|---|---|
committer | Wale Ogunwale <ogunwale@google.com> | 2015-06-12 08:40:40 -0700 |
commit | 36ee73d110ccbdcf7f7fb42e3e9a33ce4aa05051 (patch) | |
tree | b53ee0d64c2fcdb0e767094a33705b30c830f18d /services/core | |
parent | e61fc94b9b6d4ccba60cca9ac0e0a67539f18780 (diff) | |
download | frameworks_base-36ee73d110ccbdcf7f7fb42e3e9a33ce4aa05051.zip frameworks_base-36ee73d110ccbdcf7f7fb42e3e9a33ce4aa05051.tar.gz frameworks_base-36ee73d110ccbdcf7f7fb42e3e9a33ce4aa05051.tar.bz2 |
[ActivityManager] Fix index OOB when updating visible.
If there is an Activity Z of Task T needs be visible but
isn't running, and the process P of Z is existed, it will
just to schedule launch Z.
The problem will happen when P is died (e.g. kill itself)
right before scheduleLaunchActivity. Once RemoteException
is caught, startSpecificActivityLocked will try to restart
the process and run cleanup procedure because the process
record is existed (death recipient of P has not entered AMS
yet). And assume task T contains X, Y, Z. X and Y have
declared stateNotNeeded=true, so X and Y will be removed
from task T.
Now the size of task T changes from 3 to 1. And because
activityNdx=2 when updating Z, the next round (--activityNdx)
will have exception at activities.get(activityNdx):
IndexOutOfBoundsException: Invalid index 1, size is 1
The ActivityRecord in TaskRecord is removed by below flow:
ActivityStack.ensureActivitiesVisibleLocked
ActivityStackSupervisor.startSpecificActivityLocked
ActivityStackSupervisor.realStartActivityLocked
ApplicationThreadProxy.scheduleLaunchActivity -> IPC fail
ActivityManagerService.startProcessLocked
ActivityManagerService.handleAppDiedLocked
ActivityStackSupervisor.handleAppDiedLocked
ActivityStack.handleAppDiedLocked
ActivityStack.removeHistoryRecordsForAppLocked
ActivityStack.removeActivityFromHistoryLocked
task.removeActivity(r) -> mActivities.remove(r)
There is also similar patch to solve the same problem:
https://android-review.googlesource.com/143780/
Change-Id: Iac646bcb8ed3d3cfb2bda14e05e11abfcfe980d1
Diffstat (limited to 'services/core')
-rw-r--r-- | services/core/java/com/android/server/am/ActivityStack.java | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java index eb5af9e..0714d36 100644 --- a/services/core/java/com/android/server/am/ActivityStack.java +++ b/services/core/java/com/android/server/am/ActivityStack.java @@ -1326,7 +1326,12 @@ final class ActivityStack { if (r != starting) { mStackSupervisor.startSpecificActivityLocked( r, noStackActivityResumed, false); - noStackActivityResumed = false; + if (activityNdx >= activities.size()) { + // Record may be removed if its process needs to restart. + activityNdx = activities.size() - 1; + } else { + noStackActivityResumed = false; + } } } else if (r.visible) { |