Loading libs/binder/ndk/ibinder.cpp +11 −2 Original line number Diff line number Diff line Loading @@ -172,7 +172,7 @@ status_t ABBinder::dump(int fd, const ::android::Vector<String16>& args) { status_t ABBinder::onTransact(transaction_code_t code, const Parcel& data, Parcel* reply, binder_flags_t flags) { if (isUserCommand(code)) { if (!data.checkInterface(this)) { if (getClass()->writeHeader && !data.checkInterface(this)) { return STATUS_BAD_TYPE; } Loading Loading @@ -354,6 +354,12 @@ void AIBinder_Class_setOnDump(AIBinder_Class* clazz, AIBinder_onDump onDump) { clazz->onDump = onDump; } void AIBinder_Class_disableInterfaceTokenHeader(AIBinder_Class* clazz) { CHECK(clazz != nullptr) << "disableInterfaceTokenHeader requires non-null clazz"; clazz->writeHeader = false; } void AIBinder_Class_setHandleShellCommand(AIBinder_Class* clazz, AIBinder_handleShellCommand handleShellCommand) { CHECK(clazz != nullptr) << "setHandleShellCommand requires non-null clazz"; Loading Loading @@ -606,7 +612,10 @@ binder_status_t AIBinder_prepareTransaction(AIBinder* binder, AParcel** in) { *in = new AParcel(binder); (*in)->get()->markForBinder(binder->getBinder()); status_t status = (*in)->get()->writeInterfaceToken(clazz->getInterfaceDescriptor()); status_t status = android::OK; if (clazz->writeHeader) { status = (*in)->get()->writeInterfaceToken(clazz->getInterfaceDescriptor()); } binder_status_t ret = PruneStatusT(status); if (ret != STATUS_OK) { Loading libs/binder/ndk/ibinder_internal.h +3 −0 Original line number Diff line number Diff line Loading @@ -116,6 +116,9 @@ struct AIBinder_Class { const ::android::String16& getInterfaceDescriptor() const { return mWideInterfaceDescriptor; } const char* getInterfaceDescriptorUtf8() const { return mInterfaceDescriptor.c_str(); } // whether a transaction header should be written bool writeHeader = true; // required to be non-null, implemented for every class const AIBinder_Class_onCreate onCreate = nullptr; const AIBinder_Class_onDestroy onDestroy = nullptr; Loading libs/binder/ndk/include_ndk/android/binder_ibinder.h +15 −0 Original line number Diff line number Diff line Loading @@ -218,6 +218,21 @@ typedef binder_status_t (*AIBinder_onDump)(AIBinder* binder, int fd, const char* */ void AIBinder_Class_setOnDump(AIBinder_Class* clazz, AIBinder_onDump onDump) __INTRODUCED_IN(29); /** * This tells users of this class not to use a transaction header. By default, libbinder_ndk users * read/write transaction headers implicitly (in the SDK, this must be manually written by * android.os.Parcel#writeInterfaceToken, and it is read/checked with * android.os.Parcel#enforceInterface). This method is provided in order to talk to legacy code * which does not write an interface token. When this is disabled, type safety is reduced, so you * must have a separate way of determining the binder you are talking to is the right type. Must * be called before any instance of the class is created. * * Available since API level 32. * * \param clazz class to disable interface header on. */ void AIBinder_Class_disableInterfaceTokenHeader(AIBinder_Class* clazz) __INTRODUCED_IN(32); /** * Creates a new binder object of the appropriate class. * Loading libs/binder/ndk/libbinder_ndk.map.txt +5 −0 Original line number Diff line number Diff line Loading @@ -141,6 +141,11 @@ LIBBINDER_NDK31 { # introduced=31 AParcel_reset; }; LIBBINDER_NDK32 { # introduced=32 global: AIBinder_Class_disableInterfaceTokenHeader; }; LIBBINDER_NDK_PLATFORM { global: AParcel_getAllowFds; Loading Loading
libs/binder/ndk/ibinder.cpp +11 −2 Original line number Diff line number Diff line Loading @@ -172,7 +172,7 @@ status_t ABBinder::dump(int fd, const ::android::Vector<String16>& args) { status_t ABBinder::onTransact(transaction_code_t code, const Parcel& data, Parcel* reply, binder_flags_t flags) { if (isUserCommand(code)) { if (!data.checkInterface(this)) { if (getClass()->writeHeader && !data.checkInterface(this)) { return STATUS_BAD_TYPE; } Loading Loading @@ -354,6 +354,12 @@ void AIBinder_Class_setOnDump(AIBinder_Class* clazz, AIBinder_onDump onDump) { clazz->onDump = onDump; } void AIBinder_Class_disableInterfaceTokenHeader(AIBinder_Class* clazz) { CHECK(clazz != nullptr) << "disableInterfaceTokenHeader requires non-null clazz"; clazz->writeHeader = false; } void AIBinder_Class_setHandleShellCommand(AIBinder_Class* clazz, AIBinder_handleShellCommand handleShellCommand) { CHECK(clazz != nullptr) << "setHandleShellCommand requires non-null clazz"; Loading Loading @@ -606,7 +612,10 @@ binder_status_t AIBinder_prepareTransaction(AIBinder* binder, AParcel** in) { *in = new AParcel(binder); (*in)->get()->markForBinder(binder->getBinder()); status_t status = (*in)->get()->writeInterfaceToken(clazz->getInterfaceDescriptor()); status_t status = android::OK; if (clazz->writeHeader) { status = (*in)->get()->writeInterfaceToken(clazz->getInterfaceDescriptor()); } binder_status_t ret = PruneStatusT(status); if (ret != STATUS_OK) { Loading
libs/binder/ndk/ibinder_internal.h +3 −0 Original line number Diff line number Diff line Loading @@ -116,6 +116,9 @@ struct AIBinder_Class { const ::android::String16& getInterfaceDescriptor() const { return mWideInterfaceDescriptor; } const char* getInterfaceDescriptorUtf8() const { return mInterfaceDescriptor.c_str(); } // whether a transaction header should be written bool writeHeader = true; // required to be non-null, implemented for every class const AIBinder_Class_onCreate onCreate = nullptr; const AIBinder_Class_onDestroy onDestroy = nullptr; Loading
libs/binder/ndk/include_ndk/android/binder_ibinder.h +15 −0 Original line number Diff line number Diff line Loading @@ -218,6 +218,21 @@ typedef binder_status_t (*AIBinder_onDump)(AIBinder* binder, int fd, const char* */ void AIBinder_Class_setOnDump(AIBinder_Class* clazz, AIBinder_onDump onDump) __INTRODUCED_IN(29); /** * This tells users of this class not to use a transaction header. By default, libbinder_ndk users * read/write transaction headers implicitly (in the SDK, this must be manually written by * android.os.Parcel#writeInterfaceToken, and it is read/checked with * android.os.Parcel#enforceInterface). This method is provided in order to talk to legacy code * which does not write an interface token. When this is disabled, type safety is reduced, so you * must have a separate way of determining the binder you are talking to is the right type. Must * be called before any instance of the class is created. * * Available since API level 32. * * \param clazz class to disable interface header on. */ void AIBinder_Class_disableInterfaceTokenHeader(AIBinder_Class* clazz) __INTRODUCED_IN(32); /** * Creates a new binder object of the appropriate class. * Loading
libs/binder/ndk/libbinder_ndk.map.txt +5 −0 Original line number Diff line number Diff line Loading @@ -141,6 +141,11 @@ LIBBINDER_NDK31 { # introduced=31 AParcel_reset; }; LIBBINDER_NDK32 { # introduced=32 global: AIBinder_Class_disableInterfaceTokenHeader; }; LIBBINDER_NDK_PLATFORM { global: AParcel_getAllowFds; Loading