diff options
| author | 2018-11-07 19:36:15 +0000 | |
|---|---|---|
| committer | 2018-11-07 19:36:15 +0000 | |
| commit | 9532aa992803f64abf08ecefc1fe017cb06d988a (patch) | |
| tree | 80713b3fd4214c8bba56cbe0b9f62c3eed6b952c | |
| parent | bb22780922646750af51a606d80a1bbb14ef0f02 (diff) | |
| parent | 86ae9e7985642223a4388dbc9eaf5cc96663d0f1 (diff) | |
Merge changes Ib26d7840,Id07f05de,I65755b5d
* changes:
libbinder_ndk: C++ headers aren't C-compatible.
libbinder_ndk: \return & \param comments
libbinder_ndk: use clang-format
18 files changed, 692 insertions, 114 deletions
diff --git a/libs/binder/ndk/.clang-format b/libs/binder/ndk/.clang-format new file mode 100644 index 0000000000..9a9d936f15 --- /dev/null +++ b/libs/binder/ndk/.clang-format @@ -0,0 +1,10 @@ +BasedOnStyle: Google +ColumnLimit: 100 +IndentWidth: 4 +ContinuationIndentWidth: 8 +PointerAlignment: Left +TabWidth: 4 +AllowShortFunctionsOnASingleLine: Inline +PointerAlignment: Left +TabWidth: 4 +UseTab: Never diff --git a/libs/binder/ndk/ibinder.cpp b/libs/binder/ndk/ibinder.cpp index e1c2009eec..f3fb9c37d8 100644 --- a/libs/binder/ndk/ibinder.cpp +++ b/libs/binder/ndk/ibinder.cpp @@ -45,7 +45,7 @@ static bool has(const sp<IBinder>& binder) { return binder != nullptr && binder->findObject(kId) == kValue; } -} // namespace ABBinderTag +} // namespace ABBinderTag namespace ABpBinderTag { @@ -60,7 +60,7 @@ void clean(const void* id, void* obj, void* cookie) { delete static_cast<Value*>(obj); }; -} // namespace ABpBinderTag +} // namespace ABpBinderTag AIBinder::AIBinder(const AIBinder_Class* clazz) : mClazz(clazz) {} AIBinder::~AIBinder() {} @@ -91,7 +91,7 @@ bool AIBinder::associateClass(const AIBinder_Class* clazz) { return false; } - CHECK(asABpBinder() != nullptr); // ABBinder always has a descriptor + CHECK(asABpBinder() != nullptr); // ABBinder always has a descriptor String8 descriptor(getBinder()->getInterfaceDescriptor()); if (descriptor != newDescriptor) { @@ -107,7 +107,7 @@ bool AIBinder::associateClass(const AIBinder_Class* clazz) { } ABBinder::ABBinder(const AIBinder_Class* clazz, void* userData) - : AIBinder(clazz), BBinder(), mUserData(userData) { + : AIBinder(clazz), BBinder(), mUserData(userData) { CHECK(clazz != nullptr); } ABBinder::~ABBinder() { @@ -136,7 +136,7 @@ status_t ABBinder::onTransact(transaction_code_t code, const Parcel& data, Parce } ABpBinder::ABpBinder(const ::android::sp<::android::IBinder>& binder) - : AIBinder(nullptr /*clazz*/), BpRefBase(binder) { + : AIBinder(nullptr /*clazz*/), BpRefBase(binder) { CHECK(binder != nullptr); } ABpBinder::~ABpBinder() {} @@ -214,10 +214,10 @@ AIBinder* AIBinder_Weak_promote(AIBinder_Weak* weakBinder) { AIBinder_Class::AIBinder_Class(const char* interfaceDescriptor, AIBinder_Class_onCreate onCreate, AIBinder_Class_onDestroy onDestroy, AIBinder_Class_onTransact onTransact) - : onCreate(onCreate), - onDestroy(onDestroy), - onTransact(onTransact), - mInterfaceDescriptor(interfaceDescriptor) {} + : onCreate(onCreate), + onDestroy(onDestroy), + onTransact(onTransact), + mInterfaceDescriptor(interfaceDescriptor) {} AIBinder_Class* AIBinder_Class_define(const char* interfaceDescriptor, AIBinder_Class_onCreate onCreate, @@ -239,7 +239,7 @@ void AIBinder_DeathRecipient::TransferDeathRecipient::binderDied(const wp<IBinde } AIBinder_DeathRecipient::AIBinder_DeathRecipient(AIBinder_DeathRecipient_onBinderDied onDied) - : mOnDied(onDied) { + : mOnDied(onDied) { CHECK(onDied != nullptr); } diff --git a/libs/binder/ndk/ibinder_internal.h b/libs/binder/ndk/ibinder_internal.h index 5b6bc946a8..ac592ea4f7 100644 --- a/libs/binder/ndk/ibinder_internal.h +++ b/libs/binder/ndk/ibinder_internal.h @@ -49,7 +49,7 @@ struct AIBinder : public virtual ::android::RefBase { return binder->remoteBinder() != nullptr; } -private: + private: // AIBinder instance is instance of this class for a local object. In order to transact on a // remote object, this also must be set for simplicity (although right now, only the // interfaceDescriptor from it is used). @@ -69,7 +69,7 @@ struct ABBinder : public AIBinder, public ::android::BBinder { ::android::status_t onTransact(uint32_t code, const ::android::Parcel& data, ::android::Parcel* reply, binder_flags_t flags) override; -private: + private: ABBinder(const AIBinder_Class* clazz, void* userData); // only thing that should create an ABBinder @@ -96,7 +96,7 @@ struct ABpBinder : public AIBinder, public ::android::BpRefBase { ::android::sp<::android::IBinder> getBinder() override { return remote(); } ABpBinder* asABpBinder() override { return this; } -private: + private: ABpBinder(const ::android::sp<::android::IBinder>& binder); }; @@ -110,7 +110,7 @@ struct AIBinder_Class { const AIBinder_Class_onDestroy onDestroy; const AIBinder_Class_onTransact onTransact; -private: + private: // This must be a String16 since BBinder virtual getInterfaceDescriptor returns a reference to // one. const ::android::String16 mInterfaceDescriptor; @@ -128,14 +128,14 @@ struct AIBinder_DeathRecipient { struct TransferDeathRecipient : ::android::IBinder::DeathRecipient { TransferDeathRecipient(const ::android::wp<::android::IBinder>& who, void* cookie, const AIBinder_DeathRecipient_onBinderDied& onDied) - : mWho(who), mCookie(cookie), mOnDied(onDied) {} + : mWho(who), mCookie(cookie), mOnDied(onDied) {} void binderDied(const ::android::wp<::android::IBinder>& who) override; const ::android::wp<::android::IBinder>& getWho() { return mWho; } void* getCookie() { return mCookie; } - private: + private: ::android::wp<::android::IBinder> mWho; void* mCookie; const AIBinder_DeathRecipient_onBinderDied& mOnDied; @@ -145,7 +145,7 @@ struct AIBinder_DeathRecipient { binder_status_t linkToDeath(AIBinder* binder, void* cookie); binder_status_t unlinkToDeath(AIBinder* binder, void* cookie); -private: + private: std::mutex mDeathRecipientsMutex; std::vector<::android::sp<TransferDeathRecipient>> mDeathRecipients; AIBinder_DeathRecipient_onBinderDied mOnDied; diff --git a/libs/binder/ndk/include_apex/android/binder_manager.h b/libs/binder/ndk/include_apex/android/binder_manager.h index b8f38ba88b..80b6c07025 100644 --- a/libs/binder/ndk/include_apex/android/binder_manager.h +++ b/libs/binder/ndk/include_apex/android/binder_manager.h @@ -17,11 +17,18 @@ #pragma once #include <android/binder_ibinder.h> +#include <android/binder_status.h> __BEGIN_DECLS /** - * This registers the service with the default service manager under this instance name. + * This registers the service with the default service manager under this instance name. This does + * not take ownership of binder. + * + * \param binder object to register globally with the service manager. + * \param instance identifier of the service. This will be used to lookup the service. + * + * \return STATUS_OK on success. */ binder_status_t AServiceManager_addService(AIBinder* binder, const char* instance); @@ -29,6 +36,8 @@ binder_status_t AServiceManager_addService(AIBinder* binder, const char* instanc * Gets a binder object with this specific instance name. Blocks for a couple of seconds waiting on * it. This also implicitly calls AIBinder_incStrong (so the caller of this function is responsible * for calling AIBinder_decStrong). + * + * \param instance identifier of the service used to lookup the service. */ __attribute__((warn_unused_result)) AIBinder* AServiceManager_getService(const char* instance); diff --git a/libs/binder/ndk/include_ndk/android/binder_auto_utils.h b/libs/binder/ndk/include_ndk/android/binder_auto_utils.h index e52a1d69ae..5c26039717 100644 --- a/libs/binder/ndk/include_ndk/android/binder_auto_utils.h +++ b/libs/binder/ndk/include_ndk/android/binder_auto_utils.h @@ -31,10 +31,8 @@ #include <android/binder_status.h> #include <assert.h> -#include <unistd.h> - -#ifdef __cplusplus +#include <unistd.h> #include <cstddef> namespace ndk { @@ -43,7 +41,7 @@ namespace ndk { * Represents one strong pointer to an AIBinder object. */ class SpAIBinder { -public: + public: /** * Takes ownership of one strong refcount of binder. */ @@ -107,7 +105,7 @@ public: */ AIBinder** getR() { return &mBinder; } -private: + private: AIBinder* mBinder = nullptr; }; @@ -116,7 +114,7 @@ private: */ template <typename T, typename R, R (*Destroy)(T), T DEFAULT> class ScopedAResource { -public: + public: /** * Takes ownership of t. */ @@ -167,7 +165,7 @@ public: // move-constructing is okay ScopedAResource(ScopedAResource&&) = default; -private: + private: T mT; }; @@ -175,7 +173,7 @@ private: * Convenience wrapper. See AParcel. */ class ScopedAParcel : public ScopedAResource<AParcel*, void, AParcel_delete, nullptr> { -public: + public: /** * Takes ownership of a. */ @@ -188,7 +186,7 @@ public: * Convenience wrapper. See AStatus. */ class ScopedAStatus : public ScopedAResource<AStatus*, void, AStatus_delete, nullptr> { -public: + public: /** * Takes ownership of a. */ @@ -206,14 +204,14 @@ public: * Convenience wrapper. See AIBinder_DeathRecipient. */ class ScopedAIBinder_DeathRecipient - : public ScopedAResource<AIBinder_DeathRecipient*, void, AIBinder_DeathRecipient_delete, - nullptr> { -public: + : public ScopedAResource<AIBinder_DeathRecipient*, void, AIBinder_DeathRecipient_delete, + nullptr> { + public: /** * Takes ownership of a. */ explicit ScopedAIBinder_DeathRecipient(AIBinder_DeathRecipient* a = nullptr) - : ScopedAResource(a) {} + : ScopedAResource(a) {} ~ScopedAIBinder_DeathRecipient() {} ScopedAIBinder_DeathRecipient(ScopedAIBinder_DeathRecipient&&) = default; }; @@ -222,8 +220,8 @@ public: * Convenience wrapper. See AIBinder_Weak. */ class ScopedAIBinder_Weak - : public ScopedAResource<AIBinder_Weak*, void, AIBinder_Weak_delete, nullptr> { -public: + : public ScopedAResource<AIBinder_Weak*, void, AIBinder_Weak_delete, nullptr> { + public: /** * Takes ownership of a. */ @@ -241,7 +239,7 @@ public: * Convenience wrapper for a file descriptor. */ class ScopedFileDescriptor : public ScopedAResource<int, int, close, -1> { -public: + public: /** * Takes ownership of a. */ @@ -250,8 +248,6 @@ public: ScopedFileDescriptor(ScopedFileDescriptor&&) = default; }; -} // namespace ndk - -#endif // __cplusplus +} // namespace ndk /** @} */ diff --git a/libs/binder/ndk/include_ndk/android/binder_ibinder.h b/libs/binder/ndk/include_ndk/android/binder_ibinder.h index c222c161f5..5222bda21b 100644 --- a/libs/binder/ndk/include_ndk/android/binder_ibinder.h +++ b/libs/binder/ndk/include_ndk/android/binder_ibinder.h @@ -126,8 +126,9 @@ typedef struct AIBinder_DeathRecipient AIBinder_DeathRecipient; /** * This is called whenever a new AIBinder object is needed of a specific class. * - * These arguments are passed from AIBinder_new. The return value is stored and can be retrieved - * using AIBinder_getUserData. + * \param args these can be used to construct a new class. These are passed from AIBinder_new. + * \return this is the userdata representing the class. It can be retrieved using + * AIBinder_getUserData. */ typedef void* (*AIBinder_Class_onCreate)(void* args); @@ -135,23 +136,41 @@ typedef void* (*AIBinder_Class_onCreate)(void* args); * This is called whenever an AIBinder object is no longer referenced and needs destroyed. * * Typically, this just deletes whatever the implementation is. + * + * \param userData this is the same object returned by AIBinder_Class_onCreate */ typedef void (*AIBinder_Class_onDestroy)(void* userData); /** * This is called whenever a transaction needs to be processed by a local implementation. + * + * \param binder the object being transacted on. + * \param code implementation-specific code representing which transaction should be taken. + * \param in the implementation-specific input data to this transaction. + * \param out the implementation-specific output data to this transaction. + * + * \return the implementation-specific output code. This may be forwarded from another service, the + * result of a parcel read or write, or another error as is applicable to the specific + * implementation. 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. */ typedef binder_status_t (*AIBinder_Class_onTransact)(AIBinder* binder, transaction_code_t code, const AParcel* in, AParcel* out); /** - * An interfaceDescriptor uniquely identifies the type of object that is being created. This is used - * internally for sanity checks on transactions. + * This creates a new instance of a class of binders which can be instantiated. This is called one + * time during library initialization and cleaned up when the process exits or execs. * - * None of these parameters can be nullptr. + * None of these parameters can be null. * - * This is created one time during library initialization and cleaned up when the process exits or - * execs. + * \param interfaceDescriptor this is a unique identifier for the class. This is used internally for + * sanity checks on transactions. + * \param onCreate see AIBinder_Class_onCreate. + * \param onDestroy see AIBinder_Class_onDestroy. + * \param onTransact see AIBinder_Class_onTransact. + * + * \return the class object representing these parameters or null on error. */ __attribute__((warn_unused_result)) AIBinder_Class* AIBinder_Class_define( const char* interfaceDescriptor, AIBinder_Class_onCreate onCreate, @@ -174,12 +193,21 @@ __attribute__((warn_unused_result)) AIBinder_Class* AIBinder_Class_define( * hypothetical removeCallback function, the remote process would have no way to determine that * 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. + * + * \param clazz the type of the object to be created. + * \param args the args to pass to AIBinder_onCreate for that class. + * + * \return a binder object representing the newly instantiated object. */ __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. + * + * \param binder the binder being queried. + * + * \return true if the AIBinder represents an object in another process. */ bool AIBinder_isRemote(const AIBinder* binder) __INTRODUCED_IN(29); @@ -189,13 +217,21 @@ bool AIBinder_isRemote(const AIBinder* binder) __INTRODUCED_IN(29); * this is automatically updated to reflect the current alive status of this binder. This will be * 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. + * + * \param binder the binder being queried. + * + * \return true if the binder is alive. */ bool AIBinder_isAlive(const AIBinder* binder) __INTRODUCED_IN(29); /** - * Built-in transaction for all binder objects. This sends a transaction which will immediately + * Built-in transaction for all binder objects. This sends a transaction that will immediately * return. Usually this is used to make sure that a binder is alive, as a placeholder call, or as a * sanity check. + * + * \param binder the binder being queried. + * + * \return STATUS_OK if the ping succeeds. */ binder_status_t AIBinder_ping(AIBinder* binder) __INTRODUCED_IN(29); @@ -209,6 +245,12 @@ binder_status_t AIBinder_ping(AIBinder* binder) __INTRODUCED_IN(29); * identification and holding user data. * * If binder is local, this will return STATUS_INVALID_OPERATION. + * + * \param binder the binder object you want to receive death notifications from. + * \param recipient the callback that will receive notifications when/if the binder dies. + * \param cookie the value that will be passed to the death recipient on death. + * + * \return STATUS_OK on success. */ binder_status_t AIBinder_linkToDeath(AIBinder* binder, AIBinder_DeathRecipient* recipient, void* cookie) __INTRODUCED_IN(29); @@ -217,22 +259,34 @@ binder_status_t AIBinder_linkToDeath(AIBinder* binder, AIBinder_DeathRecipient* * Stops registration for the associated binder dying. 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. + * + * \param binder the binder object to remove a previously linked death recipient from. + * \param recipient the callback to remove. + * \param cookie the cookie used to link to death. + * + * \return STATUS_OK on success. STATUS_NAME_NOT_FOUND if the binder cannot be found to be unlinked. */ binder_status_t AIBinder_unlinkToDeath(AIBinder* binder, AIBinder_DeathRecipient* recipient, void* cookie) __INTRODUCED_IN(29); /** * This can only be called if a strong reference to this object already exists in process. + * + * \param binder the binder object to add a refcount to. */ void AIBinder_incStrong(AIBinder* binder) __INTRODUCED_IN(29); /** * This will delete the object and call onDestroy once the refcount reaches zero. + * + * \param binder the binder object to remove a refcount from. */ void AIBinder_decStrong(AIBinder* binder) __INTRODUCED_IN(29); /** * For debugging only! + * + * \param binder the binder object to retrieve the refcount of. */ int32_t AIBinder_debugGetRefCount(AIBinder* binder) __INTRODUCED_IN(29); @@ -244,17 +298,32 @@ int32_t AIBinder_debugGetRefCount(AIBinder* binder) __INTRODUCED_IN(29); * * This returns true if the class association succeeds. If it fails, no change is made to the * binder object. + * + * \param binder the object to attach the class to. + * \param clazz the clazz to attach to binder. + * + * \return true if the binder has the class clazz and if the association was successful. */ bool AIBinder_associateClass(AIBinder* binder, const AIBinder_Class* clazz) __INTRODUCED_IN(29); /** * Returns the class that this binder was constructed with or associated with. + * + * \param binder the object that is being queried. + * + * \return the class that this binder is associated with. If this binder wasn't created with + * AIBinder_new, and AIBinder_associateClass hasn't been called, then this will return null. */ 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. + * null), this also returns null. For a remote binder, this will always return null. + * + * \param binder the object that is being queried. + * + * \return the userdata returned from AIBinder_onCreate when this object was created. This may be + * null for stateless objects. For remote objects, this is always null. */ void* AIBinder_getUserData(AIBinder* binder) __INTRODUCED_IN(29); @@ -278,6 +347,12 @@ void* AIBinder_getUserData(AIBinder* binder) __INTRODUCED_IN(29); * 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. + * + * \param binder the binder object to start a transaction on. + * \param in out parameter for input data to the transaction. + * + * \return 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). */ binder_status_t AIBinder_prepareTransaction(AIBinder* binder, AParcel** in) __INTRODUCED_IN(29); @@ -292,6 +367,16 @@ binder_status_t AIBinder_prepareTransaction(AIBinder* binder, AParcel** in) __IN * * 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. + * + * \param binder the binder object to transact on. + * \param code the implementation-specific code representing which transaction should be taken. + * \param in the implementation-specific input data to this transaction. + * \param out the implementation-specific output data to this transaction. + * \param flags possible flags to alter the way in which the transaction is conducted or 0. + * + * \return 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. */ binder_status_t AIBinder_transact(AIBinder* binder, transaction_code_t code, AParcel** in, AParcel** out, binder_flags_t flags) __INTRODUCED_IN(29); @@ -299,29 +384,45 @@ binder_status_t AIBinder_transact(AIBinder* binder, transaction_code_t code, APa /** * 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. + * + * \param binder object to create a weak pointer to. + * + * \return object representing a weak pointer to binder (or null if binder is null). */ __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. + * + * \param weakBinder object created with AIBinder_Weak_new. */ 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. + * null. + * + * \param weakBinder weak pointer to attempt retrieving the original object from. + * + * \return an AIBinder object with one refcount given to the caller or null. */ __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. + * + * \param cookie the cookie passed to AIBinder_linkToDeath. */ 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. + * + * \param onBinderDied the callback to call when this death recipient is invoked. + * + * \return the newly constructed object (or null if onBinderDied is null). */ __attribute__((warn_unused_result)) AIBinder_DeathRecipient* AIBinder_DeathRecipient_new( AIBinder_DeathRecipient_onBinderDied onBinderDied) __INTRODUCED_IN(29); @@ -329,10 +430,12 @@ __attribute__((warn_unused_result)) AIBinder_DeathRecipient* AIBinder_DeathRecip /** * Deletes a binder death recipient. It is not necessary to call AIBinder_unlinkToDeath before * calling this as these will all be automatically unlinked. + * + * \param recipient the binder to delete (previously created with AIBinder_DeathRecipient_new). */ void AIBinder_DeathRecipient_delete(AIBinder_DeathRecipient* recipient) __INTRODUCED_IN(29); -#endif //__ANDROID_API__ >= __ANDROID_API_Q__ +#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 81fb3c5296..124f36c55b 100644 --- a/libs/binder/ndk/include_ndk/android/binder_ibinder_jni.h +++ b/libs/binder/ndk/include_ndk/android/binder_ibinder_jni.h @@ -39,6 +39,12 @@ __BEGIN_DECLS * If either env or the binder is null, null is returned. If this binder object was originally an * 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. + * + * \param env Java environment. + * \param binder android.os.IBinder java object. + * + * \return an AIBinder object representing the Java binder object. If either parameter is null, or + * the Java object is of the wrong type, this will return null. */ __attribute__((warn_unused_result)) AIBinder* AIBinder_fromJavaBinder(JNIEnv* env, jobject binder) __INTRODUCED_IN(29); @@ -48,11 +54,16 @@ __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. + * + * \param env Java environment. + * \param binder the object to convert. + * + * \return an android.os.IBinder object or null if the parameters were null. */ __attribute__((warn_unused_result)) jobject AIBinder_toJavaBinder(JNIEnv* env, AIBinder* binder) __INTRODUCED_IN(29); -#endif //__ANDROID_API__ >= __ANDROID_API_Q__ +#endif //__ANDROID_API__ >= __ANDROID_API_Q__ __END_DECLS /** @} */ diff --git a/libs/binder/ndk/include_ndk/android/binder_interface_utils.h b/libs/binder/ndk/include_ndk/android/binder_interface_utils.h index e37c388132..153272572f 100644 --- a/libs/binder/ndk/include_ndk/android/binder_interface_utils.h +++ b/libs/binder/ndk/include_ndk/android/binder_interface_utils.h @@ -32,8 +32,6 @@ #include <assert.h> -#ifdef __cplusplus - #include <memory> #include <mutex> @@ -46,7 +44,7 @@ namespace ndk { * construct this object is with SharedRefBase::make. */ class SharedRefBase { -public: + public: SharedRefBase() {} virtual ~SharedRefBase() { std::call_once(mFlagThis, [&]() { @@ -83,7 +81,7 @@ public: return t->template ref<T>(); } -private: + private: std::once_flag mFlagThis; std::weak_ptr<SharedRefBase> mThis; }; @@ -92,7 +90,7 @@ private: * wrapper analog to IInterface */ class ICInterface : public SharedRefBase { -public: + public: ICInterface() {} virtual ~ICInterface() {} @@ -113,7 +111,7 @@ public: */ template <typename INTERFACE> class BnCInterface : public INTERFACE { -public: + public: BnCInterface() {} virtual ~BnCInterface() {} @@ -121,15 +119,15 @@ public: bool isRemote() override { return true; } -protected: + protected: /** * This function should only be called by asBinder. Otherwise, there is a possibility of * multiple AIBinder* objects being created for the same instance of an object. */ virtual SpAIBinder createBinder() = 0; -private: - std::mutex mMutex; // for asBinder + private: + std::mutex mMutex; // for asBinder ScopedAIBinder_Weak mWeakBinder; }; @@ -138,7 +136,7 @@ private: */ template <typename INTERFACE> class BpCInterface : public INTERFACE { -public: + public: BpCInterface(const SpAIBinder& binder) : mBinder(binder) {} virtual ~BpCInterface() {} @@ -146,7 +144,7 @@ public: bool isRemote() override { return AIBinder_isRemote(mBinder.get()); } -private: + private: SpAIBinder mBinder; }; @@ -171,8 +169,6 @@ SpAIBinder BpCInterface<INTERFACE>::asBinder() { return mBinder; } -} // namespace ndk - -#endif // __cplusplus +} // namespace ndk /** @} */ diff --git a/libs/binder/ndk/include_ndk/android/binder_parcel.h b/libs/binder/ndk/include_ndk/android/binder_parcel.h index a303f4a33d..a5842f70e0 100644 --- a/libs/binder/ndk/include_ndk/android/binder_parcel.h +++ b/libs/binder/ndk/include_ndk/android/binder_parcel.h @@ -47,6 +47,9 @@ typedef struct AParcel AParcel; /** * Cleans up a parcel. + * + * \param parcel A parcel returned by AIBinder_prepareTransaction or AIBinder_transact when a + * transaction is being aborted. */ void AParcel_delete(AParcel* parcel) __INTRODUCED_IN(29); @@ -59,6 +62,11 @@ void AParcel_delete(AParcel* parcel) __INTRODUCED_IN(29); * See also AParcel_readString. * * If allocation fails, null should be returned. + * + * \param stringData some external representation of a string + * \param length the length of the buffer needed to fill (including the null-terminator) + * + * \return a buffer of size 'length' or null if allocation failed. */ typedef char* (*AParcel_stringAllocator)(void* stringData, size_t length); @@ -66,6 +74,11 @@ typedef char* (*AParcel_stringAllocator)(void* stringData, size_t length); * This is called to allocate an array of size 'length'. * * See also AParcel_readStringArray + * + * \param arrayData some external representation of an array + * \param length the length to allocate this array to + * + * \return true if allocation succeeded */ typedef bool (*AParcel_stringArrayAllocator)(void* arrayData, size_t length); @@ -79,6 +92,13 @@ typedef bool (*AParcel_stringArrayAllocator)(void* arrayData, size_t length); * greater than 0. * * See also AParcel_readStringArray + * + * \param arrayData some external representation of an array. + * \param index the index at which a string should be allocated. + * \param length the length of the string to be allocated at this index. See also + * AParcel_stringAllocator. This includes the length required for a null-terminator. + * + * \return a buffer of size 'length' or null if allocation failed. */ typedef char* (*AParcel_stringArrayElementAllocator)(void* arrayData, size_t index, size_t length); @@ -86,6 +106,14 @@ typedef char* (*AParcel_stringArrayElementAllocator)(void* arrayData, size_t ind * This returns the length and buffer of an array at a specific index in an arrayData object. * * See also AParcel_writeStringArray + * + * \param arrayData some external representation of an array. + * \param index the index at which a string should be allocated. + * \param outLength an out parameter for the length of the string (not including the + * null-terminator) + * + * \param a null-terminated buffer of size 'outLength + 1' representing the string at the provided + * index including the null-terminator. */ typedef const char* (*AParcel_stringArrayElementGetter)(const void* arrayData, size_t index, size_t* outLength); @@ -99,6 +127,11 @@ typedef const char* (*AParcel_stringArrayElementGetter)(const void* arrayData, s * returned. * * See also AParcel_readInt32Array + * + * \param arrayData some external representation of an array of int32_t. + * \param length the length to allocate arrayData to. + * + * \return a buffer of int32_t of size 'length'. */ typedef int32_t* (*AParcel_int32ArrayAllocator)(void* arrayData, size_t length); @@ -110,6 +143,11 @@ typedef int32_t* (*AParcel_int32ArrayAllocator)(void* arrayData, size_t length); * returned. * * See also AParcel_readUint32Array + * + * \param arrayData some external representation of an array of uint32_t. + * \param length the length to allocate arrayData to. + * + * \return a buffer of uint32_t of size 'length'. */ typedef uint32_t* (*AParcel_uint32ArrayAllocator)(void* arrayData, size_t length); @@ -121,6 +159,11 @@ typedef uint32_t* (*AParcel_uint32ArrayAllocator)(void* arrayData, size_t length * returned. * * See also AParcel_readInt64Array + * + * \param arrayData some external representation of an array of int64_t. + * \param length the length to allocate arrayData to. + * + * \return a buffer of int64_t of size 'length'. */ typedef int64_t* (*AParcel_int64ArrayAllocator)(void* arrayData, size_t length); @@ -132,6 +175,11 @@ typedef int64_t* (*AParcel_int64ArrayAllocator)(void* arrayData, size_t length); * returned. * * See also AParcel_readUint64Array + * + * \param arrayData some external representation of an array of uint64_t. + * \param length the length to allocate arrayData to. + * + * \return a buffer of uint64_t of size 'length'. */ typedef uint64_t* (*AParcel_uint64ArrayAllocator)(void* arrayData, size_t length); @@ -143,6 +191,11 @@ typedef uint64_t* (*AParcel_uint64ArrayAllocator)(void* arrayData, size_t length * returned. * * See also AParcel_readFloatArray + * + * \param arrayData some external representation of an array of float. + * \param length the length to allocate arrayData to. + * + * \return a buffer of float of size 'length'. */ typedef float* (*AParcel_floatArrayAllocator)(void* arrayData, size_t length); @@ -154,6 +207,11 @@ typedef float* (*AParcel_floatArrayAllocator)(void* arrayData, size_t length); * returned. * * See also AParcel_readDoubleArray + * + * \param arrayData some external representation of an array of double. + * \param length the length to allocate arrayData to. + * + * \return a buffer of double of size 'length'. */ typedef double* (*AParcel_doubleArrayAllocator)(void* arrayData, size_t length); @@ -162,6 +220,11 @@ typedef double* (*AParcel_doubleArrayAllocator)(void* arrayData, size_t length); * a success. * * See also AParcel_readBoolArray + * + * \param arrayData some external representation of an array of bool. + * \param length the length to allocate arrayData to. + * + * \return whether the allocation succeeded. */ typedef bool (*AParcel_boolArrayAllocator)(void* arrayData, size_t length); @@ -169,6 +232,11 @@ typedef bool (*AParcel_boolArrayAllocator)(void* arrayData, size_t length); * This is called to get the underlying data from an arrayData object at index. * * See also AParcel_writeBoolArray + * + * \param arrayData some external representation of an array of bool. + * \param index the index of the value to be retrieved. + * + * \return the value of the array at index index. */ typedef bool (*AParcel_boolArrayGetter)(const void* arrayData, size_t index); @@ -176,6 +244,10 @@ typedef bool (*AParcel_boolArrayGetter)(const void* arrayData, size_t index); * This is called to set an underlying value in an arrayData object at index. * * See also AParcel_readBoolArray + * + * \param arrayData some external representation of an array of bool. + * \param index the index of the value to be set. + * \param value the value to set at index index. */ typedef void (*AParcel_boolArraySetter)(void* arrayData, size_t index, bool value); @@ -187,6 +259,11 @@ typedef void (*AParcel_boolArraySetter)(void* arrayData, size_t index, bool valu * returned. * * See also AParcel_readCharArray + * + * \param arrayData some external representation of an array of char16_t. + * \param length the length to allocate arrayData to. + * + * \return a buffer of char16_t of size 'length'. */ typedef char16_t* (*AParcel_charArrayAllocator)(void* arrayData, size_t length); @@ -198,19 +275,36 @@ typedef char16_t* (*AParcel_charArrayAllocator)(void* arrayData, size_t length); * returned. * * See also AParcel_readByteArray + * + * \param arrayData some external representation of an array of int8_t. + * \param length the length to allocate arrayData to. + * + * \return a buffer of int8_t of size 'length'. */ typedef int8_t* (*AParcel_byteArrayAllocator)(void* arrayData, size_t length); // @END-PRIMITIVE-VECTOR-GETTERS /** - * Writes an AIBinder to the next location in a non-null parcel. Can be null. + * Writes an AIBinder to the next location in a non-null parcel. Can be null. This does not take any + * refcounts of ownership of the binder from the client. + * + * \param parcel the parcel to write to. + * \param binder the value to write to the parcel. + * + * \return STATUS_OK on successful write. */ 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. + * + * \param parcel the parcel to read from. + * \param binder the out parameter for what is read from the parcel. This will not be null on + * success. + * + * \return STATUS_OK on successful write. */ binder_status_t AParcel_readStrongBinder(const AParcel* parcel, AIBinder** binder) __INTRODUCED_IN(29); @@ -218,6 +312,12 @@ binder_status_t AParcel_readStrongBinder(const AParcel* parcel, AIBinder** binde /** * 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. + * + * \param parcel the parcel to read from. + * \param binder the out parameter for what is read from the parcel. This may be null even on + * success. + * + * \return STATUS_OK on successful write. */ binder_status_t AParcel_readNullableStrongBinder(const AParcel* parcel, AIBinder** binder) __INTRODUCED_IN(29); @@ -227,6 +327,11 @@ binder_status_t AParcel_readNullableStrongBinder(const AParcel* parcel, AIBinder * of fd. * * This corresponds to the SDK's android.os.ParcelFileDescriptor. + * + * \param parcel the parcel to write to. + * \param fd the value to write to the parcel. + * + * \return STATUS_OK on successful write. */ binder_status_t AParcel_writeParcelFileDescriptor(AParcel* parcel, int fd); @@ -236,6 +341,11 @@ binder_status_t AParcel_writeParcelFileDescriptor(AParcel* parcel, int fd); * The returned fd must be closed. * * This corresponds to the SDK's android.os.ParcelFileDescriptor. + * + * \param parcel the parcel to read from. + * \param binder the out parameter for what is read from the parcel. + * + * \return STATUS_OK on successful write. */ binder_status_t AParcel_readParcelFileDescriptor(const AParcel* parcel, int* fd); @@ -247,6 +357,11 @@ binder_status_t AParcel_readParcelFileDescriptor(const AParcel* parcel, int* fd) * 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. + * + * \param parcel the parcel to write to. + * \param status the value to write to the parcel. + * + * \return STATUS_OK on successful write. */ binder_status_t AParcel_writeStatusHeader(AParcel* parcel, const AStatus* status) __INTRODUCED_IN(29); @@ -254,12 +369,24 @@ binder_status_t AParcel_writeStatusHeader(AParcel* parcel, const AStatus* status /** * Reads an AStatus from the next location in a non-null parcel. Ownership is passed to the caller * of this function. + * + * \param parcel the parcel to read from. + * \param status the out parameter for what is read from the parcel. + * + * \return STATUS_OK on successful write. */ binder_status_t AParcel_readStatusHeader(const AParcel* parcel, AStatus** status) __INTRODUCED_IN(29); /** * Writes utf-8 string value to the next location in a non-null parcel. + * + * \param parcel the parcel to write to. + * \param string the null-terminated string to write to the parcel. The buffer including the null + * terminator should be of size 'length' + 1. + * \param length the length of the string to be written. + * + * \return STATUS_OK on successful write. */ binder_status_t AParcel_writeString(AParcel* parcel, const char* string, size_t length) __INTRODUCED_IN(29); @@ -270,6 +397,12 @@ binder_status_t AParcel_writeString(AParcel* parcel, const char* string, size_t * 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. + * + * \param parcel the parcel to read from. + * \param stringData some external representation of a string. + * \param allocator allocator that will be called once the size of the string is known. + * + * \return STATUS_OK on successful write. */ binder_status_t AParcel_readString(const AParcel* parcel, void* stringData, AParcel_stringAllocator allocator) __INTRODUCED_IN(29); @@ -280,6 +413,14 @@ binder_status_t AParcel_readString(const AParcel* parcel, void* stringData, * 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. + * + * \param parcel the parcel to write to. + * \param arrayData some external representation of an array. + * \param length the length of the array to be written. + * \param getter the callback that will be called for every index of the array to retrieve the + * corresponding string buffer. + * + * \return STATUS_OK on successful write. */ binder_status_t AParcel_writeStringArray(AParcel* parcel, const void* arrayData, size_t length, AParcel_stringArrayElementGetter getter) @@ -293,6 +434,15 @@ binder_status_t AParcel_writeStringArray(AParcel* parcel, const void* arrayData, * 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. + * + * \param parcel the parcel to read from. + * \param arrayData some external representation of an array. + * \param allocator the callback that will be called with arrayData once the size of the output + * array is known. + * \param elementAllocator the callback that will be called on every index of arrayData to allocate + * the string at that location. + * + * \return STATUS_OK on successful read. */ binder_status_t AParcel_readStringArray(const AParcel* parcel, void* arrayData, AParcel_stringArrayAllocator allocator, @@ -302,128 +452,254 @@ binder_status_t AParcel_readStringArray(const AParcel* parcel, void* arrayData, // @START-PRIMITIVE-READ-WRITE /** * Writes int32_t value to the next location in a non-null parcel. + * + * \param parcel the parcel to write to. + * \param value the value to write to the parcel. + * + * \return STATUS_OK on successful write. */ 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. + * + * \param parcel the parcel to write to. + * \param value the value to write to the parcel. + * + * \return STATUS_OK on successful write. */ 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. + * + * \param parcel the parcel to write to. + * \param value the value to write to the parcel. + * + * \return STATUS_OK on successful write. */ 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. + * + * \param parcel the parcel to write to. + * \param value the value to write to the parcel. + * + * \return STATUS_OK on successful write. */ 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. + * + * \param parcel the parcel to write to. + * \param value the value to write to the parcel. + * + * \return STATUS_OK on successful write. */ binder_status_t AParcel_writeFloat(AParcel* parcel, float value) __INTRODUCED_IN(29); /** * Writes double value to the next location in a non-null parcel. + * + * \param parcel the parcel to write to. + * \param value the value to write to the parcel. + * + * \return STATUS_OK on successful write. */ binder_status_t AParcel_writeDouble(AParcel* parcel, double value) __INTRODUCED_IN(29); /** * Writes bool value to the next location in a non-null parcel. + * + * \param parcel the parcel to write to. + * \param value the value to write to the parcel. + * + * \return STATUS_OK on successful write. */ 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. + * + * \param parcel the parcel to write to. + * \param value the value to write to the parcel. + * + * \return STATUS_OK on successful write. */ 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. + * + * \param parcel the parcel to write to. + * \param value the value to write to the parcel. + * + * \return STATUS_OK on successful write. */ 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. + * + * \param parcel the parcel to read from. + * \param value the value to read from the parcel. + * + * \return STATUS_OK on successful read. */ 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. + * + * \param parcel the parcel to read from. + * \param value the value to read from the parcel. + * + * \return STATUS_OK on successful read. */ 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. + * + * \param parcel the parcel to read from. + * \param value the value to read from the parcel. + * + * \return STATUS_OK on successful read. */ 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. + * + * \param parcel the parcel to read from. + * \param value the value to read from the parcel. + * + * \return STATUS_OK on successful read. */ 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. + * + * \param parcel the parcel to read from. + * \param value the value to read from the parcel. + * + * \return STATUS_OK on successful read. */ 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. + * + * \param parcel the parcel to read from. + * \param value the value to read from the parcel. + * + * \return STATUS_OK on successful read. */ 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. + * + * \param parcel the parcel to read from. + * \param value the value to read from the parcel. + * + * \return STATUS_OK on successful read. */ 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. + * + * \param parcel the parcel to read from. + * \param value the value to read from the parcel. + * + * \return STATUS_OK on successful read. */ 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. + * + * \param parcel the parcel to read from. + * \param value the value to read from the parcel. + * + * \return STATUS_OK on successful read. */ binder_status_t AParcel_readByte(const AParcel* parcel, int8_t* value) __INTRODUCED_IN(29); /** * Writes an array of int32_t to the next location in a non-null parcel. + * + * \param parcel the parcel to write to. + * \param arrayData an array of size 'length'. + * \param length the length of arrayData. + * + * \return STATUS_OK on successful write. */ -binder_status_t AParcel_writeInt32Array(AParcel* parcel, const int32_t* value, size_t length) +binder_status_t AParcel_writeInt32Array(AParcel* parcel, const int32_t* arrayData, size_t length) __INTRODUCED_IN(29); /** * Writes an array of uint32_t to the next location in a non-null parcel. + * + * \param parcel the parcel to write to. + * \param arrayData an array of size 'length'. + * \param length the length of arrayData. + * + * \return STATUS_OK on successful write. */ -binder_status_t AParcel_writeUint32Array(AParcel* parcel, const uint32_t* value, size_t length) +binder_status_t AParcel_writeUint32Array(AParcel* parcel, const uint32_t* arrayData, size_t length) __INTRODUCED_IN(29); /** * Writes an array of int64_t to the next location in a non-null parcel. + * + * \param parcel the parcel to write to. + * \param arrayData an array of size 'length'. + * \param length the length of arrayData. + * + * \return STATUS_OK on successful write. */ -binder_status_t AParcel_writeInt64Array(AParcel* parcel, const int64_t* value, size_t length) +binder_status_t AParcel_writeInt64Array(AParcel* parcel, const int64_t* arrayData, size_t length) __INTRODUCED_IN(29); /** * Writes an array of uint64_t to the next location in a non-null parcel. + * + * \param parcel the parcel to write to. + * \param arrayData an array of size 'length'. + * \param length the length of arrayData. + * + * \return STATUS_OK on successful write. */ -binder_status_t AParcel_writeUint64Array(AParcel* parcel, const uint64_t* value, size_t length) +binder_status_t AParcel_writeUint64Array(AParcel* parcel, const uint64_t* arrayData, size_t length) __INTRODUCED_IN(29); /** * Writes an array of float to the next location in a non-null parcel. + * + * \param parcel the parcel to write to. + * \param arrayData an array of size 'length'. + * \param length the length of arrayData. + * + * \return STATUS_OK on successful write. */ -binder_status_t AParcel_writeFloatArray(AParcel* parcel, const float* value, size_t length) +binder_status_t AParcel_writeFloatArray(AParcel* parcel, const float* arrayData, size_t length) __INTRODUCED_IN(29); /** * Writes an array of double to the next location in a non-null parcel. + * + * \param parcel the parcel to write to. + * \param arrayData an array of size 'length'. + * \param length the length of arrayData. + * + * \return STATUS_OK on successful write. */ -binder_status_t AParcel_writeDoubleArray(AParcel* parcel, const double* value, size_t length) +binder_status_t AParcel_writeDoubleArray(AParcel* parcel, const double* arrayData, size_t length) __INTRODUCED_IN(29); /** @@ -431,20 +707,39 @@ binder_status_t AParcel_writeDoubleArray(AParcel* parcel, const double* value, s * * getter(arrayData, i) will be called for each i in [0, length) in order to get the underlying * values to write to the parcel. + * + * \param parcel the parcel to write to. + * \param arrayData some external representation of an array. + * \param length the length of arrayData. + * \param getter the callback to retrieve data at specific locations in the array. + * + * \return STATUS_OK on successful write. */ binder_status_t AParcel_writeBoolArray(AParcel* parcel, const void* arrayData, size_t length, AParcel_boolArrayGetter getter) __INTRODUCED_IN(29); /** * Writes an array of char16_t to the next location in a non-null parcel. + * + * \param parcel the parcel to write to. + * \param arrayData an array of size 'length'. + * \param length the length of arrayData. + * + * \return STATUS_OK on successful write. */ -binder_status_t AParcel_writeCharArray(AParcel* parcel, const char16_t* value, size_t length) +binder_status_t AParcel_writeCharArray(AParcel* parcel, const char16_t* arrayData, size_t length) __INTRODUCED_IN(29); /** * Writes an array of int8_t to the next location in a non-null parcel. + * + * \param parcel the parcel to write to. + * \param arrayData an array of size 'length'. + * \param length the length of arrayData. + * + * \return STATUS_OK on successful write. */ -binder_status_t AParcel_writeByteArray(AParcel* parcel, const int8_t* value, size_t length) +binder_status_t AParcel_writeByteArray(AParcel* parcel, const int8_t* arrayData, size_t length) __INTRODUCED_IN(29); /** @@ -453,6 +748,12 @@ binder_status_t AParcel_writeByteArray(AParcel* parcel, const int8_t* value, siz * 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 + * + * \param parcel the parcel to read from. + * \param arrayData some external representation of an array. + * \param allocator the callback that will be called to allocate the array. + * + * \return STATUS_OK on successful read. */ binder_status_t AParcel_readInt32Array(const AParcel* parcel, void* arrayData, AParcel_int32ArrayAllocator allocator) __INTRODUCED_IN(29); @@ -463,6 +764,12 @@ binder_status_t AParcel_readInt32Array(const AParcel* parcel, void* arrayData, * 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 + * + * \param parcel the parcel to read from. + * \param arrayData some external representation of an array. + * \param allocator the callback that will be called to allocate the array. + * + * \return STATUS_OK on successful read. */ binder_status_t AParcel_readUint32Array(const AParcel* parcel, void* arrayData, AParcel_uint32ArrayAllocator allocator) __INTRODUCED_IN(29); @@ -473,6 +780,12 @@ binder_status_t AParcel_readUint32Array(const AParcel* parcel, void* arrayData, * 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 + * + * \param parcel the parcel to read from. + * \param arrayData some external representation of an array. + * \param allocator the callback that will be called to allocate the array. + * + * \return STATUS_OK on successful read. */ binder_status_t AParcel_readInt64Array(const AParcel* parcel, void* arrayData, AParcel_int64ArrayAllocator allocator) __INTRODUCED_IN(29); @@ -483,6 +796,12 @@ binder_status_t AParcel_readInt64Array(const AParcel* parcel, void* arrayData, * 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 + * + * \param parcel the parcel to read from. + * \param arrayData some external representation of an array. + * \param allocator the callback that will be called to allocate the array. + * + * \return STATUS_OK on successful read. */ binder_status_t AParcel_readUint64Array(const AParcel* parcel, void* arrayData, AParcel_uint64ArrayAllocator allocator) __INTRODUCED_IN(29); @@ -493,6 +812,12 @@ binder_status_t AParcel_readUint64Array(const AParcel* parcel, void* arrayData, * 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 + * + * \param parcel the parcel to read from. + * \param arrayData some external representation of an array. + * \param allocator the callback that will be called to allocate the array. + * + * \return STATUS_OK on successful read. */ binder_status_t AParcel_readFloatArray(const AParcel* parcel, void* arrayData, AParcel_floatArrayAllocator allocator) __INTRODUCED_IN(29); @@ -503,6 +828,12 @@ binder_status_t AParcel_readFloatArray(const AParcel* parcel, void* arrayData, * 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 + * + * \param parcel the parcel to read from. + * \param arrayData some external representation of an array. + * \param allocator the callback that will be called to allocate the array. + * + * \return STATUS_OK on successful read. */ binder_status_t AParcel_readDoubleArray(const AParcel* parcel, void* arrayData, AParcel_doubleArrayAllocator allocator) __INTRODUCED_IN(29); @@ -512,6 +843,14 @@ binder_status_t AParcel_readDoubleArray(const AParcel* parcel, void* arrayData, * * 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. + * + * \param parcel the parcel to read from. + * \param arrayData some external representation of an array. + * \param allocator the callback that will be called to allocate the array. + * \param setter the callback that will be called to set a value at a specific location in the + * array. + * + * \return STATUS_OK on successful read. */ binder_status_t AParcel_readBoolArray(const AParcel* parcel, void* arrayData, AParcel_boolArrayAllocator allocator, @@ -523,6 +862,12 @@ binder_status_t AParcel_readBoolArray(const AParcel* parcel, void* arrayData, * 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 + * + * \param parcel the parcel to read from. + * \param arrayData some external representation of an array. + * \param allocator the callback that will be called to allocate the array. + * + * \return STATUS_OK on successful read. */ binder_status_t AParcel_readCharArray(const AParcel* parcel, void* arrayData, AParcel_charArrayAllocator allocator) __INTRODUCED_IN(29); @@ -533,13 +878,19 @@ binder_status_t AParcel_readCharArray(const AParcel* parcel, void* arrayData, * 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 + * + * \param parcel the parcel to read from. + * \param arrayData some external representation of an array. + * \param allocator the callback that will be called to allocate the array. + * + * \return STATUS_OK on successful read. */ binder_status_t AParcel_readByteArray(const AParcel* parcel, void* arrayData, AParcel_byteArrayAllocator allocator) __INTRODUCED_IN(29); // @END-PRIMITIVE-READ-WRITE -#endif //__ANDROID_API__ >= __ANDROID_API_Q__ +#endif //__ANDROID_API__ >= __ANDROID_API_Q__ __END_DECLS /** @} */ diff --git a/libs/binder/ndk/include_ndk/android/binder_parcel_utils.h b/libs/binder/ndk/include_ndk/android/binder_parcel_utils.h index 3fcb1216db..2ccbe5a306 100644 --- a/libs/binder/ndk/include_ndk/android/binder_parcel_utils.h +++ b/libs/binder/ndk/include_ndk/android/binder_parcel_utils.h @@ -28,8 +28,6 @@ #include <android/binder_parcel.h> -#ifdef __cplusplus - #include <string> #include <vector> @@ -298,6 +296,9 @@ static inline binder_status_t AParcel_readVector(const AParcel* parcel, AParcel_stdVectorStringElementAllocator); } +/** + * Convenience API for writing the size of a vector. + */ template <typename T> static inline binder_status_t AParcel_writeVectorSize(AParcel* parcel, const std::vector<T>& vec) { if (vec.size() > INT32_MAX) { @@ -307,6 +308,9 @@ static inline binder_status_t AParcel_writeVectorSize(AParcel* parcel, const std return AParcel_writeInt32(parcel, static_cast<int32_t>(vec.size())); } +/** + * Convenience API for resizing a vector. + */ template <typename T> static inline binder_status_t AParcel_resizeVector(const AParcel* parcel, std::vector<T>* vec) { int32_t size; @@ -319,8 +323,6 @@ static inline binder_status_t AParcel_resizeVector(const AParcel* parcel, std::v return STATUS_OK; } -} // namespace ndk - -#endif // __cplusplus +} // namespace ndk /** @} */ diff --git a/libs/binder/ndk/include_ndk/android/binder_status.h b/libs/binder/ndk/include_ndk/android/binder_status.h index 2d8b7fa095..2671b9b6fc 100644 --- a/libs/binder/ndk/include_ndk/android/binder_status.h +++ b/libs/binder/ndk/include_ndk/android/binder_status.h @@ -35,7 +35,7 @@ __BEGIN_DECLS enum { STATUS_OK = 0, - STATUS_UNKNOWN_ERROR = (-2147483647 - 1), // INT32_MIN value + STATUS_UNKNOWN_ERROR = (-2147483647 - 1), // INT32_MIN value STATUS_NO_MEMORY = -ENOMEM, STATUS_INVALID_OPERATION = -ENOSYS, STATUS_BAD_VALUE = -EINVAL, @@ -95,24 +95,39 @@ typedef int32_t binder_exception_t; * along with service specific errors. * * It is not required to be used in order to parcel/receive transactions, but it is required in - * order to be compatible with standard AIDL transactions. + * order to be compatible with standard AIDL transactions since it is written as the header to the + * out parcel for transactions which get executed (don't fail during unparceling of input arguments + * or sooner). */ struct AStatus; typedef struct AStatus AStatus; /** * New status which is considered a success. + * + * \return a newly constructed status object that the caller owns. */ __attribute__((warn_unused_result)) AStatus* AStatus_newOk() __INTRODUCED_IN(29); /** * New status with exception code. + * + * \param exception the code that this status should represent. If this is EX_NONE, then this + * constructs an non-error status object. + * + * \return a newly constructed status object that the caller owns. */ __attribute__((warn_unused_result)) AStatus* AStatus_fromExceptionCode(binder_exception_t exception) __INTRODUCED_IN(29); /** * New status with exception code and message. + * + * \param exception the code that this status should represent. If this is EX_NONE, then this + * constructs an non-error status object. + * \param message the error message to associate with this status object. + * + * \return a newly constructed status object that the caller owns. */ __attribute__((warn_unused_result)) AStatus* AStatus_fromExceptionCodeWithMessage( binder_exception_t exception, const char* message) __INTRODUCED_IN(29); @@ -121,6 +136,10 @@ __attribute__((warn_unused_result)) AStatus* AStatus_fromExceptionCodeWithMessag * New status with a service speciic error. * * This is considered to be EX_TRANSACTION_FAILED with extra information. + * + * \param serviceSpecific an implementation defined error code. + * + * \return a newly constructed status object that the caller owns. */ __attribute__((warn_unused_result)) AStatus* AStatus_fromServiceSpecificError( int32_t serviceSpecific) __INTRODUCED_IN(29); @@ -129,6 +148,11 @@ __attribute__((warn_unused_result)) AStatus* AStatus_fromServiceSpecificError( * New status with a service specific error and message. * * This is considered to be EX_TRANSACTION_FAILED with extra information. + * + * \param serviceSpecific an implementation defined error code. + * \param message the error message to associate with this status object. + * + * \return a newly constructed status object that the caller owns. */ __attribute__((warn_unused_result)) AStatus* AStatus_fromServiceSpecificErrorWithMessage( int32_t serviceSpecific, const char* message) __INTRODUCED_IN(29); @@ -137,6 +161,10 @@ __attribute__((warn_unused_result)) AStatus* AStatus_fromServiceSpecificErrorWit * 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. + * + * \param a low-level error to associate with this status object. + * + * \return a newly constructed status object that the caller owns. */ __attribute__((warn_unused_result)) AStatus* AStatus_fromStatus(binder_status_t status) __INTRODUCED_IN(29); @@ -144,11 +172,19 @@ __attribute__((warn_unused_result)) AStatus* AStatus_fromStatus(binder_status_t /** * Whether this object represents a successful transaction. If this function returns true, then * AStatus_getExceptionCode will return EX_NONE. + * + * \param status the status being queried. + * + * \return whether the status represents a successful transaction. For more details, see below. */ bool AStatus_isOk(const AStatus* status) __INTRODUCED_IN(29); /** * The exception that this status object represents. + * + * \param status the status being queried. + * + * \return the exception code that this object represents. */ binder_exception_t AStatus_getExceptionCode(const AStatus* status) __INTRODUCED_IN(29); @@ -157,6 +193,10 @@ binder_exception_t AStatus_getExceptionCode(const AStatus* status) __INTRODUCED_ * 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. + * + * \param status the status being queried. + * + * \return the service-specific error code if the exception code is EX_SERVICE_SPECIFIC or 0. */ int32_t AStatus_getServiceSpecificError(const AStatus* status) __INTRODUCED_IN(29); @@ -165,6 +205,10 @@ int32_t AStatus_getServiceSpecificError(const AStatus* status) __INTRODUCED_IN(2 * 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. + * + * \param status the status being queried. + * + * \return the status code if the exception code is EX_TRANSACTION_FAILED or 0. */ binder_status_t AStatus_getStatus(const AStatus* status) __INTRODUCED_IN(29); @@ -173,15 +217,21 @@ binder_status_t AStatus_getStatus(const AStatus* status) __INTRODUCED_IN(29); * message, this will return an empty string. * * The returned string has the lifetime of the status object passed into this function. + * + * \param status the status being queried. + * + * \return the message associated with this error. */ const char* AStatus_getMessage(const AStatus* status) __INTRODUCED_IN(29); /** * Deletes memory associated with the status instance. + * + * \param status the status to delete, returned from AStatus_newOk or one of the AStatus_from* APIs. */ void AStatus_delete(AStatus* status) __INTRODUCED_IN(29); -#endif //__ANDROID_API__ >= __ANDROID_API_Q__ +#endif //__ANDROID_API__ >= __ANDROID_API_Q__ __END_DECLS /** @} */ diff --git a/libs/binder/ndk/parcel.cpp b/libs/binder/ndk/parcel.cpp index 3b44a622ce..8e5b4776e3 100644 --- a/libs/binder/ndk/parcel.cpp +++ b/libs/binder/ndk/parcel.cpp @@ -332,8 +332,8 @@ binder_status_t AParcel_writeStringArray(AParcel* parcel, const void* arrayData, // This implements AParcel_stringAllocator for a string using an array, index, and element // allocator. struct StringArrayElementAllocationAdapter { - void* arrayData; // stringData from the NDK - size_t index; // index into the string array + void* arrayData; // stringData from the NDK + size_t index; // index into the string array AParcel_stringArrayElementAllocator elementAllocator; static char* Allocator(void* stringData, size_t length) { @@ -463,28 +463,30 @@ binder_status_t AParcel_readByte(const AParcel* parcel, int8_t* value) { return PruneStatusT(status); } -binder_status_t AParcel_writeInt32Array(AParcel* parcel, const int32_t* value, size_t length) { - return WriteArray<int32_t>(parcel, value, length); +binder_status_t AParcel_writeInt32Array(AParcel* parcel, const int32_t* arrayData, size_t length) { + return WriteArray<int32_t>(parcel, arrayData, length); } -binder_status_t AParcel_writeUint32Array(AParcel* parcel, const uint32_t* value, size_t length) { - return WriteArray<uint32_t>(parcel, value, length); +binder_status_t AParcel_writeUint32Array(AParcel* parcel, const uint32_t* arrayData, + size_t length) { + return WriteArray<uint32_t>(parcel, arrayData, length); } -binder_status_t AParcel_writeInt64Array(AParcel* parcel, const int64_t* value, size_t length) { - return WriteArray<int64_t>(parcel, value, length); +binder_status_t AParcel_writeInt64Array(AParcel* parcel, const int64_t* arrayData, size_t length) { + return WriteArray<int64_t>(parcel, arrayData, length); } -binder_status_t AParcel_writeUint64Array(AParcel* parcel, const uint64_t* value, size_t length) { - return WriteArray<uint64_t>(parcel, value, length); +binder_status_t AParcel_writeUint64Array(AParcel* parcel, const uint64_t* arrayData, + size_t length) { + return WriteArray<uint64_t>(parcel, arrayData, length); } -binder_status_t AParcel_writeFloatArray(AParcel* parcel, const float* value, size_t length) { - return WriteArray<float>(parcel, value, length); +binder_status_t AParcel_writeFloatArray(AParcel* parcel, const float* arrayData, size_t length) { + return WriteArray<float>(parcel, arrayData, length); } -binder_status_t AParcel_writeDoubleArray(AParcel* parcel, const double* value, size_t length) { - return WriteArray<double>(parcel, value, length); +binder_status_t AParcel_writeDoubleArray(AParcel* parcel, const double* arrayData, size_t length) { + return WriteArray<double>(parcel, arrayData, length); } binder_status_t AParcel_writeBoolArray(AParcel* parcel, const void* arrayData, size_t length, @@ -492,12 +494,12 @@ binder_status_t AParcel_writeBoolArray(AParcel* parcel, const void* arrayData, s return WriteArray<bool>(parcel, arrayData, length, getter, &Parcel::writeBool); } -binder_status_t AParcel_writeCharArray(AParcel* parcel, const char16_t* value, size_t length) { - return WriteArray<char16_t>(parcel, value, length); +binder_status_t AParcel_writeCharArray(AParcel* parcel, const char16_t* arrayData, size_t length) { + return WriteArray<char16_t>(parcel, arrayData, length); } -binder_status_t AParcel_writeByteArray(AParcel* parcel, const int8_t* value, size_t length) { - return WriteArray<int8_t>(parcel, value, length); +binder_status_t AParcel_writeByteArray(AParcel* parcel, const int8_t* arrayData, size_t length) { + return WriteArray<int8_t>(parcel, arrayData, length); } binder_status_t AParcel_readInt32Array(const AParcel* parcel, void* arrayData, diff --git a/libs/binder/ndk/parcel_internal.h b/libs/binder/ndk/parcel_internal.h index d69971fdb6..f29230905a 100644 --- a/libs/binder/ndk/parcel_internal.h +++ b/libs/binder/ndk/parcel_internal.h @@ -29,7 +29,7 @@ struct AParcel { AParcel(const AIBinder* binder) : AParcel(binder, new ::android::Parcel, true /*owns*/) {} AParcel(const AIBinder* binder, ::android::Parcel* parcel, bool owns) - : mBinder(binder), mParcel(parcel), mOwns(owns) {} + : mBinder(binder), mParcel(parcel), mOwns(owns) {} ~AParcel() { if (mOwns) { @@ -43,7 +43,7 @@ struct AParcel { const AIBinder* getBinder() { return mBinder; } -private: + private: // This object is associated with a calls to a specific AIBinder object. This is used for sanity // checking to make sure that a parcel is one that is expected. const AIBinder* mBinder; diff --git a/libs/binder/ndk/scripts/gen_parcel_helper.py b/libs/binder/ndk/scripts/gen_parcel_helper.py index 0e10220496..bb762540e4 100755 --- a/libs/binder/ndk/scripts/gen_parcel_helper.py +++ b/libs/binder/ndk/scripts/gen_parcel_helper.py @@ -69,6 +69,11 @@ def main(): for pretty, cpp in data_types: header += "/**\n" header += " * Writes " + cpp + " value to the next location in a non-null parcel.\n" + header += " *\n" + header += " * \\param parcel the parcel to write to.\n" + header += " * \\param value the value to write to the parcel.\n" + header += " *\n" + header += " * \\return STATUS_OK on successful write.\n" header += " */\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" @@ -79,6 +84,11 @@ def main(): for pretty, cpp in data_types: header += "/**\n" header += " * Reads into " + cpp + " value from the next location in a non-null parcel.\n" + header += " *\n" + header += " * \\param parcel the parcel to read from.\n" + header += " * \\param value the value to read from the parcel.\n" + header += " *\n" + header += " * \\return STATUS_OK on successful read.\n" header += " */\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" @@ -89,9 +99,9 @@ def main(): for pretty, cpp in data_types: nca = pretty in non_contiguously_addressable - arg_types = "const " + cpp + "* value, size_t length" + arg_types = "const " + cpp + "* arrayData, size_t length" if nca: arg_types = "const void* arrayData, size_t length, AParcel_" + pretty.lower() + "ArrayGetter getter" - args = "value, length" + args = "arrayData, length" if nca: args = "arrayData, length, getter, &Parcel::write" + pretty header += "/**\n" @@ -100,6 +110,17 @@ def main(): header += " *\n" header += " * getter(arrayData, i) will be called for each i in [0, length) in order to get the underlying values to write " header += "to the parcel.\n" + header += " *\n" + header += " * \\param parcel the parcel to write to.\n" + if nca: + header += " * \\param arrayData some external representation of an array.\n" + header += " * \\param length the length of arrayData.\n" + header += " * \\param getter the callback to retrieve data at specific locations in the array.\n" + else: + header += " * \\param arrayData an array of size 'length'.\n" + header += " * \\param length the length of arrayData.\n" + header += " *\n" + header += " * \\return STATUS_OK on successful write.\n" header += " */\n" header += "binder_status_t AParcel_write" + pretty + "Array(AParcel* parcel, " + arg_types + ") __INTRODUCED_IN(29);\n\n" source += "binder_status_t AParcel_write" + pretty + "Array(AParcel* parcel, " + arg_types + ") {\n" @@ -121,6 +142,11 @@ def main(): pre_header += "a success.\n" pre_header += " *\n" pre_header += " * See also " + read_func + "\n" + pre_header += " *\n" + pre_header += " * \\param arrayData some external representation of an array of " + cpp + ".\n" + pre_header += " * \\param length the length to allocate arrayData to.\n" + pre_header += " *\n" + pre_header += " * \\return whether the allocation succeeded.\n" pre_header += " */\n" pre_header += "typedef bool (*" + allocator_type + ")(void* arrayData, size_t length);\n\n" @@ -128,6 +154,11 @@ def main(): pre_header += " * This is called to get the underlying data from an arrayData object at index.\n" pre_header += " *\n" pre_header += " * See also " + write_func + "\n" + pre_header += " *\n" + pre_header += " * \\param arrayData some external representation of an array of " + cpp + ".\n" + pre_header += " * \\param index the index of the value to be retrieved.\n" + pre_header += " *\n" + pre_header += " * \\return the value of the array at index index.\n" pre_header += " */\n" pre_header += "typedef " + cpp + " (*" + getter_type + ")(const void* arrayData, size_t index);\n\n" @@ -135,6 +166,10 @@ def main(): pre_header += " * This is called to set an underlying value in an arrayData object at index.\n" pre_header += " *\n" pre_header += " * See also " + read_func + "\n" + pre_header += " *\n" + pre_header += " * \\param arrayData some external representation of an array of " + cpp + ".\n" + pre_header += " * \\param index the index of the value to be set.\n" + pre_header += " * \\param value the value to set at index index.\n" pre_header += " */\n" pre_header += "typedef void (*" + setter_type + ")(void* arrayData, size_t index, " + cpp + " value);\n\n" else: @@ -146,6 +181,11 @@ def main(): pre_header += "returned.\n" pre_header += " *\n" pre_header += " * See also " + read_func + "\n" + pre_header += " *\n" + pre_header += " * \\param arrayData some external representation of an array of " + cpp + ".\n" + pre_header += " * \\param length the length to allocate arrayData to.\n" + pre_header += " *\n" + pre_header += " * \\return a buffer of " + cpp + " of size 'length'.\n" pre_header += " */\n" pre_header += "typedef " + cpp + "* (*" + allocator_type + ")(void* arrayData, size_t length);\n\n" @@ -166,6 +206,14 @@ def main(): else: header += " * First, allocator will be called with the length of the array. If the allocation succeeds and the " header += "length is greater than zero, the buffer returned by the allocator will be filled with the corresponding data\n" + header += " *\n" + header += " * \\param parcel the parcel to read from.\n" + header += " * \\param arrayData some external representation of an array.\n" + header += " * \\param allocator the callback that will be called to allocate the array.\n" + if nca: + header += " * \\param setter the callback that will be called to set a value at a specific location in the array.\n" + header += " *\n" + header += " * \\return STATUS_OK on successful read.\n" header += " */\n" header += "binder_status_t " + read_func + "(" + read_type_args + ") __INTRODUCED_IN(29);\n\n" source += "binder_status_t " + read_func + "(" + read_type_args + ") {\n" diff --git a/libs/binder/ndk/status_internal.h b/libs/binder/ndk/status_internal.h index 8c32baf83f..d39f0d887c 100644 --- a/libs/binder/ndk/status_internal.h +++ b/libs/binder/ndk/status_internal.h @@ -22,13 +22,13 @@ #include <utils/Errors.h> struct AStatus { - AStatus() {} // ok + AStatus() {} // ok AStatus(::android::binder::Status&& status) : mStatus(std::move(status)) {} ::android::binder::Status* get() { return &mStatus; } const ::android::binder::Status* get() const { return &mStatus; } -private: + private: ::android::binder::Status mStatus; }; diff --git a/libs/binder/ndk/test/iface.cpp b/libs/binder/ndk/test/iface.cpp index 0dc3cc4f95..d46fde82e3 100644 --- a/libs/binder/ndk/test/iface.cpp +++ b/libs/binder/ndk/test/iface.cpp @@ -64,7 +64,7 @@ AIBinder_Class* IFoo::kClass = AIBinder_Class_define(kIFooDescriptor, IFoo_Class IFoo_Class_onDestroy, IFoo_Class_onTransact); class BpFoo : public IFoo { -public: + public: BpFoo(AIBinder* binder) : mBinder(binder) {} virtual ~BpFoo() { AIBinder_decStrong(mBinder); } @@ -86,7 +86,7 @@ public: return out; } -private: + private: // Always assumes one refcount AIBinder* mBinder; }; @@ -118,7 +118,7 @@ binder_status_t IFoo::addService(const char* instance) { } sp<IFoo> IFoo::getService(const char* instance) { - AIBinder* binder = AServiceManager_getService(instance); // maybe nullptr + AIBinder* binder = AServiceManager_getService(instance); // maybe nullptr if (binder == nullptr) { return nullptr; } @@ -129,13 +129,13 @@ sp<IFoo> IFoo::getService(const char* instance) { } if (AIBinder_isRemote(binder)) { - sp<IFoo> ret = new BpFoo(binder); // takes ownership of binder + sp<IFoo> ret = new BpFoo(binder); // takes ownership of binder return ret; } IFoo_Class_Data* data = static_cast<IFoo_Class_Data*>(AIBinder_getUserData(binder)); - CHECK(data != nullptr); // always created with non-null data + CHECK(data != nullptr); // always created with non-null data sp<IFoo> ret = data->foo; diff --git a/libs/binder/ndk/test/include/iface/iface.h b/libs/binder/ndk/test/include/iface/iface.h index 4c61e9d849..25f51887bc 100644 --- a/libs/binder/ndk/test/include/iface/iface.h +++ b/libs/binder/ndk/test/include/iface/iface.h @@ -20,7 +20,7 @@ #include <utils/RefBase.h> class IFoo : public virtual ::android::RefBase { -public: + public: static const char* kSomeInstanceName; static AIBinder_Class* kClass; @@ -35,6 +35,6 @@ public: virtual ~IFoo(); virtual int32_t doubleNumber(int32_t in) = 0; -private: - AIBinder_Weak* mWeakBinder = nullptr; // maybe owns AIBinder + private: + AIBinder_Weak* mWeakBinder = nullptr; // maybe owns AIBinder }; diff --git a/libs/binder/ndk/test/main_client.cpp b/libs/binder/ndk/test/main_client.cpp index 6945cac015..507daa29af 100644 --- a/libs/binder/ndk/test/main_client.cpp +++ b/libs/binder/ndk/test/main_client.cpp @@ -52,7 +52,7 @@ void OnBinderDeath(void* cookie) { } TEST(NdkBinder, LinkToDeath) { - ABinderProcess_setThreadPoolMaxThreadCount(1); // to recieve death notifications + ABinderProcess_setThreadPoolMaxThreadCount(1); // to recieve death notifications ABinderProcess_startThreadPool(); AIBinder* binder = AServiceManager_getService(kExistingNonNdkService); |