Loading libs/binder/ndk/AIBinder.cpp +23 −0 Original line number Diff line number Diff line Loading @@ -202,6 +202,22 @@ bool AIBinder_isRemote(const AIBinder* binder) { return binder->isRemote(); } bool AIBinder_isAlive(const AIBinder* binder) { if (binder == nullptr) { return false; } return const_cast<AIBinder*>(binder)->getBinder()->isBinderAlive(); } binder_status_t AIBinder_ping(AIBinder* binder) { if (binder == nullptr) { return EX_NULL_POINTER; } return binder->getBinder()->pingBinder(); } void AIBinder_incStrong(AIBinder* binder) { if (binder == nullptr) { LOG(ERROR) << __func__ << ": on null binder"; Loading Loading @@ -269,6 +285,13 @@ binder_status_t AIBinder_prepareTransaction(AIBinder* binder, AParcel** in) { return EX_ILLEGAL_STATE; } if (!binder->isRemote()) { LOG(WARNING) << "A binder object at " << binder << " is being transacted on, however, this object is in the same process as " "its proxy. Transacting with this binder is expensive compared to just " "calling the corresponding functionality in the same process."; } *in = new AParcel(binder); binder_status_t status = (**in)->writeInterfaceToken(clazz->getInterfaceDescriptor()); if (status != EX_NONE) { Loading libs/binder/ndk/include_ndk/android/binder_ibinder.h +19 −3 Original line number Diff line number Diff line Loading @@ -146,6 +146,22 @@ __attribute__((warn_unused_result)) AIBinder* AIBinder_new(const AIBinder_Class* */ bool AIBinder_isRemote(const AIBinder* binder); /** * If this binder is known to be alive. This will not send a transaction to a remote process and * returns a result based on the last known information. That is, whenever a transaction is made, * 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. */ bool AIBinder_isAlive(const AIBinder* binder); /** * 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); /** * This can only be called if a strong reference to this object already exists in process. */ Loading @@ -172,7 +188,7 @@ int32_t AIBinder_debugGetRefCount(AIBinder* binder); */ bool AIBinder_associateClass(AIBinder* binder, const AIBinder_Class* clazz); /* /** * Returns the class that this binder was constructed with or associated with. */ const AIBinder_Class* AIBinder_getClass(AIBinder* binder); Loading Loading @@ -221,13 +237,13 @@ binder_status_t AIBinder_prepareTransaction(AIBinder* binder, AParcel** in); binder_status_t AIBinder_transact(AIBinder* binder, transaction_code_t code, AParcel** in, AParcel** out, binder_flags_t flags); /* /** * 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); /* /** * Deletes the weak reference. This will have no impact on the lifetime of the binder. */ void AIBinder_Weak_delete(AIBinder_Weak** weakBinder); Loading libs/binder/ndk/test/main_client.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,10 @@ TEST(NdkBinder, DoubleNumber) { TEST(NdkBinder, RetrieveNonNdkService) { AIBinder* binder = AServiceManager_getService(kExistingNonNdkService); ASSERT_NE(nullptr, binder); EXPECT_TRUE(AIBinder_isRemote(binder)); EXPECT_TRUE(AIBinder_isAlive(binder)); EXPECT_EQ(EX_NONE, AIBinder_ping(binder)); AIBinder_decStrong(binder); } Loading libs/gui/Android.bp +4 −3 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ cc_library_shared { "-Werror", ], cppflags: [ "-std=c++1z", "-Weverything", // The static constructors and destructors in this library have not been noted to Loading Loading @@ -116,7 +117,7 @@ cc_library_shared { "SyncFeatures.cpp", "view/Surface.cpp", "bufferqueue/1.0/B2HProducerListener.cpp", "bufferqueue/1.0/H2BGraphicBufferProducer.cpp" "bufferqueue/1.0/H2BGraphicBufferProducer.cpp", ], shared_libs: [ Loading libs/gui/ISurfaceComposer.cpp +31 −0 Original line number Diff line number Diff line Loading @@ -558,6 +558,25 @@ public: outLayers->clear(); return reply.readParcelableVector(outLayers); } virtual status_t getCompositionPreference(ui::Dataspace* dataSpace, ui::PixelFormat* pixelFormat) const { Parcel data, reply; status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); if (error != NO_ERROR) { return error; } error = remote()->transact(BnSurfaceComposer::GET_COMPOSITION_PREFERENCE, data, &reply); if (error != NO_ERROR) { return error; } error = static_cast<status_t>(reply.readInt32()); if (error == NO_ERROR) { *dataSpace = static_cast<ui::Dataspace>(reply.readInt32()); *pixelFormat = static_cast<ui::PixelFormat>(reply.readInt32()); } return error; } }; // Out-of-line virtual method definition to trigger vtable emission in this Loading Loading @@ -881,6 +900,18 @@ status_t BnSurfaceComposer::onTransact( } return result; } case GET_COMPOSITION_PREFERENCE: { CHECK_INTERFACE(ISurfaceComposer, data, reply); ui::Dataspace dataSpace; ui::PixelFormat pixelFormat; status_t error = getCompositionPreference(&dataSpace, &pixelFormat); reply->writeInt32(error); if (error == NO_ERROR) { reply->writeInt32(static_cast<int32_t>(dataSpace)); reply->writeInt32(static_cast<int32_t>(pixelFormat)); } return NO_ERROR; } default: { return BBinder::onTransact(code, data, reply, flags); } Loading Loading
libs/binder/ndk/AIBinder.cpp +23 −0 Original line number Diff line number Diff line Loading @@ -202,6 +202,22 @@ bool AIBinder_isRemote(const AIBinder* binder) { return binder->isRemote(); } bool AIBinder_isAlive(const AIBinder* binder) { if (binder == nullptr) { return false; } return const_cast<AIBinder*>(binder)->getBinder()->isBinderAlive(); } binder_status_t AIBinder_ping(AIBinder* binder) { if (binder == nullptr) { return EX_NULL_POINTER; } return binder->getBinder()->pingBinder(); } void AIBinder_incStrong(AIBinder* binder) { if (binder == nullptr) { LOG(ERROR) << __func__ << ": on null binder"; Loading Loading @@ -269,6 +285,13 @@ binder_status_t AIBinder_prepareTransaction(AIBinder* binder, AParcel** in) { return EX_ILLEGAL_STATE; } if (!binder->isRemote()) { LOG(WARNING) << "A binder object at " << binder << " is being transacted on, however, this object is in the same process as " "its proxy. Transacting with this binder is expensive compared to just " "calling the corresponding functionality in the same process."; } *in = new AParcel(binder); binder_status_t status = (**in)->writeInterfaceToken(clazz->getInterfaceDescriptor()); if (status != EX_NONE) { Loading
libs/binder/ndk/include_ndk/android/binder_ibinder.h +19 −3 Original line number Diff line number Diff line Loading @@ -146,6 +146,22 @@ __attribute__((warn_unused_result)) AIBinder* AIBinder_new(const AIBinder_Class* */ bool AIBinder_isRemote(const AIBinder* binder); /** * If this binder is known to be alive. This will not send a transaction to a remote process and * returns a result based on the last known information. That is, whenever a transaction is made, * 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. */ bool AIBinder_isAlive(const AIBinder* binder); /** * 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); /** * This can only be called if a strong reference to this object already exists in process. */ Loading @@ -172,7 +188,7 @@ int32_t AIBinder_debugGetRefCount(AIBinder* binder); */ bool AIBinder_associateClass(AIBinder* binder, const AIBinder_Class* clazz); /* /** * Returns the class that this binder was constructed with or associated with. */ const AIBinder_Class* AIBinder_getClass(AIBinder* binder); Loading Loading @@ -221,13 +237,13 @@ binder_status_t AIBinder_prepareTransaction(AIBinder* binder, AParcel** in); binder_status_t AIBinder_transact(AIBinder* binder, transaction_code_t code, AParcel** in, AParcel** out, binder_flags_t flags); /* /** * 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); /* /** * Deletes the weak reference. This will have no impact on the lifetime of the binder. */ void AIBinder_Weak_delete(AIBinder_Weak** weakBinder); Loading
libs/binder/ndk/test/main_client.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,10 @@ TEST(NdkBinder, DoubleNumber) { TEST(NdkBinder, RetrieveNonNdkService) { AIBinder* binder = AServiceManager_getService(kExistingNonNdkService); ASSERT_NE(nullptr, binder); EXPECT_TRUE(AIBinder_isRemote(binder)); EXPECT_TRUE(AIBinder_isAlive(binder)); EXPECT_EQ(EX_NONE, AIBinder_ping(binder)); AIBinder_decStrong(binder); } Loading
libs/gui/Android.bp +4 −3 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ cc_library_shared { "-Werror", ], cppflags: [ "-std=c++1z", "-Weverything", // The static constructors and destructors in this library have not been noted to Loading Loading @@ -116,7 +117,7 @@ cc_library_shared { "SyncFeatures.cpp", "view/Surface.cpp", "bufferqueue/1.0/B2HProducerListener.cpp", "bufferqueue/1.0/H2BGraphicBufferProducer.cpp" "bufferqueue/1.0/H2BGraphicBufferProducer.cpp", ], shared_libs: [ Loading
libs/gui/ISurfaceComposer.cpp +31 −0 Original line number Diff line number Diff line Loading @@ -558,6 +558,25 @@ public: outLayers->clear(); return reply.readParcelableVector(outLayers); } virtual status_t getCompositionPreference(ui::Dataspace* dataSpace, ui::PixelFormat* pixelFormat) const { Parcel data, reply; status_t error = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); if (error != NO_ERROR) { return error; } error = remote()->transact(BnSurfaceComposer::GET_COMPOSITION_PREFERENCE, data, &reply); if (error != NO_ERROR) { return error; } error = static_cast<status_t>(reply.readInt32()); if (error == NO_ERROR) { *dataSpace = static_cast<ui::Dataspace>(reply.readInt32()); *pixelFormat = static_cast<ui::PixelFormat>(reply.readInt32()); } return error; } }; // Out-of-line virtual method definition to trigger vtable emission in this Loading Loading @@ -881,6 +900,18 @@ status_t BnSurfaceComposer::onTransact( } return result; } case GET_COMPOSITION_PREFERENCE: { CHECK_INTERFACE(ISurfaceComposer, data, reply); ui::Dataspace dataSpace; ui::PixelFormat pixelFormat; status_t error = getCompositionPreference(&dataSpace, &pixelFormat); reply->writeInt32(error); if (error == NO_ERROR) { reply->writeInt32(static_cast<int32_t>(dataSpace)); reply->writeInt32(static_cast<int32_t>(pixelFormat)); } return NO_ERROR; } default: { return BBinder::onTransact(code, data, reply, flags); } Loading