一、简介
# service --help Usage: service [-h|-?] service list service check SERVICE service call SERVICE CODE [i32 N | i64 N | f N | d N | s16 STR | null | fd f | nfd n | afd f ] ... Options: i32: Write the 32-bit integer N into the send parcel. i64: Write the 64-bit integer N into the send parcel. f: Write the 32-bit single-precision number N into the send parcel. d: Write the 64-bit double-precision number N into the send parcel. s16: Write the UTF-16 string STR into the send parcel. null: Write a null binder into the send parcel. fd: Write a file descriptor for the file f to the send parcel. nfd: Write file descriptor n to the send parcel. afd: Write an ashmem file descriptor for a region containing the data from file f to the send parcel.
此命令会自动写接口进去,使用时不需要再手动写接口了(由于其会自动写接口,服务端实现时也要有读接口的动作)。
二、实验
1. 调用服务函数
service call boostservice 7 s16 com.samsung.perf.IBoostManager s16 /proc/ed_task s16 "w 1125" //失败,不应该写接口 service call boostservice 7 s16 /proc/ed_task s16 "w 1125" //成功
等效代理端使用第7个函数(函数序号从1开始):
virtual void TestwriteProcNode(String16& path, String16& val) { Parcel data, reply; data.writeInterfaceToken(IBoostManager::getInterfaceDescriptor()); data.writeString16(path); data.writeString16(val); remote()->transact(IBinder::FIRST_CALL_TRANSACTION + 6,, data, &reply); reply.readExceptionCode(); }
标签:parcel,service,into,s16,send,Write,命令,笔记 From: https://www.cnblogs.com/hellokitty2/p/18007522