reference to : http://blog.csdn.net/g19920917/article/details/38032413
有两种方法可以查看service list:
1. adb shell dumpsys
输出信息的开始部分就是所有运行的service,如下:
Currently running services:
SurfaceFlinger:
accessibility:
account:
activity:
alarm:
appwidget:
audio:
backup:
battery:
batteryinfo:
clipboard:
connectivity:
content:
cpuinfo:
device_policy:
devicestoragemonitor:
diskstats:
dropbox:
entropy:
hardware:
input_method:
iphonesubinfo:
isms:
location:
media.audio_flinger:
media.audio_policy:
media.camera:
media.player:
meminfo:
mount:
netstat:
network_management:
notification:
package:
permission:
phone:
power:
search:
sensorservice:
simphonebook:
statusbar:
telephony.registry:
throttle:
uimode:
usagestats:
vibrator:
wallpaper:
wifi:
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
Load: 7.48 / 7.87 / 7.93 CPU usage from 26882ms to 5779ms ago: 5% 29692/adbd: 0.3% user + 4.7% kernel / faults: 8579 minor 4.9% 798/system_server: 2.8% user + 2% kernel / faults: 1616 minor 1.5% 21935/com.qihoo360.mobilesafe:GuardService: 0.8% user + 0.7% kernel / faults: 1052 minor 0.2% 970/com.baidu.superservice: 0.1% user + 0% kernel / faults: 2327 minor 0.9% 1433/mpdecision: 0% user + 0.9% kernel 0.9% 193/sensors.qcom: 0.2% user + 0.7% kernel / faults: 2 minor 0.8% 1948/com.baidu.appsearch: 0.6% user + 0.1% kernel / faults: 534 minor 0.4% 22189/com.qihoo360.contacts:guard: 0.3% user + 0% kernel / faults: 11 minor 0.3% 9913/kworker/0:2: 0% user + 0.3% kernel 0.2% 3220/com.cleanmaster.security:DefendService: 0.1% user + 0% kernel / faults: 114 minor 0.2% 3389/kworker/u:1: 0% user + 0.2% kernel 0.2% 22792/kworker/0:0H: 0% user + 0.2% kernel 0.2% 27872/kworker/u:2: 0% user + 0.2% kernel 0% 493/com.qiyi.video:bdservice_v1: 0% user + 0% kernel / faults: 1421 minor
adb shell dumpsys battery
Current Battery Service state: AC powered: false USB powered: true Wireless powered: false status: 5 health: 2 present: true level: 100 scale: 100 voltage: 4315 current now: 2871 temperature: 317 technology: Li-ion
adb shell dumpsys window(最后部分可以看到分辨率的信息)
有些service能够接收额外的参数,我们可以使用-h查看帮助信息。
adb shell dumpsys package -h
Package [com.nuomi] (42692a10): userId=10081 gids=[3003, 1028, 1015, 3002, 3001] pkg=Package{42a3ad30 com.nuomi} codePath=/data/app/com.nuomi-1.apk resourcePath=/data/app/com.nuomi-1.apk nativeLibraryPath=/data/app-lib/com.nuomi-1 versionCode=153 targetSdk=18 versionName=6.1.0 applicationInfo=ApplicationInfo{42a3ade0 com.nuomi} flags=[ HAS_CODE ALLOW_CLEAR_USER_DATA ALLOW_BACKUP LARGE_HEAP ] dataDir=/data/data/com.nuomi supportsScreens=[small, medium, large, xlarge, resizeable, anyDensity] timeStamp=2015-12-30 05:59:29 firstInstallTime=2015-12-30 05:59:40 lastUpdateTime=2015-12-30 05:59:40 installerPackageName=com.baidu.appsearch signatures=PackageSignatures{42647fe8 [426d0960]} permissionsFixed=true haveGids=true installStatus=1 pkgFlags=[ HAS_CODE ALLOW_CLEAR_USER_DATA ALLOW_BACKUP LARGE_HEAP ] User 0: installed=true blocked=false stopped=false notLaunched=false enabled=0 grantedPermissions: android.permission.READ_EXTERNAL_STORAGE android.permission.GET_TASKS android.permission.WRITE_EXTERNAL_STORAGE android.permission.ACCESS_WIFI_STATE android.permission.RECEIVE_SMS android.permission.ACCESS_COARSE_LOCATION android.permission.CALL_PHONE android.permission.READ_CONTACTS android.permission.READ_PHONE_STATE android.permission.READ_SMS android.permission.RECEIVE_BOOT_COMPLETED android.permission.CAMERA android.permission.ACCESS_FINE_LOCATION android.permission.BROADCAST_STICKY android.permission.WAKE_LOCK android.permission.RECORD_AUDIO android.permission.FLASHLIGHT android.permission.ACCESS_NETWORK_STATE com.android.launcher.permission.INSTALL_SHORTCUT android.permission.SEND_SMS android.permission.MODIFY_AUDIO_SETTINGS android.permission.DISABLE_KEYGUARD android.permission.SYSTEM_ALERT_WINDOW android.permission.BLUETOOTH android.permission.WRITE_SETTINGS android.permission.INTERNET android.permission.CHANGE_WIFI_STATE android.permission.ACCESS_LOCATION_EXTRA_COMMANDS android.permission.VIBRATE android.permission.BLUETOOTH_ADMIN android.permission.CHANGE_NETWORK_STATE android.permission.DOWNLOAD_WITHOUT_NOTIFICATION
adb shell dumpsys activity -h