Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 86cf053e authored by Yifan Hong's avatar Yifan Hong
Browse files

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
parent 5a05ef70
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -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",
    ],
}
+6 −1
Original line number Diff line number Diff line
@@ -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();
@@ -95,6 +96,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);
@@ -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) {