Add a new dumpsys to fetch app component usage info.

Bug: 250015991
Test: adb shell dumpsys usagestats app-component-usage
Change-Id: Iadc86117fbbd9316390f7ae1298a5b5fbd34d48a
This commit is contained in:
Varun Shah
2022-09-30 10:56:33 -07:00
parent 677d18848e
commit 003c5e72d2

View File

@@ -1864,6 +1864,21 @@ public class UsageStatsService extends SystemService implements
mResponseStatsTracker.dump(idpw);
}
return;
} else if ("app-component-usage".equals(arg)) {
final IndentingPrintWriter ipw = new IndentingPrintWriter(pw, " ");
synchronized (mLock) {
if (!mLastTimeComponentUsedGlobal.isEmpty()) {
ipw.println("App Component Usages:");
ipw.increaseIndent();
for (String pkg : mLastTimeComponentUsedGlobal.keySet()) {
ipw.println("package=" + pkg
+ " lastUsed=" + UserUsageStatsService.formatDateTime(
mLastTimeComponentUsedGlobal.get(pkg), true));
}
ipw.decreaseIndent();
}
}
return;
} else if (arg != null && !arg.startsWith("-")) {
// Anything else that doesn't start with '-' is a pkg to filter
pkgs.add(arg);