Adb

Adbシェルdumpsysコマンドの使用法(badmaskの記事を再現)



Adb Shell Dumpsys Command Usage



出発点1:

Androidは、Androidデバイスの戻るボタンにとって非常に重要な「タスクスタック」の概念を導入しています。戻るボタンを押すか、クリックして現在のアクティビティを閉じると、Androidシステムがプログラムを実行するアクティビティがわからず、これが最後のアクティビティであり、プログラム全体を終了するかどうかがわからない場合があります。または、一部のボタンと操作ループがアクティビティを生成し、メモリの肥大化を引き起こします。これらの問題について、デバッグ中に現在のタスクスタックを知ることができれば、問題の原因を簡単に観察して見つけ、正しいlaunchModeを選択し、インテントフラグを設定して使用し、プログラムに目的の効果を実現させることができます。

出発点2:

お使いの携帯電話には、逆コンパイルや他のことをせずにこのアプリについて学ぶことができるアプリがあります。



出発点3: ' 公式文書から

dumpsysは、Androidデバイスで実行され、システムサービスに関する情報を提供するツールです。コマンドラインからdumpsysを呼び出すには、 Androidデバッグブリッジ(ADB) 接続されたデバイスで実行されているすべてのシステムサービスの診断出力を取得します。この出力は通常、必要以上に冗長であるため、以下で説明するコマンドラインオプションを使用して、関心のあるシステムサービスのみの出力を取得します。このページでは、dumpsysを使用して入力の検査などの一般的なタスクを実行する方法についても説明します。 、RAM、バッテリー、またはネットワーク診断。

コマンド形式:
adb shelldumpsysアクティビティ[オプション] [何]



オプションパラメータ
オプション 意味
-に 利用可能なすべてのServier状態が含まれます
-c クライアントの状態、つまりアプリ側の状況を含む
-pパッケージ 限定出力指定パッケージ名
WHATパラメータ
意味
a [活動] 活動状況
b [ロードキャスト] [PACKAGE_NAME] 放送状況
s [サービス] [COMP_SPEC ...] サービスステータス
プロバイダー[iders] [COMP_SPEC ...] コンテンツプロバイダーのステータス
p [プロセス] [パッケージ名] プロセスステータス
o [om] メモリ管理
i [ntents] [PACKAGE_NAME] 保留中のインテント状態
r [ecents] 最近の活動
パーマ[issions] URI認証ステータス
すべて すべての活動情報
トップアクティビティ情報
パッケージ パッケージ関連情報
練習を始める
演習1:演習1:

入る:

adb shell dumpsys activity

出力:

ACTIVITY MANAGER PENDING INTENTS (dumpsys activity intents) //Note * PendingIntentRecord{1004eb1 com.tencent.mobileqq broadcastIntent} * PendingIntentRecord{a9858c7 com.google.android.gms broadcastIntent} * PendingIntentRecord{dc3ae3d com.tencent.mm startService} // omit N lines... ACTIVITY MANAGER BROADCAST STATE (dumpsys activity broadcasts) //Note Historical broadcasts [foreground]: #0: BroadcastRecord{63c6dd9 u-1 android.hardware.usb.action.USB_STATE} // omit N lines... ACTIVITY MANAGER CONTENT PROVIDERS (dumpsys activity providers) //Note Published single-user content providers (by class): * ContentProviderRecord{ef6fc1f u0 com.android.providers.telephony/.TelephonyProvider} proc=ProcessRecord{efab720 3684:com.android.phone/1001} singleton=true authority=telephony // omit N lines... ACTIVITY MANAGER URI PERMISSIONS (dumpsys activity permissions) //Note Granted Uri Permissions: * UID 10129 holds: UriPermission{b827fb4 0 @ content://downloads/all_downloads/125} UriPermission{2b167dd 0 @ content://downloads/all_downloads/134} UriPermission{51cbf52 0 @ content://downloads/all_downloads/148} UriPermission{af4a223 0 @ content://downloads/all_downloads/169} ACTIVITY MANAGER SERVICES (dumpsys activity services) //Note User 0 active services: * ServiceRecord{da1e320 u0 com.android.bluetooth/.hid.HidService} app=null created=-12d3h35m44s197ms started=false connections=1 // omit N lines... ACTIVITY MANAGER RECENT TASKS (dumpsys activity recents) //Note Recent tasks: * Recent #0: TaskRecord{162657c #917 A=android.task.mms U=0 sz=1} // omit N lines... ACTIVITY MANAGER ACTIVITIES (dumpsys activity activities) //Note Display #0 (activities from top to bottom): // omit N lines... ACTIVITY MANAGER RUNNING PROCESSES (dumpsys activity processes) //Note Isolated process list (sorted by uid): Isolated # 0: ProcessRecord{ffa12e5 3187:WebViewLoader-arm64-v8a/1037} UID states: UID 1000: UidRecord{15a01ba 1000 P / 19 procs} // omit N lines...

