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

Commit 2bc66dfb authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "libbinder_ndk: Expose UTF-8 interface descriptor string" am: 1372bd49

Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1504976

Change-Id: I14413c6d95f839cac3b111f2177b1eef2e755c96
parents 9d4c2643 1372bd49
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -307,7 +307,8 @@ AIBinder_Class::AIBinder_Class(const char* interfaceDescriptor, AIBinder_Class_o
    : onCreate(onCreate),
      onDestroy(onDestroy),
      onTransact(onTransact),
      mInterfaceDescriptor(interfaceDescriptor) {}
      mInterfaceDescriptor(interfaceDescriptor),
      mWideInterfaceDescriptor(interfaceDescriptor) {}

AIBinder_Class* AIBinder_Class_define(const char* interfaceDescriptor,
                                      AIBinder_Class_onCreate onCreate,
@@ -335,6 +336,12 @@ void AIBinder_Class_setHandleShellCommand(AIBinder_Class* clazz,
    clazz->handleShellCommand = handleShellCommand;
}

const char* AIBinder_Class_getDescriptor(const AIBinder_Class* clazz) {
    CHECK(clazz != nullptr) << "getDescriptor requires non-null clazz";

    return clazz->getInterfaceDescriptorUtf8();
}

void AIBinder_DeathRecipient::TransferDeathRecipient::binderDied(const wp<IBinder>& who) {
    CHECK(who == mWho);

+5 −2
Original line number Diff line number Diff line
@@ -112,7 +112,8 @@ struct AIBinder_Class {
    AIBinder_Class(const char* interfaceDescriptor, AIBinder_Class_onCreate onCreate,
                   AIBinder_Class_onDestroy onDestroy, AIBinder_Class_onTransact onTransact);

    const ::android::String16& getInterfaceDescriptor() const { return mInterfaceDescriptor; }
    const ::android::String16& getInterfaceDescriptor() const { return mWideInterfaceDescriptor; }
    const char* getInterfaceDescriptorUtf8() const { return mInterfaceDescriptor.c_str(); }

    // required to be non-null, implemented for every class
    const AIBinder_Class_onCreate onCreate = nullptr;
@@ -124,9 +125,11 @@ struct AIBinder_Class {
    AIBinder_handleShellCommand handleShellCommand = nullptr;

   private:
    // Copy of the raw char string for when we don't have to return UTF-16
    const std::string mInterfaceDescriptor;
    // This must be a String16 since BBinder virtual getInterfaceDescriptor returns a reference to
    // one.
    const ::android::String16 mInterfaceDescriptor;
    const ::android::String16 mWideInterfaceDescriptor;
};

// Ownership is like this (when linked to death):
+17 −0
Original line number Diff line number Diff line
@@ -642,6 +642,23 @@ binder_status_t AIBinder_setExtension(AIBinder* binder, AIBinder* ext) __INTRODU

#endif  //__ANDROID_API__ >= 30

#if __ANDROID_API__ >= 31

/**
 * Retrieve the class descriptor for the class.
 *
 * Available since API level 31.
 *
 * \param clazz the class to fetch the descriptor from
 *
 * \return the class descriptor string. This pointer will never be null; a
 * descriptor is required to define a class. The pointer is owned by the class
 * and will remain valid as long as the class does.
 */
const char* AIBinder_Class_getDescriptor(const AIBinder_Class* clazz) __INTRODUCED_IN(31);

#endif  //__ANDROID_API__ >= 31

__END_DECLS

/** @} */
+1 −0
Original line number Diff line number Diff line
@@ -121,6 +121,7 @@ LIBBINDER_NDK31 { # introduced=31
    AServiceManager_registerLazyService; # llndk
    AServiceManager_waitForService; # apex llndk

    AIBinder_Class_getDescriptor;
    AParcel_appendFrom;
    AParcel_create;
    AParcel_getDataSize;
+1 −1
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ using ::android::wp;

const char* IFoo::kSomeInstanceName = "libbinder_ndk-test-IFoo";
const char* IFoo::kInstanceNameToDieFor = "libbinder_ndk-test-IFoo-to-die";
const char* kIFooDescriptor = "my-special-IFoo-class";
const char* IFoo::kIFooDescriptor = "my-special-IFoo-class";

struct IFoo_Class_Data {
    sp<IFoo> foo;
Loading