diff options
| author | 2018-09-04 13:29:55 -0700 | |
|---|---|---|
| committer | 2018-09-04 13:33:18 -0700 | |
| commit | 5ea54dab99550e00fdc80cd1e8bb2a07c95f4014 (patch) | |
| tree | f1e63445de7cb0f9d9f2bd7156392b321f683933 | |
| parent | 71cddc3c7f8a6bf6791643598e80b6f76bbef475 (diff) | |
libbinder_ndk: make AIBinder_isRemote const.
It's a C function, so it is not const, but it now takes a const
AIBinder object.
There isn't a way to do a check on a const IBinder if it is remote. We
could store the isRemote status as a member of AIBinder to avoid this,
but this would be wasted space. A const isRemote method can't be added
to IBinder for legacy reasons.
Bug: 111445392
Test: ./ndk/runtests.sh
Change-Id: I72df61e429e06e24dcffd4158447670ec1b41d7a
| -rw-r--r-- | libs/binder/ndk/AIBinder.cpp | 2 | ||||
| -rw-r--r-- | libs/binder/ndk/AIBinder_internal.h | 5 | ||||
| -rw-r--r-- | libs/binder/ndk/include_ndk/android/binder_ibinder.h | 2 |
3 files changed, 6 insertions, 3 deletions
diff --git a/libs/binder/ndk/AIBinder.cpp b/libs/binder/ndk/AIBinder.cpp index fe07914c04..f452511b70 100644 --- a/libs/binder/ndk/AIBinder.cpp +++ b/libs/binder/ndk/AIBinder.cpp @@ -183,7 +183,7 @@ AIBinder* AIBinder_new(const AIBinder_Class* clazz, void* args) { return ret.get(); } -bool AIBinder_isRemote(AIBinder* binder) { +bool AIBinder_isRemote(const AIBinder* binder) { if (binder == nullptr) { return true; } diff --git a/libs/binder/ndk/AIBinder_internal.h b/libs/binder/ndk/AIBinder_internal.h index ed3b37b9f2..23949bb034 100644 --- a/libs/binder/ndk/AIBinder_internal.h +++ b/libs/binder/ndk/AIBinder_internal.h @@ -42,7 +42,10 @@ struct AIBinder : public virtual ::android::RefBase { virtual ABBinder* asABBinder() { return nullptr; } virtual ABpBinder* asABpBinder() { return nullptr; } - bool isRemote() { return getBinder()->remoteBinder() != nullptr; } + bool isRemote() const { + ::android::sp<::android::IBinder> binder = const_cast<AIBinder*>(this)->getBinder(); + return binder->remoteBinder() != nullptr; + } private: // AIBinder instance is instance of this class for a local object. In order to transact on a diff --git a/libs/binder/ndk/include_ndk/android/binder_ibinder.h b/libs/binder/ndk/include_ndk/android/binder_ibinder.h index fb82ab6ba9..2f88779267 100644 --- a/libs/binder/ndk/include_ndk/android/binder_ibinder.h +++ b/libs/binder/ndk/include_ndk/android/binder_ibinder.h @@ -144,7 +144,7 @@ __attribute__((warn_unused_result)) AIBinder* AIBinder_new(const AIBinder_Class* /** * If this is hosted in a process other than the current one. */ -bool AIBinder_isRemote(AIBinder* binder); +bool AIBinder_isRemote(const AIBinder* binder); /** * This can only be called if a strong reference to this object already exists in process. |