上記の「注意」とマークされた場所は、実際には、括弧内のコマンドを使用して、この部分の対応するコンテンツを取得するためのヒントです。
したがって、「adb shell dumpsys activity」コマンドは、次の8つのコマンドを順番に出力することと同じです。



Adb shell dumpsys activity intents // main output PendingIntentRecord adb shell dumpsys activity broadcasts adb shell dumpsys activity providers// Published single-user content providers (by class) / Published user 0 content providers (by class) / adb shell dumpsys activity permissions adb shell dumpsys activity services adb shell dumpsys activity recents adb shell dumpsys activity activities adb shell dumpsys activity processes
演習2:演習2:

入る:

adb shell dumpsys activity top

出力:

TASK com.jianshu.haruki id=101 ACTIVITY com.jianshu.haruki/com.baiji.jianshu.MainActivity fb571c1 pid=21291 // ... just mention the first two lines, omitting the N line of code

現在のAndroidシステムでユーザーとやり取りしているアクティビティの詳細を取得します。出力によると、ショートブックのアプリケーションパッケージ名は次のとおりです。'com.jianshu.haruki '

演習3:

入る:

adb shell dumpsys activity activities

意義:

Shows all currently running task stacks, and what their ids are. For each Task, there is also information such as the number of activities, as well as a list of activities in it, and a detailed description of each activity, such as the content of the Intent that starts it. If you think that the content is too much, just want to look at the contents of the stack, you can also jump directly to the 'Running activities (most recent first) part, a more concise and clear list of the Activity list on the stack, you can know when pressed Which activity should I return to when returning the key?
演習4:演習4:

入る:

Adb shell dumpsys package com.jianshu.haruki[here is the application package name of 'Jianshu']

出力:

