Loading services/core/java/com/android/server/am/ActivityMetricsLogger.java +17 −20 Original line number Diff line number Diff line Loading @@ -51,6 +51,7 @@ import android.util.SparseIntArray; import android.util.StatsLog; import com.android.internal.logging.MetricsLogger; import com.android.internal.os.BackgroundThread; import com.android.internal.os.SomeArgs; import com.android.server.LocalServices; Loading @@ -74,8 +75,6 @@ class ActivityMetricsLogger { private static final long INVALID_START_TIME = -1; private static final int MSG_CHECK_VISIBILITY = 0; private static final int MSG_LOG_APP_TRANSITION = 1; private static final int MSG_LOG_APP_START_MEMORY_STATE_CAPTURE = 2; // Preallocated strings we are sending to tron, so we don't have to allocate a new one every // time we log. Loading Loading @@ -116,13 +115,6 @@ class ActivityMetricsLogger { final SomeArgs args = (SomeArgs) msg.obj; checkVisibility((TaskRecord) args.arg1, (ActivityRecord) args.arg2); break; case MSG_LOG_APP_TRANSITION: logAppTransition(msg.arg1, msg.arg2, (WindowingModeTransitionInfoSnapshot) msg.obj); break; case MSG_LOG_APP_START_MEMORY_STATE_CAPTURE: logAppStartMemoryStateCapture((WindowingModeTransitionInfo) msg.obj); break; } } } Loading @@ -141,11 +133,13 @@ class ActivityMetricsLogger { private final class WindowingModeTransitionInfoSnapshot { final private ApplicationInfo applicationInfo; final private ProcessRecord processRecord; final private String packageName; final private String launchedActivityName; final private String launchedActivityLaunchedFromPackage; final private String launchedActivityLaunchToken; final private String launchedActivityAppRecordRequiredAbi; final private String processName; final private int reason; final private int startingWindowDelayMs; final private int bindApplicationDelayMs; Loading @@ -166,6 +160,8 @@ class ActivityMetricsLogger { bindApplicationDelayMs = info.bindApplicationDelayMs; windowsDrawnDelayMs = info.windowsDrawnDelayMs; type = getTransitionType(info); processRecord = findProcessForActivity(info.launchedActivity); processName = info.launchedActivity.processName; } } Loading Loading @@ -505,15 +501,16 @@ class ActivityMetricsLogger { // This will avoid any races with other operations that modify the ActivityRecord. final WindowingModeTransitionInfoSnapshot infoSnapshot = new WindowingModeTransitionInfoSnapshot(info); mHandler.obtainMessage(MSG_LOG_APP_TRANSITION, mCurrentTransitionDeviceUptime, mCurrentTransitionDelayMs, infoSnapshot).sendToTarget(); final int currentTransitionDeviceUptime = mCurrentTransitionDeviceUptime; final int currentTransitionDelayMs = mCurrentTransitionDelayMs; BackgroundThread.getHandler().post(() -> logAppTransition( currentTransitionDeviceUptime, currentTransitionDelayMs, infoSnapshot)); info.launchedActivity.info.launchToken = null; mHandler.obtainMessage(MSG_LOG_APP_START_MEMORY_STATE_CAPTURE, info).sendToTarget(); } } // This gets called on the handler without holding the activity manager lock. // This gets called on a background thread without holding the activity manager lock. private void logAppTransition(int currentTransitionDeviceUptime, int currentTransitionDelayMs, WindowingModeTransitionInfoSnapshot info) { final LogMaker builder = new LogMaker(APP_TRANSITION); Loading Loading @@ -572,6 +569,7 @@ class ActivityMetricsLogger { launchToken, packageOptimizationInfo.getCompilationReason(), packageOptimizationInfo.getCompilationFilter()); logAppStartMemoryStateCapture(info); } private int convertAppStartTransitionType(int tronType) { Loading Loading @@ -629,15 +627,14 @@ class ActivityMetricsLogger { return -1; } private void logAppStartMemoryStateCapture(WindowingModeTransitionInfo info) { final ProcessRecord processRecord = findProcessForActivity(info.launchedActivity); if (processRecord == null) { private void logAppStartMemoryStateCapture(WindowingModeTransitionInfoSnapshot info) { if (info.processRecord == null) { if (DEBUG_METRICS) Slog.i(TAG, "logAppStartMemoryStateCapture processRecord null"); return; } final int pid = processRecord.pid; final int uid = info.launchedActivity.appInfo.uid; final int pid = info.processRecord.pid; final int uid = info.applicationInfo.uid; final MemoryStat memoryStat = readMemoryStatFromMemcg(uid, pid); if (memoryStat == null) { if (DEBUG_METRICS) Slog.i(TAG, "logAppStartMemoryStateCapture memoryStat null"); Loading @@ -647,8 +644,8 @@ class ActivityMetricsLogger { StatsLog.write( StatsLog.APP_START_MEMORY_STATE_CAPTURED, uid, info.launchedActivity.processName, info.launchedActivity.info.name, info.processName, info.launchedActivityName, memoryStat.pgfault, memoryStat.pgmajfault, memoryStat.rssInBytes, Loading Loading
services/core/java/com/android/server/am/ActivityMetricsLogger.java +17 −20 Original line number Diff line number Diff line Loading @@ -51,6 +51,7 @@ import android.util.SparseIntArray; import android.util.StatsLog; import com.android.internal.logging.MetricsLogger; import com.android.internal.os.BackgroundThread; import com.android.internal.os.SomeArgs; import com.android.server.LocalServices; Loading @@ -74,8 +75,6 @@ class ActivityMetricsLogger { private static final long INVALID_START_TIME = -1; private static final int MSG_CHECK_VISIBILITY = 0; private static final int MSG_LOG_APP_TRANSITION = 1; private static final int MSG_LOG_APP_START_MEMORY_STATE_CAPTURE = 2; // Preallocated strings we are sending to tron, so we don't have to allocate a new one every // time we log. Loading Loading @@ -116,13 +115,6 @@ class ActivityMetricsLogger { final SomeArgs args = (SomeArgs) msg.obj; checkVisibility((TaskRecord) args.arg1, (ActivityRecord) args.arg2); break; case MSG_LOG_APP_TRANSITION: logAppTransition(msg.arg1, msg.arg2, (WindowingModeTransitionInfoSnapshot) msg.obj); break; case MSG_LOG_APP_START_MEMORY_STATE_CAPTURE: logAppStartMemoryStateCapture((WindowingModeTransitionInfo) msg.obj); break; } } } Loading @@ -141,11 +133,13 @@ class ActivityMetricsLogger { private final class WindowingModeTransitionInfoSnapshot { final private ApplicationInfo applicationInfo; final private ProcessRecord processRecord; final private String packageName; final private String launchedActivityName; final private String launchedActivityLaunchedFromPackage; final private String launchedActivityLaunchToken; final private String launchedActivityAppRecordRequiredAbi; final private String processName; final private int reason; final private int startingWindowDelayMs; final private int bindApplicationDelayMs; Loading @@ -166,6 +160,8 @@ class ActivityMetricsLogger { bindApplicationDelayMs = info.bindApplicationDelayMs; windowsDrawnDelayMs = info.windowsDrawnDelayMs; type = getTransitionType(info); processRecord = findProcessForActivity(info.launchedActivity); processName = info.launchedActivity.processName; } } Loading Loading @@ -505,15 +501,16 @@ class ActivityMetricsLogger { // This will avoid any races with other operations that modify the ActivityRecord. final WindowingModeTransitionInfoSnapshot infoSnapshot = new WindowingModeTransitionInfoSnapshot(info); mHandler.obtainMessage(MSG_LOG_APP_TRANSITION, mCurrentTransitionDeviceUptime, mCurrentTransitionDelayMs, infoSnapshot).sendToTarget(); final int currentTransitionDeviceUptime = mCurrentTransitionDeviceUptime; final int currentTransitionDelayMs = mCurrentTransitionDelayMs; BackgroundThread.getHandler().post(() -> logAppTransition( currentTransitionDeviceUptime, currentTransitionDelayMs, infoSnapshot)); info.launchedActivity.info.launchToken = null; mHandler.obtainMessage(MSG_LOG_APP_START_MEMORY_STATE_CAPTURE, info).sendToTarget(); } } // This gets called on the handler without holding the activity manager lock. // This gets called on a background thread without holding the activity manager lock. private void logAppTransition(int currentTransitionDeviceUptime, int currentTransitionDelayMs, WindowingModeTransitionInfoSnapshot info) { final LogMaker builder = new LogMaker(APP_TRANSITION); Loading Loading @@ -572,6 +569,7 @@ class ActivityMetricsLogger { launchToken, packageOptimizationInfo.getCompilationReason(), packageOptimizationInfo.getCompilationFilter()); logAppStartMemoryStateCapture(info); } private int convertAppStartTransitionType(int tronType) { Loading Loading @@ -629,15 +627,14 @@ class ActivityMetricsLogger { return -1; } private void logAppStartMemoryStateCapture(WindowingModeTransitionInfo info) { final ProcessRecord processRecord = findProcessForActivity(info.launchedActivity); if (processRecord == null) { private void logAppStartMemoryStateCapture(WindowingModeTransitionInfoSnapshot info) { if (info.processRecord == null) { if (DEBUG_METRICS) Slog.i(TAG, "logAppStartMemoryStateCapture processRecord null"); return; } final int pid = processRecord.pid; final int uid = info.launchedActivity.appInfo.uid; final int pid = info.processRecord.pid; final int uid = info.applicationInfo.uid; final MemoryStat memoryStat = readMemoryStatFromMemcg(uid, pid); if (memoryStat == null) { if (DEBUG_METRICS) Slog.i(TAG, "logAppStartMemoryStateCapture memoryStat null"); Loading @@ -647,8 +644,8 @@ class ActivityMetricsLogger { StatsLog.write( StatsLog.APP_START_MEMORY_STATE_CAPTURED, uid, info.launchedActivity.processName, info.launchedActivity.info.name, info.processName, info.launchedActivityName, memoryStat.pgfault, memoryStat.pgmajfault, memoryStat.rssInBytes, Loading