查看 activity 棧的狀態: adb shell dumpsys activityandroid
Android has an interesting command called dumpsys to dump some system information. shell
Even described on adb manual I think that some points should be reinforced. In orderapp
to get the complete status just run (will produce a large output):iphone
adb shell dumpsys一些關鍵命令解釋
名字 功能
account 顯示accounts信息
activity 顯示全部的activities的信息
cpuinfo 顯示CPU信息
window 顯示鍵盤,窗口和它們的關係
wifi 顯示wifi信息
batteryinfo $package_name 電量信息及CPU 使用時長
package packagename 獲取安裝包信息
usagestats 每一個界面啓動的時間
statusbar 顯示狀態欄相關的信息
meminfo 內存信息(meminfo $package_name or $pid 使用程序的包名或者進程id顯示內存信息)
diskstats 磁盤相關信息
battery 電池信息
alarm 顯示Alarm信息
activity - 使用adb shell dumpsys檢測Android的Activity任務棧
window - 經過adb shell dumpsys命令獲取當前應用的component
statusbar - 找出廣告通知屬於哪一個應用 dumpsys statusbar | grep notification=Notification ui
adb shell dumpsys activity 顯示activity相關的信息spa
adb shell dumpsys statusbar 顯示狀態欄相關的信息.net
adb shell dumpsys meminfo $package_name or $pid 使用程序的包名或者進程id顯示內存信息rest
adb shell dumpsys cpuinfocode
adb shell dumpsys batterycomponent
adb shell dumpsys window(最後部分能夠看到分辨率的信息)
有些service可以接收額外的參數,咱們能夠使用-h查看幫助信息。
adb shell dumpsys package -h
adb shell dumpsys activity -h
該命令用於打印出當前系統信息,默認打印出設備中全部service的信息,能夠在命令後面加指定的service name. 有兩種方法能夠查看service list: 1. adb shell dumpsys 輸出信息的開始部分就是全部運行的service,以下: 1 SurfaceFlinger 2 accessibility 3 account 4 activity 5 alarm 6 appwidget 7 audio 8 backup 9 battery 10 batteryinfo 11 bluetooth 12 bluetooth_a2dp 13 clipboard 14 connectivity 15 content 16 cpuinfo 17 device_policy 18 devicestoragemonitor 19 diskstats 20 dropbox 21 entropy 22 ethernet 23 hardware 24 input_method 25 iphonesubinfo 26 isms 27 keybar 28 location 29 media.audio_flinger 30 media.audio_policy 31 media.camera 32 media.player 33 meminfo 34 mount 35 netstat 36 network_management 37 notification 38 package 39 permission 40 phone 41 power 42 search 43 sensorservice 44 simphonebook 45 statusbar 46 telephony.registry 47 throttle 48 uimode 49 usagestats 50 vibrator 51 wallpaper 52 wifi 53 window 2. adb shell service list 輸出結果以下: Found 49 services: 0 phone: [com.android.internal.telephony.ITelephony] 1 iphonesubinfo: [com.android.internal.telephony.IPhoneSubInfo] 2 simphonebook: [com.android.internal.telephony.IIccPhoneBook] 3 isms: [com.android.internal.telephony.ISms] 4 diskstats: [] 5 appwidget: [com.android.internal.appwidget.IAppWidgetService] 6 backup: [android.app.backup.IBackupManager] 7 uimode: [android.app.IUiModeManager] 8 audio: [android.media.IAudioService] 9 wallpaper: [android.app.IWallpaperManager] 10 dropbox: [com.android.internal.os.IDropBoxManagerService] 11 search: [android.app.ISearchManager] 12 location: [android.location.ILocationManager] 13 devicestoragemonitor: [] 14 notification: [android.app.INotificationManager] 15 mount: [IMountService] 16 accessibility: [android.view.accessibility.IAccessibilityManager] 17 throttle: [android.net.IThrottleManager] 18 connectivity: [android.net.IConnectivityManager] 19 wifi: [android.net.wifi.IWifiManager] 20 network_management: [android.os.INetworkManagementService] 21 netstat: [android.os.INetStatService] 22 input_method: [com.android.internal.view.IInputMethodManager] 23 clipboard: [android.text.IClipboard] 24 statusbar: [com.android.internal.statusbar.IStatusBarService] 25 device_policy: [android.app.admin.IDevicePolicyManager] 26 window: [android.view.IWindowManager] 27 alarm: [android.app.IAlarmManager] 28 vibrator: [android.os.IVibratorService] 29 hardware: [android.os.IHardwareService] 30 battery: [] 31 content: [android.content.IContentService] 32 account: [android.accounts.IAccountManager] 33 permission: [android.os.IPermissionController] 34 cpuinfo: [] 35 meminfo: [] 36 activity: [android.app.IActivityManager] 37 package: [android.content.pm.IPackageManager] 38 telephony.registry: [com.android.internal.telephony.ITelephonyRegistry] 39 usagestats: [com.android.internal.app.IUsageStats] 40 batteryinfo: [com.android.internal.app.IBatteryStats] 41 power: [android.os.IPowerManager] 42 entropy: [] 43 sensorservice: [android.gui.SensorServer] 44 SurfaceFlinger: [android.ui.ISurfaceComposer] 45 media.audio_policy: [android.media.IAudioPolicyService] 46 media.camera: [android.hardware.ICameraService] 47 media.player: [android.media.IMediaPlayerService] 48 media.audio_flinger: [android.media.IAudioFlinger] 查詢到運行的system service後,就能夠在dumpsys後面加上service的名字,查看指定的service信息。 adb shell dumpsys activity adb shell dumpsys cpuinfo adb shell dumpsys battery adb shell dumpsys window(最後部分能夠看到分辨率的信息) 有些service可以接收額外的參數,咱們能夠使用-h查看幫助信息。 adb shell dumpsys package -h adb shell dumpsys activity -h
查看Android手機的Activtiy堆棧頂部的應用包名
方法1:
C:\Users\beijing_zbs> adb shell dumpsys activity|findstr top-activity Proc # 0: fore F/A/T trm: 0 4203:com.tencent.news/u0a101 (top-activity)
方法2:
C:\Users\beijing_zbs> adb shell dumpsys activity|findstr mFocusedActivity mFocusedActivity: ActivityRecord{437904d0 u0 com.tencent.news/.ui.MainActivity2 t2}
查看Android手機分辨率的方法:
C:\Users\beijing_zbs>adb shell dumpsys window|findstr mOverscanScreen mOverscanScreen=(0,0) 1536x2560 C:\Users\beijing_zbs>adb shell dumpsys window|findstr mOverscanScreen mOverscanScreen=(0,0) 1080x1920
查看Android手機分辨率的通用方法(適用於android4.0以上):
C:\Users\beijing_zbs>adb shell dumpsys window|findstr mUnrestrictedScreen mUnrestrictedScreen=(0,0) 540x960 #在批處理中拿到該分辨率的值得方法以下: FOR /f "tokens=3 delims=), " %%a in ('adb shell dumpsys window^|findstr mUnrestrictedScreen') do SET resolutionratio=%%a ECHO The Android Phone Displayed Ratio: %resolutionratio%
查看Android手機分辨率的方法(適用於android4.3以上):
C:\Users\beijing_zbs>adb shell wm size Physical size: 1080x1920