Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 003c5e72 authored by Varun Shah's avatar Varun Shah
Browse files

Add a new dumpsys to fetch app component usage info.

Bug: 250015991
Test: adb shell dumpsys usagestats app-component-usage
Change-Id: Iadc86117fbbd9316390f7ae1298a5b5fbd34d48a
parent 677d1884
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -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);