错误:error: static_assert failed due to requirement 'internal::allowedManualInterface("android.test.Icallback")' "b/64223827: Manually written binder interfaces are considered error prone and frequently have bugs. The preferred way to add interfaces is to define an .aidl file to auto-generate the interface. If an interface must be manually written, add its name to the whitelist."
IMPLEMENT_META_INTERFACE(callback, "android.test.Icallback");
我在开发android系统私有服务 版本28之前都是使用Andorid.mk,编译都没大问题
现在Android11后,变成Andorid.bp,编译规则特别严格
之前的CS结构,进程间接口都是我自己手写的,最新编译
IMPLEMENT_META_INTERFACE 直接static_assert报错,看提示需要加入一个白名单;
#define IMPLEMENT_META_INTERFACE(INTERFACE, NAME) \
static_assert(internal::allowedManualInterface(NAME), \
"b/64223827: Manually written binder interfaces are " \
"considered error prone and frequently have bugs. " \
"The preferred way to add interfaces is to define " \
"an .aidl file to auto-generate the interface. If " \
"an interface must be manually written, add its " \
"name to the whitelist."); \
DO_NOT_DIRECTLY_USE_ME_IMPLEMENT_META_INTERFACE(INTERFACE, NAME) \
1、我最后在IInterface.h中找打白名单,加入我的就行frameworks\native\libs\binder\include\binder\IInterface.h
kManualInterfaces是白名单
2、暂时的粗暴规避
#ifndef DO_NOT_CHECK_MANUAL_BINDER_INTERFACES
#define DO_NOT_CHECK_MANUAL_BINDER_INTERFACES 1
#endif