diff options
author | 2021-06-16 22:56:50 -0700 | |
---|---|---|
committer | 2021-10-11 16:43:40 -0700 | |
commit | 86cf053ec0e9df426f2ab52f1fb037963697e8f7 (patch) | |
tree | 50e8d419e49817280a5974cfacf052e5375a3805 /cmds | |
parent | 5a05ef704e0f27e57af08695e01d8486f7f89af6 (diff) |
Compile the utility `service` on host as `aservice`
... and run it.
It is not named `service` on host to avoid collision
with service(8).
fds don't work yet because of b/185909244.
Test: aservice list
# doesn't work well because of Java support b/190450693 and
# single-threaded service support b/191059588
Test: aservice call manager 4 i32 15
# listServices
Test: aservice call manager 7 s16 android.hardware.light.ILights/default
# isDelcared
Fixes: 190868305
Change-Id: I71b563ca0229164c2d96f8dba5a98107ed9f1e48
Diffstat (limited to 'cmds')
-rw-r--r-- | cmds/service/Android.bp | 18 | ||||
-rw-r--r-- | cmds/service/service.cpp | 7 |
2 files changed, 24 insertions, 1 deletions
diff --git a/cmds/service/Android.bp b/cmds/service/Android.bp index 3e8e3f67f8..21ac11b4cf 100644 --- a/cmds/service/Android.bp +++ b/cmds/service/Android.bp @@ -52,3 +52,21 @@ cc_binary { "-Werror", ], } + +cc_binary_host { + name: "aservice", + + srcs: ["service.cpp"], + + shared_libs: [ + "libcutils", + "libutils", + "libbinder", + ], + + cflags: [ + "-DXP_UNIX", + "-Wall", + "-Werror", + ], +} diff --git a/cmds/service/service.cpp b/cmds/service/service.cpp index 18b6b58a9e..0b00c2da08 100644 --- a/cmds/service/service.cpp +++ b/cmds/service/service.cpp @@ -50,6 +50,7 @@ static String16 get_interface_name(sp<IBinder> service) { if (service != nullptr) { Parcel data, reply; + data.markForBinder(service); status_t err = service->transact(IBinder::INTERFACE_TRANSACTION, data, &reply); if (err == NO_ERROR) { return reply.readString16(); @@ -96,6 +97,9 @@ int main(int argc, char* const argv[]) #ifdef VENDORSERVICES ProcessState::initWithDriver("/dev/vndbinder"); #endif +#ifndef __ANDROID__ + setDefaultServiceManager(createRpcDelegateServiceManager({.maxOutgoingThreads = 1})); +#endif sp<IServiceManager> sm = defaultServiceManager(); fflush(stdout); if (sm == nullptr) { @@ -138,6 +142,7 @@ int main(int argc, char* const argv[]) int32_t code = atoi(argv[optind++]); if (service != nullptr && ifName.size() > 0) { Parcel data, reply; + data.markForBinder(service); // the interface name is first data.writeInterfaceToken(ifName); @@ -229,7 +234,7 @@ int main(int argc, char* const argv[]) int afd = ashmem_create_region("test", statbuf.st_size); void* ptr = mmap(NULL, statbuf.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, afd, 0); - read(fd, ptr, statbuf.st_size); + (void)read(fd, ptr, statbuf.st_size); close(fd); data.writeFileDescriptor(afd, true /* take ownership */); } else if (strcmp(argv[optind], "nfd") == 0) { |