diff options
| author | 2020-10-06 19:29:17 +0000 | |
|---|---|---|
| committer | 2020-10-06 19:29:17 +0000 | |
| commit | 77ebd6e060284fbdf5a80cd908a0df4fc5854d45 (patch) | |
| tree | b27382b7514cd57a7814d63c50f2dd57bf843f2f | |
| parent | 94dbcdfd6864416777aa2f6f57832632da175bd0 (diff) | |
| parent | 7dbc3c92f2e1d5e17fc776f81a7aea5ba81d41d2 (diff) | |
Merge "libbinder_ndk: association: rem heap allocs" am: 7dbc3c92f2
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1446780
Change-Id: Ia7b5486726fc451115153821867556f5ec3249c9
| -rw-r--r-- | libs/binder/ndk/ibinder.cpp | 17 | ||||
| -rw-r--r-- | libs/binder/ndk/ibinder_internal.h | 2 |
2 files changed, 9 insertions, 10 deletions
diff --git a/libs/binder/ndk/ibinder.cpp b/libs/binder/ndk/ibinder.cpp index 577f0a0f2b..2a2eed7879 100644 --- a/libs/binder/ndk/ibinder.cpp +++ b/libs/binder/ndk/ibinder.cpp @@ -74,12 +74,12 @@ AIBinder::AIBinder(const AIBinder_Class* clazz) : mClazz(clazz) {} AIBinder::~AIBinder() {} std::optional<bool> AIBinder::associateClassInternal(const AIBinder_Class* clazz, - const String8& newDescriptor, bool set) { + const String16& newDescriptor, bool set) { std::lock_guard<std::mutex> lock(mClazzMutex); if (mClazz == clazz) return true; if (mClazz != nullptr) { - String8 currentDescriptor(mClazz->getInterfaceDescriptor()); + const String16& currentDescriptor = mClazz->getInterfaceDescriptor(); if (newDescriptor == currentDescriptor) { LOG(ERROR) << __func__ << ": Class descriptors '" << currentDescriptor << "' match during associateClass, but they are different class objects. " @@ -88,8 +88,7 @@ std::optional<bool> AIBinder::associateClassInternal(const AIBinder_Class* clazz LOG(ERROR) << __func__ << ": Class cannot be associated on object which already has a class. " "Trying to associate to '" - << newDescriptor.c_str() << "' but already set to '" - << currentDescriptor.c_str() << "'."; + << newDescriptor << "' but already set to '" << currentDescriptor << "'."; } // always a failure because we know mClazz != clazz @@ -108,21 +107,21 @@ std::optional<bool> AIBinder::associateClassInternal(const AIBinder_Class* clazz bool AIBinder::associateClass(const AIBinder_Class* clazz) { if (clazz == nullptr) return false; - String8 newDescriptor(clazz->getInterfaceDescriptor()); + const String16& newDescriptor = clazz->getInterfaceDescriptor(); auto result = associateClassInternal(clazz, newDescriptor, false); if (result.has_value()) return *result; CHECK(asABpBinder() != nullptr); // ABBinder always has a descriptor - String8 descriptor(getBinder()->getInterfaceDescriptor()); + const String16& descriptor = getBinder()->getInterfaceDescriptor(); if (descriptor != newDescriptor) { if (getBinder()->isBinderAlive()) { - LOG(ERROR) << __func__ << ": Expecting binder to have class '" << newDescriptor.c_str() - << "' but descriptor is actually '" << descriptor.c_str() << "'."; + LOG(ERROR) << __func__ << ": Expecting binder to have class '" << newDescriptor + << "' but descriptor is actually '" << descriptor << "'."; } else { // b/155793159 - LOG(ERROR) << __func__ << ": Cannot associate class '" << newDescriptor.c_str() + LOG(ERROR) << __func__ << ": Cannot associate class '" << newDescriptor << "' to dead binder."; } return false; diff --git a/libs/binder/ndk/ibinder_internal.h b/libs/binder/ndk/ibinder_internal.h index f4e2704882..f60112787d 100644 --- a/libs/binder/ndk/ibinder_internal.h +++ b/libs/binder/ndk/ibinder_internal.h @@ -54,7 +54,7 @@ struct AIBinder : public virtual ::android::RefBase { private: std::optional<bool> associateClassInternal(const AIBinder_Class* clazz, - const ::android::String8& newDescriptor, bool set); + const ::android::String16& newDescriptor, bool set); // AIBinder instance is instance of this class for a local object. In order to transact on a // remote object, this also must be set for simplicity (although right now, only the |