Loading services/core/java/com/android/server/am/AppProfiler.java +9 −5 Original line number Diff line number Diff line Loading @@ -506,10 +506,14 @@ public class AppProfiler { } if (profile != null) { long startTime = SystemClock.currentThreadTimeMillis(); // skip background PSS calculation of apps that are capturing // camera imagery final boolean usingCamera = mService.isCameraActiveForUid(profile.mApp.uid); long pss = usingCamera ? 0 : Debug.getPss(pid, tmp, null); // skip background PSS calculation under the following situations: // - app is capturing camera imagery // - app is frozen and we have already collected PSS once. final boolean skipPSSCollection = (profile.mApp.mOptRecord != null && profile.mApp.mOptRecord.skipPSSCollectionBecauseFrozen()) || mService.isCameraActiveForUid(profile.mApp.uid); long pss = skipPSSCollection ? 0 : Debug.getPss(pid, tmp, null); long endTime = SystemClock.currentThreadTimeMillis(); synchronized (mProfilerLock) { if (pss != 0 && profile.getThread() != null Loading @@ -524,7 +528,7 @@ public class AppProfiler { if (DEBUG_PSS) { Slog.d(TAG_PSS, "Skipped pss collection of " + pid + ": " + (profile.getThread() == null ? "NO_THREAD " : "") + (usingCamera ? "CAMERA " : "") + (skipPSSCollection ? "SKIP_PSS_COLLECTION " : "") + (profile.getPid() != pid ? "PID_CHANGED " : "") + " initState=" + procState + " curState=" + profile.getSetProcState() + " " Loading services/core/java/com/android/server/am/CachedAppOptimizer.java +1 −0 Original line number Diff line number Diff line Loading @@ -2004,6 +2004,7 @@ public final class CachedAppOptimizer { opt.setFreezeUnfreezeTime(SystemClock.uptimeMillis()); opt.setFrozen(true); opt.setHasCollectedFrozenPSS(false); mFrozenProcesses.put(pid, proc); } catch (Exception e) { Slog.w(TAG_AM, "Unable to freeze " + pid + " " + name); Loading services/core/java/com/android/server/am/ProcessCachedOptimizerRecord.java +25 −0 Original line number Diff line number Diff line Loading @@ -72,6 +72,12 @@ final class ProcessCachedOptimizerRecord { @GuardedBy("mProcLock") private boolean mFrozen; /** * Set to false after the process has been frozen. * Set to true after we have collected PSS for the frozen process. */ private boolean mHasCollectedFrozenPSS; /** * An override on the freeze state is in progress. */ Loading Loading @@ -188,6 +194,25 @@ final class ProcessCachedOptimizerRecord { mFrozen = frozen; } boolean skipPSSCollectionBecauseFrozen() { boolean collected = mHasCollectedFrozenPSS; // This check is racy but it isn't critical to PSS collection that we have the most up to // date idea of whether a task is frozen. if (!mFrozen) { // not frozen == always ask to collect PSS return false; } // We don't want to count PSS for a frozen process more than once. mHasCollectedFrozenPSS = true; return collected; } void setHasCollectedFrozenPSS(boolean collected) { mHasCollectedFrozenPSS = collected; } @GuardedBy("mProcLock") boolean hasFreezerOverride() { return mFreezerOverride; Loading Loading
services/core/java/com/android/server/am/AppProfiler.java +9 −5 Original line number Diff line number Diff line Loading @@ -506,10 +506,14 @@ public class AppProfiler { } if (profile != null) { long startTime = SystemClock.currentThreadTimeMillis(); // skip background PSS calculation of apps that are capturing // camera imagery final boolean usingCamera = mService.isCameraActiveForUid(profile.mApp.uid); long pss = usingCamera ? 0 : Debug.getPss(pid, tmp, null); // skip background PSS calculation under the following situations: // - app is capturing camera imagery // - app is frozen and we have already collected PSS once. final boolean skipPSSCollection = (profile.mApp.mOptRecord != null && profile.mApp.mOptRecord.skipPSSCollectionBecauseFrozen()) || mService.isCameraActiveForUid(profile.mApp.uid); long pss = skipPSSCollection ? 0 : Debug.getPss(pid, tmp, null); long endTime = SystemClock.currentThreadTimeMillis(); synchronized (mProfilerLock) { if (pss != 0 && profile.getThread() != null Loading @@ -524,7 +528,7 @@ public class AppProfiler { if (DEBUG_PSS) { Slog.d(TAG_PSS, "Skipped pss collection of " + pid + ": " + (profile.getThread() == null ? "NO_THREAD " : "") + (usingCamera ? "CAMERA " : "") + (skipPSSCollection ? "SKIP_PSS_COLLECTION " : "") + (profile.getPid() != pid ? "PID_CHANGED " : "") + " initState=" + procState + " curState=" + profile.getSetProcState() + " " Loading
services/core/java/com/android/server/am/CachedAppOptimizer.java +1 −0 Original line number Diff line number Diff line Loading @@ -2004,6 +2004,7 @@ public final class CachedAppOptimizer { opt.setFreezeUnfreezeTime(SystemClock.uptimeMillis()); opt.setFrozen(true); opt.setHasCollectedFrozenPSS(false); mFrozenProcesses.put(pid, proc); } catch (Exception e) { Slog.w(TAG_AM, "Unable to freeze " + pid + " " + name); Loading
services/core/java/com/android/server/am/ProcessCachedOptimizerRecord.java +25 −0 Original line number Diff line number Diff line Loading @@ -72,6 +72,12 @@ final class ProcessCachedOptimizerRecord { @GuardedBy("mProcLock") private boolean mFrozen; /** * Set to false after the process has been frozen. * Set to true after we have collected PSS for the frozen process. */ private boolean mHasCollectedFrozenPSS; /** * An override on the freeze state is in progress. */ Loading Loading @@ -188,6 +194,25 @@ final class ProcessCachedOptimizerRecord { mFrozen = frozen; } boolean skipPSSCollectionBecauseFrozen() { boolean collected = mHasCollectedFrozenPSS; // This check is racy but it isn't critical to PSS collection that we have the most up to // date idea of whether a task is frozen. if (!mFrozen) { // not frozen == always ask to collect PSS return false; } // We don't want to count PSS for a frozen process more than once. mHasCollectedFrozenPSS = true; return collected; } void setHasCollectedFrozenPSS(boolean collected) { mHasCollectedFrozenPSS = collected; } @GuardedBy("mProcLock") boolean hasFreezerOverride() { return mFreezerOverride; Loading