diff options
author | Dianne Hackborn <hackbod@google.com> | 2013-09-16 17:40:27 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2013-09-16 17:40:27 -0700 |
commit | 50ef0b62f076c509d5edaef5588080d685f063e8 (patch) | |
tree | 40e6dbdd59b596208710a0f7c497ca8874468ada /core/java/com | |
parent | 0a6a80f43de1b64b452aff2cbb6bdbfc9915c2a9 (diff) | |
download | frameworks_base-50ef0b62f076c509d5edaef5588080d685f063e8.zip frameworks_base-50ef0b62f076c509d5edaef5588080d685f063e8.tar.gz frameworks_base-50ef0b62f076c509d5edaef5588080d685f063e8.tar.bz2 |
Work on issue #10771346: runtime restart
Haven't found the underlying cause, but this will give us more
information when we get into the bad state.
Change-Id: I9aebd3a025a7c0d931f43098461b64ee3c220746
Diffstat (limited to 'core/java/com')
-rw-r--r-- | core/java/com/android/internal/app/ProcessStats.java | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/core/java/com/android/internal/app/ProcessStats.java b/core/java/com/android/internal/app/ProcessStats.java index 07854e2..d3fe34e 100644 --- a/core/java/com/android/internal/app/ProcessStats.java +++ b/core/java/com/android/internal/app/ProcessStats.java @@ -24,6 +24,7 @@ import android.os.UserHandle; import android.text.format.DateFormat; import android.util.ArrayMap; import android.util.ArraySet; +import android.util.Log; import android.util.Slog; import android.util.SparseArray; import android.util.TimeUtils; @@ -969,6 +970,7 @@ public final class ProcessStats implements Parcelable { if (ps.isInUse()) { uids.valueAt(iu).resetSafely(now); } else { + uids.valueAt(iu).makeDead(); uids.removeAt(iu); } } @@ -986,6 +988,7 @@ public final class ProcessStats implements Parcelable { if (ps.isInUse() || ps.mCommonProcess.isInUse()) { pkgState.mProcesses.valueAt(iproc).resetSafely(now); } else { + pkgState.mProcesses.valueAt(iproc).makeDead(); pkgState.mProcesses.removeAt(iproc); } } @@ -2127,6 +2130,7 @@ public final class ProcessStats implements Parcelable { int mNumExcessiveCpu; boolean mMultiPackage; + boolean mDead; public long mTmpTotalTime; @@ -2230,6 +2234,18 @@ public final class ProcessStats implements Parcelable { mNumExcessiveCpu = 0; } + void makeDead() { + mDead = true; + } + + private void ensureNotDead() { + if (!mDead) { + return; + } + throw new IllegalStateException("ProcessState dead: name=" + mName + + " pkg=" + mPackage + " uid=" + mUid + " common.name=" + mCommonProcess.mName); + } + void writeToParcel(Parcel out, long now) { out.writeInt(mMultiPackage ? 1 : 0); out.writeInt(mDurationsTableSize); @@ -2271,6 +2287,7 @@ public final class ProcessStats implements Parcelable { } public void makeActive() { + ensureNotDead(); mActive = true; } @@ -2279,7 +2296,8 @@ public final class ProcessStats implements Parcelable { } public boolean isInUse() { - return mActive || mNumActiveServices > 0 || mNumStartedServices > 0; + return mActive || mNumActiveServices > 0 || mNumStartedServices > 0 + || mCurState != STATE_NOTHING; } /** @@ -2315,6 +2333,7 @@ public final class ProcessStats implements Parcelable { } void setState(int state, long now) { + ensureNotDead(); if (mCurState != state) { //Slog.i(TAG, "Setting state in " + mName + "/" + mPackage + ": " + state); commitStateTime(now); @@ -2392,6 +2411,7 @@ public final class ProcessStats implements Parcelable { } public void addPss(long pss, long uss, boolean always) { + ensureNotDead(); if (!always) { if (mLastPssState == mCurState && SystemClock.uptimeMillis() < (mLastPssTime+(30*1000))) { @@ -2453,6 +2473,7 @@ public final class ProcessStats implements Parcelable { } public void reportExcessiveWake(ArrayMap<String, ProcessState> pkgList) { + ensureNotDead(); mCommonProcess.mNumExcessiveWake++; if (!mCommonProcess.mMultiPackage) { return; @@ -2464,6 +2485,7 @@ public final class ProcessStats implements Parcelable { } public void reportExcessiveCpu(ArrayMap<String, ProcessState> pkgList) { + ensureNotDead(); mCommonProcess.mNumExcessiveCpu++; if (!mCommonProcess.mMultiPackage) { return; @@ -2489,9 +2511,17 @@ public final class ProcessStats implements Parcelable { return this; } - private ProcessState pullFixedProc(ArrayMap<String, ProcessState> pkgList, - int index) { + private ProcessState pullFixedProc(ArrayMap<String, ProcessState> pkgList, int index) { ProcessState proc = pkgList.valueAt(index); + if (mDead && proc.mCommonProcess != proc) { + // Somehow we try to continue to use a process state that is dead, because + // it was not being told it was active during the last commit. We can recover + // from this by generating a fresh new state, but this is bad because we + // are losing whatever data we had in the old process state. + Log.wtf(TAG, "Pulling dead proc: name=" + mName + " pkg=" + mPackage + + " uid=" + mUid + " common.name=" + mCommonProcess.mName); + proc = mStats.getProcessStateLocked(proc.mPackage, proc.mUid, proc.mName); + } if (proc.mMultiPackage) { // The array map is still pointing to a common process state // that is now shared across packages. Update it to point to |