Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dccb770b authored by Craig Mautner's avatar Craig Mautner
Browse files

Add bounds checks before accessing ArrayList.

Add a test for emptiness before accessing either mTaskHistory[0] or
TaskRecord.mActivities[0]. This will keep us from hitting
IndexOutOfBoundsException.

Fixes bug 10789624.

Change-Id: If726df888a2c8b393788793b6220a6bffe2df883
parent c06b1db2
Loading
Loading
Loading
Loading
+8 −7
Original line number Diff line number Diff line
@@ -1843,16 +1843,17 @@ final class ActivityStack {
                // bottom of the activity stack.  This also keeps it
                // correctly ordered with any activities we previously
                // moved.
                TaskRecord bottomTask = mTaskHistory.get(0);
                ActivityRecord p = bottomTask.mActivities.get(0);
                if (target.taskAffinity != null
                        && target.taskAffinity.equals(p.task.affinity)) {
                final ActivityRecord bottom =
                        !mTaskHistory.isEmpty() && !mTaskHistory.get(0).mActivities.isEmpty() ?
                        mTaskHistory.get(0).mActivities.get(0) : null;
                if (bottom != null && target.taskAffinity != null
                        && target.taskAffinity.equals(bottom.task.affinity)) {
                    // If the activity currently at the bottom has the
                    // same task affinity as the one we are moving,
                    // then merge it into the same task.
                    target.setTask(p.task, p.thumbHolder, false);
                    target.setTask(bottom.task, bottom.thumbHolder, false);
                    if (DEBUG_TASKS) Slog.v(TAG, "Start pushing activity " + target
                            + " out to bottom task " + p.task);
                            + " out to bottom task " + bottom.task);
                } else {
                    target.setTask(createTaskRecord(mStackSupervisor.getNextTaskId(), target.info,
                            null, false), null, false);
@@ -1868,7 +1869,7 @@ final class ActivityStack {
                boolean noOptions = canMoveOptions;
                final int start = replyChainEnd < 0 ? i : replyChainEnd;
                for (int srcPos = start; srcPos >= i; --srcPos) {
                    p = activities.get(srcPos);
                    final ActivityRecord p = activities.get(srcPos);
                    if (p.finishing) {
                        continue;
                    }