dumpsys | Android Studio | Android Developers
Android dump的使用1_android 如何dump systemui-CSDN博客
1、列举所有的模块
dumpsys -l
但有时候并不是很清楚自己的模块名称叫啥,可以去一些相关的service类里找dump函数
比如NTP时间同步:
NTP的dumpsys的tag是network_time_update_service
$ dumpsys network_time_update_service
PollingIntervalMs: +1d0h0m0s0ms
PollingIntervalShorterMs: +1m0s0ms
TryAgainTimesMax: 3TryAgainCounter: 0
NTP cache result: null
比如下面的NetworkTimeUpdateService.java,的dumpsys的DumpUtils的第二个参数为tag,是
NetworkTimeUpdateService,应该是将它跟词分割,并且加上下划线,然后变成小写就可以
NetworkTimeUpdateService.java protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { if (DumpUtils.checkDumpPermission(this.mContext, "NetworkTimeUpdateService", pw)) { pw.print("PollingIntervalMs: "); TimeUtils.formatDuration(this.mPollingIntervalMs, pw); pw.print("\nPollingIntervalShorterMs: "); TimeUtils.formatDuration(this.mPollingIntervalShorterMs, pw); pw.println("\nTryAgainTimesMax: " + this.mTryAgainTimesMax); pw.println("\nTryAgainCounter: " + this.mTryAgainCounter); NtpTrustedTime.TimeResult ntpResult = this.mTime.getCachedTimeResult(); pw.println("NTP cache result: " + ntpResult); if (ntpResult != null) { pw.println("NTP result age: " + ntpResult.getAgeMillis()); } pw.println(); } }
也可以dumpsys全部打印到某个文件里,然后搜索关键词,比如说上面NTP的 "NTP cache result",会出现下面的打印
DUMP OF SERVICE network_time_update_service:
PollingIntervalMs: +1d0h0m0s0ms
PollingIntervalShorterMs: +1m0s0ms
TryAgainTimesMax: 3TryAgainCounter: 0
NTP cache result: null--------- 0.001s was the duration of dumpsys network_time_update_service, ending at: 2024-06-18 09:50:54