Activity Resolver Table: // Callout: Start parsing the 'activity' tag here Full MIME Types: text/plain: 28edf2a com.jianshu.haruki/com.baiji.jianshu.ui.editor.EditorActivityV19 Base MIME Types: text: 28edf2a com.jianshu.haruki/com.baiji.jianshu.ui.editor.EditorActivityV19 Schemes: Jianshu: // annotation: lists all activities with jianshu as the scheme 3057264 com.jianshu.haruki/com.baiji.jianshu.ui.messages.submission.SubmissionDetailActivity 350011b com.jianshu.haruki/com.baiji.jianshu.MainActivity 96cc891 com.jianshu.haruki/com.baiji.jianshu.ui.user.collection.CollectionActivity (2 filters) 993c3f6 com.jianshu.haruki/com.baiji.jianshu.ui.user.userinfo.UserCenterActivity (2 filters) f48e2b8 com.jianshu.haruki/com.baiji.jianshu.activity.NotifyDetailActivity f845ccd com.jianshu.haruki/com.baiji.jianshu.ui.articledetail.ArticleDetailActivity fe393f7 com.jianshu.haruki/com.baiji.jianshu.ui.user.notebook.normal.NotebookActivity (2 filters) tencent100410602: 3302982 com.jianshu.haruki/com.tencent.tauth.AuthActivity Non-Data Actions: // Annotation: Lists all activities that have an 'intent-filter' tag but no 'data' tag. android.intent.action.MAIN: 4b37893 com.jianshu.haruki/com.baiji.jianshu.ui.splash.SplashScreenActivity com.sina.weibo.sdk.action.ACTION_SDK_REQ_ACTIVITY: 3d950d0 com.jianshu.haruki/haruki.jianshu.com.lib_share.weibo.WBShareActivity android.intent.action.CREATE_SHORTCUT: 28edf2a com.jianshu.haruki/com.baiji.jianshu.ui.editor.EditorActivityV19 // omit multiple lines MIME Typed Actions: android.intent.action.SEND: 28edf2a com.jianshu.haruki/com.baiji.jianshu.ui.editor.EditorActivityV19 Receiver Resolver Table: // Label: Start parsing the 'receiver' tag here Schemes: Package: // annotation: lists all receivers with jianshu as the scheme c930aef com.jianshu.haruki/com.huawei.android.pushagent.PushEventReceiver Non-Data Actions:// Annotation: Lists all receivers that have an 'intent-filter' tag but no 'action' tag. com.xiaomi.mipush.MESSAGE_ARRIVED: bcaa9fc com.jianshu.haruki/com.baiji.jianshu.ui.receiver.xiaomi.XiaoMiPushReceiver android.intent.action.ACTION_POWER_DISCONNECTED: 9fd5885 com.jianshu.haruki/com.igexin.sdk.PushReceiver // omit multiple lines Service Resolver Table:// Callout: Start parsing the 'service' tag here Non-Data Actions:// Annotation: Lists all services that have an 'intent-filter' tag but no 'action' tag com.google.firebase.INSTANCE_ID_EVENT: 649f732 com.jianshu.haruki/com.google.firebase.iid.FirebaseInstanceIdService com.igexin.sdk.action.service.message: 97bac83 com.jianshu.haruki/com.igexin.sdk.PushService Permissions: Permission [com.jianshu.haruki.permission.C2D_MESSAGE] (88a8e00): sourcePackage=com.jianshu.haruki uid=10141 gids=null type=0 prot=signature perm=Permission{e42a639 com.jianshu.haruki.permission.C2D_MESSAGE} packageSetting=PackageSetting{a1c547e com.jianshu.haruki/10141} Permission [getui.permission.GetuiService.com.jianshu.haruki] (7428ddf): sourcePackage=com.jianshu.haruki uid=10141 gids=null type=0 prot=normal perm=Permission{80a8a2c getui.permission.GetuiService.com.jianshu.haruki} packageSetting=PackageSetting{a1c547e com.jianshu.haruki/10141} Permission [com.jianshu.haruki.permission.MIPUSH_RECEIVE] (c9e6cf5): sourcePackage=com.jianshu.haruki uid=10141 gids=null type=0 prot=signature perm=Permission{f253a8a com.jianshu.haruki.permission.MIPUSH_RECEIVE} packageSetting=PackageSetting{a1c547e com.jianshu.haruki/10141} Registered ContentProviders: com.jianshu.haruki/com.google.firebase.provider.FirebaseInitProvider: Provider{b6c28fb com.jianshu.haruki/com.google.firebase.provider.FirebaseInitProvider} com.jianshu.haruki/com.baiji.jianshu.db.core.JianshuProvider: Provider{eac1d18 com.jianshu.haruki/com.baiji.jianshu.db.core.JianshuProvider} com.jianshu.haruki/com.sensorsdata.analytics.android.sdk.SensorsDataContentProvider: Provider{8b5e371 com.jianshu.haruki/com.sensorsdata.analytics.android.sdk.SensorsDataContentProvider} ContentProvider Authorities: [com.jianshu.haruki.SensorsDataContentProvider]: Provider{8b5e371 com.jianshu.haruki/com.sensorsdata.analytics.android.sdk.SensorsDataContentProvider} applicationInfo=ApplicationInfo{b247556 com.jianshu.haruki} [com.jianshu.haruki.firebaseinitprovider]: Provider{b6c28fb com.jianshu.haruki/com.google.firebase.provider.FirebaseInitProvider} applicationInfo=ApplicationInfo{b247556 com.jianshu.haruki} [com.jianshu.haruki.provider]: Provider{eac1d18 com.jianshu.haruki/com.baiji.jianshu.db.core.JianshuProvider} applicationInfo=ApplicationInfo{b247556 com.jianshu.haruki} Key Set Manager: [com.jianshu.haruki] Signing KeySets: 67 Packages: Package [com.jianshu.haruki] (a1c547e): userId=10141 pkg=Package{ca59d7 com.jianshu.haruki} codePath=/data/app/com.jianshu.haruki-2 resourcePath=/data/app/com.jianshu.haruki-2 legacyNativeLibraryDir=/data/app/com.jianshu.haruki-2/lib primaryCpuAbi=arm64-v8a secondaryCpuAbi=null versionCode=2017082915 targetSdk=23 versionName=2.6.0 splits=[base] applicationInfo=ApplicationInfo{b247556 com.jianshu.haruki} flags=[ HAS_CODE ALLOW_CLEAR_USER_DATA LARGE_HEAP ] dataDir=/data/user/0/com.jianshu.haruki supportsScreens=[small, medium, large, xlarge, resizeable, anyDensity] timeStamp=2017-09-22 15:39:43 firstInstallTime=2017-09-22 15:38:20 lastUpdateTime=2017-09-22 15:40:02 signatures=PackageSignatures{d1f2c4 [8f445ad]} installPermissionsFixed=true installStatus=1 pkgFlags=[ HAS_CODE ALLOW_CLEAR_USER_DATA LARGE_HEAP ] declared permissions: getui.permission.GetuiService.com.jianshu.haruki: prot=normal, INSTALLED com.jianshu.haruki.permission.MIPUSH_RECEIVE: prot=signature, INSTALLED com.jianshu.haruki.permission.C2D_MESSAGE: prot=signature, INSTALLED requested permissions: android.permission.INTERNET android.permission.WRITE_EXTERNAL_STORAGE // omit multiple lines install permissions: com.jianshu.haruki.permission.C2D_MESSAGE: granted=true com.google.android.c2dm.permission.RECEIVE: granted=true android.permission.MANAGE_ACCOUNTS: granted=true getui.permission.GetuiService.com.jianshu.haruki: granted=true // omit multiple lines User 0: installed=true hidden=false stopped=false notLaunched=false enabled=0 gids=[3002, 3003, 3001] runtime permissions: android.permission.READ_EXTERNAL_STORAGE: granted=true android.permission.READ_PHONE_STATE: granted=true android.permission.WRITE_EXTERNAL_STORAGE: granted=true disabledComponents: com.huawei.android.pushagent.PushBootReceiver
演習5:

