linux下service的命令用法

一、用法概述:

# service

service

Usage: service [-h|-?]

       service list

       service check SERVICE

       service call SERVICE CODE [i32 INT | s16 STR] [intent] ...

Options:

   i32: Write the integer INT into the send parcel.

   s16: Write the UTF-16 string STR into the send parcel.

   intent: Write and Intent int the send parcel. ARGS can be/n"

   action=STR data=STR type=STR launchFlags=INT component=STR categories=STR[,STR,...]/n

 

二、详解:

1. service list

会列出本机所有正在运行的service, 如:

Found 42 services:

0       phone: [com.android.internal.telephony.ITelephony]

1       iphonesubinfo: [com.android.internal.telephony.IPhoneSubInfo]

2       isms: [com.android.internal.telephony.gsm.ISms]

3       simphonebook: [com.android.internal.telephony.gsm.ISimPhoneBook]

4       appwidget: [com.android.internal.appwidget.IAppWidgetService]

5       audio: [android.media.IAudioService]

6       wallpaper: [android.app.IWallpaperService]

7       checkin: [android.os.ICheckinService]

8       search: [android.app.ISearchManager]

9       location: [android.location.ILocationManager]

10      devicestoragemonitor: []

11      mount: [android.os.IMountService]

12      notification: [android.app.INotificationManager]

13      connectivity: [android.net.IConnectivityManager]

14      wifi: [android.net.wifi.IWifiManager]

15      netstat: [android.os.INetStatService]

16      input_method: [com.android.internal.view.IInputMethodManager]

17      clipboard: [android.text.IClipboard]

18      statusbar: [android.app.IStatusBar]

19      window: [android.view.IWindowManager]

20      sensor: [android.hardware.ISensorService]

21      alarm: [android.app.IAlarmManager]

22      hardware: [android.os.IHardwareService]

23      battery: []

24      content: [android.content.IContentService]

25      permission: [android.os.IPermissionController]

26      activity.providers: []

27      activity.senders: []

28      activity.services: []

29      activity.broadcasts: []

30      cpuinfo: []

31      meminfo: []

32      activity: [android.app.IActivityManager]

33      package: [android.content.pm.IPackageManager]

34      telephony.registry: [com.android.internal.telephony.ITelephonyRegistry]

35      usagestats: [com.android.internal.app.IUsageStats]

36      batteryinfo: [com.android.internal.app.IBatteryStats]

37      power: [android.os.IPowerManager]

38      SurfaceFlinger: [android.ui.ISurfaceComposer]

39      media.camera: [android.hardware.ICameraService]

40      media.player: [android.hardware.IMediaPlayerService]

41      media.audio_flinger: [android.media.IAudioFlinger]

 

2、service check "service name" 检查service是否存在

如:

 # service check phone

Service phone: found

 

# service check dd

Service dd: not found

 

3、service call "service name" code intent ....

   service call SERVICE CODE [i32 INT | s16 STR] ...

   i32: Write the integer INT into the send parcel.

   s16: Write the UTF-16 string STR into the send parcel.

 

在网络上查找了一下使用adb命令来控制真机的横竖屏的命令,普遍找到的结果是:

  adb shell service call window 2013 i32 0(设置横屏)

  adb shell service call window 2013 i32 1(设置竖屏)

  但是在真机(root过)上测试普遍没有通过,会有出错信息。(Result: Parcel(Error: 0xffffffb6 "Not a data message"))

 

SERVICE可从list中获取,CODE的获取方法(,CODE列表:),但是发现看到的不是很准确,(这个可以自己写个循环脚本试验一下)。i32代表数字,s16代表字符串。

  本人找不到真正代表window横竖屏的CODE,所以写了个循环脚本,通过观察现象,找到了对应的CODE,那就是74。

  adb shell service call window 74 i32 0(设置横屏)

  adb shell service call window 74 i32 1(设置竖屏)

  符上脚本代码:

  #!bin/bash count=0 while [ "$count" -lt 1000 ]; do echo "$count" adb shell service call window "$count" i32 0 count=$(($count+1)) done

 

如:service call power 1

service call phone 2 s16  "10086"

你可能感兴趣的:(Android系统,Linux技术)