diff options
author | 2021-10-28 15:54:59 -0700 | |
---|---|---|
committer | 2021-10-28 22:59:32 +0000 | |
commit | 619b935854a01f9691d85ef47aedc65e7b388f7f (patch) | |
tree | 39e10dc374f05f29b7d758f2caa1c2503e49c3cc | |
parent | 36227a85fce1ffa2a83e428cd014d8f77b487e3a (diff) |
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
-rw-r--r-- | cmds/service/service.cpp | 33 |
1 files changed, 3 insertions, 30 deletions
diff --git a/cmds/service/service.cpp b/cmds/service/service.cpp index fdbe85b4a8..fe417a362f 100644 --- a/cmds/service/service.cpp +++ b/cmds/service/service.cpp @@ -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; |