@ -25,6 +25,15 @@
# include "absl/strings/str_cat.h"
# include "src/core/lib/gprpp/sync.h"
// TODO(mingcl): This function is introduced at API level 32 and is not
// available in any NDK release yet. So we export it weakly so that we can use
// it without triggering undefined reference error. Its purpose is to disable
// header in Parcel to conform to the BinderChannel wire format.
extern " C " {
extern void AIBinder_Class_disableInterfaceTokenHeader ( AIBinder_Class * clazz )
__attribute__ ( ( weak ) ) ;
}
namespace grpc_binder {
namespace {
@ -92,6 +101,16 @@ TransactionReceiverAndroid::TransactionReceiverAndroid(
/*interfaceDescriptor=*/ " " , f_onCreate_userdata , f_onDestroy_delete ,
f_onTransact ) ;
if ( AIBinder_Class_disableInterfaceTokenHeader ) {
AIBinder_Class_disableInterfaceTokenHeader ( aibinder_class ) ;
} else {
// TODO(mingcl): Make this a fatal error
gpr_log ( GPR_ERROR ,
" AIBinder_Class_disableInterfaceTokenHeader remain unresolved. "
" This BinderTransport implementation contains header and is not "
" compatible with Java's implementation " ) ;
}
// Pass the on-transact callback to the on-create function of the binder. The
// on-create function equips the callback with a mutex and gives it to the
// user data stored in the binder which can be retrieved later.
@ -124,6 +143,17 @@ void AssociateWithNoopClass(AIBinder* binder) {
// Need to associate class before using it
AIBinder_Class * aibinder_class = AIBinder_Class_define (
" " , f_onCreate_noop , f_onDestroy_noop , f_onTransact_noop ) ;
if ( AIBinder_Class_disableInterfaceTokenHeader ) {
AIBinder_Class_disableInterfaceTokenHeader ( aibinder_class ) ;
} else {
// TODO(mingcl): Make this a fatal error
gpr_log ( GPR_ERROR ,
" AIBinder_Class_disableInterfaceTokenHeader remain unresolved. "
" This BinderTransport implementation contains header and is not "
" compatible with Java's implementation " ) ;
}
gpr_log ( GPR_INFO , " AIBinder_associateClass = %d " ,
static_cast < int > ( AIBinder_associateClass ( binder , aibinder_class ) ) ) ;
}