/system/bin/service分析与使用
16lz
2021-01-23
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);
更多相关文章
- Android文件浏览器的开发
- android布局文件中的include
- 整理android环境离线安装搭建方法——支持android 2.3.3和androi
- Android上传文件到Web服务器,PHP接收文件(二)
- Android电话拨号器实现方法