/system/bin/service分析与使用
16lz
2021-12-04
service可以列出android使用的所有服务,还可以通过Binder与实现了aidl的服务通信 mmm frameworks/native/cmds/service编译出来的service root@tcc893x:/ # /system/bin/service Usage: service [-h|-?] service list service check SERVICE service call SERVICE CODE [i32 INT | s16 STR] ... Options: i32: Write the integer INT into the send parcel. s16: Write the UTF-16 string STR into the send parcel.
1) list的使用 root@tcc893x:/ # service list Found 92 services: 0 goodbye: [] 1 hello: [] 2 AutoService: [com.semisky.midLevel.aidl.IAutoIPCService] 3 McuService: [com.semisky.midLevel.aidl.IMcuService] 4 KeyEventService: [com.semisky.midLevel.aidl.IKeyEventService] 5 RadioService: [com.semisky.midLevel.aidl.IRadioService] 6 CarInfoService: [com.semisky.midLevel.aidl.ICarInfoService] 7 sip: [android.net.sip.ISipService] 8 phone: [com.android.internal.telephony.ITelephony] 2)call的使用 调用服务定义的方法service call CarInfoService 4 i32 7,将会执行CarInfoService.test(7),其中4就是代表 void test(int code) aidl文件在eclipse里面会自动生产java文件,名字和aidl相同。 每个方法自动对于一个code,列如ICarInfoService.aidl里面的test的方法 /* *ICarInfoService.aidl */ interface ICarInfoService { void requestWaitRsgInit(IServiceCallBack serviceCallBack,String packageName,int grpId, int subId, in byte[] reqData); void observer(IServiceCallBack serviceCallBack,String packageName,int grpId, int subId); void unregisterListener(IServiceCallBack serviceCallBack,String packageName); void test(int code); } eclipse自动给test()分配 android.os.IBinder.FIRST_CALL_TRANSACTION + 3 = 4 static final int TRANSACTION_requestWaitRsgInit = (android.os.IBinder.FIRST_CALL_TRANSACTION + 0); static final int TRANSACTION_observer = (android.os.IBinder.FIRST_CALL_TRANSACTION + 1); static final int TRANSACTION_unregisterListener = (android.os.IBinder.FIRST_CALL_TRANSACTION + 2); static final int TRANSACTION_test = (android.os.IBinder.FIRST_CALL_TRANSACTION + 3);
1) list的使用 root@tcc893x:/ # service list Found 92 services: 0 goodbye: [] 1 hello: [] 2 AutoService: [com.semisky.midLevel.aidl.IAutoIPCService] 3 McuService: [com.semisky.midLevel.aidl.IMcuService] 4 KeyEventService: [com.semisky.midLevel.aidl.IKeyEventService] 5 RadioService: [com.semisky.midLevel.aidl.IRadioService] 6 CarInfoService: [com.semisky.midLevel.aidl.ICarInfoService] 7 sip: [android.net.sip.ISipService] 8 phone: [com.android.internal.telephony.ITelephony] 2)call的使用 调用服务定义的方法service call CarInfoService 4 i32 7,将会执行CarInfoService.test(7),其中4就是代表 void test(int code) aidl文件在eclipse里面会自动生产java文件,名字和aidl相同。 每个方法自动对于一个code,列如ICarInfoService.aidl里面的test的方法 /* *ICarInfoService.aidl */ interface ICarInfoService { void requestWaitRsgInit(IServiceCallBack serviceCallBack,String packageName,int grpId, int subId, in byte[] reqData); void observer(IServiceCallBack serviceCallBack,String packageName,int grpId, int subId); void unregisterListener(IServiceCallBack serviceCallBack,String packageName); void test(int code); } eclipse自动给test()分配 android.os.IBinder.FIRST_CALL_TRANSACTION + 3 = 4 static final int TRANSACTION_requestWaitRsgInit = (android.os.IBinder.FIRST_CALL_TRANSACTION + 0); static final int TRANSACTION_observer = (android.os.IBinder.FIRST_CALL_TRANSACTION + 1); static final int TRANSACTION_unregisterListener = (android.os.IBinder.FIRST_CALL_TRANSACTION + 2); static final int TRANSACTION_test = (android.os.IBinder.FIRST_CALL_TRANSACTION + 3);
更多相关文章
- 浅谈Java中Collections.sort对List排序的两种方法
- 箭头函数的基础使用
- NPM 和webpack 的基础使用
- Python list sort方法的具体使用
- 【阿里云镜像】使用阿里巴巴DNS镜像源——DNS配置教程
- python list.sort()根据多个关键字排序的方法实现
- Ubuntu 下配置使用Android(安卓)adb
- 实现简单的Android的播放视频功能
- WINDOWS下ECLIPSE ANDROID源码SETTINGS模块调试