入る:

Adb shell dumpsys meminfo com.jianshu.haruki[here is the application package name of 'Jianshu']

出力:

Applications Memory Usage (kB): Uptime: 94384953 Realtime: 367426401 ** MEMINFO in pid 21291 [com.jianshu.haruki] ** Pss Private Private Swapped Heap Heap Heap Total Dirty Clean Dirty Size Alloc Free ------ ------ ------ ------ ------ ------ ------ Native Heap 20236 19432 0 1180 50580 48838 1741 Dalvik Heap 12299 12264 0 56 52530 45197 7333 Dalvik Other 23104 23064 0 9680 Stack 1484 1484 0 0 Ashmem 134 128 0 0 Gfx dev 14698 14596 0 0 Other dev 10 0 8 0 .so mmap 5924 252 4312 2908 .apk mmap 27189 144 26692 0 .ttf mmap 130 0 104 0 .dex mmap 12242 12 11060 0 .oat mmap 3661 0 1256 4 .art mmap 2450 1940 92 144 Other mmap 1300 12 1280 0 EGL mtrack 41280 41280 0 0 Unknown 6052 6044 0 84 TOTAL 172193 120652 44804 14056 103110 94035 9074 App Summary Pss(KB) ------ Java Heap: 14296 Native Heap: 19432 Code: 43832 Stack: 1484 Graphics: 55876 Private Other: 30536 System: 6737 TOTAL: 172193 TOTAL SWAP (KB): 14056 Objects Views: 837 ViewRootImpl: 1 AppContexts: 2 Activities: 1 Assets: 4 AssetManagers: 2 Local Binders: 31 Proxy Binders: 31 Parcel memory: 23 Parcel count: 92 Death Recipients: 1 OpenSSL Sockets: 2 SQL MEMORY_USED: 1054 PAGECACHE_OVERFLOW: 297 MALLOC_SIZE: 62 DATABASES pgsz dbsz Lookaside(b) cache Dbname 4 24 36 112/19/5 /data/user/0/com.jianshu.haruki/databases/com.jianshu.haruki 4 76 176 116/64/25 /data/user/0/com.jianshu.haruki/databases/google_app_measurement.db 4 40 33 6/21/5 /data/user/0/com.jianshu.haruki/databases/tencent_analysis.db 4 32 98 75/26/12 /data/user/0/com.jianshu.haruki/databases/bugly_db_ 4 40 19 4/19/3 /data/user/0/com.jianshu.haruki/databases/pri_tencent_analysis.db 4 20 34 3/18/4 /data/user/0/com.jianshu.haruki/databases/ThrowalbeLog.db 4 20 32 786/19/5 /data/user/0/com.jianshu.haruki/databases/sharesdk.db 4 124 57 45/24/10 /data/user/0/com.jianshu.haruki/databases/jian_shu.db
コマンド 説明
adbシェルdumpsysアクティビティ 現在のAndroidシステムのアクティビティスタックでアクティビティ情報を取得します
adbシェルdumpsysアクティビティトップ 現在のAndroidシステムでユーザーとやり取りするアクティビティの詳細を取得します
Adbシェルdumpsysmeminfo [アプリパッケージ名] アプリのメモリ使用量を表示する
Adbシェルdumpsysパッケージ[アプリケーション登録] 携帯電話でapkのアプリケーション情報とバージョン情報を取得する
adb shelldumpsysアクティビティアクティビティ 現在実行中のすべてのタスクスタックを表示し、スタック内のすべてのアクティビティのリストを表示します

参照リンク:
公式ドキュメント、より詳細なドキュメントがあります: https://developer.android.com/studio/command-line/dumpsys.html
DevelopmentEssentials-知っておくべきいくつかのADBコマンド http://www.jianshu.com/p/0693b841c83b
dumpsysコマンドの使用法 http://gityuan.com/2017/07/04/ams_dumpsys/

著者:badmask
リンク: https://www.jianshu.com/p/d859480613a4
出典:ショートブック
本の著作権は著者が所有しています。いかなる形式の転載も、承認と出典について著者が連絡する必要があります。

転載:https://www.jianshu.com/p/e69488a58922