am bea7afc5: Merge "Fix issue #6284404: ArrayIndexOutOfBoundsException in..." into jb-dev

* commit 'bea7afc52cc85e35b7fc200912246c62d3791198':
  Fix issue #6284404: ArrayIndexOutOfBoundsException in...
This commit is contained in:
Dianne Hackborn
2012-05-15 13:59:47 -07:00
committed by Android Git Automerger
4 changed files with 21 additions and 5 deletions

View File

@@ -2090,8 +2090,15 @@ public final class ActivityThread {
r.activity.mCalled = false;
mInstrumentation.callActivityOnPause(r.activity);
// We need to keep around the original state, in case
// we need to be created again.
r.state = oldState;
// we need to be created again. But we only do this
// for pre-Honeycomb apps, which always save their state
// when pausing, so we can not have them save their state
// when restarting from a paused state. For HC and later,
// we want to (and can) let the state be saved as the normal
// part of stopping the activity.
if (r.isPreHoneycomb()) {
r.state = oldState;
}
if (!r.activity.mCalled) {
throw new SuperNotCalledException(
"Activity " + r.intent.getComponent().toShortString() +

View File

@@ -28,6 +28,7 @@ import android.os.Parcelable;
import android.util.AndroidRuntimeException;
import android.util.AttributeSet;
import android.util.DebugUtils;
import android.util.Log;
import android.util.SparseArray;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
@@ -108,7 +109,9 @@ final class FragmentState implements Parcelable {
mInstance.mRetainInstance = mRetainInstance;
mInstance.mDetached = mDetached;
mInstance.mFragmentManager = activity.mFragments;
if (FragmentManagerImpl.DEBUG) Log.v(FragmentManagerImpl.TAG,
"Instantiated fragment " + mInstance);
return mInstance;
}

View File

@@ -1074,6 +1074,7 @@ final class FragmentManagerImpl extends FragmentManager {
f.setIndex(mAvailIndices.remove(mAvailIndices.size()-1));
mActive.set(f.mIndex, f);
}
if (DEBUG) Log.v(TAG, "Allocated fragment index " + f);
}
void makeInactive(Fragment f) {
@@ -1081,7 +1082,7 @@ final class FragmentManagerImpl extends FragmentManager {
return;
}
if (DEBUG) Log.v(TAG, "Freeing fragment index " + f.mIndex);
if (DEBUG) Log.v(TAG, "Freeing fragment index " + f);
mActive.set(f.mIndex, null);
if (mAvailIndices == null) {
mAvailIndices = new ArrayList<Integer>();
@@ -1493,6 +1494,7 @@ final class FragmentManagerImpl extends FragmentManager {
fragments.add(f);
f.mRetaining = true;
f.mTargetIndex = f.mTarget != null ? f.mTarget.mIndex : -1;
if (DEBUG) Log.v(TAG, "retainNonConfig: keeping retained " + f);
}
}
}

View File

@@ -2619,6 +2619,7 @@ final class ActivityStack {
}
boolean addingToTask = false;
boolean movedHome = false;
TaskRecord reuseTask = null;
if (((launchFlags&Intent.FLAG_ACTIVITY_NEW_TASK) != 0 &&
(launchFlags&Intent.FLAG_ACTIVITY_MULTIPLE_TASK) == 0)
@@ -2657,6 +2658,7 @@ final class ActivityStack {
if (callerAtFront) {
// We really do want to push this one into the
// user's face, right now.
movedHome = true;
moveHomeToFrontFromLaunchLocked(launchFlags);
moveTaskToFrontLocked(taskTop.task, r, options);
}
@@ -2835,7 +2837,9 @@ final class ActivityStack {
r.setTask(reuseTask, reuseTask, true);
}
newTask = true;
moveHomeToFrontFromLaunchLocked(launchFlags);
if (!movedHome) {
moveHomeToFrontFromLaunchLocked(launchFlags);
}
} else if (sourceRecord != null) {
if (!addingToTask &&