Loading core/java/com/android/internal/app/procstats/ProcessState.java +31 −31 Original line number Diff line number Diff line Loading @@ -129,7 +129,7 @@ public final class ProcessState { private final PssTable mPssTable; private ProcessState mCommonProcess; private int mCurState = STATE_NOTHING; private int mCurCombinedState = STATE_NOTHING; private long mStartTime; private int mLastPssState = STATE_NOTHING; Loading Loading @@ -180,7 +180,7 @@ public final class ProcessState { mPackage = pkg; mUid = uid; mVersion = vers; mCurState = commonProcess.mCurState; mCurCombinedState = commonProcess.mCurCombinedState; mStartTime = now; mDurations = new DurationsTable(commonProcess.mStats.mTableData); mPssTable = new PssTable(commonProcess.mStats.mTableData); Loading Loading @@ -324,7 +324,7 @@ public final class ProcessState { public boolean isInUse() { return mActive || mNumActiveServices > 0 || mNumStartedServices > 0 || mCurState != STATE_NOTHING; || mCurCombinedState != STATE_NOTHING; } public boolean isActive() { Loading @@ -333,7 +333,7 @@ public final class ProcessState { public boolean hasAnyData() { return !(mDurations.getKeyCount() == 0 && mCurState == STATE_NOTHING && mCurCombinedState == STATE_NOTHING && mPssTable.getKeyCount() == 0); } Loading @@ -355,7 +355,7 @@ public final class ProcessState { } // First update the common process. mCommonProcess.setState(state, now); mCommonProcess.setCombinedState(state, now); // If the common process is not multi-package, there is nothing else to do. if (!mCommonProcess.mMultiPackage) { Loading @@ -364,29 +364,29 @@ public final class ProcessState { if (pkgList != null) { for (int ip=pkgList.size()-1; ip>=0; ip--) { pullFixedProc(pkgList, ip).setState(state, now); pullFixedProc(pkgList, ip).setCombinedState(state, now); } } } public void setState(int state, long now) { public void setCombinedState(int state, long now) { ensureNotDead(); if (!mDead && (mCurState != state)) { if (!mDead && (mCurCombinedState != state)) { //Slog.i(TAG, "Setting state in " + mName + "/" + mPackage + ": " + state); commitStateTime(now); mCurState = state; mCurCombinedState = state; } } public int getState() { return mCurState; public int getCombinedState() { return mCurCombinedState; } public void commitStateTime(long now) { if (mCurState != STATE_NOTHING) { if (mCurCombinedState != STATE_NOTHING) { long dur = now - mStartTime; if (dur > 0) { mDurations.addDuration(mCurState, dur); mDurations.addDuration(mCurCombinedState, dur); } } mStartTime = now; Loading Loading @@ -434,8 +434,8 @@ public final class ProcessState { mCommonProcess.incStartedServices(memFactor, now, serviceName); } mNumStartedServices++; if (mNumStartedServices == 1 && mCurState == STATE_NOTHING) { setState(STATE_SERVICE_RESTARTING + (memFactor*STATE_COUNT), now); if (mNumStartedServices == 1 && mCurCombinedState == STATE_NOTHING) { setCombinedState(STATE_SERVICE_RESTARTING + (memFactor*STATE_COUNT), now); } } Loading @@ -450,8 +450,8 @@ public final class ProcessState { mCommonProcess.decStartedServices(memFactor, now, serviceName); } mNumStartedServices--; if (mNumStartedServices == 0 && (mCurState%STATE_COUNT) == STATE_SERVICE_RESTARTING) { setState(STATE_NOTHING, now); if (mNumStartedServices == 0 && (mCurCombinedState %STATE_COUNT) == STATE_SERVICE_RESTARTING) { setCombinedState(STATE_NOTHING, now); } else if (mNumStartedServices < 0) { Slog.wtfStack(TAG, "Proc started services underrun: pkg=" + mPackage + " uid=" + mUid + " name=" + mName); Loading Loading @@ -485,16 +485,16 @@ public final class ProcessState { break; } if (!always) { if (mLastPssState == mCurState && SystemClock.uptimeMillis() if (mLastPssState == mCurCombinedState && SystemClock.uptimeMillis() < (mLastPssTime+(30*1000))) { return; } } mLastPssState = mCurState; mLastPssState = mCurCombinedState; mLastPssTime = SystemClock.uptimeMillis(); if (mCurState != STATE_NOTHING) { if (mCurCombinedState != STATE_NOTHING) { // First update the common process. mCommonProcess.mPssTable.mergeStats(mCurState, 1, pss, pss, pss, uss, uss, uss, mCommonProcess.mPssTable.mergeStats(mCurCombinedState, 1, pss, pss, pss, uss, uss, uss, rss, rss, rss); // If the common process is not multi-package, there is nothing else to do. Loading @@ -504,7 +504,7 @@ public final class ProcessState { if (pkgList != null) { for (int ip=pkgList.size()-1; ip>=0; ip--) { pullFixedProc(pkgList, ip).mPssTable.mergeStats(mCurState, 1, pullFixedProc(pkgList, ip).mPssTable.mergeStats(mCurCombinedState, 1, pss, pss, pss, uss, uss, uss, rss, rss, rss); } } Loading Loading @@ -623,7 +623,7 @@ public final class ProcessState { public long getDuration(int state, long now) { long time = mDurations.getValueForId((byte)state); if (mCurState == state) { if (mCurCombinedState == state) { time += now - mStartTime; } return time; Loading Loading @@ -728,7 +728,7 @@ public final class ProcessState { final int key = mDurations.getKeyAt(i); final int type = SparseMappingTable.getIdFromKey(key); long time = mDurations.getValue(key); if (mCurState == type) { if (mCurCombinedState == type) { time += now - mStartTime; } final int procState = type % STATE_COUNT; Loading Loading @@ -831,7 +831,7 @@ public final class ProcessState { final int bucket = ((iscreen + imem) * STATE_COUNT) + procStates[ip]; long time = mDurations.getValueForId((byte)bucket); String running = ""; if (mCurState == bucket) { if (mCurCombinedState == bucket) { running = " (running)"; } if (time != 0) { Loading Loading @@ -1181,14 +1181,14 @@ public final class ProcessState { final int key = mDurations.getKeyAt(i); final int type = SparseMappingTable.getIdFromKey(key); long time = mDurations.getValue(key); if (mCurState == type) { if (mCurCombinedState == type) { didCurState = true; time += now - mStartTime; } DumpUtils.printProcStateTagAndValue(pw, type, time); } if (!didCurState && mCurState != STATE_NOTHING) { DumpUtils.printProcStateTagAndValue(pw, mCurState, now - mStartTime); if (!didCurState && mCurCombinedState != STATE_NOTHING) { DumpUtils.printProcStateTagAndValue(pw, mCurCombinedState, now - mStartTime); } } Loading Loading @@ -1255,14 +1255,14 @@ public final class ProcessState { final int key = mDurations.getKeyAt(i); final int type = SparseMappingTable.getIdFromKey(key); long time = mDurations.getValue(key); if (mCurState == type) { if (mCurCombinedState == type) { didCurState = true; time += now - mStartTime; } durationByState.put(type, time); } if (!didCurState && mCurState != STATE_NOTHING) { durationByState.put(mCurState, now - mStartTime); if (!didCurState && mCurCombinedState != STATE_NOTHING) { durationByState.put(mCurCombinedState, now - mStartTime); } for (int i=0; i<mPssTable.getKeyCount(); i++) { Loading core/java/com/android/internal/app/procstats/ProcessStats.java +4 −3 Original line number Diff line number Diff line Loading @@ -1387,14 +1387,15 @@ public final class ProcessStats implements Parcelable { } else { final ProcessState proc = act.getAssociationState().getProcess(); if (proc != null) { if (act.mProcState == proc.getState()) { final int procState = proc.getCombinedState() % STATE_COUNT; if (act.mProcState == procState) { act.startActive(now); } else { act.stopActive(now); if (act.mProcState < proc.getState()) { if (act.mProcState < procState) { Slog.w(TAG, "Tracking association " + act + " whose proc state " + act.mProcState + " is better than process " + proc + " proc state " + proc.getState()); + " proc state " + procState); } } } else { Loading services/core/java/com/android/server/am/ActivityManagerService.java +3 −0 Original line number Diff line number Diff line Loading @@ -520,6 +520,9 @@ public class ActivityManagerService extends IActivityManager.Stub // Used to indicate that an app transition should be animated. static final boolean ANIMATE = true; // If set, we will push process association information in to procstats. static final boolean TRACK_PROCSTATS_ASSOCIATIONS = true; /** * Default value for {@link Settings.Global#NETWORK_ACCESS_TIMEOUT_MS}. */ Loading services/core/java/com/android/server/am/ConnectionRecord.java +6 −4 Original line number Diff line number Diff line Loading @@ -108,10 +108,12 @@ final class ConnectionRecord { public void startAssociationIfNeeded() { // If we don't already have an active association, create one... but only if this // is an association between two different processes. if (association == null && (binding.service.appInfo.uid != clientUid if (ActivityManagerService.TRACK_PROCSTATS_ASSOCIATIONS && association == null && binding.service.app != null && (binding.service.appInfo.uid != clientUid || !binding.service.processName.equals(clientProcessName))) { ProcessStats.ProcessStateHolder holder = binding.service.app != null ? binding.service.app.pkgList.get(binding.service.name.getPackageName()) : null; ProcessStats.ProcessStateHolder holder = binding.service.app.pkgList.get( binding.service.name.getPackageName()); if (holder == null) { Slog.wtf(TAG_AM, "No package in referenced service " + binding.service.name.toShortString() + ": proc=" + binding.service.app); Loading services/core/java/com/android/server/am/ContentProviderConnection.java +6 −4 Original line number Diff line number Diff line Loading @@ -55,10 +55,12 @@ public final class ContentProviderConnection extends Binder { public void startAssociationIfNeeded() { // If we don't already have an active association, create one... but only if this // is an association between two different processes. if (association == null && (provider.appInfo.uid != client.uid if (ActivityManagerService.TRACK_PROCSTATS_ASSOCIATIONS && association == null && provider.proc != null && (provider.appInfo.uid != client.uid || !provider.info.processName.equals(client.processName))) { ProcessStats.ProcessStateHolder holder = provider.proc != null ? provider.proc.pkgList.get(provider.name.getPackageName()) : null; ProcessStats.ProcessStateHolder holder = provider.proc.pkgList.get( provider.name.getPackageName()); if (holder == null) { Slog.wtf(TAG_AM, "No package in referenced provider " + provider.name.toShortString() + ": proc=" + provider.proc); Loading Loading
core/java/com/android/internal/app/procstats/ProcessState.java +31 −31 Original line number Diff line number Diff line Loading @@ -129,7 +129,7 @@ public final class ProcessState { private final PssTable mPssTable; private ProcessState mCommonProcess; private int mCurState = STATE_NOTHING; private int mCurCombinedState = STATE_NOTHING; private long mStartTime; private int mLastPssState = STATE_NOTHING; Loading Loading @@ -180,7 +180,7 @@ public final class ProcessState { mPackage = pkg; mUid = uid; mVersion = vers; mCurState = commonProcess.mCurState; mCurCombinedState = commonProcess.mCurCombinedState; mStartTime = now; mDurations = new DurationsTable(commonProcess.mStats.mTableData); mPssTable = new PssTable(commonProcess.mStats.mTableData); Loading Loading @@ -324,7 +324,7 @@ public final class ProcessState { public boolean isInUse() { return mActive || mNumActiveServices > 0 || mNumStartedServices > 0 || mCurState != STATE_NOTHING; || mCurCombinedState != STATE_NOTHING; } public boolean isActive() { Loading @@ -333,7 +333,7 @@ public final class ProcessState { public boolean hasAnyData() { return !(mDurations.getKeyCount() == 0 && mCurState == STATE_NOTHING && mCurCombinedState == STATE_NOTHING && mPssTable.getKeyCount() == 0); } Loading @@ -355,7 +355,7 @@ public final class ProcessState { } // First update the common process. mCommonProcess.setState(state, now); mCommonProcess.setCombinedState(state, now); // If the common process is not multi-package, there is nothing else to do. if (!mCommonProcess.mMultiPackage) { Loading @@ -364,29 +364,29 @@ public final class ProcessState { if (pkgList != null) { for (int ip=pkgList.size()-1; ip>=0; ip--) { pullFixedProc(pkgList, ip).setState(state, now); pullFixedProc(pkgList, ip).setCombinedState(state, now); } } } public void setState(int state, long now) { public void setCombinedState(int state, long now) { ensureNotDead(); if (!mDead && (mCurState != state)) { if (!mDead && (mCurCombinedState != state)) { //Slog.i(TAG, "Setting state in " + mName + "/" + mPackage + ": " + state); commitStateTime(now); mCurState = state; mCurCombinedState = state; } } public int getState() { return mCurState; public int getCombinedState() { return mCurCombinedState; } public void commitStateTime(long now) { if (mCurState != STATE_NOTHING) { if (mCurCombinedState != STATE_NOTHING) { long dur = now - mStartTime; if (dur > 0) { mDurations.addDuration(mCurState, dur); mDurations.addDuration(mCurCombinedState, dur); } } mStartTime = now; Loading Loading @@ -434,8 +434,8 @@ public final class ProcessState { mCommonProcess.incStartedServices(memFactor, now, serviceName); } mNumStartedServices++; if (mNumStartedServices == 1 && mCurState == STATE_NOTHING) { setState(STATE_SERVICE_RESTARTING + (memFactor*STATE_COUNT), now); if (mNumStartedServices == 1 && mCurCombinedState == STATE_NOTHING) { setCombinedState(STATE_SERVICE_RESTARTING + (memFactor*STATE_COUNT), now); } } Loading @@ -450,8 +450,8 @@ public final class ProcessState { mCommonProcess.decStartedServices(memFactor, now, serviceName); } mNumStartedServices--; if (mNumStartedServices == 0 && (mCurState%STATE_COUNT) == STATE_SERVICE_RESTARTING) { setState(STATE_NOTHING, now); if (mNumStartedServices == 0 && (mCurCombinedState %STATE_COUNT) == STATE_SERVICE_RESTARTING) { setCombinedState(STATE_NOTHING, now); } else if (mNumStartedServices < 0) { Slog.wtfStack(TAG, "Proc started services underrun: pkg=" + mPackage + " uid=" + mUid + " name=" + mName); Loading Loading @@ -485,16 +485,16 @@ public final class ProcessState { break; } if (!always) { if (mLastPssState == mCurState && SystemClock.uptimeMillis() if (mLastPssState == mCurCombinedState && SystemClock.uptimeMillis() < (mLastPssTime+(30*1000))) { return; } } mLastPssState = mCurState; mLastPssState = mCurCombinedState; mLastPssTime = SystemClock.uptimeMillis(); if (mCurState != STATE_NOTHING) { if (mCurCombinedState != STATE_NOTHING) { // First update the common process. mCommonProcess.mPssTable.mergeStats(mCurState, 1, pss, pss, pss, uss, uss, uss, mCommonProcess.mPssTable.mergeStats(mCurCombinedState, 1, pss, pss, pss, uss, uss, uss, rss, rss, rss); // If the common process is not multi-package, there is nothing else to do. Loading @@ -504,7 +504,7 @@ public final class ProcessState { if (pkgList != null) { for (int ip=pkgList.size()-1; ip>=0; ip--) { pullFixedProc(pkgList, ip).mPssTable.mergeStats(mCurState, 1, pullFixedProc(pkgList, ip).mPssTable.mergeStats(mCurCombinedState, 1, pss, pss, pss, uss, uss, uss, rss, rss, rss); } } Loading Loading @@ -623,7 +623,7 @@ public final class ProcessState { public long getDuration(int state, long now) { long time = mDurations.getValueForId((byte)state); if (mCurState == state) { if (mCurCombinedState == state) { time += now - mStartTime; } return time; Loading Loading @@ -728,7 +728,7 @@ public final class ProcessState { final int key = mDurations.getKeyAt(i); final int type = SparseMappingTable.getIdFromKey(key); long time = mDurations.getValue(key); if (mCurState == type) { if (mCurCombinedState == type) { time += now - mStartTime; } final int procState = type % STATE_COUNT; Loading Loading @@ -831,7 +831,7 @@ public final class ProcessState { final int bucket = ((iscreen + imem) * STATE_COUNT) + procStates[ip]; long time = mDurations.getValueForId((byte)bucket); String running = ""; if (mCurState == bucket) { if (mCurCombinedState == bucket) { running = " (running)"; } if (time != 0) { Loading Loading @@ -1181,14 +1181,14 @@ public final class ProcessState { final int key = mDurations.getKeyAt(i); final int type = SparseMappingTable.getIdFromKey(key); long time = mDurations.getValue(key); if (mCurState == type) { if (mCurCombinedState == type) { didCurState = true; time += now - mStartTime; } DumpUtils.printProcStateTagAndValue(pw, type, time); } if (!didCurState && mCurState != STATE_NOTHING) { DumpUtils.printProcStateTagAndValue(pw, mCurState, now - mStartTime); if (!didCurState && mCurCombinedState != STATE_NOTHING) { DumpUtils.printProcStateTagAndValue(pw, mCurCombinedState, now - mStartTime); } } Loading Loading @@ -1255,14 +1255,14 @@ public final class ProcessState { final int key = mDurations.getKeyAt(i); final int type = SparseMappingTable.getIdFromKey(key); long time = mDurations.getValue(key); if (mCurState == type) { if (mCurCombinedState == type) { didCurState = true; time += now - mStartTime; } durationByState.put(type, time); } if (!didCurState && mCurState != STATE_NOTHING) { durationByState.put(mCurState, now - mStartTime); if (!didCurState && mCurCombinedState != STATE_NOTHING) { durationByState.put(mCurCombinedState, now - mStartTime); } for (int i=0; i<mPssTable.getKeyCount(); i++) { Loading
core/java/com/android/internal/app/procstats/ProcessStats.java +4 −3 Original line number Diff line number Diff line Loading @@ -1387,14 +1387,15 @@ public final class ProcessStats implements Parcelable { } else { final ProcessState proc = act.getAssociationState().getProcess(); if (proc != null) { if (act.mProcState == proc.getState()) { final int procState = proc.getCombinedState() % STATE_COUNT; if (act.mProcState == procState) { act.startActive(now); } else { act.stopActive(now); if (act.mProcState < proc.getState()) { if (act.mProcState < procState) { Slog.w(TAG, "Tracking association " + act + " whose proc state " + act.mProcState + " is better than process " + proc + " proc state " + proc.getState()); + " proc state " + procState); } } } else { Loading
services/core/java/com/android/server/am/ActivityManagerService.java +3 −0 Original line number Diff line number Diff line Loading @@ -520,6 +520,9 @@ public class ActivityManagerService extends IActivityManager.Stub // Used to indicate that an app transition should be animated. static final boolean ANIMATE = true; // If set, we will push process association information in to procstats. static final boolean TRACK_PROCSTATS_ASSOCIATIONS = true; /** * Default value for {@link Settings.Global#NETWORK_ACCESS_TIMEOUT_MS}. */ Loading
services/core/java/com/android/server/am/ConnectionRecord.java +6 −4 Original line number Diff line number Diff line Loading @@ -108,10 +108,12 @@ final class ConnectionRecord { public void startAssociationIfNeeded() { // If we don't already have an active association, create one... but only if this // is an association between two different processes. if (association == null && (binding.service.appInfo.uid != clientUid if (ActivityManagerService.TRACK_PROCSTATS_ASSOCIATIONS && association == null && binding.service.app != null && (binding.service.appInfo.uid != clientUid || !binding.service.processName.equals(clientProcessName))) { ProcessStats.ProcessStateHolder holder = binding.service.app != null ? binding.service.app.pkgList.get(binding.service.name.getPackageName()) : null; ProcessStats.ProcessStateHolder holder = binding.service.app.pkgList.get( binding.service.name.getPackageName()); if (holder == null) { Slog.wtf(TAG_AM, "No package in referenced service " + binding.service.name.toShortString() + ": proc=" + binding.service.app); Loading
services/core/java/com/android/server/am/ContentProviderConnection.java +6 −4 Original line number Diff line number Diff line Loading @@ -55,10 +55,12 @@ public final class ContentProviderConnection extends Binder { public void startAssociationIfNeeded() { // If we don't already have an active association, create one... but only if this // is an association between two different processes. if (association == null && (provider.appInfo.uid != client.uid if (ActivityManagerService.TRACK_PROCSTATS_ASSOCIATIONS && association == null && provider.proc != null && (provider.appInfo.uid != client.uid || !provider.info.processName.equals(client.processName))) { ProcessStats.ProcessStateHolder holder = provider.proc != null ? provider.proc.pkgList.get(provider.name.getPackageName()) : null; ProcessStats.ProcessStateHolder holder = provider.proc.pkgList.get( provider.name.getPackageName()); if (holder == null) { Slog.wtf(TAG_AM, "No package in referenced provider " + provider.name.toShortString() + ": proc=" + provider.proc); Loading