NdkBinder
摘要
类型定义 |
|
---|---|
AIBinder
|
typedefstruct AIBinder
|
AIBinder
|
typedefstruct AIBinder
|
AIBinder_Class
|
typedefstruct AIBinder_Class
|
AIBinder_Class_onCreate)(void *args)
|
typedefvoid *(*
每当需要特定类的新 AIBinder 对象时,就会调用此函数。 |
AIBinder_Class_onDestroy)(void *userData)
|
typedefvoid(*
每当 AIBinder 对象不再被引用且需要销毁时,就会调用此函数。 |
AIBinder_Class_onTransact)(AIBinder *binder, transaction_code_t code, const AParcel *in, AParcel *out)
|
typedef 每当需要由本地实现处理事务时,就会调用此函数。 |
AIBinder_DeathRecipient
|
typedefstruct AIBinder_DeathRecipient
|
AIBinder_DeathRecipient_onBinderDied)(void *cookie)
|
typedefvoid(*
此函数在收到死亡通知时执行。 |
AIBinder_DeathRecipient_onBinderUnlinked)(void *cookie)
|
typedefvoid(*
此函数旨在清理提供的 cookie 中的数据,并在 DeathRecipient 解除关联时执行。 |
AIBinder_Weak
|
typedefstruct AIBinder_Weak
|
AIBinder_onDump)(AIBinder *binder, int fd, const char **args, uint32_t numArgs)
|
typedef dump(通常用于调试)有关 AIBinder 的信息。 |
AParcel
|
typedefstruct AParcel
|
AParcel_boolArrayAllocator)(void *arrayData, int32_t length)
|
typedefbool(*
这会在 arrayData 内部分配一个大小为“length”的数组,并返回是否成功。 |
AParcel_boolArrayGetter)(const void *arrayData, size_t index)
|
typedefbool(*
用于从 arrayData 对象中的 index 处获取底层数据。 |
AParcel_boolArraySetter)(void *arrayData, size_t index, bool value)
|
typedefvoid(*
用于在 arrayData 对象中的 index 处设置底层值。 |
AParcel_byteArrayAllocator)(void *arrayData, int32_t length, int8_t **outBuffer)
|
typedefbool(*
用于从 arrayData 对象中获取底层数据。 |
AParcel_charArrayAllocator)(void *arrayData, int32_t length, char16_t **outBuffer)
|
typedefbool(*
用于从 arrayData 对象中获取底层数据。 |
AParcel_doubleArrayAllocator)(void *arrayData, int32_t length, double **outBuffer)
|
typedefbool(*
用于从 arrayData 对象中获取底层数据。 |
AParcel_floatArrayAllocator)(void *arrayData, int32_t length, float **outBuffer)
|
typedefbool(*
用于从 arrayData 对象中获取底层数据。 |
AParcel_int32ArrayAllocator)(void *arrayData, int32_t length, int32_t **outBuffer)
|
typedefbool(*
用于从 arrayData 对象中获取底层数据。 |
AParcel_int64ArrayAllocator)(void *arrayData, int32_t length, int64_t **outBuffer)
|
typedefbool(*
用于从 arrayData 对象中获取底层数据。 |
AParcel_parcelableArrayAllocator)(void *arrayData, int32_t length)
|
typedefbool(*
用于分配大小为“length”的数组。 |
AParcel_readParcelableElement)(const AParcel *parcel, void *arrayData, size_t index)
|
typedef 用于在 arrayData 对象中的 index 处设置底层值。 |
AParcel_stringAllocator)(void *stringData, int32_t length, char **buffer)
|
typedefbool(*
用于为 C 风格字符串(null 终止)分配缓冲区。 |
AParcel_stringArrayAllocator)(void *arrayData, int32_t length)
|
typedefbool(*
用于分配大小为“length”的数组。 |
AParcel_stringArrayElementAllocator)(void *arrayData, size_t index, int32_t length, char **buffer)
|
typedefbool(*
用于在由 AParcel_stringArrayAllocator 分配的数组内部分配字符串。 |
AParcel_stringArrayElementGetter)(const void *arrayData, size_t index, int32_t *outLength)
|
typedefconst char *(*
这返回数组在 arrayData 对象中特定 index 处的长度和缓冲区。 |
AParcel_uint32ArrayAllocator)(void *arrayData, int32_t length, uint32_t **outBuffer)
|
typedefbool(*
用于从 arrayData 对象中获取底层数据。 |
AParcel_uint64ArrayAllocator)(void *arrayData, int32_t length, uint64_t **outBuffer)
|
typedefbool(*
用于从 arrayData 对象中获取底层数据。 |
AParcel_writeParcelableElement)(AParcel *parcel, const void *arrayData, size_t index)
|
typedef 用于将 arrayData 对象在 index 处的底层数据 Parcel 化。 |
AStatus
|
typedefstruct AStatus
|
binder_exception_t
|
typedefint32_t
EX_* 枚举数之一。 |
binder_flags_t
|
typedefuint32_t
AIBinder_transact 的标志。 |
binder_status_t
|
typedefint32_t
STATUS_* 值之一。 |
transaction_code_t
|
typedefuint32_t
AIBinder_transact 的代码。 |
函数 |
|
---|---|
AIBinder_Class_define(const char *interfaceDescriptor, AIBinder_Class_onCreate onCreate, AIBinder_Class_onDestroy onDestroy, AIBinder_Class_onTransact onTransact)
|
AIBinder_Class *
这会创建 Binder 类的新实例,该实例可以实例化。
|
AIBinder_Class_disableInterfaceTokenHeader(AIBinder_Class *clazz)
|
void
这会告知该类的用户不要使用事务头。
|
AIBinder_Class_getDescriptor(const AIBinder_Class *clazz)
|
const char *
检索该类的类描述符。
|
AIBinder_Class_getFunctionName(AIBinder_Class *clazz, transaction_code_t code)
|
const char *
获取给定类关联的事务代码的函数名称。
|
AIBinder_Class_setOnDump(AIBinder_Class *clazz, AIBinder_onDump onDump)
|
void
这为类设置 dump 方法的实现。
|
AIBinder_Class_setTransactionCodeToFunctionNameMap(AIBinder_Class *clazz, const char **transactionCodeToFunctionMap, size_t length)
|
void
为给定类关联事务代码 (transaction_code_t) 到函数名称的映射。
|
AIBinder_DeathRecipient_delete(AIBinder_DeathRecipient *recipient)
|
void
删除 Binder 死亡接收者。
|
AIBinder_DeathRecipient_new(AIBinder_DeathRecipient_onBinderDied onBinderDied)
|
AIBinder_DeathRecipient *
创建新的 Binder 死亡接收者。
|
AIBinder_DeathRecipient_setOnUnlinked(AIBinder_DeathRecipient *recipient, AIBinder_DeathRecipient_onBinderUnlinked onUnlinked)
|
void
设置当此 DeathRecipient 与 Binder 解除关联时调用的回调。
|
AIBinder_Weak_clone(const AIBinder_Weak *weak)
|
AIBinder_Weak *
克隆 AIBinder_Weak。
|
AIBinder_Weak_delete(AIBinder_Weak *weakBinder)
|
void
删除弱引用。
|
AIBinder_Weak_lt(const AIBinder_Weak *lhs, const AIBinder_Weak *rhs)
|
bool
一个 AIBinder_Weak 是否小于另一个。
|
AIBinder_Weak_new(AIBinder *binder)
|
AIBinder_Weak *
这不拥有输入 Binder 的所有权,但如果在某些进程中还有其他东西持有它的引用,则可以使用它来检索该引用。
|
AIBinder_Weak_promote(AIBinder_Weak *weakBinder)
|
AIBinder *
如果升级成功,结果将增加一个强引用计数。
|
AIBinder_associateClass(AIBinder *binder, const AIBinder_Class *clazz)
|
bool
这会设置 AIBinder 对象的类。
|
AIBinder_debugGetRefCount(AIBinder *binder)
|
int32_t
仅用于调试!
|
AIBinder_decStrong(AIBinder *binder)
|
void
当引用计数达到零时,这将删除对象并调用 onDestroy。
|
AIBinder_dump(AIBinder *binder, int fd, const char **args, uint32_t numArgs)
|
所有 Binder 对象的内置事务。
|
AIBinder_fromJavaBinder(JNIEnv *env, jobject binder)
|
AIBinder *
将 android.os.IBinder 对象转换为 AIBinder* 对象。
|
AIBinder_getCallingPid()
|
pid_t
假定此线程是从处理 Binder 事务的线程调用(例如,在 AIBinder_Class_onTransact 的实现中),则返回调用方 PID。
|
AIBinder_getCallingUid()
|
uid_t
假定此线程是从处理 Binder 事务的线程调用(例如,在 AIBinder_Class_onTransact 的实现中),则返回调用方 UID。
|
AIBinder_getClass(AIBinder *binder)
|
const AIBinder_Class *
返回构造或关联此 Binder 时使用的类。
|
AIBinder_getExtension(AIBinder *binder, AIBinder **outExt)
|
获取使用 AIBinder_setExtension 注册的扩展。
|
AIBinder_getUserData(AIBinder *binder)
|
void *
onCreate 为本地 Binder 返回的值。
|
AIBinder_incStrong(AIBinder *binder)
|
void
仅当此对象的强引用已存在于进程中时才能调用此函数。
|
AIBinder_isAlive(const AIBinder *binder)
|
bool
如果已知此 Binder 处于活跃状态。
|
AIBinder_isHandlingTransaction()
|
bool
确定当前线程是否正在执行传入事务。
|
AIBinder_isRemote(const AIBinder *binder)
|
bool
如果此对象托管在当前进程以外的进程中。
|
AIBinder_linkToDeath(AIBinder *binder, AIBinder_DeathRecipient *recipient, void *cookie)
|
注册以接收关联 Binder 死亡的通知。
|
AIBinder_lt(const AIBinder *lhs, const AIBinder *rhs)
|
bool
一个 AIBinder 是否小于另一个。
|
AIBinder_new(const AIBinder_Class *clazz, void *args)
|
AIBinder *
创建相应类的新 Binder 对象。
|
AIBinder_ping(AIBinder *binder)
|
所有 Binder 对象的内置事务。
|
AIBinder_prepareTransaction(AIBinder *binder, AParcel **in)
|
事务是一系列对此类函数的调用,其示例如下。
|
AIBinder_setExtension(AIBinder *binder, AIBinder *ext)
|
获取 Binder 接口的扩展。
|
AIBinder_toJavaBinder(JNIEnv *env, AIBinder *binder)
|
jobject
将 AIBinder* 对象转换为 android.os.IBinder 对象。
|
AIBinder_transact(AIBinder *binder, transaction_code_t code, AParcel **in, AParcel **out, binder_flags_t flags)
|
使用通过 AIBinder_prepareTransaction 创建的 Parcel 进行事务处理。
|
AIBinder_unlinkToDeath(AIBinder *binder, AIBinder_DeathRecipient *recipient, void *cookie)
|
停止注册关联 Binder 死亡的通知。
|
AParcel_appendFrom(const AParcel *from, AParcel *to, int32_t start, int32_t size)
|
将一个 Parcel 的数据复制到另一个 Parcel。
|
AParcel_create()
|
AParcel *
创建 Parcel。
|
AParcel_delete(AParcel *parcel)
|
void
清理 Parcel。
|
AParcel_fromJavaParcel(JNIEnv *env, jobject parcel)
|
AParcel *
将 android.os.Parcel 对象转换为 AParcel* 对象。
|
AParcel_getDataPosition(const AParcel *parcel)
|
int32_t
获取 Parcel 中的当前位置。
|
AParcel_getDataSize(const AParcel *parcel)
|
int32_t
获取 Parcel 的大小。
|
AParcel_marshal(const AParcel *parcel, uint8_t *buffer, size_t start, size_t len)
|
将 Parcel 的原始字节数据封送(Marshal)到缓冲区。
|
AParcel_readBool(const AParcel *parcel, bool *value)
|
从非空 Parcel 中的下一位置读取 bool 值。
|
AParcel_readBoolArray(const AParcel *parcel, void *arrayData, AParcel_boolArrayAllocator allocator, AParcel_boolArraySetter setter)
|
从非空 Parcel 中的下一位置读取 bool 数组。
|
AParcel_readByte(const AParcel *parcel, int8_t *value)
|
从非空 Parcel 中的下一位置读取 int8_t 值。
|
AParcel_readByteArray(const AParcel *parcel, void *arrayData, AParcel_byteArrayAllocator allocator)
|
从非空 Parcel 中的下一位置读取 int8_t 数组。
|
AParcel_readChar(const AParcel *parcel, char16_t *value)
|
从非空 Parcel 中的下一位置读取 char16_t 值。
|
AParcel_readCharArray(const AParcel *parcel, void *arrayData, AParcel_charArrayAllocator allocator)
|
从非空 Parcel 中的下一位置读取 char16_t 数组。
|
AParcel_readDouble(const AParcel *parcel, double *value)
|
从非空 Parcel 中的下一位置读取 double 值。
|
AParcel_readDoubleArray(const AParcel *parcel, void *arrayData, AParcel_doubleArrayAllocator allocator)
|
从非空 Parcel 中的下一位置读取 double 数组。
|
AParcel_readFloat(const AParcel *parcel, float *value)
|
从非空 Parcel 中的下一位置读取 float 值。
|
AParcel_readFloatArray(const AParcel *parcel, void *arrayData, AParcel_floatArrayAllocator allocator)
|
从非空 Parcel 中的下一位置读取 float 数组。
|
AParcel_readInt32(const AParcel *parcel, int32_t *value)
|
从非空 Parcel 中的下一位置读取 int32_t 值。
|
AParcel_readInt32Array(const AParcel *parcel, void *arrayData, AParcel_int32ArrayAllocator allocator)
|
从非空 Parcel 中的下一位置读取 int32_t 数组。
|
AParcel_readInt64(const AParcel *parcel, int64_t *value)
|
从非空 Parcel 中的下一位置读取 int64_t 值。
|
AParcel_readInt64Array(const AParcel *parcel, void *arrayData, AParcel_int64ArrayAllocator allocator)
|
从非空 Parcel 中的下一位置读取 int64_t 数组。
|
AParcel_readParcelFileDescriptor(const AParcel *parcel, int *fd)
|
从非空 Parcel 中的下一位置读取 int 值。
|
AParcel_readParcelableArray(const AParcel *parcel, void *arrayData, AParcel_parcelableArrayAllocator allocator, AParcel_readParcelableElement elementReader)
|
从非空 Parcel 中的下一位置读取 Parcelable 数组(用户定义类型)。
|
AParcel_readStatusHeader(const AParcel *parcel, AStatus **status)
|
从非空 Parcel 中的下一位置读取 AStatus。
|
AParcel_readString(const AParcel *parcel, void *stringData, AParcel_stringAllocator allocator)
|
从非空 Parcel 中的下一位置读取并分配 UTF-8 字符串值。
|
AParcel_readStringArray(const AParcel *parcel, void *arrayData, AParcel_stringArrayAllocator allocator, AParcel_stringArrayElementAllocator elementAllocator)
|
从非空 Parcel 中的下一位置读取并分配 UTF-8 字符串数组值。
|
AParcel_readStrongBinder(const AParcel *parcel, AIBinder **binder)
|
从非空 Parcel 中的下一位置读取 AIBinder。
|
AParcel_readUint32(const AParcel *parcel, uint32_t *value)
|
从非空 Parcel 中的下一位置读取 uint32_t 值。
|
AParcel_readUint32Array(const AParcel *parcel, void *arrayData, AParcel_uint32ArrayAllocator allocator)
|
从非空 Parcel 中的下一位置读取 uint32_t 数组。
|
AParcel_readUint64(const AParcel *parcel, uint64_t *value)
|
从非空 Parcel 中的下一位置读取 uint64_t 值。
|
AParcel_readUint64Array(const AParcel *parcel, void *arrayData, AParcel_uint64ArrayAllocator allocator)
|
从非空 Parcel 中的下一位置读取 uint64_t 数组。
|
AParcel_reset(AParcel *parcel)
|
将 Parcel 重置为初始状态。
|
AParcel_setDataPosition(const AParcel *parcel, int32_t position)
|
设置 Parcel 中的位置。
|
AParcel_unmarshal(AParcel *parcel, const uint8_t *buffer, size_t len)
|
将 Parcel 中的数据设置为缓冲区中的原始字节。
|
AParcel_writeBool(AParcel *parcel, bool value)
|
将 bool 值写入非空 Parcel 中的下一位置。
|
AParcel_writeBoolArray(AParcel *parcel, const void *arrayData, int32_t length, AParcel_boolArrayGetter getter)
|
将 bool 数组写入非空 Parcel 中的下一位置。
|
AParcel_writeByte(AParcel *parcel, int8_t value)
|
将 int8_t 值写入非空 Parcel 中的下一位置。
|
AParcel_writeByteArray(AParcel *parcel, const int8_t *arrayData, int32_t length)
|
将 int8_t 数组写入非空 Parcel 中的下一位置。
|
AParcel_writeChar(AParcel *parcel, char16_t value)
|
将 char16_t 值写入非空 Parcel 中的下一位置。
|
AParcel_writeCharArray(AParcel *parcel, const char16_t *arrayData, int32_t length)
|
将 char16_t 数组写入非空 Parcel 中的下一位置。
|
AParcel_writeDouble(AParcel *parcel, double value)
|
将 double 值写入非空 Parcel 中的下一位置。
|
AParcel_writeDoubleArray(AParcel *parcel, const double *arrayData, int32_t length)
|
将 double 数组写入非空 Parcel 中的下一位置。
|
AParcel_writeFloat(AParcel *parcel, float value)
|
将 float 值写入非空 Parcel 中的下一位置。
|
AParcel_writeFloatArray(AParcel *parcel, const float *arrayData, int32_t length)
|
将 float 数组写入非空 Parcel 中的下一位置。
|
AParcel_writeInt32(AParcel *parcel, int32_t value)
|
将 int32_t 值写入非空 Parcel 中的下一位置。
|
AParcel_writeInt32Array(AParcel *parcel, const int32_t *arrayData, int32_t length)
|
将 int32_t 数组写入非空 Parcel 中的下一位置。
|
AParcel_writeInt64(AParcel *parcel, int64_t value)
|
将 int64_t 值写入非空 Parcel 中的下一位置。
|
AParcel_writeInt64Array(AParcel *parcel, const int64_t *arrayData, int32_t length)
|
将 int64_t 数组写入非空 Parcel 中的下一位置。
|
AParcel_writeParcelFileDescriptor(AParcel *parcel, int fd)
|
将文件描述符写入非空 Parcel 中的下一位置。
|
AParcel_writeParcelableArray(AParcel *parcel, const void *arrayData, int32_t length, AParcel_writeParcelableElement elementWriter)
|
将 Parcelable 数组(用户定义类型)写入非空 Parcel 中的下一位置。
|
AParcel_writeStatusHeader(AParcel *parcel, const AStatus *status)
|
将 AStatus 对象写入非空 Parcel 中的下一位置。
|
AParcel_writeString(AParcel *parcel, const char *string, int32_t length)
|
将 UTF-8 字符串值写入非空 Parcel 中的下一位置。
|
AParcel_writeStringArray(AParcel *parcel, const void *arrayData, int32_t length, AParcel_stringArrayElementGetter getter)
|
将 UTF-8 字符串数组数据写入非空 Parcel 中的下一位置。
|
AParcel_writeStrongBinder(AParcel *parcel, AIBinder *binder)
|
将 AIBinder 写入非空 Parcel 中的下一位置。
|
AParcel_writeUint32(AParcel *parcel, uint32_t value)
|
将 uint32_t 值写入非空 Parcel 中的下一位置。
|
AParcel_writeUint32Array(AParcel *parcel, const uint32_t *arrayData, int32_t length)
|
将 uint32_t 数组写入非空 Parcel 中的下一位置。
|
AParcel_writeUint64(AParcel *parcel, uint64_t value)
|
将 uint64_t 值写入非空 Parcel 中的下一位置。
|
AParcel_writeUint64Array(AParcel *parcel, const uint64_t *arrayData, int32_t length)
|
将 uint64_t 数组写入非空 Parcel 中的下一位置。
|
AStatus_delete(AStatus *status)
|
void
删除与 status 实例关联的内存。
|
AStatus_deleteDescription(const char *description)
|
void
删除描述。
|
AStatus_fromExceptionCode(binder_exception_t exception)
|
AStatus *
带有异常代码的新 status。
|
AStatus_fromExceptionCodeWithMessage(binder_exception_t exception, const char *message)
|
AStatus *
带有异常代码和消息的新 status。
|
AStatus_fromServiceSpecificError(int32_t serviceSpecific)
|
AStatus *
带有服务特定错误的新 status。
|
AStatus_fromServiceSpecificErrorWithMessage(int32_t serviceSpecific, const char *message)
|
AStatus *
带有服务特定错误和消息的新 status。
|
AStatus_fromStatus(binder_status_t status)
|
AStatus *
带有 binder_status_t 的新 status。
|
AStatus_getDescription(const AStatus *status)
|
const char *
获取可读的调试描述。
|
AStatus_getExceptionCode(const AStatus *status)
|
此 status 对象表示的异常。
|
AStatus_getMessage(const AStatus *status)
|
const char *
如果此 status 关联了消息,则将返回该消息。
|
AStatus_getServiceSpecificError(const AStatus *status)
|
int32_t
如果此对象表示服务特定错误,则返回该错误。
|
AStatus_getStatus(const AStatus *status)
|
如果此对象表示 status,则返回该 status。
|
AStatus_isOk(const AStatus *status)
|
bool
此对象是否表示成功的事务。
|
AStatus_newOk()
|
AStatus *
被视为成功的新 status。
|
枚举
匿名枚举 17
声明于android/binder_ibinder.h
Anonymous Enum 17
属性 | |
---|---|
FLAG_ONEWAY |
事务将被分派,然后返回给调用者。 出站进程无法阻止由其发起的调用,并且不会等待调用的执行。如果 Binder 驱动程序无法处理该调用,仍可能返回错误。 |
匿名枚举 18
声明于android/binder_ibinder.h
Anonymous Enum 18
属性 | |
---|---|
FIRST_CALL_TRANSACTION |
用户命令可用的第一个事务代码(包括该代码)。 |
LAST_CALL_TRANSACTION |
用户命令可用的最后一个事务代码(包括该代码)。 |
匿名枚举 19
声明于android/binder_status.h
Anonymous Enum 19
用于 Binder 的低级别状态类型。
这是 Binder 服务返回错误的最不推荐方式(应使用 binder_exception_t,特别是 EX_SERVICE_SPECIFIC)。
匿名枚举 20
声明于android/binder_status.h
Anonymous Enum 20
适用于 Android Binder 错误、映射到 Java 异常的顶级异常类型。
另请参阅 Parcel.java。
类型定义
AIBinder
声明于android/binder_ibinder.h
struct AIBinder AIBinder
AIBinder
声明于android/binder_parcel.h
struct AIBinder AIBinder
AIBinder_Class
声明于android/binder_ibinder.h
struct AIBinder_Class AIBinder_Class
AIBinder_Class_onCreate
声明于android/binder_ibinder.h
void *(* AIBinder_Class_onCreate)(void *args)
每当需要特定类的新 AIBinder 对象时,就会调用此函数。
详情 | |||
---|---|---|---|
参数 |
|
||
返回 |
这是表示该类的用户数据。可以使用 AIBinder_getUserData 检索。
|
AIBinder_Class_onDestroy
声明于android/binder_ibinder.h
void(* AIBinder_Class_onDestroy)(void *userData)
每当 AIBinder 对象不再被引用且需要销毁时,就会调用此函数。
通常,这只是删除实现的内容。
详情 | |||
---|---|---|---|
参数 |
|
AIBinder_Class_onTransact
声明于android/binder_ibinder.h
binder_status_t(* AIBinder_Class_onTransact)(AIBinder *binder, transaction_code_t code, const AParcel *in, AParcel *out)
每当需要由本地实现处理事务时,就会调用此函数。
此方法将在调用等同于 android.os.Parcel::enforceInterface 的方法之后调用。也就是说,与 AIBinder_Class 描述符关联的接口描述符将已被检查。
详情 | |||||||||
---|---|---|---|---|---|---|---|---|---|
参数 |
|
||||||||
返回 |
实现特定的输出代码。这可能从另一个服务转发、是 Parcel 读取或写入的结果,或适用于特定实现的另一个错误。通常,实现特定的错误代码会写入输出 Parcel,而事务代码保留用于内核错误或后续事务中重复出现的错误代码。
|
AIBinder_DeathRecipient
声明于android/binder_ibinder.h
struct AIBinder_DeathRecipient AIBinder_DeathRecipient
AIBinder_DeathRecipient_onBinderDied
声明于android/binder_ibinder.h
void(* AIBinder_DeathRecipient_onBinderDied)(void *cookie)
此函数在收到死亡通知时执行。
请参阅 AIBinder_linkToDeath/AIBinder_unlinkToDeath。
自 API 级别 29 起可用。
详情 | |||
---|---|---|---|
参数 |
|
AIBinder_DeathRecipient_onBinderUnlinked
声明于android/binder_ibinder.h
void(* AIBinder_DeathRecipient_onBinderUnlinked)(void *cookie)
此函数旨在清理提供的 cookie 中的数据,并在 DeathRecipient 解除关联时执行。
当 DeathRecipient 因收到死亡通知而解除关联时,此方法在调用 onBinderDied 之后调用。
对于解除关联的每个 Binder,此方法调用一次。因此,如果将相同的 cookie 传递给多个 Binder,则调用方负责对 cookie 进行引用计数。
另请参阅 AIBinder_linkToDeath/AIBinder_unlinkToDeath。
警告:请确保此 cookie 的生命周期足够长。如果它是动态分配的,则应使用 AIBinder_DeathRecipient_setOnUnlinked 删除它。
自 API 级别 33 起可用。
详情 | |||
---|---|---|---|
参数 |
|
AIBinder_Weak
声明于android/binder_ibinder.h
struct AIBinder_Weak AIBinder_Weak
AIBinder_onDump
声明于android/binder_ibinder.h
binder_status_t(* AIBinder_onDump)(AIBinder *binder, int fd, const char **args, uint32_t numArgs)
dump(通常用于调试)有关 AIBinder 的信息。
未提供参数时,应提供对接口的简要概述。
详情 | |||||||||
---|---|---|---|---|---|---|---|---|---|
参数 |
|
||||||||
返回 |
事务的 binder_status_t 结果(例如,如果是远程)
|
AParcel
声明于android/binder_parcel.h
struct AParcel AParcel
AParcel_boolArrayAllocator
声明于android/binder_parcel.h
bool(* AParcel_boolArrayAllocator)(void *arrayData, int32_t length)
这会在 arrayData 内部分配一个大小为“length”的数组,并返回是否成功。
如果 length 是 -1,则应分配 null 数组的某种表示形式。
另请参阅 AParcel_readBoolArray
详情 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
分配是否成功。
|
AParcel_boolArrayGetter
声明于android/binder_parcel.h
bool(* AParcel_boolArrayGetter)(const void *arrayData, size_t index)
用于从 arrayData 对象中的 index 处获取底层数据。
另请参阅 AParcel_writeBoolArray
详情 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
数组在 index 处的 value。
|
AParcel_boolArraySetter
声明于android/binder_parcel.h
void(* AParcel_boolArraySetter)(void *arrayData, size_t index, bool value)
用于在 arrayData 对象中的 index 处设置底层值。
另请参阅 AParcel_readBoolArray
详情 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
AParcel_byteArrayAllocator
声明于android/binder_parcel.h
bool(* AParcel_byteArrayAllocator)(void *arrayData, int32_t length, int8_t **outBuffer)
用于从 arrayData 对象中获取底层数据。
此函数的实现应分配一个大小为“length”的连续数组,并返回要填充的底层缓冲区。如果出现错误或 length 为 0,则可能返回 null。如果 length 是 -1,则应分配 null 数组的某种表示形式。
另请参阅 AParcel_readByteArray
详情 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
||||||
返回 |
分配是否成功(或当 length 为 -1 时是否表示 null 数组)。
|
AParcel_charArrayAllocator
声明于android/binder_parcel.h
bool(* AParcel_charArrayAllocator)(void *arrayData, int32_t length, char16_t **outBuffer)
用于从 arrayData 对象中获取底层数据。
此函数的实现应分配一个大小为“length”的连续数组,并返回要填充的底层缓冲区。如果出现错误或 length 为 0,则可能返回 null。如果 length 是 -1,则应分配 null 数组的某种表示形式。
另请参阅 AParcel_readCharArray
详情 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
||||||
返回 |
分配是否成功(或当 length 为 -1 时是否表示 null 数组)。
|
AParcel_doubleArrayAllocator
声明于android/binder_parcel.h
bool(* AParcel_doubleArrayAllocator)(void *arrayData, int32_t length, double **outBuffer)
用于从 arrayData 对象中获取底层数据。
此函数的实现应分配一个大小为“length”的连续数组,并返回要填充的底层缓冲区。如果出现错误或 length 为 0,则可能返回 null。如果 length 是 -1,则应分配 null 数组的某种表示形式。
另请参阅 AParcel_readDoubleArray
详情 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
||||||
返回 |
分配是否成功(或当 length 为 -1 时是否表示 null 数组)。
|
AParcel_floatArrayAllocator
声明于android/binder_parcel.h
bool(* AParcel_floatArrayAllocator)(void *arrayData, int32_t length, float **outBuffer)
用于从 arrayData 对象中获取底层数据。
此函数的实现应分配一个大小为“length”的连续数组,并返回要填充的底层缓冲区。如果出现错误或 length 为 0,则可能返回 null。如果 length 是 -1,则应分配 null 数组的某种表示形式。
另请参阅 AParcel_readFloatArray
详情 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
||||||
返回 |
分配是否成功(或当 length 为 -1 时是否表示 null 数组)。
|
AParcel_int32ArrayAllocator
声明于android/binder_parcel.h
bool(* AParcel_int32ArrayAllocator)(void *arrayData, int32_t length, int32_t **outBuffer)
用于从 arrayData 对象中获取底层数据。
此函数的实现应分配一个大小为“length”的连续数组,并返回要填充的底层缓冲区。如果出现错误或 length 为 0,则可能返回 null。如果 length 是 -1,则应分配 null 数组的某种表示形式。
另请参阅 AParcel_readInt32Array
详情 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
||||||
返回 |
分配是否成功(或当 length 为 -1 时是否表示 null 数组)。
|
AParcel_int64ArrayAllocator
声明于android/binder_parcel.h
bool(* AParcel_int64ArrayAllocator)(void *arrayData, int32_t length, int64_t **outBuffer)
用于从 arrayData 对象中获取底层数据。
此函数的实现应分配一个大小为“length”的连续数组,并返回要填充的底层缓冲区。如果出现错误或 length 为 0,则可能返回 null。如果 length 是 -1,则应分配 null 数组的某种表示形式。
另请参阅 AParcel_readInt64Array
详情 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
||||||
返回 |
分配是否成功(或当 length 为 -1 时是否表示 null 数组)。
|
AParcel_parcelableArrayAllocator
声明于android/binder_parcel.h
bool(* AParcel_parcelableArrayAllocator)(void *arrayData, int32_t length)
用于分配大小为“length”的数组。
如果 length 是 -1,则应创建“null”数组(或等效项)。
另请参阅 AParcel_readParcelableArray
详情 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
如果分配成功,则为 true。如果 length 是 -1,则此处返回 true 表示已成功存储“null”值(或等效项)。
|
AParcel_readParcelableElement
声明于android/binder_parcel.h
binder_status_t(* AParcel_readParcelableElement)(const AParcel *parcel, void *arrayData, size_t index)
用于在 arrayData 对象中的 index 处设置底层值。
另请参阅 AParcel_readParcelableArray
详情 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
||||||
返回 |
status(通常由其他 Parcel 化函数返回)。
|
AParcel_stringAllocator
声明于android/binder_parcel.h
bool(* AParcel_stringAllocator)(void *stringData, int32_t length, char **buffer)
用于为 C 风格字符串(null 终止)分配缓冲区。
返回的缓冲区大小应至少为 length 字节。这包括用于 null 终止符的空间。对于字符串,length 将始终严格小于或等于 size_t 中可容纳的最大大小,并且始终大于 0。但是,如果正在读取“null”字符串,则 length 将为 -1。
另请参阅 AParcel_readString。
如果分配失败,则应返回 null。
详情 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
||||||
返回 |
如果分配成功,则为 true,否则为 false。如果 length 是 -1,则此处返回 true 表示已成功存储“null”值(或等效项)。
|
AParcel_stringArrayAllocator
声明于android/binder_parcel.h
bool(* AParcel_stringArrayAllocator)(void *arrayData, int32_t length)
用于分配大小为“length”的数组。
如果 length 是 -1,则应创建“null”数组(或等效项)。
另请参阅 AParcel_readStringArray
详情 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
如果分配成功,则为 true。如果 length 是 -1,则此处返回 true 表示已成功存储“null”值(或等效项)。
|
AParcel_stringArrayElementAllocator
声明于android/binder_parcel.h
bool(* AParcel_stringArrayElementAllocator)(void *arrayData, size_t index, int32_t length, char **buffer)
用于在由 AParcel_stringArrayAllocator 分配的数组内部分配字符串。
返回的 index 将始终在 [0, arrayData 的 length) 范围内。返回的缓冲区大小应至少为 length 字节。这包括用于 null 终止符的空间。对于字符串,length 将始终严格小于或等于 size_t 中可容纳的最大大小,并且始终大于 0。但是,如果正在读取“null”字符串,则 length 将为 -1。
另请参阅 AParcel_readStringArray
详情 | |||||||||
---|---|---|---|---|---|---|---|---|---|
参数 |
|
||||||||
返回 |
如果分配成功,则为 true,否则为 false。如果 length 是 -1,则此处返回 true 表示已成功存储“null”值(或等效项)。
|
AParcel_stringArrayElementGetter
声明于android/binder_parcel.h
const char *(* AParcel_stringArrayElementGetter)(const void *arrayData, size_t index, int32_t *outLength)
这返回数组在 arrayData 对象中特定 index 处的长度和缓冲区。
另请参阅 AParcel_writeStringArray
详情 | |||||||||
---|---|---|---|---|---|---|---|---|---|
参数 |
|
AParcel_uint32ArrayAllocator
声明于android/binder_parcel.h
bool(* AParcel_uint32ArrayAllocator)(void *arrayData, int32_t length, uint32_t **outBuffer)
用于从 arrayData 对象中获取底层数据。
此函数的实现应分配一个大小为“length”的连续数组,并返回要填充的底层缓冲区。如果出现错误或 length 为 0,则可能返回 null。如果 length 是 -1,则应分配 null 数组的某种表示形式。
另请参阅 AParcel_readUint32Array
详情 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
||||||
返回 |
分配是否成功(或当 length 为 -1 时是否表示 null 数组)。
|
AParcel_uint64ArrayAllocator
声明于android/binder_parcel.h
bool(* AParcel_uint64ArrayAllocator)(void *arrayData, int32_t length, uint64_t **outBuffer)
用于从 arrayData 对象中获取底层数据。
此函数的实现应分配一个大小为“length”的连续数组,并返回要填充的底层缓冲区。如果出现错误或 length 为 0,则可能返回 null。如果 length 是 -1,则应分配 null 数组的某种表示形式。
另请参阅 AParcel_readUint64Array
详情 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
||||||
返回 |
分配是否成功(或当 length 为 -1 时是否表示 null 数组)。
|
AParcel_writeParcelableElement
声明于android/binder_parcel.h
binder_status_t(* AParcel_writeParcelableElement)(AParcel *parcel, const void *arrayData, size_t index)
用于将 arrayData 对象在 index 处的底层数据 Parcel 化。
另请参阅 AParcel_writeParcelableArray
详情 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
||||||
返回 |
status(通常由其他 Parcel 化函数返回)。
|
AStatus
声明于android/binder_status.h
struct AStatus AStatus
binder_exception_t
声明于android/binder_status.h
int32_t binder_exception_t
EX_* 枚举数之一。
所有无法识别的值都将被强制转换为 EX_TRANSACTION_FAILED。
这些异常值由 SDK 用于 Parcelable。另请参阅 Parcel.java。
binder_flags_t
声明于android/binder_ibinder.h
uint32_t binder_flags_t
AIBinder_transact 的标志。
binder_status_t
声明于android/binder_status.h
int32_t binder_status_t
STATUS_* 值之一。
所有无法识别的值都将被强制转换为 STATUS_UNKNOWN_ERROR。
transaction_code_t
声明于android/binder_ibinder.h
uint32_t transaction_code_t
AIBinder_transact 的代码。
这定义了可使用的代码范围。其他代码被 Android 系统使用或保留。
函数
AIBinder_Class_define
声明于android/binder_ibinder.h
AIBinder_Class * AIBinder_Class_define( const char *interfaceDescriptor, AIBinder_Class_onCreate onCreate, AIBinder_Class_onDestroy onDestroy, AIBinder_Class_onTransact onTransact )
这会创建 Binder 类的新实例,该实例可以实例化。
这在库初始化期间调用一次,并在进程退出或 exec 时清理。
这些参数都不能为 null。
自 API 级别 29 起可用。
详情 | |||||||||
---|---|---|---|---|---|---|---|---|---|
参数 |
|
||||||||
返回 |
表示这些参数的类对象,或在出错时为 null。
|
AIBinder_Class_disableInterfaceTokenHeader
声明于android/binder_ibinder.h
void AIBinder_Class_disableInterfaceTokenHeader( AIBinder_Class *clazz )
这会告知该类的用户不要使用事务头。
默认情况下,libbinder_ndk 用户隐式读取/写入事务头(在 SDK 中,必须通过 android.os.Parcel::writeInterfaceToken 手动写入,并使用 android.os.Parcel::enforceInterface 读取/检查)。提供此方法是为了与不写入接口令牌的旧代码进行通信。
自 API 级别 33 起可用。
禁用此功能后,类型安全性会降低,因此必须有单独的方式来确定通信的 Binder 是否为正确类型。必须在创建类的任何实例之前调用。
详情 | |||
---|---|---|---|
参数 |
|
要禁用接口头的类。
声明于android/binder_ibinder.h
const char * AIBinder_Class_getDescriptor( const AIBinder_Class *clazz )
检索该类的类描述符。
自 API 级别 31 起可用。
详情 | |||
---|---|---|---|
参数 |
|
||
返回 |
类描述符字符串。此指针永远不会为 null;定义类需要描述符。此指针由类拥有,只要类存在,它就一直有效。对于本地类,此值与传递给 AIBinder_Class_define 的值相同(不一定指针相等)。格式为 UTF-8。
|
AIBinder_Class_getFunctionName
声明于android/binder_ibinder.h
const char * AIBinder_Class_getFunctionName( AIBinder_Class *clazz, transaction_code_t code )
获取给定类关联的事务代码的函数名称。
此函数返回与给定类的事务代码关联的函数名称。必须先调用 AIBinder_Class_setTransactionCodeToFunctionNameMap 才能关联函数到事务代码的映射。
自 API 级别 36 起可用。
详情 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
如果事务代码对给定类有效,则为 const char* 形式的函数名称。返回的值在 clazz 的生命周期内有效。如果事务代码无效或未设置 transactionCodeToFunctionMap,则返回 nullptr。
|
AIBinder_Class_setOnDump
声明于android/binder_ibinder.h
void AIBinder_Class_setOnDump( AIBinder_Class *clazz, AIBinder_onDump onDump )
这为类设置 dump 方法的实现。
如果未设置此项,则在调用 dump 时(例如使用 android.os.Binder::dump)不会 dump 任何内容。必须在创建类的任何实例之前调用。
自 API 级别 29 起可用。
详情 | |||||
---|---|---|---|---|---|
参数 |
|
AIBinder_Class_setTransactionCodeToFunctionNameMap
声明于android/binder_ibinder.h
void AIBinder_Class_setTransactionCodeToFunctionNameMap( AIBinder_Class *clazz, const char **transactionCodeToFunctionMap, size_t length )
为给定类关联事务代码 (transaction_code_t) 到函数名称的映射。
设置后,跟踪消息将使用提供的名称,而不是裸露的整数代码。如果此函数未设置此项,则跟踪消息只能通过裸露的代码标识。这应在 clazz 初始化期间调用一次。clazz 使用 AIBinder_Class_define 定义,且 transactionCodeToFunctionMap 应与 clazz 具有相同的范围。不允许重置/清除 transactionCodeToFunctionMap。为 clazz 或 transactionCodeToFunctionMap 传递 null 将导致中止。
自 API 级别 36 起可用。
详情 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
AIBinder_DeathRecipient_delete
声明于android/binder_ibinder.h
void AIBinder_DeathRecipient_delete( AIBinder_DeathRecipient *recipient )
删除 Binder 死亡接收者。
在调用此函数之前无需调用 AIBinder_unlinkToDeath,因为这些都将自动解除关联。
请注意,此调用返回后立即释放 cookie 是不安全的。如果需要清理 cookie,应在 onUnlinked 回调中进行,该回调可以使用 AIBinder_DeathRecipient_setOnUnlinked 设置。
自 API 级别 29 起可用。
详情 | |||
---|---|---|---|
参数 |
|
AIBinder_DeathRecipient_new
声明于android/binder_ibinder.h
AIBinder_DeathRecipient * AIBinder_DeathRecipient_new( AIBinder_DeathRecipient_onBinderDied onBinderDied )
创建新的 Binder 死亡接收者。
这可以附加到多个不同的 Binder 对象。
自 API 级别 29 起可用。
警告:请确保此 cookie 的生命周期足够长。如果它是动态分配的,则应使用 AIBinder_DeathRecipient_setOnUnlinked 删除它。
详情 | |||
---|---|---|---|
参数 |
|
||
返回 |
新构造的对象(如果 onBinderDied 为 null,则为 null)。
|
AIBinder_DeathRecipient_setOnUnlinked
声明于android/binder_ibinder.h
void AIBinder_DeathRecipient_setOnUnlinked( AIBinder_DeathRecipient *recipient, AIBinder_DeathRecipient_onBinderUnlinked onUnlinked )
设置当此 DeathRecipient 与 Binder 解除关联时调用的回调。
回调在以下情况下调用
- 如果 Binder 死亡,则在调用 onBinderDied 后不久。
- 如果 Binder 通过 AIBinder_unlinkToDeath 或 AIBinder_DeathRecipient_delete 显式解除关联,则在任何待处理的 onBinderDied 调用完成后。
- 在 AIBinder_linkToDeath 调用期间或之后不久,如果它返回错误。
保证对 linkToDeath 的每次调用都将调用一次回调,除非在 Binder 解除关联之前进程中止。
请注意,当 Binder 被显式解除关联时,不保证在调用 AIBinder_unlinkToDeath 或 AIBinder_DeathRecipient_delete 返回之前调用 onUnlinked。例如,如果 Binder 与 AIBinder_unlinkToDeath 的调用同时死亡,即使 AIBinder_unlinkToDeath 在此之前返回,Binder 也不会解除关联,直到死亡通知送达之后。
应在将 DeathRecipient 链接到 Binder 之前调用此方法,因为函数指针会被缓存。如果在链接到 Binder 后更改它,则不确定旧 Binder 会调用旧的还是新的 onUnlinked 回调。
onUnlinked 参数可以为 null。在这种情况下,当 Binder 解除关联时不会发出通知。
自 API 级别 33 起可用。
详情 | |||||
---|---|---|---|---|---|
参数 |
|
AIBinder_Weak_clone
声明于android/binder_ibinder.h
AIBinder_Weak * AIBinder_Weak_clone( const AIBinder_Weak *weak )
克隆 AIBinder_Weak。
这很有用,因为即使弱 Binder 升级为 null 值,在进一步的 Binder 事务后,它可能不再升级为 null 值。
自 API 级别 31 起可用。
详情 | |||
---|---|---|---|
参数 |
|
||
返回 |
输入参数的克隆。必须使用 AIBinder_Weak_delete 删除此对象。如果 weak 输入参数也为 null,则返回 null。
|
AIBinder_Weak_delete
声明于android/binder_ibinder.h
void AIBinder_Weak_delete( AIBinder_Weak *weakBinder )
删除弱引用。
这不会影响 Binder 的生命周期。
自 API 级别 29 起可用。
详情 | |||
---|---|---|---|
参数 |
|
AIBinder_Weak_lt
声明于android/binder_ibinder.h
bool AIBinder_Weak_lt( const AIBinder_Weak *lhs, const AIBinder_Weak *rhs )
一个 AIBinder_Weak 是否小于另一个。
这提供了一个进程内唯一的 Binder 全序,与 AIBinder_lt 完全相同。类似地,null AIBinder_Weak* 被认为排在所有其他弱引用之前。
即使其中一个 Binder 被释放,此函数也能正确区分 Binder。因此,例如,表示已删除 Binder 的 AIBinder_Weak* 条目永远不会与表示 Binder 不同分配的 AIBinder_Weak* 条目比较相等,即使这两个 Binder 最初分配在相同的地址。
AIBinder* a = ...; // imagine this has address 0x8 AIBinder_Weak* bWeak = AIBinder_Weak_new(a); AIBinder_decStrong(a); // a may be deleted, if this is the last reference AIBinder* b = ...; // imagine this has address 0x8 (same address as b) AIBinder_Weak* bWeak = AIBinder_Weak_new(b);
也就是说
然后,当将 a/b 与其他 Binder 进行比较时,它们的顺序将得以保留,并且 AIBinder_Weak_lt(aWeak, bWeak) 或 AIBinder_Weak_lt(bWeak, aWeak) 之一将为真,但不能同时为真。
自 API 级别 31 起可用。
详情 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
rhs
|
“lhs < rhs”是否为 true
声明于android/binder_ibinder.h
AIBinder_Weak * AIBinder_Weak_new( AIBinder *binder )
这不拥有输入 Binder 的所有权,但如果在某些进程中还有其他东西持有它的引用,则可以使用它来检索该引用。
自 API 级别 29 起可用。
详情 | |||
---|---|---|---|
参数 |
|
||
返回 |
要创建弱指针的对象。
|
表示 Binder 弱指针的对象(如果 Binder 为 null,则为 null)。
声明于android/binder_ibinder.h
AIBinder * AIBinder_Weak_promote( AIBinder_Weak *weakBinder )
如果升级成功,结果将增加一个强引用计数。
AIBinder_Weak_promote
自 API 级别 29 起可用。
详情 | |||
---|---|---|---|
参数 |
|
||
返回 |
尝试从中检索原始对象的弱指针。
|
一个 AIBinder 对象,其中有一个引用计数交给调用方,或为 null。
声明于android/binder_ibinder.h
bool AIBinder_associateClass( AIBinder *binder, const AIBinder_Class *clazz )
这会设置 AIBinder 对象的类。
AIBinder_associateClass
这会检查以确保远程对象是预期类型。必须设置类才能在 AIBinder 对象上使用事务。但是,如果对象仅用于传递到另一个进程或用作句柄,则无需调用此函数。
如果类关联成功,则返回 true。如果失败,则不会更改 Binder 对象。
自 API 级别 29 起可用。
详情 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
要附加类的对象。
|
clazz
声明于android/binder_ibinder.h
int32_t AIBinder_debugGetRefCount( AIBinder *binder )
仅用于调试!
自 API 级别 29 起可用。
详情 | |||
---|---|---|---|
参数 |
|
||
返回 |
如果 Binder 具有类 clazz 并且关联成功,则为 true。
|
AIBinder_debugGetRefCount
声明于android/binder_ibinder.h
void AIBinder_decStrong( AIBinder *binder )
当引用计数达到零时,这将删除对象并调用 onDestroy。
自 API 级别 29 起可用。
详情 | |||
---|---|---|---|
参数 |
|
此进程中此 Binder 上的强引用数。如果 Binder 为 null,则此值为 -1。
声明于android/binder_ibinder.h
binder_status_t AIBinder_dump( AIBinder *binder, int fd, const char **args, uint32_t numArgs )
所有 Binder 对象的内置事务。
AIBinder_decStrong
the binder object to remove a refcount from.
自 API 级别 29 起可用。
详情 | |||||||||
---|---|---|---|---|---|---|---|---|---|
参数 |
|
||||||||
返回 |
如果 dump 成功(或没有什么可 dump),则为 STATUS_OK
|
AIBinder_fromJavaBinder
声明于android/binder_ibinder_jni.h
AIBinder * AIBinder_fromJavaBinder( JNIEnv *env, jobject binder )
将 android.os.IBinder 对象转换为 AIBinder* 对象。
如果 Binder 为 null,则返回 null。如果此 Binder 对象最初是 AIBinder 对象,则返回原始对象。返回的对象具有一个关联的引用计数,因此应伴随一个 AIBinder_decStrong 调用。
自 API 级别 29 起可用。
详情 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
表示 Java Binder 对象的 AIBinder 对象。如果任一参数为 null,或 Java 对象类型错误,则将返回 null。
|
AIBinder_getCallingPid
声明于android/binder_ibinder.h
pid_t AIBinder_getCallingPid()
假定此线程是从处理 Binder 事务的线程调用(例如,在 AIBinder_Class_onTransact 的实现中),则返回调用方 PID。
这可以与更高级别的系统服务一起使用,以确定调用方身份并检查权限。但是,执行此操作时,应注意可能存在的 TOCTOU(检查时有结果,使用时已变化)问题,当调用进程死亡并被另一个具有提升权限和相同 PID 的进程替换时。
警告:单向事务不接收 PID。
自 API 级别 29 起可用。
详情 | |
---|---|
返回 |
调用方 PID,如果此线程未处理事务,则为当前进程的 PID。如果正在处理的事务是单向事务,则此方法将返回 0。
|
AIBinder_getCallingUid
声明于android/binder_ibinder.h
uid_t AIBinder_getCallingUid()
假定此线程是从处理 Binder 事务的线程调用(例如,在 AIBinder_Class_onTransact 的实现中),则返回调用方 UID。
这可以与更高级别的系统服务一起使用,以确定调用方身份并检查权限。
自 API 级别 29 起可用。
详情 | |
---|---|
返回 |
调用方 UID,如果此线程未处理事务,则为当前进程的 UID。
|
AIBinder_getClass
声明于android/binder_ibinder.h
const AIBinder_Class * AIBinder_getClass( AIBinder *binder )
返回构造或关联此 Binder 时使用的类。
自 API 级别 29 起可用。
详情 | |||
---|---|---|---|
参数 |
|
||
返回 |
返回构造或关联此 Binder 时使用的类。如果此 Binder 不是使用 AIBinder_new 创建的,并且尚未调用 AIBinder_associateClass,则此方法将返回 null。
|
AIBinder_getExtension
声明于android/binder_ibinder.h
binder_status_t AIBinder_getExtension( AIBinder *binder, AIBinder **outExt )
获取使用 AIBinder_setExtension 注册的扩展。
请参阅 AIBinder_setExtension。
自 API 级别 30 起可用。
详情 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
获取接口的错误(如果是远程 Binder,可能是事务错误)。如果 Binder 为 null,则为 STATUS_UNEXPECTED_NULL。
|
AIBinder_getUserData
声明于android/binder_ibinder.h
void * AIBinder_getUserData( AIBinder *binder )
onCreate 为本地 Binder 返回的值。
对于无状态类(如果 onCreate 返回 null),此方法也返回 null。对于远程 Binder,此方法将始终返回 null。
自 API 级别 29 起可用。
详情 | |||
---|---|---|---|
参数 |
|
||
返回 |
创建此对象时 AIBinder_onCreate 返回的用户数据。对于无状态对象,此数据可能为 null。对于远程对象,此数据始终为 null。
|
AIBinder_incStrong
声明于android/binder_ibinder.h
void AIBinder_incStrong( AIBinder *binder )
仅当此对象的强引用已存在于进程中时才能调用此函数。
自 API 级别 29 起可用。
详情 | |||
---|---|---|---|
参数 |
|
AIBinder_isAlive
声明于android/binder_ibinder.h
bool AIBinder_isAlive( const AIBinder *binder )
如果已知此 Binder 处于活跃状态。
这不会向远程进程发送事务,并根据已知最新信息返回结果。也就是说,每当执行事务时,此状态都会自动更新以反映此 Binder 的当前活跃状态。通过 AIBinder_transact 执行的事务会更新此状态,内部进行的簿记或其他事务也会更新此状态。
自 API 级别 29 起可用。
详情 | |||
---|---|---|---|
参数 |
|
||
返回 |
如果 Binder 处于活跃状态,则为 true。
|
AIBinder_isHandlingTransaction
声明于android/binder_ibinder.h
bool AIBinder_isHandlingTransaction()
确定当前线程是否正在执行传入事务。
详情 | |
---|---|
返回 |
如果当前线程正在执行传入事务,则为 true,否则为 false。
|
AIBinder_isRemote
声明于android/binder_ibinder.h
bool AIBinder_isRemote( const AIBinder *binder )
如果此对象托管在当前进程以外的进程中。
自 API 级别 29 起可用。
详情 | |||
---|---|---|---|
参数 |
|
||
返回 |
如果 AIBinder 表示另一个进程中的对象,则为 true。
|
AIBinder_linkToDeath
声明于android/binder_ibinder.h
binder_status_t AIBinder_linkToDeath( AIBinder *binder, AIBinder_DeathRecipient *recipient, void *cookie )
注册以接收关联 Binder 死亡的通知。
同一个死亡接收者可以关联到多个不同的 Binder。如果 Binder 是本地的,则不会给出死亡接收者(因为如果本地进程死亡,则不会存在接收事务的接收者)。如果此 Binder 死亡,cookie 将传递给 recipient,且可以为 null。必须使用完全相同的 cookie 来解除此事务的关联(请参阅 AIBinder_unlinkToDeath)。此函数可能返回 Binder 事务失败。cookie 既可用于标识,也可用于保存用户数据。
如果 Binder 是本地的,将返回 STATUS_INVALID_OPERATION。
自 API 级别 29 起可用。
详情 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
||||||
返回 |
成功时返回 STATUS_OK。
|
AIBinder_lt
声明于android/binder_ibinder.h
bool AIBinder_lt( const AIBinder *lhs, const AIBinder *rhs )
一个 AIBinder 是否小于另一个。
这提供了一个进程内唯一的 Binder 全序,其中 null AIBinder* 对象被认为排在所有其他 Binder 对象之前。例如,当 AIBinder_lt(a, b) 和 AIBinder_lt(b, a) 都为 false 时,两个 Binder 在本地或远程进程中引用同一个对象。此 API 可用于在二叉搜索树中插入和查找 Binder。
AIBinder* 指针本身实际上也创建了一个进程内唯一的全序。但是,对于远程 Binder,此顺序与 AIBinder_Weak_lt 不一致。
自 API 级别 31 起可用。
详情 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
rhs
|
因此,通常应优先使用此函数。
声明于android/binder_ibinder.h
AIBinder * AIBinder_new( const AIBinder_Class *clazz, void *args )
创建相应类的新 Binder 对象。
AIBinder_new
args 的所有权被传递给此对象。生命周期通过 AIBinder_incStrong 和 AIBinder_decStrong 实现。当引用计数达到零时,调用 onDestroy。
调用此函数时,引用计数隐式为 1。因此,必须准确调用一次 decStrong 来删除此对象。
自 API 级别 29 起可用。
详情 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
要创建的对象的类型。
|
要传递给该类的 AIBinder_onCreate 的 args。
声明于android/binder_ibinder.h
binder_status_t AIBinder_ping( AIBinder *binder )
所有 Binder 对象的内置事务。
表示新实例化对象的 Binder 对象。
自 API 级别 29 起可用。
详情 | |||
---|---|---|---|
参数 |
|
||
返回 |
AIBinder_ping
|
这会发送一个将立即返回的事务。通常用于确保 Binder 处于活跃状态,作为占位符调用或一致性检查。
声明于android/binder_ibinder.h
binder_status_t AIBinder_prepareTransaction( AIBinder *binder, AParcel **in )
事务是一系列对此类函数的调用,其示例如下。
- 如果 ping 成功,则为 STATUS_OK。
- AIBinder_prepareTransaction
- 事务是一系列对此类函数的调用,其示例如下。
- read results from the out parcel (lifetime of the 'out' variable) Creates a parcel to start filling out for a transaction. This will add a header to the transaction that corresponds to android.os.Parcel::writeInterfaceToken. This may add debugging or other information to the transaction for platform use or to enable other features to work. The contents of this header is a platform implementation detail, and it is required to use libbinder_ndk. This parcel is to be sent via AIBinder_transact and it represents the input data to the transaction. It is recommended to check if the object is local and call directly into its user data before calling this as the parceling and unparceling cost can be avoided. This AIBinder must be either built with a class or associated with a class before using this API.
This does not affect the ownership of binder. When this function succeeds, the in parcel's ownership is passed to the caller. At this point, the parcel can be filled out and passed to AIBinder_transact. Alternatively, if there is an error while filling out the parcel, it can be deleted with AParcel_delete.
自 API 级别 29 起可用。
详情 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
STATUS_OK on success. This will return STATUS_INVALID_OPERATION if the binder has not yet been associated with a class (see AIBinder_new and AIBinder_associateClass).
|
AIBinder_setExtension
声明于android/binder_ibinder.h
binder_status_t AIBinder_setExtension( AIBinder *binder, AIBinder *ext )
获取 Binder 接口的扩展。
This allows a downstream developer to add an extension to an interface without modifying its interface file. This should be called immediately when the object is created before it is passed to another thread. No thread safety is required.
For instance, imagine if we have this interface: interface IFoo { void doFoo(); }
A). Historical option that has proven to be BAD! Only the original author of an interface should change an interface. If someone downstream wants additional functionality, they should not ever change the interface or use this method.
BAD TO DO: interface IFoo { BAD TO DO BAD TO DO: void doFoo(); BAD TO DO BAD TO DO: + void doBar(); // adding a method BAD TO DO BAD TO DO: } BAD TO DO
B). Option that this method enables. Leave the original interface unchanged (do not change IFoo!). Instead, create a new interface in a downstream package
package com.; // new functionality in a new package interface IBar { void doBar(); }
When registering the interface, add: std::shared_ptr
Do not use foo->asBinder().get() as the target binder argument to AIBinder_setExtensions because asBinder it creates a new binder object that will be destroyed after the function is called. The same binder object must be used for AIBinder_setExtension and AServiceManager_addService to register the service with an extension.
Then, clients of IFoo can get this extension: SpAIBinder binder = ...; std::shared_ptr
自 API 级别 30 起可用。
详情 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
OK on success, STATUS_INVALID_OPERATION if binder is not local, STATUS_UNEXPECTED_NULL if either binder is null.
|
AIBinder_toJavaBinder
声明于android/binder_ibinder_jni.h
jobject AIBinder_toJavaBinder( JNIEnv *env, AIBinder *binder )
将 AIBinder* 对象转换为 android.os.IBinder 对象。
If the binder is null, null is returned. If this binder object was originally an IBinder object, the original java object will be returned.
WARNING: this function returns global and local references. This can be figured out using GetObjectRefType. Though, when this function is called from within a Java context, the local ref will automatically be cleaned up. If this is called outside of a Java frame, PushObjectFrame/PopObjectFrame can simulate this automatic cleanup.
自 API 级别 29 起可用。
详情 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
an android.os.IBinder object or null if the parameters were null.
|
AIBinder_transact
声明于android/binder_ibinder.h
binder_status_t AIBinder_transact( AIBinder *binder, transaction_code_t code, AParcel **in, AParcel **out, binder_flags_t flags )
使用通过 AIBinder_prepareTransaction 创建的 Parcel 进行事务处理。
This actually communicates with the object representing this binder object. This also passes out a parcel to be used for the return transaction. This takes ownership of the in parcel and automatically deletes it after it is sent to the remote process. The output parcel is the result of the transaction. If the transaction has FLAG_ONEWAY, the out parcel will be empty. Otherwise, this will block until the remote process has processed the transaction, and the out parcel will contain the output data from transaction.
This does not affect the ownership of binder. The out parcel's ownership is passed to the caller and must be released with AParcel_delete when finished reading.
自 API 级别 29 起可用。
详情 | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
参数 |
|
||||||||||
返回 |
the result from the kernel or from the remote process. Usually, implementation-specific error codes are written to the output parcel, and the transaction code is reserved for kernel errors or error codes that have been repeated from subsequent transactions.
|
AIBinder_unlinkToDeath
声明于android/binder_ibinder.h
binder_status_t AIBinder_unlinkToDeath( AIBinder *binder, AIBinder_DeathRecipient *recipient, void *cookie )
停止注册关联 Binder 死亡的通知。
Does not delete the recipient. This function may return a binder transaction failure and in case the death recipient cannot be found, it returns STATUS_NAME_NOT_FOUND.
This only ever needs to be called when the AIBinder_DeathRecipient remains for use with other AIBinder objects. If the death recipient is deleted, all binders will automatically be unlinked. If the binder dies, it will automatically unlink. If the binder is deleted, it will be automatically unlinked.
请注意,此调用返回后立即释放 cookie 是不安全的。如果需要清理 cookie,应在 onUnlinked 回调中进行,该回调可以使用 AIBinder_DeathRecipient_setOnUnlinked 设置。
自 API 级别 29 起可用。
详情 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
||||||
返回 |
STATUS_OK on success. STATUS_NAME_NOT_FOUND if the binder cannot be found to be unlinked.
|
AParcel_appendFrom
声明于android/binder_parcel.h
binder_status_t AParcel_appendFrom( const AParcel *from, AParcel *to, int32_t start, int32_t size )
将一个 Parcel 的数据复制到另一个 Parcel。
自 API 级别 31 起可用。
详情 | |||||||||
---|---|---|---|---|---|---|---|---|---|
参数 |
|
||||||||
返回 |
成功时返回 STATUS_OK。
|
AParcel_create
声明于android/binder_parcel.h
AParcel * AParcel_create()
创建 Parcel。
自 API 级别 31 起可用。
详情 | |
---|---|
返回 |
A parcel which is not related to any IBinder objects.
|
AParcel_delete
声明于android/binder_parcel.h
void AParcel_delete( AParcel *parcel )
清理 Parcel。
自 API 级别 29 起可用。
详情 | |||
---|---|---|---|
参数 |
|
AParcel_fromJavaParcel
Declared inandroid/binder_parcel_jni.h
AParcel * AParcel_fromJavaParcel( JNIEnv *env, jobject parcel )
将 android.os.Parcel 对象转换为 AParcel* 对象。
If the parcel is null, null is returned.
自 API 级别 30 起可用。
详情 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
an AParcel object representing the Java parcel object. If either parameter is null, this will return null. This must be deleted with AParcel_delete. This does not take ownership of the jobject and is only good for as long as the jobject is alive.
|
AParcel_getDataPosition
声明于android/binder_parcel.h
int32_t AParcel_getDataPosition( const AParcel *parcel )
获取 Parcel 中的当前位置。
自 API 级别 29 起可用。
详情 | |||
---|---|---|---|
参数 |
|
||
返回 |
The size of the parcel. This will always be greater than 0. The values returned by this function before and after calling various reads and writes are not defined. Only the delta between two positions between a specific sequence of calls is defined. For instance, if position is X, writeBool is called, and then position is Y, readBool can be called from position X will return the same value, and then position will be Y.
|
AParcel_getDataSize
声明于android/binder_parcel.h
int32_t AParcel_getDataSize( const AParcel *parcel )
获取 Parcel 的大小。
自 API 级别 31 起可用。
详情 | |||
---|---|---|---|
参数 |
|
||
返回 |
The size of the parcel.
|
AParcel_marshal
声明于android/binder_parcel.h
binder_status_t AParcel_marshal( const AParcel *parcel, uint8_t *buffer, size_t start, size_t len )
将 Parcel 的原始字节数据封送(Marshal)到缓冲区。
自 API 级别 33 起可用。
The parcel must not contain any binders or file descriptors.
The data you retrieve here must not be placed in any kind of persistent storage. (on local disk, across a network, etc). For that, you should use standard serialization or another kind of general serialization mechanism. The Parcel marshalled representation is highly optimized for local IPC, and as such does not attempt to maintain compatibility with data created in different versions of the platform.
详情 | |||||||||
---|---|---|---|---|---|---|---|---|---|
参数 |
|
||||||||
返回 |
STATUS_OK on success, STATUS_INVALID_OPERATION if parcel contains binders or file descriptors. STATUS_BAD_VALUE if the buffer size is less than parcel size.
|
AParcel_readBool
声明于android/binder_parcel.h
binder_status_t AParcel_readBool( const AParcel *parcel, bool *value )
从非空 Parcel 中的下一位置读取 bool 值。
自 API 级别 29 起可用。
详情 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
STATUS_OK on successful read.
|
AParcel_readBoolArray
声明于android/binder_parcel.h
binder_status_t AParcel_readBoolArray( const AParcel *parcel, void *arrayData, AParcel_boolArrayAllocator allocator, AParcel_boolArraySetter setter )
从非空 Parcel 中的下一位置读取 bool 数组。
First, allocator will be called with the length of the array. Then, for every i in [0, length), setter(arrayData, i, x) will be called where x is the value at the associated index.
自 API 级别 29 起可用。
详情 | |||||||||
---|---|---|---|---|---|---|---|---|---|
参数 |
|
||||||||
返回 |
STATUS_OK on successful read.
|
AParcel_readByte
声明于android/binder_parcel.h
binder_status_t AParcel_readByte( const AParcel *parcel, int8_t *value )
从非空 Parcel 中的下一位置读取 int8_t 值。
自 API 级别 29 起可用。
详情 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
STATUS_OK on successful read.
|
AParcel_readByteArray
声明于android/binder_parcel.h
binder_status_t AParcel_readByteArray( const AParcel *parcel, void *arrayData, AParcel_byteArrayAllocator allocator )
从非空 Parcel 中的下一位置读取 int8_t 数组。
First, allocator will be called with the length of the array. If the allocation succeeds and the length is greater than zero, the buffer returned by the allocator will be filled with the corresponding data
自 API 级别 29 起可用。
详情 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
||||||
返回 |
STATUS_OK on successful read.
|
AParcel_readChar
声明于android/binder_parcel.h
binder_status_t AParcel_readChar( const AParcel *parcel, char16_t *value )
从非空 Parcel 中的下一位置读取 char16_t 值。
自 API 级别 29 起可用。
详情 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
STATUS_OK on successful read.
|
AParcel_readCharArray
声明于android/binder_parcel.h
binder_status_t AParcel_readCharArray( const AParcel *parcel, void *arrayData, AParcel_charArrayAllocator allocator )
从非空 Parcel 中的下一位置读取 char16_t 数组。
First, allocator will be called with the length of the array. If the allocation succeeds and the length is greater than zero, the buffer returned by the allocator will be filled with the corresponding data
自 API 级别 29 起可用。
详情 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
||||||
返回 |
STATUS_OK on successful read.
|
AParcel_readDouble
声明于android/binder_parcel.h
binder_status_t AParcel_readDouble( const AParcel *parcel, double *value )
从非空 Parcel 中的下一位置读取 double 值。
自 API 级别 29 起可用。
详情 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
STATUS_OK on successful read.
|
AParcel_readDoubleArray
声明于android/binder_parcel.h
binder_status_t AParcel_readDoubleArray( const AParcel *parcel, void *arrayData, AParcel_doubleArrayAllocator allocator )
从非空 Parcel 中的下一位置读取 double 数组。
First, allocator will be called with the length of the array. If the allocation succeeds and the length is greater than zero, the buffer returned by the allocator will be filled with the corresponding data
自 API 级别 29 起可用。
详情 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
||||||
返回 |
STATUS_OK on successful read.
|
AParcel_readFloat
声明于android/binder_parcel.h
binder_status_t AParcel_readFloat( const AParcel *parcel, float *value )
从非空 Parcel 中的下一位置读取 float 值。
自 API 级别 29 起可用。
详情 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
STATUS_OK on successful read.
|
AParcel_readFloatArray
声明于android/binder_parcel.h
binder_status_t AParcel_readFloatArray( const AParcel *parcel, void *arrayData, AParcel_floatArrayAllocator allocator )
从非空 Parcel 中的下一位置读取 float 数组。
First, allocator will be called with the length of the array. If the allocation succeeds and the length is greater than zero, the buffer returned by the allocator will be filled with the corresponding data
自 API 级别 29 起可用。
详情 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
||||||
返回 |
STATUS_OK on successful read.
|
AParcel_readInt32
声明于android/binder_parcel.h
binder_status_t AParcel_readInt32( const AParcel *parcel, int32_t *value )
从非空 Parcel 中的下一位置读取 int32_t 值。
自 API 级别 29 起可用。
详情 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
STATUS_OK on successful read.
|
AParcel_readInt32Array
声明于android/binder_parcel.h
binder_status_t AParcel_readInt32Array( const AParcel *parcel, void *arrayData, AParcel_int32ArrayAllocator allocator )
从非空 Parcel 中的下一位置读取 int32_t 数组。
First, allocator will be called with the length of the array. If the allocation succeeds and the length is greater than zero, the buffer returned by the allocator will be filled with the corresponding data
自 API 级别 29 起可用。
详情 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
||||||
返回 |
STATUS_OK on successful read.
|
AParcel_readInt64
声明于android/binder_parcel.h
binder_status_t AParcel_readInt64( const AParcel *parcel, int64_t *value )
从非空 Parcel 中的下一位置读取 int64_t 值。
自 API 级别 29 起可用。
详情 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
STATUS_OK on successful read.
|
AParcel_readInt64Array
声明于android/binder_parcel.h
binder_status_t AParcel_readInt64Array( const AParcel *parcel, void *arrayData, AParcel_int64ArrayAllocator allocator )
从非空 Parcel 中的下一位置读取 int64_t 数组。
First, allocator will be called with the length of the array. If the allocation succeeds and the length is greater than zero, the buffer returned by the allocator will be filled with the corresponding data
自 API 级别 29 起可用。
详情 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
||||||
返回 |
STATUS_OK on successful read.
|
AParcel_readParcelFileDescriptor
声明于android/binder_parcel.h
binder_status_t AParcel_readParcelFileDescriptor( const AParcel *parcel, int *fd )
从非空 Parcel 中的下一位置读取 int 值。
The returned fd must be closed.
This corresponds to the SDK's android.os.ParcelFileDescriptor.
自 API 级别 29 起可用。
详情 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
STATUS_OK on successful write.
|
AParcel_readParcelableArray
声明于android/binder_parcel.h
binder_status_t AParcel_readParcelableArray( const AParcel *parcel, void *arrayData, AParcel_parcelableArrayAllocator allocator, AParcel_readParcelableElement elementReader )
从非空 Parcel 中的下一位置读取 Parcelable 数组(用户定义类型)。
First, allocator will be called with the length of the array. If the allocation succeeds and the length is greater than zero, elementReader will be called for every index to read the corresponding parcelable.
自 API 级别 29 起可用。
详情 | |||||||||
---|---|---|---|---|---|---|---|---|---|
参数 |
|
||||||||
返回 |
STATUS_OK on successful read.
|
AParcel_readStatusHeader
声明于android/binder_parcel.h
binder_status_t AParcel_readStatusHeader( const AParcel *parcel, AStatus **status )
从非空 Parcel 中的下一位置读取 AStatus。
Ownership is passed to the caller of this function.
自 API 级别 29 起可用。
详情 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
STATUS_OK on successful write.
|
AParcel_readString
声明于android/binder_parcel.h
binder_status_t AParcel_readString( const AParcel *parcel, void *stringData, AParcel_stringAllocator allocator )
从非空 Parcel 中的下一位置读取并分配 UTF-8 字符串值。
Data is passed to the string allocator once the string size is known. This size includes the space for the null-terminator of this string. This allocator returns a buffer which is used as the output buffer from this read. If there is a 'null' string on the binder buffer, the allocator will be called with length -1.
自 API 级别 29 起可用。
详情 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
||||||
返回 |
STATUS_OK on successful write.
|
AParcel_readStringArray
声明于android/binder_parcel.h
binder_status_t AParcel_readStringArray( const AParcel *parcel, void *arrayData, AParcel_stringArrayAllocator allocator, AParcel_stringArrayElementAllocator elementAllocator )
从非空 Parcel 中的下一位置读取并分配 UTF-8 字符串数组值。
First, AParcel_stringArrayAllocator will be called with the size of the array to be read where length is the length of the array to be read from the parcel. Then, for each index i in [0, length), AParcel_stringArrayElementAllocator will be called with the length of the string to be read from the parcel. The resultant buffer from each of these calls will be filled according to the contents of the string that is read. If the string array being read is 'null', this will instead just pass -1 to AParcel_stringArrayAllocator.
自 API 级别 29 起可用。
详情 | |||||||||
---|---|---|---|---|---|---|---|---|---|
参数 |
|
||||||||
返回 |
STATUS_OK on successful read.
|
AParcel_readStrongBinder
声明于android/binder_parcel.h
binder_status_t AParcel_readStrongBinder( const AParcel *parcel, AIBinder **binder )
从非空 Parcel 中的下一位置读取 AIBinder。
One strong ref-count of ownership is passed to the caller of this function.
自 API 级别 29 起可用。
详情 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
STATUS_OK on successful write.
|
AParcel_readUint32
声明于android/binder_parcel.h
binder_status_t AParcel_readUint32( const AParcel *parcel, uint32_t *value )
从非空 Parcel 中的下一位置读取 uint32_t 值。
自 API 级别 29 起可用。
详情 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
STATUS_OK on successful read.
|
AParcel_readUint32Array
声明于android/binder_parcel.h
binder_status_t AParcel_readUint32Array( const AParcel *parcel, void *arrayData, AParcel_uint32ArrayAllocator allocator )
从非空 Parcel 中的下一位置读取 uint32_t 数组。
First, allocator will be called with the length of the array. If the allocation succeeds and the length is greater than zero, the buffer returned by the allocator will be filled with the corresponding data
自 API 级别 29 起可用。
详情 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
||||||
返回 |
STATUS_OK on successful read.
|
AParcel_readUint64
声明于android/binder_parcel.h
binder_status_t AParcel_readUint64( const AParcel *parcel, uint64_t *value )
从非空 Parcel 中的下一位置读取 uint64_t 值。
自 API 级别 29 起可用。
详情 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
STATUS_OK on successful read.
|
AParcel_readUint64Array
声明于android/binder_parcel.h
binder_status_t AParcel_readUint64Array( const AParcel *parcel, void *arrayData, AParcel_uint64ArrayAllocator allocator )
从非空 Parcel 中的下一位置读取 uint64_t 数组。
First, allocator will be called with the length of the array. If the allocation succeeds and the length is greater than zero, the buffer returned by the allocator will be filled with the corresponding data
自 API 级别 29 起可用。
详情 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
||||||
返回 |
STATUS_OK on successful read.
|
AParcel_reset
声明于android/binder_parcel.h
binder_status_t AParcel_reset( AParcel *parcel )
将 Parcel 重置为初始状态。
自 API 级别 31 起可用。
详情 | |||
---|---|---|---|
参数 |
|
||
返回 |
成功时返回 STATUS_OK。
|
AParcel_setDataPosition
声明于android/binder_parcel.h
binder_status_t AParcel_setDataPosition( const AParcel *parcel, int32_t position )
设置 Parcel 中的位置。
This must be called with a position that has been previously returned from AParcel_getDataPosition. If writes are made after setting the data position, they must be made in the exact same sequence used before resetting data position. Writing over objects such as binders or file descriptors is not supported.
自 API 级别 29 起可用。
详情 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
STATUS_OK on success. If position is negative, then STATUS_BAD_VALUE will be returned.
|
AParcel_unmarshal
声明于android/binder_parcel.h
binder_status_t AParcel_unmarshal( AParcel *parcel, const uint8_t *buffer, size_t len )
将 Parcel 中的数据设置为缓冲区中的原始字节。
自 API 级别 33 起可用。
详情 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
||||||
返回 |
成功时返回 STATUS_OK。
|
AParcel_writeBool
声明于android/binder_parcel.h
binder_status_t AParcel_writeBool( AParcel *parcel, bool value )
将 bool 值写入非空 Parcel 中的下一位置。
自 API 级别 29 起可用。
详情 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
STATUS_OK on successful write.
|
AParcel_writeBoolArray
声明于android/binder_parcel.h
binder_status_t AParcel_writeBoolArray( AParcel *parcel, const void *arrayData, int32_t length, AParcel_boolArrayGetter getter )
将 bool 数组写入非空 Parcel 中的下一位置。
getter(arrayData, i) will be called for each i in [0, length) in order to get the underlying values to write to the parcel.
自 API 级别 29 起可用。
详情 | |||||||||
---|---|---|---|---|---|---|---|---|---|
参数 |
|
||||||||
返回 |
STATUS_OK on successful write.
|
AParcel_writeByte
声明于android/binder_parcel.h
binder_status_t AParcel_writeByte( AParcel *parcel, int8_t value )
将 int8_t 值写入非空 Parcel 中的下一位置。
自 API 级别 29 起可用。
详情 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
STATUS_OK on successful write.
|
AParcel_writeByteArray
声明于android/binder_parcel.h
binder_status_t AParcel_writeByteArray( AParcel *parcel, const int8_t *arrayData, int32_t length )
将 int8_t 数组写入非空 Parcel 中的下一位置。
自 API 级别 29 起可用。
详情 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
||||||
返回 |
STATUS_OK on successful write.
|
AParcel_writeChar
声明于android/binder_parcel.h
binder_status_t AParcel_writeChar( AParcel *parcel, char16_t value )
将 char16_t 值写入非空 Parcel 中的下一位置。
自 API 级别 29 起可用。
详情 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
STATUS_OK on successful write.
|
AParcel_writeCharArray
声明于android/binder_parcel.h
binder_status_t AParcel_writeCharArray( AParcel *parcel, const char16_t *arrayData, int32_t length )
将 char16_t 数组写入非空 Parcel 中的下一位置。
自 API 级别 29 起可用。
详情 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
||||||
返回 |
STATUS_OK on successful write.
|
AParcel_writeDouble
声明于android/binder_parcel.h
binder_status_t AParcel_writeDouble( AParcel *parcel, double value )
将 double 值写入非空 Parcel 中的下一位置。
自 API 级别 29 起可用。
详情 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
STATUS_OK on successful write.
|
AParcel_writeDoubleArray
声明于android/binder_parcel.h
binder_status_t AParcel_writeDoubleArray( AParcel *parcel, const double *arrayData, int32_t length )
将 double 数组写入非空 Parcel 中的下一位置。
自 API 级别 29 起可用。
详情 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
||||||
返回 |
STATUS_OK on successful write.
|
AParcel_writeFloat
声明于android/binder_parcel.h
binder_status_t AParcel_writeFloat( AParcel *parcel, float value )
将 float 值写入非空 Parcel 中的下一位置。
自 API 级别 29 起可用。
详情 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
STATUS_OK on successful write.
|
AParcel_writeFloatArray
声明于android/binder_parcel.h
binder_status_t AParcel_writeFloatArray( AParcel *parcel, const float *arrayData, int32_t length )
将 float 数组写入非空 Parcel 中的下一位置。
自 API 级别 29 起可用。
详情 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
||||||
返回 |
STATUS_OK on successful write.
|
AParcel_writeInt32
声明于android/binder_parcel.h
binder_status_t AParcel_writeInt32( AParcel *parcel, int32_t value )
将 int32_t 值写入非空 Parcel 中的下一位置。
自 API 级别 29 起可用。
详情 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
STATUS_OK on successful write.
|
AParcel_writeInt32Array
声明于android/binder_parcel.h
binder_status_t AParcel_writeInt32Array( AParcel *parcel, const int32_t *arrayData, int32_t length )
将 int32_t 数组写入非空 Parcel 中的下一位置。
自 API 级别 29 起可用。
详情 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
||||||
返回 |
STATUS_OK on successful write.
|
AParcel_writeInt64
声明于android/binder_parcel.h
binder_status_t AParcel_writeInt64( AParcel *parcel, int64_t value )
将 int64_t 值写入非空 Parcel 中的下一位置。
自 API 级别 29 起可用。
详情 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
STATUS_OK on successful write.
|
AParcel_writeInt64Array
声明于android/binder_parcel.h
binder_status_t AParcel_writeInt64Array( AParcel *parcel, const int64_t *arrayData, int32_t length )
将 int64_t 数组写入非空 Parcel 中的下一位置。
自 API 级别 29 起可用。
详情 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
||||||
返回 |
STATUS_OK on successful write.
|
AParcel_writeParcelFileDescriptor
声明于android/binder_parcel.h
binder_status_t AParcel_writeParcelFileDescriptor( AParcel *parcel, int fd )
将文件描述符写入非空 Parcel 中的下一位置。
This does not take ownership of fd.
This corresponds to the SDK's android.os.ParcelFileDescriptor.
自 API 级别 29 起可用。
详情 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
STATUS_OK on successful write.
|
AParcel_writeParcelableArray
声明于android/binder_parcel.h
binder_status_t AParcel_writeParcelableArray( AParcel *parcel, const void *arrayData, int32_t length, AParcel_writeParcelableElement elementWriter )
将 Parcelable 数组(用户定义类型)写入非空 Parcel 中的下一位置。
自 API 级别 29 起可用。
详情 | |||||||||
---|---|---|---|---|---|---|---|---|---|
参数 |
|
||||||||
返回 |
STATUS_OK on successful write.
|
AParcel_writeStatusHeader
声明于android/binder_parcel.h
binder_status_t AParcel_writeStatusHeader( AParcel *parcel, const AStatus *status )
将 AStatus 对象写入非空 Parcel 中的下一位置。
If the status is considered to be a low-level status and has no additional information other than a binder_status_t (for instance, if it is created with AStatus_fromStatus), then that status will be returned from this method and nothing will be written to the parcel. If either this happens or if writing the status object itself fails, the return value from this function should be propagated to the client, and AParcel_readStatusHeader shouldn't be called.
自 API 级别 29 起可用。
详情 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
STATUS_OK on successful write.
|
AParcel_writeString
声明于android/binder_parcel.h
binder_status_t AParcel_writeString( AParcel *parcel, const char *string, int32_t length )
将 UTF-8 字符串值写入非空 Parcel 中的下一位置。
If length is -1, and string is nullptr, this will write a 'null' string to the parcel.
自 API 级别 29 起可用。
详情 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
||||||
返回 |
STATUS_OK on successful write.
|
AParcel_writeStringArray
声明于android/binder_parcel.h
binder_status_t AParcel_writeStringArray( AParcel *parcel, const void *arrayData, int32_t length, AParcel_stringArrayElementGetter getter )
将 UTF-8 字符串数组数据写入非空 Parcel 中的下一位置。
length is the length of the array. AParcel_stringArrayElementGetter will be called for all indices in range [0, length) with the arrayData provided here. The string length and buffer returned from this function will be used to fill out the data from the parcel. If length is -1, this will write a 'null' string array to the binder buffer.
自 API 级别 29 起可用。
详情 | |||||||||
---|---|---|---|---|---|---|---|---|---|
参数 |
|
||||||||
返回 |
STATUS_OK on successful write.
|
AParcel_writeStrongBinder
声明于android/binder_parcel.h
binder_status_t AParcel_writeStrongBinder( AParcel *parcel, AIBinder *binder )
将 AIBinder 写入非空 Parcel 中的下一位置。
Can be null. This does not take any refcounts of ownership of the binder from the client.
自 API 级别 29 起可用。
详情 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
STATUS_OK on successful write.
|
AParcel_writeUint32
声明于android/binder_parcel.h
binder_status_t AParcel_writeUint32( AParcel *parcel, uint32_t value )
将 uint32_t 值写入非空 Parcel 中的下一位置。
自 API 级别 29 起可用。
详情 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
STATUS_OK on successful write.
|
AParcel_writeUint32Array
声明于android/binder_parcel.h
binder_status_t AParcel_writeUint32Array( AParcel *parcel, const uint32_t *arrayData, int32_t length )
将 uint32_t 数组写入非空 Parcel 中的下一位置。
自 API 级别 29 起可用。
详情 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
||||||
返回 |
STATUS_OK on successful write.
|
AParcel_writeUint64
声明于android/binder_parcel.h
binder_status_t AParcel_writeUint64( AParcel *parcel, uint64_t value )
将 uint64_t 值写入非空 Parcel 中的下一位置。
自 API 级别 29 起可用。
详情 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
STATUS_OK on successful write.
|
AParcel_writeUint64Array
声明于android/binder_parcel.h
binder_status_t AParcel_writeUint64Array( AParcel *parcel, const uint64_t *arrayData, int32_t length )
将 uint64_t 数组写入非空 Parcel 中的下一位置。
自 API 级别 29 起可用。
详情 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
||||||
返回 |
STATUS_OK on successful write.
|
AStatus_delete
声明于android/binder_status.h
void AStatus_delete( AStatus *status )
删除与 status 实例关联的内存。
自 API 级别 29 起可用。
详情 | |||
---|---|---|---|
参数 |
|
AStatus_deleteDescription
声明于android/binder_status.h
void AStatus_deleteDescription( const char *description )
删除描述。
详情 | |||
---|---|---|---|
参数 |
|
AStatus_fromExceptionCode
声明于android/binder_status.h
AStatus * AStatus_fromExceptionCode( binder_exception_t exception )
带有异常代码的新 status。
自 API 级别 29 起可用。
详情 | |||
---|---|---|---|
参数 |
|
||
返回 |
a newly constructed status object that the caller owns.
|
AStatus_fromExceptionCodeWithMessage
声明于android/binder_status.h
AStatus * AStatus_fromExceptionCodeWithMessage( binder_exception_t exception, const char *message )
带有异常代码和消息的新 status。
自 API 级别 29 起可用。
详情 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
a newly constructed status object that the caller owns.
|
AStatus_fromServiceSpecificError
声明于android/binder_status.h
AStatus * AStatus_fromServiceSpecificError( int32_t serviceSpecific )
带有服务特定错误的新 status。
This is considered to be EX_TRANSACTION_FAILED with extra information.
自 API 级别 29 起可用。
详情 | |||
---|---|---|---|
参数 |
|
||
返回 |
a newly constructed status object that the caller owns.
|
AStatus_fromServiceSpecificErrorWithMessage
声明于android/binder_status.h
AStatus * AStatus_fromServiceSpecificErrorWithMessage( int32_t serviceSpecific, const char *message )
带有服务特定错误和消息的新 status。
This is considered to be EX_TRANSACTION_FAILED with extra information.
自 API 级别 29 起可用。
详情 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
a newly constructed status object that the caller owns.
|
AStatus_fromStatus
声明于android/binder_status.h
AStatus * AStatus_fromStatus( binder_status_t status )
带有 binder_status_t 的新 status。
This is typically for low level failures when a binder_status_t is returned by an API on AIBinder or AParcel, and that is to be returned from a method returning an AStatus instance. This is the least preferable way to return errors. Prefer exceptions (particularly service-specific errors) when possible.
自 API 级别 29 起可用。
详情 | |||
---|---|---|---|
参数 |
|
||
返回 |
a newly constructed status object that the caller owns.
|
AStatus_getDescription
声明于android/binder_status.h
const char * AStatus_getDescription( const AStatus *status )
获取可读的调试描述。
自 API 级别 30 起可用。
详情 | |||
---|---|---|---|
参数 |
|
||
返回 |
a description, must be deleted with AStatus_deleteDescription.
|
AStatus_getExceptionCode
声明于android/binder_status.h
binder_exception_t AStatus_getExceptionCode( const AStatus *status )
此 status 对象表示的异常。
自 API 级别 29 起可用。
详情 | |||
---|---|---|---|
参数 |
|
||
返回 |
the exception code that this object represents.
|
AStatus_getMessage
声明于android/binder_status.h
const char * AStatus_getMessage( const AStatus *status )
如果此 status 关联了消息,则将返回该消息。
If there is no message, this will return an empty string.
The returned string has the lifetime of the status object passed into this function.
自 API 级别 29 起可用。
详情 | |||
---|---|---|---|
参数 |
|
||
返回 |
the message associated with this error.
|
AStatus_getServiceSpecificError
声明于android/binder_status.h
int32_t AStatus_getServiceSpecificError( const AStatus *status )
如果此对象表示服务特定错误,则返回该错误。
This function will only ever return a non-zero result if AStatus_getExceptionCode returns EX_SERVICE_SPECIFIC. If this function returns 0, the status object may still represent a different exception or status. To find out if this transaction as a whole is okay, use AStatus_isOk instead.
自 API 级别 29 起可用。
详情 | |||
---|---|---|---|
参数 |
|
||
返回 |
the service-specific error code if the exception code is EX_SERVICE_SPECIFIC or 0.
|
AStatus_getStatus
声明于android/binder_status.h
binder_status_t AStatus_getStatus( const AStatus *status )
如果此对象表示 status,则返回该 status。
This function will only ever return a non-zero result if AStatus_getExceptionCode returns EX_TRANSACTION_FAILED. If this function return 0, the status object may represent a different exception or a service specific error. To find out if this transaction as a whole is okay, use AStatus_isOk instead.
自 API 级别 29 起可用。
详情 | |||
---|---|---|---|
参数 |
|
||
返回 |
the status code if the exception code is EX_TRANSACTION_FAILED or 0.
|
AStatus_isOk
声明于android/binder_status.h
bool AStatus_isOk( const AStatus *status )
此对象是否表示成功的事务。
If this function returns true, then AStatus_getExceptionCode will return EX_NONE.
自 API 级别 29 起可用。
详情 | |||
---|---|---|---|
参数 |
|
||
返回 |
whether the status represents a successful transaction. For more details, see below.
|
AStatus_newOk
声明于android/binder_status.h
AStatus * AStatus_newOk()
被视为成功的新 status。
自 API 级别 29 起可用。
详情 | |
---|---|
返回 |
a newly constructed status object that the caller owns.
|