diff options
5 files changed, 81 insertions, 62 deletions
diff --git a/libs/binder/ndk/include_ndk/android/binder_ibinder.h b/libs/binder/ndk/include_ndk/android/binder_ibinder.h index 871335d79d..f237e695ce 100644 --- a/libs/binder/ndk/include_ndk/android/binder_ibinder.h +++ b/libs/binder/ndk/include_ndk/android/binder_ibinder.h @@ -33,6 +33,7 @@ #include <android/binder_status.h> __BEGIN_DECLS +#if __ANDROID_API__ >= __ANDROID_API_Q__ // Also see TF_* in kernel's binder.h typedef uint32_t binder_flags_t; @@ -154,7 +155,8 @@ typedef binder_status_t (*AIBinder_Class_onTransact)(AIBinder* binder, transacti */ __attribute__((warn_unused_result)) AIBinder_Class* AIBinder_Class_define( const char* interfaceDescriptor, AIBinder_Class_onCreate onCreate, - AIBinder_Class_onDestroy onDestroy, AIBinder_Class_onTransact onTransact); + AIBinder_Class_onDestroy onDestroy, AIBinder_Class_onTransact onTransact) + __INTRODUCED_IN(29); /** * Creates a new binder object of the appropriate class. @@ -173,12 +175,13 @@ __attribute__((warn_unused_result)) AIBinder_Class* AIBinder_Class_define( * these two objects are actually equal using the AIBinder pointer alone (which they should be able * to do). Also see the suggested memory ownership model suggested above. */ -__attribute__((warn_unused_result)) AIBinder* AIBinder_new(const AIBinder_Class* clazz, void* args); +__attribute__((warn_unused_result)) AIBinder* AIBinder_new(const AIBinder_Class* clazz, void* args) + __INTRODUCED_IN(29); /** * If this is hosted in a process other than the current one. */ -bool AIBinder_isRemote(const AIBinder* binder); +bool AIBinder_isRemote(const AIBinder* binder) __INTRODUCED_IN(29); /** * If this binder is known to be alive. This will not send a transaction to a remote process and @@ -187,14 +190,14 @@ bool AIBinder_isRemote(const AIBinder* binder); * updated as the result of a transaction made using AIBinder_transact, but it will also be updated * based on the results of bookkeeping or other transactions made internally. */ -bool AIBinder_isAlive(const AIBinder* binder); +bool AIBinder_isAlive(const AIBinder* binder) __INTRODUCED_IN(29); /** * Built-in transaction for all binder objects. This sends a transaction which will immediately * return. Usually this is used to make sure that a binder is alive, as a placeholder call, or as a * sanity check. */ -binder_status_t AIBinder_ping(AIBinder* binder); +binder_status_t AIBinder_ping(AIBinder* binder) __INTRODUCED_IN(29); /** * Registers for notifications that the associated binder is dead. The same death recipient may be @@ -206,7 +209,7 @@ binder_status_t AIBinder_ping(AIBinder* binder); * identification and holding user data. */ binder_status_t AIBinder_linkToDeath(AIBinder* binder, AIBinder_DeathRecipient* recipient, - void* cookie); + void* cookie) __INTRODUCED_IN(29); /** * Stops registration for the associated binder dying. Does not delete the recipient. This function @@ -214,22 +217,22 @@ binder_status_t AIBinder_linkToDeath(AIBinder* binder, AIBinder_DeathRecipient* * returns STATUS_NAME_NOT_FOUND. */ binder_status_t AIBinder_unlinkToDeath(AIBinder* binder, AIBinder_DeathRecipient* recipient, - void* cookie); + void* cookie) __INTRODUCED_IN(29); /** * This can only be called if a strong reference to this object already exists in process. */ -void AIBinder_incStrong(AIBinder* binder); +void AIBinder_incStrong(AIBinder* binder) __INTRODUCED_IN(29); /** * This will delete the object and call onDestroy once the refcount reaches zero. */ -void AIBinder_decStrong(AIBinder* binder); +void AIBinder_decStrong(AIBinder* binder) __INTRODUCED_IN(29); /** * For debugging only! */ -int32_t AIBinder_debugGetRefCount(AIBinder* binder); +int32_t AIBinder_debugGetRefCount(AIBinder* binder) __INTRODUCED_IN(29); /** * This sets the class of an AIBinder object. This checks to make sure the remote object is of @@ -240,18 +243,18 @@ int32_t AIBinder_debugGetRefCount(AIBinder* binder); * This returns true if the class association succeeds. If it fails, no change is made to the * binder object. */ -bool AIBinder_associateClass(AIBinder* binder, const AIBinder_Class* clazz); +bool AIBinder_associateClass(AIBinder* binder, const AIBinder_Class* clazz) __INTRODUCED_IN(29); /** * Returns the class that this binder was constructed with or associated with. */ -const AIBinder_Class* AIBinder_getClass(AIBinder* binder); +const AIBinder_Class* AIBinder_getClass(AIBinder* binder) __INTRODUCED_IN(29); /** * Value returned by onCreate for a local binder. For stateless classes (if onCreate returns * nullptr), this also returns nullptr. For a remote binder, this will always return nullptr. */ -void* AIBinder_getUserData(AIBinder* binder); +void* AIBinder_getUserData(AIBinder* binder) __INTRODUCED_IN(29); /** * A transaction is a series of calls to these functions which looks this @@ -274,7 +277,7 @@ void* AIBinder_getUserData(AIBinder* binder); * AIBinder_transact. Alternatively, if there is an error while filling out the parcel, it can be * deleted with AParcel_delete. */ -binder_status_t AIBinder_prepareTransaction(AIBinder* binder, AParcel** in); +binder_status_t AIBinder_prepareTransaction(AIBinder* binder, AParcel** in) __INTRODUCED_IN(29); /** * Transact using a parcel created from AIBinder_prepareTransaction. This actually communicates with @@ -289,42 +292,45 @@ binder_status_t AIBinder_prepareTransaction(AIBinder* binder, AParcel** in); * and must be released with AParcel_delete when finished reading. */ binder_status_t AIBinder_transact(AIBinder* binder, transaction_code_t code, AParcel** in, - AParcel** out, binder_flags_t flags); + AParcel** out, binder_flags_t flags) __INTRODUCED_IN(29); /** * This does not take any ownership of the input binder, but it can be used to retrieve it if * something else in some process still holds a reference to it. */ -__attribute__((warn_unused_result)) AIBinder_Weak* AIBinder_Weak_new(AIBinder* binder); +__attribute__((warn_unused_result)) AIBinder_Weak* AIBinder_Weak_new(AIBinder* binder) + __INTRODUCED_IN(29); /** * Deletes the weak reference. This will have no impact on the lifetime of the binder. */ -void AIBinder_Weak_delete(AIBinder_Weak* weakBinder); +void AIBinder_Weak_delete(AIBinder_Weak* weakBinder) __INTRODUCED_IN(29); /** * If promotion succeeds, result will have one strong refcount added to it. Otherwise, this returns * nullptr. */ -__attribute__((warn_unused_result)) AIBinder* AIBinder_Weak_promote(AIBinder_Weak* weakBinder); +__attribute__((warn_unused_result)) AIBinder* AIBinder_Weak_promote(AIBinder_Weak* weakBinder) + __INTRODUCED_IN(29); /** * This function is executed on death receipt. See AIBinder_linkToDeath/AIBinder_unlinkToDeath. */ -typedef void (*AIBinder_DeathRecipient_onBinderDied)(void* cookie); +typedef void (*AIBinder_DeathRecipient_onBinderDied)(void* cookie) __INTRODUCED_IN(29); /** * Creates a new binder death recipient. This can be attached to multiple different binder objects. */ __attribute__((warn_unused_result)) AIBinder_DeathRecipient* AIBinder_DeathRecipient_new( - AIBinder_DeathRecipient_onBinderDied onBinderDied); + AIBinder_DeathRecipient_onBinderDied onBinderDied) __INTRODUCED_IN(29); /** * Deletes a binder death recipient. It is not necessary to call AIBinder_unlinkToDeath before * calling this as these will all be automatically unlinked. */ -void AIBinder_DeathRecipient_delete(AIBinder_DeathRecipient* recipient); +void AIBinder_DeathRecipient_delete(AIBinder_DeathRecipient* recipient) __INTRODUCED_IN(29); +#endif //__ANDROID_API__ >= __ANDROID_API_Q__ __END_DECLS /** @} */ diff --git a/libs/binder/ndk/include_ndk/android/binder_ibinder_jni.h b/libs/binder/ndk/include_ndk/android/binder_ibinder_jni.h index 2f4acd1903..81fb3c5296 100644 --- a/libs/binder/ndk/include_ndk/android/binder_ibinder_jni.h +++ b/libs/binder/ndk/include_ndk/android/binder_ibinder_jni.h @@ -31,6 +31,7 @@ #include <jni.h> __BEGIN_DECLS +#if __ANDROID_API__ >= __ANDROID_API_Q__ /** * Converts an android.os.IBinder object into an AIBinder* object. @@ -39,7 +40,8 @@ __BEGIN_DECLS * AIBinder object, the original object is returned. The returned object has one refcount * associated with it, and so this should be accompanied with an AIBinder_decStrong call. */ -__attribute__((warn_unused_result)) AIBinder* AIBinder_fromJavaBinder(JNIEnv* env, jobject binder); +__attribute__((warn_unused_result)) AIBinder* AIBinder_fromJavaBinder(JNIEnv* env, jobject binder) + __INTRODUCED_IN(29); /** * Converts an AIBinder* object into an android.os.IBinder object. @@ -47,8 +49,10 @@ __attribute__((warn_unused_result)) AIBinder* AIBinder_fromJavaBinder(JNIEnv* en * If either env or the binder is null, null is returned. If this binder object was originally an * IBinder object, the original java object will be returned. */ -__attribute__((warn_unused_result)) jobject AIBinder_toJavaBinder(JNIEnv* env, AIBinder* binder); +__attribute__((warn_unused_result)) jobject AIBinder_toJavaBinder(JNIEnv* env, AIBinder* binder) + __INTRODUCED_IN(29); +#endif //__ANDROID_API__ >= __ANDROID_API_Q__ __END_DECLS /** @} */ diff --git a/libs/binder/ndk/include_ndk/android/binder_parcel.h b/libs/binder/ndk/include_ndk/android/binder_parcel.h index 271810af6d..27ff23684f 100644 --- a/libs/binder/ndk/include_ndk/android/binder_parcel.h +++ b/libs/binder/ndk/include_ndk/android/binder_parcel.h @@ -34,6 +34,7 @@ struct AIBinder; typedef struct AIBinder AIBinder; __BEGIN_DECLS +#if __ANDROID_API__ >= __ANDROID_API_Q__ /** * This object represents a package of data that can be sent between processes. When transacting, an @@ -47,129 +48,134 @@ typedef struct AParcel AParcel; /** * Cleans up a parcel. */ -void AParcel_delete(AParcel* parcel); +void AParcel_delete(AParcel* parcel) __INTRODUCED_IN(29); /** * Writes an AIBinder to the next location in a non-null parcel. Can be null. */ -binder_status_t AParcel_writeStrongBinder(AParcel* parcel, AIBinder* binder); +binder_status_t AParcel_writeStrongBinder(AParcel* parcel, AIBinder* binder) __INTRODUCED_IN(29); /** * Reads an AIBinder from the next location in a non-null parcel. This will fail if the binder is * non-null. One strong ref-count of ownership is passed to the caller of this function. */ -binder_status_t AParcel_readStrongBinder(const AParcel* parcel, AIBinder** binder); +binder_status_t AParcel_readStrongBinder(const AParcel* parcel, AIBinder** binder) + __INTRODUCED_IN(29); /** * Reads an AIBinder from the next location in a non-null parcel. This may read a null. One strong * ref-count of ownership is passed to the caller of this function. */ -binder_status_t AParcel_readNullableStrongBinder(const AParcel* parcel, AIBinder** binder); +binder_status_t AParcel_readNullableStrongBinder(const AParcel* parcel, AIBinder** binder) + __INTRODUCED_IN(29); /** * Writes an AStatus object to the next location in a non-null parcel. */ -binder_status_t AParcel_writeStatusHeader(AParcel* parcel, const AStatus* status); +binder_status_t AParcel_writeStatusHeader(AParcel* parcel, const AStatus* status) + __INTRODUCED_IN(29); /** * Reads an AStatus from the next location in a non-null parcel. Ownership is passed to the caller * of this function. */ -binder_status_t AParcel_readStatusHeader(const AParcel* parcel, AStatus** status); +binder_status_t AParcel_readStatusHeader(const AParcel* parcel, AStatus** status) + __INTRODUCED_IN(29); // @START /** * Writes int32_t value to the next location in a non-null parcel. */ -binder_status_t AParcel_writeInt32(AParcel* parcel, int32_t value); +binder_status_t AParcel_writeInt32(AParcel* parcel, int32_t value) __INTRODUCED_IN(29); /** * Writes uint32_t value to the next location in a non-null parcel. */ -binder_status_t AParcel_writeUint32(AParcel* parcel, uint32_t value); +binder_status_t AParcel_writeUint32(AParcel* parcel, uint32_t value) __INTRODUCED_IN(29); /** * Writes int64_t value to the next location in a non-null parcel. */ -binder_status_t AParcel_writeInt64(AParcel* parcel, int64_t value); +binder_status_t AParcel_writeInt64(AParcel* parcel, int64_t value) __INTRODUCED_IN(29); /** * Writes uint64_t value to the next location in a non-null parcel. */ -binder_status_t AParcel_writeUint64(AParcel* parcel, uint64_t value); +binder_status_t AParcel_writeUint64(AParcel* parcel, uint64_t value) __INTRODUCED_IN(29); /** * Writes float value to the next location in a non-null parcel. */ -binder_status_t AParcel_writeFloat(AParcel* parcel, float value); +binder_status_t AParcel_writeFloat(AParcel* parcel, float value) __INTRODUCED_IN(29); /** * Writes double value to the next location in a non-null parcel. */ -binder_status_t AParcel_writeDouble(AParcel* parcel, double value); +binder_status_t AParcel_writeDouble(AParcel* parcel, double value) __INTRODUCED_IN(29); /** * Writes bool value to the next location in a non-null parcel. */ -binder_status_t AParcel_writeBool(AParcel* parcel, bool value); +binder_status_t AParcel_writeBool(AParcel* parcel, bool value) __INTRODUCED_IN(29); /** * Writes char16_t value to the next location in a non-null parcel. */ -binder_status_t AParcel_writeChar(AParcel* parcel, char16_t value); +binder_status_t AParcel_writeChar(AParcel* parcel, char16_t value) __INTRODUCED_IN(29); /** * Writes int8_t value to the next location in a non-null parcel. */ -binder_status_t AParcel_writeByte(AParcel* parcel, int8_t value); +binder_status_t AParcel_writeByte(AParcel* parcel, int8_t value) __INTRODUCED_IN(29); /** * Reads into int32_t value from the next location in a non-null parcel. */ -binder_status_t AParcel_readInt32(const AParcel* parcel, int32_t* value); +binder_status_t AParcel_readInt32(const AParcel* parcel, int32_t* value) __INTRODUCED_IN(29); /** * Reads into uint32_t value from the next location in a non-null parcel. */ -binder_status_t AParcel_readUint32(const AParcel* parcel, uint32_t* value); +binder_status_t AParcel_readUint32(const AParcel* parcel, uint32_t* value) __INTRODUCED_IN(29); /** * Reads into int64_t value from the next location in a non-null parcel. */ -binder_status_t AParcel_readInt64(const AParcel* parcel, int64_t* value); +binder_status_t AParcel_readInt64(const AParcel* parcel, int64_t* value) __INTRODUCED_IN(29); /** * Reads into uint64_t value from the next location in a non-null parcel. */ -binder_status_t AParcel_readUint64(const AParcel* parcel, uint64_t* value); +binder_status_t AParcel_readUint64(const AParcel* parcel, uint64_t* value) __INTRODUCED_IN(29); /** * Reads into float value from the next location in a non-null parcel. */ -binder_status_t AParcel_readFloat(const AParcel* parcel, float* value); +binder_status_t AParcel_readFloat(const AParcel* parcel, float* value) __INTRODUCED_IN(29); /** * Reads into double value from the next location in a non-null parcel. */ -binder_status_t AParcel_readDouble(const AParcel* parcel, double* value); +binder_status_t AParcel_readDouble(const AParcel* parcel, double* value) __INTRODUCED_IN(29); /** * Reads into bool value from the next location in a non-null parcel. */ -binder_status_t AParcel_readBool(const AParcel* parcel, bool* value); +binder_status_t AParcel_readBool(const AParcel* parcel, bool* value) __INTRODUCED_IN(29); /** * Reads into char16_t value from the next location in a non-null parcel. */ -binder_status_t AParcel_readChar(const AParcel* parcel, char16_t* value); +binder_status_t AParcel_readChar(const AParcel* parcel, char16_t* value) __INTRODUCED_IN(29); /** * Reads into int8_t value from the next location in a non-null parcel. */ -binder_status_t AParcel_readByte(const AParcel* parcel, int8_t* value); +binder_status_t AParcel_readByte(const AParcel* parcel, int8_t* value) __INTRODUCED_IN(29); // @END +#endif //__ANDROID_API__ >= __ANDROID_API_Q__ __END_DECLS /** @} */ diff --git a/libs/binder/ndk/include_ndk/android/binder_status.h b/libs/binder/ndk/include_ndk/android/binder_status.h index 1a6a6f032a..2d8b7fa095 100644 --- a/libs/binder/ndk/include_ndk/android/binder_status.h +++ b/libs/binder/ndk/include_ndk/android/binder_status.h @@ -30,6 +30,7 @@ #include <sys/cdefs.h> __BEGIN_DECLS +#if __ANDROID_API__ >= __ANDROID_API_Q__ enum { STATUS_OK = 0, @@ -102,19 +103,19 @@ typedef struct AStatus AStatus; /** * New status which is considered a success. */ -__attribute__((warn_unused_result)) AStatus* AStatus_newOk(); +__attribute__((warn_unused_result)) AStatus* AStatus_newOk() __INTRODUCED_IN(29); /** * New status with exception code. */ -__attribute__((warn_unused_result)) AStatus* AStatus_fromExceptionCode( - binder_exception_t exception); +__attribute__((warn_unused_result)) AStatus* AStatus_fromExceptionCode(binder_exception_t exception) + __INTRODUCED_IN(29); /** * New status with exception code and message. */ __attribute__((warn_unused_result)) AStatus* AStatus_fromExceptionCodeWithMessage( - binder_exception_t exception, const char* message); + binder_exception_t exception, const char* message) __INTRODUCED_IN(29); /** * New status with a service speciic error. @@ -122,7 +123,7 @@ __attribute__((warn_unused_result)) AStatus* AStatus_fromExceptionCodeWithMessag * This is considered to be EX_TRANSACTION_FAILED with extra information. */ __attribute__((warn_unused_result)) AStatus* AStatus_fromServiceSpecificError( - int32_t serviceSpecific); + int32_t serviceSpecific) __INTRODUCED_IN(29); /** * New status with a service specific error and message. @@ -130,25 +131,26 @@ __attribute__((warn_unused_result)) AStatus* AStatus_fromServiceSpecificError( * This is considered to be EX_TRANSACTION_FAILED with extra information. */ __attribute__((warn_unused_result)) AStatus* AStatus_fromServiceSpecificErrorWithMessage( - int32_t serviceSpecific, const char* message); + int32_t serviceSpecific, const char* message) __INTRODUCED_IN(29); /** * New status with binder_status_t. 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. */ -__attribute__((warn_unused_result)) AStatus* AStatus_fromStatus(binder_status_t status); +__attribute__((warn_unused_result)) AStatus* AStatus_fromStatus(binder_status_t status) + __INTRODUCED_IN(29); /** * Whether this object represents a successful transaction. If this function returns true, then * AStatus_getExceptionCode will return EX_NONE. */ -bool AStatus_isOk(const AStatus* status); +bool AStatus_isOk(const AStatus* status) __INTRODUCED_IN(29); /** * The exception that this status object represents. */ -binder_exception_t AStatus_getExceptionCode(const AStatus* status); +binder_exception_t AStatus_getExceptionCode(const AStatus* status) __INTRODUCED_IN(29); /** * The service specific error if this object represents one. This function will only ever return a @@ -156,7 +158,7 @@ binder_exception_t AStatus_getExceptionCode(const AStatus* status); * 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. */ -int32_t AStatus_getServiceSpecificError(const AStatus* status); +int32_t AStatus_getServiceSpecificError(const AStatus* status) __INTRODUCED_IN(29); /** * The status if this object represents one. This function will only ever return a non-zero result @@ -164,7 +166,7 @@ int32_t AStatus_getServiceSpecificError(const AStatus* 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. */ -binder_status_t AStatus_getStatus(const AStatus* status); +binder_status_t AStatus_getStatus(const AStatus* status) __INTRODUCED_IN(29); /** * If there is a message associated with this status, this will return that message. If there is no @@ -172,13 +174,14 @@ binder_status_t AStatus_getStatus(const AStatus* status); * * The returned string has the lifetime of the status object passed into this function. */ -const char* AStatus_getMessage(const AStatus* status); +const char* AStatus_getMessage(const AStatus* status) __INTRODUCED_IN(29); /** * Deletes memory associated with the status instance. */ -void AStatus_delete(AStatus* status); +void AStatus_delete(AStatus* status) __INTRODUCED_IN(29); +#endif //__ANDROID_API__ >= __ANDROID_API_Q__ __END_DECLS /** @} */ diff --git a/libs/binder/ndk/scripts/gen_parcel_helper.py b/libs/binder/ndk/scripts/gen_parcel_helper.py index 85ee755783..bbd3e5de07 100755 --- a/libs/binder/ndk/scripts/gen_parcel_helper.py +++ b/libs/binder/ndk/scripts/gen_parcel_helper.py @@ -66,7 +66,7 @@ def main(): header += "/**\n" header += " * Writes " + cpp + " value to the next location in a non-null parcel.\n" header += " */\n" - header += "binder_status_t AParcel_write" + pretty + "(AParcel* parcel, " + cpp + " value);\n\n" + header += "binder_status_t AParcel_write" + pretty + "(AParcel* parcel, " + cpp + " value) __INTRODUCED_IN(29);\n\n" source += "binder_status_t AParcel_write" + pretty + "(AParcel* parcel, " + cpp + " value) {\n" source += " status_t status = parcel->get()->write" + pretty + "(value);\n" source += " return PruneStatusT(status);\n" @@ -76,7 +76,7 @@ def main(): header += "/**\n" header += " * Reads into " + cpp + " value from the next location in a non-null parcel.\n" header += " */\n" - header += "binder_status_t AParcel_read" + pretty + "(const AParcel* parcel, " + cpp + "* value);\n\n" + header += "binder_status_t AParcel_read" + pretty + "(const AParcel* parcel, " + cpp + "* value) __INTRODUCED_IN(29);\n\n" source += "binder_status_t AParcel_read" + pretty + "(const AParcel* parcel, " + cpp + "* value) {\n" source += " status_t status = parcel->get()->read" + pretty + "(value);\n" source += " return PruneStatusT(status);\n" |