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

Commit 619b9358 authored by Steven Moreland's avatar Steven Moreland
Browse files

service: remove re-implemented functions

We have 'ostream << (const String16&)' and
'IBinder::getInterfaceDescriptor' now, so we don't need implementations
here.

One side-effect of this change is that rather than printing only the
ascii characters from a utf-16 interface type, we will actually convert
the name to utf-8. This would increase the clarity of the output, but
we don't actually expect to benefit from this since interface names
are in utf-8.

Bug: N/A
Test: 'aservice list'
Change-Id: If9bbcf0cdd5be06974d979d9ad7cffb37efd930e
parent 36227a85
Loading
Loading
Loading
Loading
+3 −30
Original line number Diff line number Diff line
@@ -45,33 +45,6 @@ void writeString16(Parcel& parcel, const char* string)
    }
}

// get the name of the generic interface we hold a reference to
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();
        }
    }
    return String16();
}

static String8 good_old_string(const String16& src)
{
    String8 name8;
    char ch8[2];
    ch8[1] = 0;
    for (unsigned j = 0; j < src.size(); j++) {
        char16_t ch = src[j];
        if (ch < 128) ch8[0] = (char)ch;
        name8.append(ch8);
    }
    return name8;
}

int main(int argc, char* const argv[])
{
    bool wantsUsage = false;
@@ -132,8 +105,8 @@ int main(int argc, char* const argv[])
                String16 name = services[i];
                sp<IBinder> service = sm->checkService(name);
                aout << i
                     << "\t" << good_old_string(name)
                     << ": [" << good_old_string(get_interface_name(service)) << "]"
                     << "\t" << name
                     << ": [" << (service ? service->getInterfaceDescriptor() : String16()) << "]"
                     << endl;
            }
        } else if (strcmp(argv[optind], "call") == 0) {
@@ -141,7 +114,7 @@ int main(int argc, char* const argv[])
            if (optind+1 < argc) {
                int serviceArg = optind;
                sp<IBinder> service = sm->checkService(String16(argv[optind++]));
                String16 ifName = get_interface_name(service);
                String16 ifName = (service ? service->getInterfaceDescriptor() : String16());
                int32_t code = atoi(argv[optind++]);
                if (service != nullptr && ifName.size() > 0) {
                    Parcel data, reply;