Some improvements to process state dumpsys output.
The detailed dumpsys output of ProcessRecord had some formatting
issues. Cleaned this up, also reorganized and improved some of
the other output.
And improved debugging output of capabilities -- have special
formatting to print the flags in a more human-readable way, and
added this to the process list summaries.
Looks like this:
Proc #28: psvc F/ /PER LCM t: 0 32602:com.google.android.providers.media.module/u0a236 (service)
com.google.android.providers.media.module/com.android.providers.media.fuse.ExternalStorageServiceImpl<=Proc{31384:system/1000}
Proc # 4: psvc F/ /PER LCM t: 0 31614:com.android.bluetooth/1002 (service)
com.android.bluetooth/.gatt.GattService<=Proc{31384:system/1000}
Proc # 2: fg+50 F/A/TOP LCM t: 0 4029:com.google.android.apps.maps/u0a186 (fg-service-act)
Proc # 0: vis F/A/TOP LCM t: 0 32033:com.google.android.apps.nexuslauncher/u0a155 (service)
com.google.android.apps.nexuslauncher/com.android.launcher3.notification.NotificationListener<=Proc{31384:system/1000}
Proc # 8: vis F/ /BTOP LCM t: 0 32563:com.google.android.googlequicksearchbox:interactor/u0a151 (service)
com.google.android.googlequicksearchbox/com.google.android.voiceinteraction.GsaVoiceInteractionService<=Proc{777:com.google.android.googlequicksearchbox:search/u0a151}
Proc # 7: vis F/ /BTOP LCM t: 0 4406:com.google.android.tts/u0a204 (service)
com.google.android.tts/.service.GoogleTTSService<=Proc{4029:com.google.android.apps.maps/u0a186}
Proc # 6: vis F/ /BTOP LCM t: 0 777:com.google.android.googlequicksearchbox:search/u0a151 (service)
com.google.android.googlequicksearchbox/com.google.android.apps.gsa.publicsearch.PublicSearchService<=Proc{4029:com.google.android.apps.maps/u0a186}
Proc # 1: vis F/ /BTOP LCM t: 0 32254:com.google.android.gms.persistent/u0a152 (service)
com.google.android.gms/com.google.android.location.internal.GoogleLocationManagerService<=Proc{4029:com.google.android.apps.maps/u0a186}
Proc #47: vis F/ /BFGS --- t: 0 31954:com.google.android.ext.services/u0a70 (service)
com.google.android.ext.services/android.ext.services.notification.Assistant<=Proc{31384:system/1000}
Proc #16: vis F/ /BFGS LCM t: 0 32515:com.google.android.as/u0a112 (service)
com.google.android.as/com.google.android.apps.miphone.aiai.captions.SystemCaptionsManagerService<=Proc{31384:system/1000}
Proc #51: vis F/ /IMPF --- t: 0 2072:com.qualcomm.qcrilmsgtunnel/1001 (service)
com.qualcomm.qcrilmsgtunnel/.QcrilMsgTunnelService<=Proc{31915:com.android.phone/1001}
Proc #48: prcp b/ /IMPB --- t: 0 3783:com.google.android.inputmethod.latin/u0a182 (service)
com.google.android.inputmethod.latin/com.android.inputmethod.latin.LatinIME<=Proc{31384:system/1000}
Bug: 156545187
Test: manually checked output
Change-Id: I99d8136b98b39e74d9f316da5954f85aec570c01
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java
index 9067069..731fc5a 100644
--- a/core/java/android/app/ActivityManager.java
+++ b/core/java/android/app/ActivityManager.java
@@ -601,6 +601,20 @@
@TestApi
public static final int PROCESS_CAPABILITY_FOREGROUND_MICROPHONE = 1 << 2;
+ // TODO: remove this when development is done.
+ // These are debug flags used between OomAdjuster and AppOpsService to detect and report absence
+ // of the real flags.
+ /** @hide */
+ public static final int DEBUG_PROCESS_CAPABILITY_FOREGROUND_MICROPHONE_Q = 1 << 27;
+ /** @hide */
+ public static final int DEBUG_PROCESS_CAPABILITY_FOREGROUND_CAMERA_Q = 1 << 28;
+ /** @hide */
+ public static final int DEBUG_PROCESS_CAPABILITY_FOREGROUND_MICROPHONE = 1 << 29;
+ /** @hide */
+ public static final int DEBUG_PROCESS_CAPABILITY_FOREGROUND_CAMERA = 1 << 30;
+ /** @hide */
+ public static final int DEBUG_PROCESS_CAPABILITY_FOREGROUND_LOCATION = 1 << 31;
+
/** @hide all capabilities, the ORing of all flags in {@link ProcessCapability}*/
@TestApi
public static final int PROCESS_CAPABILITY_ALL = PROCESS_CAPABILITY_FOREGROUND_LOCATION
@@ -623,6 +637,51 @@
public static final int PROCESS_CAPABILITY_ALL_IMPLICIT = PROCESS_CAPABILITY_FOREGROUND_CAMERA
| PROCESS_CAPABILITY_FOREGROUND_MICROPHONE;
+ /**
+ * Print capability bits in human-readable form.
+ * @hide
+ */
+ public static void printCapabilitiesSummary(PrintWriter pw, @ProcessCapability int caps) {
+ pw.print((caps & PROCESS_CAPABILITY_FOREGROUND_LOCATION) != 0 ? 'L' : '-');
+ pw.print((caps & PROCESS_CAPABILITY_FOREGROUND_CAMERA) != 0 ? 'C' : '-');
+ pw.print((caps & PROCESS_CAPABILITY_FOREGROUND_MICROPHONE) != 0 ? 'M' : '-');
+ }
+
+ /**
+ * Print capability bits in human-readable form.
+ * @hide
+ */
+ public static void printCapabilitiesFull(PrintWriter pw, @ProcessCapability int caps) {
+ printCapabilitiesSummary(pw, caps);
+ if ((caps & DEBUG_PROCESS_CAPABILITY_FOREGROUND_LOCATION) != 0) {
+ pw.print(" !L");
+ }
+ if ((caps & DEBUG_PROCESS_CAPABILITY_FOREGROUND_CAMERA) != 0) {
+ pw.print(" !C");
+ }
+ if ((caps & DEBUG_PROCESS_CAPABILITY_FOREGROUND_CAMERA_Q) != 0) {
+ pw.print(" !Cq");
+ }
+ if ((caps & DEBUG_PROCESS_CAPABILITY_FOREGROUND_MICROPHONE) != 0) {
+ pw.print(" !M");
+ }
+ if ((caps & DEBUG_PROCESS_CAPABILITY_FOREGROUND_MICROPHONE_Q) != 0) {
+ pw.print(" !Mq");
+ }
+ final int remain = caps & ~(PROCESS_CAPABILITY_FOREGROUND_LOCATION
+ | PROCESS_CAPABILITY_FOREGROUND_CAMERA
+ | PROCESS_CAPABILITY_FOREGROUND_MICROPHONE
+ | DEBUG_PROCESS_CAPABILITY_FOREGROUND_LOCATION
+ | DEBUG_PROCESS_CAPABILITY_FOREGROUND_CAMERA
+ | DEBUG_PROCESS_CAPABILITY_FOREGROUND_CAMERA_Q
+ | DEBUG_PROCESS_CAPABILITY_FOREGROUND_MICROPHONE
+ | DEBUG_PROCESS_CAPABILITY_FOREGROUND_MICROPHONE_Q);
+ if (remain != 0) {
+ pw.print('+');
+ pw.print(remain);
+ }
+ }
+
// NOTE: If PROCESS_STATEs are added, then new fields must be added
// to frameworks/base/core/proto/android/app/enums.proto and the following method must
// be updated to correctly map between them.
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 930f124..2b86d7f 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -11083,18 +11083,22 @@
void dumpLruEntryLocked(PrintWriter pw, int index, ProcessRecord proc, String prefix) {
pw.print(prefix);
- pw.print("#");
+ pw.print('#');
+ if (index < 10) {
+ pw.print(' ');
+ }
pw.print(index);
pw.print(": ");
pw.print(ProcessList.makeOomAdjString(proc.setAdj, false));
- pw.print(" ");
+ pw.print(' ');
pw.print(ProcessList.makeProcStateString(proc.getCurProcState()));
- pw.print(" ");
+ pw.print(' ');
+ ActivityManager.printCapabilitiesSummary(pw, proc.curCapability);
+ pw.print(' ');
pw.print(proc.toShortString());
- pw.print(" ");
if (proc.hasActivitiesOrRecentTasks() || proc.hasClientActivities()
|| proc.treatLikeActivity) {
- pw.print(" activity=");
+ pw.print(" act:");
boolean printed = false;
if (proc.hasActivities()) {
pw.print("activities");
@@ -12559,7 +12563,7 @@
char schedGroup;
switch (r.setSchedGroup) {
case ProcessList.SCHED_GROUP_BACKGROUND:
- schedGroup = 'B';
+ schedGroup = 'b';
break;
case ProcessList.SCHED_GROUP_DEFAULT:
schedGroup = 'F';
@@ -12570,6 +12574,9 @@
case ProcessList.SCHED_GROUP_RESTRICTED:
schedGroup = 'R';
break;
+ case ProcessList.SCHED_GROUP_TOP_APP_BOUND:
+ schedGroup = 'B';
+ break;
default:
schedGroup = '?';
break;
@@ -12597,7 +12604,10 @@
pw.print(foreground);
pw.print('/');
pw.print(procState);
- pw.print(" trm:");
+ pw.print(' ');
+ ActivityManager.printCapabilitiesSummary(pw, r.curCapability);
+ pw.print(' ');
+ pw.print(" t:");
if (r.trimMemoryLevel < 10) pw.print(' ');
pw.print(r.trimMemoryLevel);
pw.print(' ');
diff --git a/services/core/java/com/android/server/am/OomAdjuster.java b/services/core/java/com/android/server/am/OomAdjuster.java
index ad85853..c13bb5a 100644
--- a/services/core/java/com/android/server/am/OomAdjuster.java
+++ b/services/core/java/com/android/server/am/OomAdjuster.java
@@ -151,15 +151,6 @@
@EnabledAfter(targetSdkVersion=android.os.Build.VERSION_CODES.Q)
static final long CAMERA_MICROPHONE_CAPABILITY_CHANGE_ID = 136219221L;
- // TODO: remove this when development is done.
- // These are debug flags used between OomAdjuster and AppOpsService to detect and report absence
- // of the real flags.
- public static final int DEBUG_PROCESS_CAPABILITY_FOREGROUND_MICROPHONE_Q = 1 << 27;
- public static final int DEBUG_PROCESS_CAPABILITY_FOREGROUND_CAMERA_Q = 1 << 28;
- public static final int DEBUG_PROCESS_CAPABILITY_FOREGROUND_MICROPHONE = 1 << 29;
- public static final int DEBUG_PROCESS_CAPABILITY_FOREGROUND_CAMERA = 1 << 30;
- public static final int DEBUG_PROCESS_CAPABILITY_FOREGROUND_LOCATION = 1 << 31;
-
/**
* For some direct access we need to power manager.
*/
@@ -1506,8 +1497,9 @@
//lost the capability, use temp location capability to mark this case.
//TODO: remove this block when development is done.
capabilityFromFGS |=
- (fgsType & FOREGROUND_SERVICE_TYPE_LOCATION)
- != 0 ? DEBUG_PROCESS_CAPABILITY_FOREGROUND_LOCATION : 0;
+ (fgsType & FOREGROUND_SERVICE_TYPE_LOCATION) != 0
+ ? ActivityManager.DEBUG_PROCESS_CAPABILITY_FOREGROUND_LOCATION
+ : 0;
}
if (s.mAllowWhileInUsePermissionInFgs) {
boolean enabled = false;
@@ -1520,22 +1512,22 @@
capabilityFromFGS |=
(fgsType & FOREGROUND_SERVICE_TYPE_CAMERA)
!= 0 ? PROCESS_CAPABILITY_FOREGROUND_CAMERA
- : DEBUG_PROCESS_CAPABILITY_FOREGROUND_CAMERA;
+ : ActivityManager.DEBUG_PROCESS_CAPABILITY_FOREGROUND_CAMERA;
capabilityFromFGS |=
(fgsType & FOREGROUND_SERVICE_TYPE_MICROPHONE)
!= 0 ? PROCESS_CAPABILITY_FOREGROUND_MICROPHONE
- : DEBUG_PROCESS_CAPABILITY_FOREGROUND_MICROPHONE;
+ : ActivityManager.DEBUG_PROCESS_CAPABILITY_FOREGROUND_MICROPHONE;
} else {
// Remove fgsType check and assign PROCESS_CAPABILITY_FOREGROUND_CAMERA
// and MICROPHONE when finish debugging.
capabilityFromFGS |=
(fgsType & FOREGROUND_SERVICE_TYPE_CAMERA)
!= 0 ? PROCESS_CAPABILITY_FOREGROUND_CAMERA
- : DEBUG_PROCESS_CAPABILITY_FOREGROUND_CAMERA_Q;
+ : ActivityManager.DEBUG_PROCESS_CAPABILITY_FOREGROUND_CAMERA_Q;
capabilityFromFGS |=
(fgsType & FOREGROUND_SERVICE_TYPE_MICROPHONE)
!= 0 ? PROCESS_CAPABILITY_FOREGROUND_MICROPHONE
- : DEBUG_PROCESS_CAPABILITY_FOREGROUND_MICROPHONE_Q;
+ : ActivityManager.DEBUG_PROCESS_CAPABILITY_FOREGROUND_MICROPHONE_Q;
}
}
}
diff --git a/services/core/java/com/android/server/am/ProcessList.java b/services/core/java/com/android/server/am/ProcessList.java
index b753de9..108fb7d 100644
--- a/services/core/java/com/android/server/am/ProcessList.java
+++ b/services/core/java/com/android/server/am/ProcessList.java
@@ -972,7 +972,7 @@
return buildOomTag("vis", "vis", " ", setAdj,
ProcessList.VISIBLE_APP_ADJ, compact);
} else if (setAdj >= ProcessList.FOREGROUND_APP_ADJ) {
- return buildOomTag("fore ", "fore", null, setAdj,
+ return buildOomTag("fg ", "fg ", " ", setAdj,
ProcessList.FOREGROUND_APP_ADJ, compact);
} else if (setAdj >= ProcessList.PERSISTENT_SERVICE_ADJ) {
return buildOomTag("psvc ", "psvc", null, setAdj,
diff --git a/services/core/java/com/android/server/am/ProcessRecord.java b/services/core/java/com/android/server/am/ProcessRecord.java
index fc6931d..c5152c0 100644
--- a/services/core/java/com/android/server/am/ProcessRecord.java
+++ b/services/core/java/com/android/server/am/ProcessRecord.java
@@ -431,16 +431,46 @@
pw.print(" nextPssTime=");
TimeUtils.formatDuration(nextPssTime, nowUptime, pw);
pw.println();
- pw.print(prefix); pw.print("adjSeq="); pw.print(adjSeq);
- pw.print(" lruSeq="); pw.print(lruSeq);
- pw.print(" lastPss="); DebugUtils.printSizeValue(pw, lastPss*1024);
- pw.print(" lastSwapPss="); DebugUtils.printSizeValue(pw, lastSwapPss*1024);
- pw.print(" lastCachedPss="); DebugUtils.printSizeValue(pw, lastCachedPss*1024);
- pw.print(" lastCachedSwapPss="); DebugUtils.printSizeValue(pw, lastCachedSwapPss*1024);
- pw.print(" lastRss="); DebugUtils.printSizeValue(pw, mLastRss * 1024);
+ pw.print(prefix); pw.print("lastPss="); DebugUtils.printSizeValue(pw, lastPss * 1024);
+ pw.print(" lastSwapPss="); DebugUtils.printSizeValue(pw, lastSwapPss * 1024);
+ pw.print(" lastCachedPss="); DebugUtils.printSizeValue(pw, lastCachedPss * 1024);
+ pw.print(" lastCachedSwapPss="); DebugUtils.printSizeValue(pw,
+ lastCachedSwapPss * 1024);
+ pw.print(" lastRss="); DebugUtils.printSizeValue(pw, mLastRss * 1024);
pw.println();
pw.print(prefix); pw.print("procStateMemTracker: ");
procStateMemTracker.dumpLine(pw);
+ pw.print(prefix); pw.print("adjSeq="); pw.print(adjSeq);
+ pw.print(" lruSeq="); pw.println(lruSeq);
+ pw.print(prefix); pw.print("oom adj: max="); pw.print(maxAdj);
+ pw.print(" curRaw="); pw.print(mCurRawAdj);
+ pw.print(" setRaw="); pw.print(setRawAdj);
+ pw.print(" cur="); pw.print(curAdj);
+ pw.print(" set="); pw.println(setAdj);
+ pw.print(prefix); pw.print("lastCompactTime="); pw.print(lastCompactTime);
+ pw.print(" lastCompactAction="); pw.println(lastCompactAction);
+ pw.print(prefix); pw.print("mCurSchedGroup="); pw.print(mCurSchedGroup);
+ pw.print(" setSchedGroup="); pw.print(setSchedGroup);
+ pw.print(" systemNoUi="); pw.print(systemNoUi);
+ pw.print(" trimMemoryLevel="); pw.println(trimMemoryLevel);
+ pw.print(prefix); pw.print("curProcState="); pw.print(getCurProcState());
+ pw.print(" mRepProcState="); pw.print(mRepProcState);
+ pw.print(" pssProcState="); pw.print(pssProcState);
+ pw.print(" setProcState="); pw.print(setProcState);
+ pw.print(" lastStateTime=");
+ TimeUtils.formatDuration(lastStateTime, nowUptime, pw);
+ pw.println();
+ pw.print(prefix); pw.print("curCapability=");
+ ActivityManager.printCapabilitiesFull(pw, curCapability);
+ pw.print(" setCapability=");
+ ActivityManager.printCapabilitiesFull(pw, setCapability);
+ pw.println();
+ if (hasShownUi || mPendingUiClean || hasAboveClient || treatLikeActivity) {
+ pw.print(prefix); pw.print("hasShownUi="); pw.print(hasShownUi);
+ pw.print(" pendingUiClean="); pw.print(mPendingUiClean);
+ pw.print(" hasAboveClient="); pw.print(hasAboveClient);
+ pw.print(" treatLikeActivity="); pw.println(treatLikeActivity);
+ }
pw.print(prefix); pw.print("cached="); pw.print(mCached);
pw.print(" empty="); pw.println(empty);
if (serviceb) {
@@ -451,32 +481,6 @@
pw.print(prefix); pw.print("notCachedSinceIdle="); pw.print(notCachedSinceIdle);
pw.print(" initialIdlePss="); pw.println(initialIdlePss);
}
- pw.print(prefix); pw.print("oom: max="); pw.print(maxAdj);
- pw.print(" curRaw="); pw.print(mCurRawAdj);
- pw.print(" setRaw="); pw.print(setRawAdj);
- pw.print(" cur="); pw.print(curAdj);
- pw.print(" set="); pw.println(setAdj);
- pw.print(prefix); pw.print("lastCompactTime="); pw.print(lastCompactTime);
- pw.print(" lastCompactAction="); pw.print(lastCompactAction);
- pw.print(prefix); pw.print("mCurSchedGroup="); pw.print(mCurSchedGroup);
- pw.print(" setSchedGroup="); pw.print(setSchedGroup);
- pw.print(" systemNoUi="); pw.print(systemNoUi);
- pw.print(" trimMemoryLevel="); pw.println(trimMemoryLevel);
- pw.print(prefix); pw.print("curProcState="); pw.print(getCurProcState());
- pw.print(" mRepProcState="); pw.print(mRepProcState);
- pw.print(" pssProcState="); pw.print(pssProcState);
- pw.print(" setProcState="); pw.print(setProcState);
- pw.print(" curCapability="); pw.print(curCapability);
- pw.print(" setCapability="); pw.print(setCapability);
- pw.print(" lastStateTime=");
- TimeUtils.formatDuration(lastStateTime, nowUptime, pw);
- pw.println();
- if (hasShownUi || mPendingUiClean || hasAboveClient || treatLikeActivity) {
- pw.print(prefix); pw.print("hasShownUi="); pw.print(hasShownUi);
- pw.print(" pendingUiClean="); pw.print(mPendingUiClean);
- pw.print(" hasAboveClient="); pw.print(hasAboveClient);
- pw.print(" treatLikeActivity="); pw.println(treatLikeActivity);
- }
if (connectionService != null || connectionGroup != 0) {
pw.print(prefix); pw.print("connectionGroup="); pw.print(connectionGroup);
pw.print(" Importance="); pw.print(connectionImportance);
diff --git a/services/core/java/com/android/server/appop/AppOpsService.java b/services/core/java/com/android/server/appop/AppOpsService.java
index 5ebfb00..ae38e81 100644
--- a/services/core/java/com/android/server/appop/AppOpsService.java
+++ b/services/core/java/com/android/server/appop/AppOpsService.java
@@ -66,11 +66,11 @@
import static android.content.pm.PermissionInfo.PROTECTION_DANGEROUS;
import static android.content.pm.PermissionInfo.PROTECTION_FLAG_APPOP;
-import static com.android.server.am.OomAdjuster.DEBUG_PROCESS_CAPABILITY_FOREGROUND_CAMERA;
-import static com.android.server.am.OomAdjuster.DEBUG_PROCESS_CAPABILITY_FOREGROUND_CAMERA_Q;
-import static com.android.server.am.OomAdjuster.DEBUG_PROCESS_CAPABILITY_FOREGROUND_LOCATION;
-import static com.android.server.am.OomAdjuster.DEBUG_PROCESS_CAPABILITY_FOREGROUND_MICROPHONE;
-import static com.android.server.am.OomAdjuster.DEBUG_PROCESS_CAPABILITY_FOREGROUND_MICROPHONE_Q;
+import static android.app.ActivityManager.DEBUG_PROCESS_CAPABILITY_FOREGROUND_CAMERA;
+import static android.app.ActivityManager.DEBUG_PROCESS_CAPABILITY_FOREGROUND_CAMERA_Q;
+import static android.app.ActivityManager.DEBUG_PROCESS_CAPABILITY_FOREGROUND_LOCATION;
+import static android.app.ActivityManager.DEBUG_PROCESS_CAPABILITY_FOREGROUND_MICROPHONE;
+import static android.app.ActivityManager.DEBUG_PROCESS_CAPABILITY_FOREGROUND_MICROPHONE_Q;
import static com.android.server.appop.AppOpsService.ModeCallback.ALL_OPS;
import static java.lang.Long.max;