Loading core/proto/android/os/processstarttime.proto 0 → 100644 +92 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ syntax = "proto2"; package android.os; option java_multiple_files = true; // This message is used for statsd logging and should be kept in sync with // frameworks/proto_logging/stats/atoms.proto /** * Logs information about process start time. * * Logged from: * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java */ message ProcessStartTime { // The uid of the ProcessRecord. optional int32 uid = 1; // The process pid. optional int32 pid = 2; // The process name. // Usually package name, "system" for system server. // Provided by ActivityManagerService. optional string process_name = 3; enum StartType { UNKNOWN = 0; WARM = 1; HOT = 2; COLD = 3; } // The start type. optional StartType type = 4; // The elapsed realtime at the start of the process. optional int64 process_start_time_millis = 5; // Number of milliseconds it takes to reach bind application. optional int32 bind_application_delay_millis = 6; // Number of milliseconds it takes to finish start of the process. optional int32 process_start_delay_millis = 7; // hostingType field in ProcessRecord, the component type such as "activity", // "service", "content provider", "broadcast" or other strings. optional string hosting_type = 8; // hostingNameStr field in ProcessRecord. The component class name that runs // in this process. optional string hosting_name = 9; // Broadcast action name. optional string broadcast_action_name = 10; enum HostingTypeId { HOSTING_TYPE_UNKNOWN = 0; HOSTING_TYPE_ACTIVITY = 1; HOSTING_TYPE_ADDED_APPLICATION = 2; HOSTING_TYPE_BACKUP = 3; HOSTING_TYPE_BROADCAST = 4; HOSTING_TYPE_CONTENT_PROVIDER = 5; HOSTING_TYPE_LINK_FAIL = 6; HOSTING_TYPE_ON_HOLD = 7; HOSTING_TYPE_NEXT_ACTIVITY = 8; HOSTING_TYPE_NEXT_TOP_ACTIVITY = 9; HOSTING_TYPE_RESTART = 10; HOSTING_TYPE_SERVICE = 11; HOSTING_TYPE_SYSTEM = 12; HOSTING_TYPE_TOP_ACTIVITY = 13; HOSTING_TYPE_EMPTY = 14; } optional HostingTypeId hosting_type_id = 11; } services/core/java/com/android/server/am/ActiveServices.java +2 −1 Original line number Diff line number Diff line Loading @@ -4177,7 +4177,8 @@ public final class ActiveServices { final boolean isolated = (r.serviceInfo.flags&ServiceInfo.FLAG_ISOLATED_PROCESS) != 0; final String procName = r.processName; HostingRecord hostingRecord = new HostingRecord("service", r.instanceName, HostingRecord hostingRecord = new HostingRecord( HostingRecord.HOSTING_TYPE_SERVICE, r.instanceName, r.definingPackageName, r.definingUid, r.serviceInfo.processName); ProcessRecord app; Loading services/core/java/com/android/server/am/ActivityManagerService.java +24 −9 Original line number Diff line number Diff line Loading @@ -1872,7 +1872,7 @@ public class ActivityManagerService extends IActivityManager.Stub false, 0, null, new HostingRecord("system")); new HostingRecord(HostingRecord.HOSTING_TYPE_SYSTEM)); app.setPersistent(true); app.setPid(MY_PID); app.mState.setMaxAdj(ProcessList.SYSTEM_ADJ); Loading Loading @@ -4721,7 +4721,7 @@ public class ActivityManagerService extends IActivityManager.Stub } catch (RemoteException e) { app.resetPackageList(mProcessStats); mProcessList.startProcessLocked(app, new HostingRecord("link fail", processName), new HostingRecord(HostingRecord.HOSTING_TYPE_LINK_FAIL, processName), ZYGOTE_POLICY_FLAG_EMPTY); return false; } Loading Loading @@ -4990,6 +4990,17 @@ public class ActivityManagerService extends IActivityManager.Stub checkTime(startTime, "attachApplicationLocked: after updateOomAdjLocked"); } final HostingRecord hostingRecord = app.getHostingRecord(); final String action = hostingRecord.getAction(); String shortAction = action; if (action != null) { // only log the last part of the action string to save stats data. int index = action.lastIndexOf("."); if (index != -1 && index != action.length() - 1) { shortAction = action.substring(index + 1); } } FrameworkStatsLog.write( FrameworkStatsLog.PROCESS_START_TIME, app.info.uid, Loading @@ -4999,8 +5010,10 @@ public class ActivityManagerService extends IActivityManager.Stub app.getStartElapsedTime(), (int) (bindApplicationTimeMillis - app.getStartUptime()), (int) (SystemClock.uptimeMillis() - app.getStartUptime()), app.getHostingRecord().getType(), (app.getHostingRecord().getName() != null ? app.getHostingRecord().getName() : "")); hostingRecord.getType(), hostingRecord.getName(), shortAction, HostingRecord.getHostingTypeIdStatsd(hostingRecord.getType())); return true; } Loading Loading @@ -5099,7 +5112,7 @@ public class ActivityManagerService extends IActivityManager.Stub Slog.v(TAG_PROCESSES, "Starting process on hold: " + procs.get(ip)); } mProcessList.startProcessLocked(procs.get(ip), new HostingRecord("on-hold"), new HostingRecord(HostingRecord.HOSTING_TYPE_ON_HOLD), ZYGOTE_POLICY_FLAG_BATCH_LAUNCH); } } Loading Loading @@ -6685,7 +6698,7 @@ public class ActivityManagerService extends IActivityManager.Stub isSdkSandbox, sdkSandboxUid, sdkSandboxClientAppPackage, new HostingRecord("added application", new HostingRecord(HostingRecord.HOSTING_TYPE_ADDED_APPLICATION, customProcess != null ? customProcess : info.processName)); updateLruProcessLocked(app, false, null); updateOomAdjLocked(app, OomAdjuster.OOM_ADJ_REASON_PROCESS_BEGIN); Loading Loading @@ -6714,7 +6727,8 @@ public class ActivityManagerService extends IActivityManager.Stub } if (app.getThread() == null && mPersistentStartingProcesses.indexOf(app) < 0) { mPersistentStartingProcesses.add(app); mProcessList.startProcessLocked(app, new HostingRecord("added application", mProcessList.startProcessLocked(app, new HostingRecord( HostingRecord.HOSTING_TYPE_ADDED_APPLICATION, customProcess != null ? customProcess : app.processName), zygotePolicyFlags, disableHiddenApiChecks, disableTestApiChecks, abiOverride); Loading Loading @@ -12365,7 +12379,8 @@ public class ActivityManagerService extends IActivityManager.Stub mProcessList.addProcessNameLocked(app); app.setPendingStart(false); mProcessList.startProcessLocked(app, new HostingRecord("restart", app.processName), mProcessList.startProcessLocked(app, new HostingRecord( HostingRecord.HOSTING_TYPE_RESTART, app.processName), ZYGOTE_POLICY_FLAG_EMPTY); return true; } else if (pid > 0 && pid != MY_PID) { Loading Loading @@ -12750,7 +12765,7 @@ public class ActivityManagerService extends IActivityManager.Stub // startProcessLocked() returns existing proc's record if it's already running ProcessRecord proc = startProcessLocked(app.processName, app, false, 0, new HostingRecord("backup", hostingName), new HostingRecord(HostingRecord.HOSTING_TYPE_BACKUP, hostingName), ZYGOTE_POLICY_FLAG_SYSTEM_PROCESS, false, false); if (proc == null) { Slog.e(TAG, "Unable to start backup agent process " + r); services/core/java/com/android/server/am/BroadcastQueue.java +3 −2 Original line number Diff line number Diff line Loading @@ -1870,8 +1870,9 @@ public final class BroadcastQueue { r.curApp = mService.startProcessLocked(targetProcess, info.activityInfo.applicationInfo, true, r.intent.getFlags() | Intent.FLAG_FROM_BACKGROUND, new HostingRecord("broadcast", r.curComponent), isActivityCapable ? ZYGOTE_POLICY_FLAG_LATENCY_SENSITIVE : ZYGOTE_POLICY_FLAG_EMPTY, new HostingRecord(HostingRecord.HOSTING_TYPE_BROADCAST, r.curComponent, r.intent.getAction()), isActivityCapable ? ZYGOTE_POLICY_FLAG_LATENCY_SENSITIVE : ZYGOTE_POLICY_FLAG_EMPTY, (r.intent.getFlags() & Intent.FLAG_RECEIVER_BOOT_UPGRADE) != 0, false); if (r.curApp == null) { // Ah, this recipient is unavailable. Finish it if necessary, Loading services/core/java/com/android/server/am/ContentProviderHelper.java +1 −1 Original line number Diff line number Diff line Loading @@ -482,7 +482,7 @@ public class ContentProviderHelper { checkTime(startTime, "getContentProviderImpl: before start process"); proc = mService.startProcessLocked( cpi.processName, cpr.appInfo, false, 0, new HostingRecord("content provider", new HostingRecord(HostingRecord.HOSTING_TYPE_CONTENT_PROVIDER, new ComponentName( cpi.applicationInfo.packageName, cpi.name)), Process.ZYGOTE_POLICY_FLAG_EMPTY, false, false); Loading Loading
core/proto/android/os/processstarttime.proto 0 → 100644 +92 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ syntax = "proto2"; package android.os; option java_multiple_files = true; // This message is used for statsd logging and should be kept in sync with // frameworks/proto_logging/stats/atoms.proto /** * Logs information about process start time. * * Logged from: * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java */ message ProcessStartTime { // The uid of the ProcessRecord. optional int32 uid = 1; // The process pid. optional int32 pid = 2; // The process name. // Usually package name, "system" for system server. // Provided by ActivityManagerService. optional string process_name = 3; enum StartType { UNKNOWN = 0; WARM = 1; HOT = 2; COLD = 3; } // The start type. optional StartType type = 4; // The elapsed realtime at the start of the process. optional int64 process_start_time_millis = 5; // Number of milliseconds it takes to reach bind application. optional int32 bind_application_delay_millis = 6; // Number of milliseconds it takes to finish start of the process. optional int32 process_start_delay_millis = 7; // hostingType field in ProcessRecord, the component type such as "activity", // "service", "content provider", "broadcast" or other strings. optional string hosting_type = 8; // hostingNameStr field in ProcessRecord. The component class name that runs // in this process. optional string hosting_name = 9; // Broadcast action name. optional string broadcast_action_name = 10; enum HostingTypeId { HOSTING_TYPE_UNKNOWN = 0; HOSTING_TYPE_ACTIVITY = 1; HOSTING_TYPE_ADDED_APPLICATION = 2; HOSTING_TYPE_BACKUP = 3; HOSTING_TYPE_BROADCAST = 4; HOSTING_TYPE_CONTENT_PROVIDER = 5; HOSTING_TYPE_LINK_FAIL = 6; HOSTING_TYPE_ON_HOLD = 7; HOSTING_TYPE_NEXT_ACTIVITY = 8; HOSTING_TYPE_NEXT_TOP_ACTIVITY = 9; HOSTING_TYPE_RESTART = 10; HOSTING_TYPE_SERVICE = 11; HOSTING_TYPE_SYSTEM = 12; HOSTING_TYPE_TOP_ACTIVITY = 13; HOSTING_TYPE_EMPTY = 14; } optional HostingTypeId hosting_type_id = 11; }
services/core/java/com/android/server/am/ActiveServices.java +2 −1 Original line number Diff line number Diff line Loading @@ -4177,7 +4177,8 @@ public final class ActiveServices { final boolean isolated = (r.serviceInfo.flags&ServiceInfo.FLAG_ISOLATED_PROCESS) != 0; final String procName = r.processName; HostingRecord hostingRecord = new HostingRecord("service", r.instanceName, HostingRecord hostingRecord = new HostingRecord( HostingRecord.HOSTING_TYPE_SERVICE, r.instanceName, r.definingPackageName, r.definingUid, r.serviceInfo.processName); ProcessRecord app; Loading
services/core/java/com/android/server/am/ActivityManagerService.java +24 −9 Original line number Diff line number Diff line Loading @@ -1872,7 +1872,7 @@ public class ActivityManagerService extends IActivityManager.Stub false, 0, null, new HostingRecord("system")); new HostingRecord(HostingRecord.HOSTING_TYPE_SYSTEM)); app.setPersistent(true); app.setPid(MY_PID); app.mState.setMaxAdj(ProcessList.SYSTEM_ADJ); Loading Loading @@ -4721,7 +4721,7 @@ public class ActivityManagerService extends IActivityManager.Stub } catch (RemoteException e) { app.resetPackageList(mProcessStats); mProcessList.startProcessLocked(app, new HostingRecord("link fail", processName), new HostingRecord(HostingRecord.HOSTING_TYPE_LINK_FAIL, processName), ZYGOTE_POLICY_FLAG_EMPTY); return false; } Loading Loading @@ -4990,6 +4990,17 @@ public class ActivityManagerService extends IActivityManager.Stub checkTime(startTime, "attachApplicationLocked: after updateOomAdjLocked"); } final HostingRecord hostingRecord = app.getHostingRecord(); final String action = hostingRecord.getAction(); String shortAction = action; if (action != null) { // only log the last part of the action string to save stats data. int index = action.lastIndexOf("."); if (index != -1 && index != action.length() - 1) { shortAction = action.substring(index + 1); } } FrameworkStatsLog.write( FrameworkStatsLog.PROCESS_START_TIME, app.info.uid, Loading @@ -4999,8 +5010,10 @@ public class ActivityManagerService extends IActivityManager.Stub app.getStartElapsedTime(), (int) (bindApplicationTimeMillis - app.getStartUptime()), (int) (SystemClock.uptimeMillis() - app.getStartUptime()), app.getHostingRecord().getType(), (app.getHostingRecord().getName() != null ? app.getHostingRecord().getName() : "")); hostingRecord.getType(), hostingRecord.getName(), shortAction, HostingRecord.getHostingTypeIdStatsd(hostingRecord.getType())); return true; } Loading Loading @@ -5099,7 +5112,7 @@ public class ActivityManagerService extends IActivityManager.Stub Slog.v(TAG_PROCESSES, "Starting process on hold: " + procs.get(ip)); } mProcessList.startProcessLocked(procs.get(ip), new HostingRecord("on-hold"), new HostingRecord(HostingRecord.HOSTING_TYPE_ON_HOLD), ZYGOTE_POLICY_FLAG_BATCH_LAUNCH); } } Loading Loading @@ -6685,7 +6698,7 @@ public class ActivityManagerService extends IActivityManager.Stub isSdkSandbox, sdkSandboxUid, sdkSandboxClientAppPackage, new HostingRecord("added application", new HostingRecord(HostingRecord.HOSTING_TYPE_ADDED_APPLICATION, customProcess != null ? customProcess : info.processName)); updateLruProcessLocked(app, false, null); updateOomAdjLocked(app, OomAdjuster.OOM_ADJ_REASON_PROCESS_BEGIN); Loading Loading @@ -6714,7 +6727,8 @@ public class ActivityManagerService extends IActivityManager.Stub } if (app.getThread() == null && mPersistentStartingProcesses.indexOf(app) < 0) { mPersistentStartingProcesses.add(app); mProcessList.startProcessLocked(app, new HostingRecord("added application", mProcessList.startProcessLocked(app, new HostingRecord( HostingRecord.HOSTING_TYPE_ADDED_APPLICATION, customProcess != null ? customProcess : app.processName), zygotePolicyFlags, disableHiddenApiChecks, disableTestApiChecks, abiOverride); Loading Loading @@ -12365,7 +12379,8 @@ public class ActivityManagerService extends IActivityManager.Stub mProcessList.addProcessNameLocked(app); app.setPendingStart(false); mProcessList.startProcessLocked(app, new HostingRecord("restart", app.processName), mProcessList.startProcessLocked(app, new HostingRecord( HostingRecord.HOSTING_TYPE_RESTART, app.processName), ZYGOTE_POLICY_FLAG_EMPTY); return true; } else if (pid > 0 && pid != MY_PID) { Loading Loading @@ -12750,7 +12765,7 @@ public class ActivityManagerService extends IActivityManager.Stub // startProcessLocked() returns existing proc's record if it's already running ProcessRecord proc = startProcessLocked(app.processName, app, false, 0, new HostingRecord("backup", hostingName), new HostingRecord(HostingRecord.HOSTING_TYPE_BACKUP, hostingName), ZYGOTE_POLICY_FLAG_SYSTEM_PROCESS, false, false); if (proc == null) { Slog.e(TAG, "Unable to start backup agent process " + r);
services/core/java/com/android/server/am/BroadcastQueue.java +3 −2 Original line number Diff line number Diff line Loading @@ -1870,8 +1870,9 @@ public final class BroadcastQueue { r.curApp = mService.startProcessLocked(targetProcess, info.activityInfo.applicationInfo, true, r.intent.getFlags() | Intent.FLAG_FROM_BACKGROUND, new HostingRecord("broadcast", r.curComponent), isActivityCapable ? ZYGOTE_POLICY_FLAG_LATENCY_SENSITIVE : ZYGOTE_POLICY_FLAG_EMPTY, new HostingRecord(HostingRecord.HOSTING_TYPE_BROADCAST, r.curComponent, r.intent.getAction()), isActivityCapable ? ZYGOTE_POLICY_FLAG_LATENCY_SENSITIVE : ZYGOTE_POLICY_FLAG_EMPTY, (r.intent.getFlags() & Intent.FLAG_RECEIVER_BOOT_UPGRADE) != 0, false); if (r.curApp == null) { // Ah, this recipient is unavailable. Finish it if necessary, Loading
services/core/java/com/android/server/am/ContentProviderHelper.java +1 −1 Original line number Diff line number Diff line Loading @@ -482,7 +482,7 @@ public class ContentProviderHelper { checkTime(startTime, "getContentProviderImpl: before start process"); proc = mService.startProcessLocked( cpi.processName, cpr.appInfo, false, 0, new HostingRecord("content provider", new HostingRecord(HostingRecord.HOSTING_TYPE_CONTENT_PROVIDER, new ComponentName( cpi.applicationInfo.packageName, cpi.name)), Process.ZYGOTE_POLICY_FLAG_EMPTY, false, false); Loading