Skip to content

Commit bea7afc

Browse files
Dianne HackbornAndroid (Google) Code Review
authored andcommitted
Merge "Fix issue #6284404: ArrayIndexOutOfBoundsException in..." into jb-dev
2 parents 0a28334 + 03fcc33 commit bea7afc

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

core/java/android/app/ActivityThread.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2090,8 +2090,15 @@ private void handleLaunchActivity(ActivityClientRecord r, Intent customIntent) {
20902090
r.activity.mCalled = false;
20912091
mInstrumentation.callActivityOnPause(r.activity);
20922092
// We need to keep around the original state, in case
2093-
// we need to be created again.
2094-
r.state = oldState;
2093+
// we need to be created again. But we only do this
2094+
// for pre-Honeycomb apps, which always save their state
2095+
// when pausing, so we can not have them save their state
2096+
// when restarting from a paused state. For HC and later,
2097+
// we want to (and can) let the state be saved as the normal
2098+
// part of stopping the activity.
2099+
if (r.isPreHoneycomb()) {
2100+
r.state = oldState;
2101+
}
20952102
if (!r.activity.mCalled) {
20962103
throw new SuperNotCalledException(
20972104
"Activity " + r.intent.getComponent().toShortString() +

core/java/android/app/Fragment.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import android.util.AndroidRuntimeException;
2929
import android.util.AttributeSet;
3030
import android.util.DebugUtils;
31+
import android.util.Log;
3132
import android.util.SparseArray;
3233
import android.view.ContextMenu;
3334
import android.view.ContextMenu.ContextMenuInfo;
@@ -108,7 +109,9 @@ public Fragment instantiate(Activity activity) {
108109
mInstance.mRetainInstance = mRetainInstance;
109110
mInstance.mDetached = mDetached;
110111
mInstance.mFragmentManager = activity.mFragments;
111-
112+
if (FragmentManagerImpl.DEBUG) Log.v(FragmentManagerImpl.TAG,
113+
"Instantiated fragment " + mInstance);
114+
112115
return mInstance;
113116
}
114117

core/java/android/app/FragmentManager.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1074,14 +1074,15 @@ void makeActive(Fragment f) {
10741074
f.setIndex(mAvailIndices.remove(mAvailIndices.size()-1));
10751075
mActive.set(f.mIndex, f);
10761076
}
1077+
if (DEBUG) Log.v(TAG, "Allocated fragment index " + f);
10771078
}
10781079

10791080
void makeInactive(Fragment f) {
10801081
if (f.mIndex < 0) {
10811082
return;
10821083
}
10831084

1084-
if (DEBUG) Log.v(TAG, "Freeing fragment index " + f.mIndex);
1085+
if (DEBUG) Log.v(TAG, "Freeing fragment index " + f);
10851086
mActive.set(f.mIndex, null);
10861087
if (mAvailIndices == null) {
10871088
mAvailIndices = new ArrayList<Integer>();
@@ -1493,6 +1494,7 @@ ArrayList<Fragment> retainNonConfig() {
14931494
fragments.add(f);
14941495
f.mRetaining = true;
14951496
f.mTargetIndex = f.mTarget != null ? f.mTarget.mIndex : -1;
1497+
if (DEBUG) Log.v(TAG, "retainNonConfig: keeping retained " + f);
14961498
}
14971499
}
14981500
}

services/java/com/android/server/am/ActivityStack.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2619,6 +2619,7 @@ final int startActivityUncheckedLocked(ActivityRecord r,
26192619
}
26202620

26212621
boolean addingToTask = false;
2622+
boolean movedHome = false;
26222623
TaskRecord reuseTask = null;
26232624
if (((launchFlags&Intent.FLAG_ACTIVITY_NEW_TASK) != 0 &&
26242625
(launchFlags&Intent.FLAG_ACTIVITY_MULTIPLE_TASK) == 0)
@@ -2657,6 +2658,7 @@ final int startActivityUncheckedLocked(ActivityRecord r,
26572658
if (callerAtFront) {
26582659
// We really do want to push this one into the
26592660
// user's face, right now.
2661+
movedHome = true;
26602662
moveHomeToFrontFromLaunchLocked(launchFlags);
26612663
moveTaskToFrontLocked(taskTop.task, r, options);
26622664
}
@@ -2835,7 +2837,9 @@ final int startActivityUncheckedLocked(ActivityRecord r,
28352837
r.setTask(reuseTask, reuseTask, true);
28362838
}
28372839
newTask = true;
2838-
moveHomeToFrontFromLaunchLocked(launchFlags);
2840+
if (!movedHome) {
2841+
moveHomeToFrontFromLaunchLocked(launchFlags);
2842+
}
28392843

28402844
} else if (sourceRecord != null) {
28412845
if (!addingToTask &&

0 commit comments

Comments
 (0)