Loading libs/binder/ndk/include_cpp/android/binder_auto_utils.h +19 −7 Original line number Diff line number Diff line Loading @@ -115,17 +115,29 @@ class SpAIBinder { */ AIBinder** getR() { return &mBinder; } bool operator!=(const SpAIBinder& rhs) const { return get() != rhs.get(); } bool operator<(const SpAIBinder& rhs) const { return get() < rhs.get(); } bool operator<=(const SpAIBinder& rhs) const { return get() <= rhs.get(); } bool operator==(const SpAIBinder& rhs) const { return get() == rhs.get(); } bool operator>(const SpAIBinder& rhs) const { return get() > rhs.get(); } bool operator>=(const SpAIBinder& rhs) const { return get() >= rhs.get(); } private: AIBinder* mBinder = nullptr; }; #define SP_AIBINDER_COMPARE(_op_) \ static inline bool operator _op_(const SpAIBinder& lhs, const SpAIBinder& rhs) { \ return lhs.get() _op_ rhs.get(); \ } \ static inline bool operator _op_(const SpAIBinder& lhs, const AIBinder* rhs) { \ return lhs.get() _op_ rhs; \ } \ static inline bool operator _op_(const AIBinder* lhs, const SpAIBinder& rhs) { \ return lhs _op_ rhs.get(); \ } SP_AIBINDER_COMPARE(!=) SP_AIBINDER_COMPARE(<) SP_AIBINDER_COMPARE(<=) SP_AIBINDER_COMPARE(==) SP_AIBINDER_COMPARE(>) SP_AIBINDER_COMPARE(>=) #undef SP_AIBINDER_COMPARE namespace impl { /** Loading libs/binder/ndk/tests/libbinder_ndk_unit_test.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -761,9 +761,9 @@ TEST(NdkBinder, ConvertToPlatformBinder) { // local ndk::SharedRefBase::make<MyBinderNdkUnitTest>()->asBinder()}) { // convert to platform binder EXPECT_NE(binder.get(), nullptr); EXPECT_NE(binder, nullptr); sp<IBinder> platformBinder = AIBinder_toPlatformBinder(binder.get()); EXPECT_NE(platformBinder.get(), nullptr); EXPECT_NE(platformBinder, nullptr); auto proxy = interface_cast<IBinderNdkUnitTest>(platformBinder); EXPECT_NE(proxy, nullptr); Loading @@ -774,7 +774,7 @@ TEST(NdkBinder, ConvertToPlatformBinder) { // convert back ndk::SpAIBinder backBinder = ndk::SpAIBinder(AIBinder_fromPlatformBinder(platformBinder)); EXPECT_EQ(backBinder.get(), binder.get()); EXPECT_EQ(backBinder, binder); } } Loading Loading
libs/binder/ndk/include_cpp/android/binder_auto_utils.h +19 −7 Original line number Diff line number Diff line Loading @@ -115,17 +115,29 @@ class SpAIBinder { */ AIBinder** getR() { return &mBinder; } bool operator!=(const SpAIBinder& rhs) const { return get() != rhs.get(); } bool operator<(const SpAIBinder& rhs) const { return get() < rhs.get(); } bool operator<=(const SpAIBinder& rhs) const { return get() <= rhs.get(); } bool operator==(const SpAIBinder& rhs) const { return get() == rhs.get(); } bool operator>(const SpAIBinder& rhs) const { return get() > rhs.get(); } bool operator>=(const SpAIBinder& rhs) const { return get() >= rhs.get(); } private: AIBinder* mBinder = nullptr; }; #define SP_AIBINDER_COMPARE(_op_) \ static inline bool operator _op_(const SpAIBinder& lhs, const SpAIBinder& rhs) { \ return lhs.get() _op_ rhs.get(); \ } \ static inline bool operator _op_(const SpAIBinder& lhs, const AIBinder* rhs) { \ return lhs.get() _op_ rhs; \ } \ static inline bool operator _op_(const AIBinder* lhs, const SpAIBinder& rhs) { \ return lhs _op_ rhs.get(); \ } SP_AIBINDER_COMPARE(!=) SP_AIBINDER_COMPARE(<) SP_AIBINDER_COMPARE(<=) SP_AIBINDER_COMPARE(==) SP_AIBINDER_COMPARE(>) SP_AIBINDER_COMPARE(>=) #undef SP_AIBINDER_COMPARE namespace impl { /** Loading
libs/binder/ndk/tests/libbinder_ndk_unit_test.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -761,9 +761,9 @@ TEST(NdkBinder, ConvertToPlatformBinder) { // local ndk::SharedRefBase::make<MyBinderNdkUnitTest>()->asBinder()}) { // convert to platform binder EXPECT_NE(binder.get(), nullptr); EXPECT_NE(binder, nullptr); sp<IBinder> platformBinder = AIBinder_toPlatformBinder(binder.get()); EXPECT_NE(platformBinder.get(), nullptr); EXPECT_NE(platformBinder, nullptr); auto proxy = interface_cast<IBinderNdkUnitTest>(platformBinder); EXPECT_NE(proxy, nullptr); Loading @@ -774,7 +774,7 @@ TEST(NdkBinder, ConvertToPlatformBinder) { // convert back ndk::SpAIBinder backBinder = ndk::SpAIBinder(AIBinder_fromPlatformBinder(platformBinder)); EXPECT_EQ(backBinder.get(), binder.get()); EXPECT_EQ(backBinder, binder); } } Loading