查看 activity 栈的状态: adb shell dumpsys activity
Android has an interesting command called dumpsys to dump some system information.
Even described on adb manual I think that some points should be reinforced. In order
to get the complete status just run (will produce a large output):
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
adb shell dumpsys activity 显示activity相关的信息
adb shell dumpsys statusbar 显示状态栏相关的信息
adb shell dumpsys meminfo $package_name or $pid 使用程序的包名或者进程id显示内存信息
adb shell dumpsys cpuinfo
adb shell dumpsys battery
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