Loading libs/binder/ndk/include_ndk/android/binder_parcel.h +5 −6 Original line number Diff line number Diff line Loading @@ -109,11 +109,11 @@ typedef char* (*AParcel_stringArrayElementAllocator)(void* arrayData, size_t ind * * \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 outLength an out parameter for the length of the string at the specified index. This * should not include the length for a null-terminator if there is one. * * \param a null-terminated buffer of size 'outLength + 1' representing the string at the provided * index including the null-terminator. * \param a buffer of size outLength or more representing the string at the provided index. This is * not required to be null-terminated. */ typedef const char* (*AParcel_stringArrayElementGetter)(const void* arrayData, size_t index, size_t* outLength); Loading Loading @@ -382,8 +382,7 @@ binder_status_t AParcel_readStatusHeader(const AParcel* parcel, AStatus** status * 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 string the null-terminated string to write to the parcel, at least of size 'length'. * \param length the length of the string to be written. * * \return STATUS_OK on successful write. Loading libs/gui/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -107,6 +107,7 @@ cc_library_shared { "IProducerListener.cpp", "ISurfaceComposer.cpp", "ISurfaceComposerClient.cpp", "ITransactionCompletedListener.cpp", "LayerDebugInfo.cpp", "LayerState.cpp", "OccupancyTracker.cpp", Loading libs/gui/ISurfaceComposer.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -634,10 +634,10 @@ status_t BnSurfaceComposer::onTransact( if (count > data.dataSize()) { return BAD_VALUE; } ComposerState s; Vector<ComposerState> state; state.setCapacity(count); for (size_t i = 0; i < count; i++) { ComposerState s; if (s.read(data) == BAD_VALUE) { return BAD_VALUE; } Loading libs/gui/ITransactionCompletedListener.cpp 0 → 100644 +167 −0 Original line number Diff line number Diff line /* * Copyright 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #define LOG_TAG "ITransactionCompletedListener" //#define LOG_NDEBUG 0 #include <gui/ITransactionCompletedListener.h> namespace android { namespace { // Anonymous enum class Tag : uint32_t { ON_TRANSACTION_COMPLETED = IBinder::FIRST_CALL_TRANSACTION, LAST = ON_TRANSACTION_COMPLETED, }; } // Anonymous namespace status_t SurfaceStats::writeToParcel(Parcel* output) const { status_t err = output->writeStrongBinder(surfaceControl); if (err != NO_ERROR) { return err; } err = output->writeInt64(acquireTime); if (err != NO_ERROR) { return err; } return output->writeBool(releasePreviousBuffer); } status_t SurfaceStats::readFromParcel(const Parcel* input) { status_t err = input->readStrongBinder(&surfaceControl); if (err != NO_ERROR) { return err; } err = input->readInt64(&acquireTime); if (err != NO_ERROR) { return err; } return input->readBool(&releasePreviousBuffer); } status_t TransactionStats::writeToParcel(Parcel* output) const { status_t err = output->writeInt64(latchTime); if (err != NO_ERROR) { return err; } err = output->writeInt64(presentTime); if (err != NO_ERROR) { return err; } return output->writeParcelableVector(surfaceStats); } status_t TransactionStats::readFromParcel(const Parcel* input) { status_t err = input->readInt64(&latchTime); if (err != NO_ERROR) { return err; } err = input->readInt64(&presentTime); if (err != NO_ERROR) { return err; } return input->readParcelableVector(&surfaceStats); } status_t ListenerStats::writeToParcel(Parcel* output) const { status_t err = output->writeInt32(static_cast<int32_t>(transactionStats.size())); if (err != NO_ERROR) { return err; } for (const auto& [callbackIds, stats] : transactionStats) { err = output->writeParcelable(stats); if (err != NO_ERROR) { return err; } err = output->writeInt64Vector(callbackIds); if (err != NO_ERROR) { return err; } } return NO_ERROR; } status_t ListenerStats::readFromParcel(const Parcel* input) { int32_t transactionStats_size = input->readInt32(); for (int i = 0; i < transactionStats_size; i++) { TransactionStats stats; std::vector<CallbackId> callbackIds; status_t err = input->readParcelable(&stats); if (err != NO_ERROR) { return err; } err = input->readInt64Vector(&callbackIds); if (err != NO_ERROR) { return err; } transactionStats.emplace(callbackIds, stats); } return NO_ERROR; } ListenerStats ListenerStats::createEmpty(const sp<ITransactionCompletedListener>& listener, const std::unordered_set<CallbackId>& callbackIds) { ListenerStats listenerStats; listenerStats.listener = listener; TransactionStats transactionStats; listenerStats.transactionStats.emplace(std::piecewise_construct, std::forward_as_tuple(callbackIds.begin(), callbackIds.end()), std::forward_as_tuple(transactionStats)); return listenerStats; } class BpTransactionCompletedListener : public SafeBpInterface<ITransactionCompletedListener> { public: explicit BpTransactionCompletedListener(const sp<IBinder>& impl) : SafeBpInterface<ITransactionCompletedListener>(impl, "BpTransactionCompletedListener") { } ~BpTransactionCompletedListener() override; void onTransactionCompleted(ListenerStats stats) override { callRemoteAsync<decltype(&ITransactionCompletedListener:: onTransactionCompleted)>(Tag::ON_TRANSACTION_COMPLETED, stats); } }; // Out-of-line virtual method definitions to trigger vtable emission in this translation unit (see // clang warning -Wweak-vtables) BpTransactionCompletedListener::~BpTransactionCompletedListener() = default; IMPLEMENT_META_INTERFACE(TransactionCompletedListener, "android.gui.ITransactionComposerListener"); status_t BnTransactionCompletedListener::onTransact(uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { if (code < IBinder::FIRST_CALL_TRANSACTION || code > static_cast<uint32_t>(Tag::LAST)) { return BBinder::onTransact(code, data, reply, flags); } auto tag = static_cast<Tag>(code); switch (tag) { case Tag::ON_TRANSACTION_COMPLETED: return callLocalAsync(data, reply, &ITransactionCompletedListener::onTransactionCompleted); } } }; // namespace android libs/gui/LayerState.cpp +19 −0 Original line number Diff line number Diff line Loading @@ -80,6 +80,13 @@ status_t layer_state_t::write(Parcel& output) const memcpy(output.writeInplace(16 * sizeof(float)), colorTransform.asArray(), 16 * sizeof(float)); if (output.writeVectorSize(listenerCallbacks) == NO_ERROR) { for (const auto& [listener, callbackIds] : listenerCallbacks) { output.writeStrongBinder(IInterface::asBinder(listener)); output.writeInt64Vector(callbackIds); } } return NO_ERROR; } Loading Loading @@ -135,6 +142,14 @@ status_t layer_state_t::read(const Parcel& input) colorTransform = mat4(static_cast<const float*>(input.readInplace(16 * sizeof(float)))); int32_t listenersSize = input.readInt32(); for (int32_t i = 0; i < listenersSize; i++) { auto listener = interface_cast<ITransactionCompletedListener>(input.readStrongBinder()); std::vector<CallbackId> callbackIds; input.readInt64Vector(&callbackIds); listenerCallbacks.emplace_back(listener, callbackIds); } return NO_ERROR; } Loading Loading @@ -323,6 +338,10 @@ void layer_state_t::merge(const layer_state_t& other) { what |= eColorTransformChanged; colorTransform = other.colorTransform; } if (other.what & eListenerCallbacksChanged) { what |= eListenerCallbacksChanged; listenerCallbacks = other.listenerCallbacks; } if ((other.what & what) != other.what) { ALOGE("Unmerged SurfaceComposer Transaction properties. LayerState::merge needs updating? " Loading Loading
libs/binder/ndk/include_ndk/android/binder_parcel.h +5 −6 Original line number Diff line number Diff line Loading @@ -109,11 +109,11 @@ typedef char* (*AParcel_stringArrayElementAllocator)(void* arrayData, size_t ind * * \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 outLength an out parameter for the length of the string at the specified index. This * should not include the length for a null-terminator if there is one. * * \param a null-terminated buffer of size 'outLength + 1' representing the string at the provided * index including the null-terminator. * \param a buffer of size outLength or more representing the string at the provided index. This is * not required to be null-terminated. */ typedef const char* (*AParcel_stringArrayElementGetter)(const void* arrayData, size_t index, size_t* outLength); Loading Loading @@ -382,8 +382,7 @@ binder_status_t AParcel_readStatusHeader(const AParcel* parcel, AStatus** status * 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 string the null-terminated string to write to the parcel, at least of size 'length'. * \param length the length of the string to be written. * * \return STATUS_OK on successful write. Loading
libs/gui/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -107,6 +107,7 @@ cc_library_shared { "IProducerListener.cpp", "ISurfaceComposer.cpp", "ISurfaceComposerClient.cpp", "ITransactionCompletedListener.cpp", "LayerDebugInfo.cpp", "LayerState.cpp", "OccupancyTracker.cpp", Loading
libs/gui/ISurfaceComposer.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -634,10 +634,10 @@ status_t BnSurfaceComposer::onTransact( if (count > data.dataSize()) { return BAD_VALUE; } ComposerState s; Vector<ComposerState> state; state.setCapacity(count); for (size_t i = 0; i < count; i++) { ComposerState s; if (s.read(data) == BAD_VALUE) { return BAD_VALUE; } Loading
libs/gui/ITransactionCompletedListener.cpp 0 → 100644 +167 −0 Original line number Diff line number Diff line /* * Copyright 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #define LOG_TAG "ITransactionCompletedListener" //#define LOG_NDEBUG 0 #include <gui/ITransactionCompletedListener.h> namespace android { namespace { // Anonymous enum class Tag : uint32_t { ON_TRANSACTION_COMPLETED = IBinder::FIRST_CALL_TRANSACTION, LAST = ON_TRANSACTION_COMPLETED, }; } // Anonymous namespace status_t SurfaceStats::writeToParcel(Parcel* output) const { status_t err = output->writeStrongBinder(surfaceControl); if (err != NO_ERROR) { return err; } err = output->writeInt64(acquireTime); if (err != NO_ERROR) { return err; } return output->writeBool(releasePreviousBuffer); } status_t SurfaceStats::readFromParcel(const Parcel* input) { status_t err = input->readStrongBinder(&surfaceControl); if (err != NO_ERROR) { return err; } err = input->readInt64(&acquireTime); if (err != NO_ERROR) { return err; } return input->readBool(&releasePreviousBuffer); } status_t TransactionStats::writeToParcel(Parcel* output) const { status_t err = output->writeInt64(latchTime); if (err != NO_ERROR) { return err; } err = output->writeInt64(presentTime); if (err != NO_ERROR) { return err; } return output->writeParcelableVector(surfaceStats); } status_t TransactionStats::readFromParcel(const Parcel* input) { status_t err = input->readInt64(&latchTime); if (err != NO_ERROR) { return err; } err = input->readInt64(&presentTime); if (err != NO_ERROR) { return err; } return input->readParcelableVector(&surfaceStats); } status_t ListenerStats::writeToParcel(Parcel* output) const { status_t err = output->writeInt32(static_cast<int32_t>(transactionStats.size())); if (err != NO_ERROR) { return err; } for (const auto& [callbackIds, stats] : transactionStats) { err = output->writeParcelable(stats); if (err != NO_ERROR) { return err; } err = output->writeInt64Vector(callbackIds); if (err != NO_ERROR) { return err; } } return NO_ERROR; } status_t ListenerStats::readFromParcel(const Parcel* input) { int32_t transactionStats_size = input->readInt32(); for (int i = 0; i < transactionStats_size; i++) { TransactionStats stats; std::vector<CallbackId> callbackIds; status_t err = input->readParcelable(&stats); if (err != NO_ERROR) { return err; } err = input->readInt64Vector(&callbackIds); if (err != NO_ERROR) { return err; } transactionStats.emplace(callbackIds, stats); } return NO_ERROR; } ListenerStats ListenerStats::createEmpty(const sp<ITransactionCompletedListener>& listener, const std::unordered_set<CallbackId>& callbackIds) { ListenerStats listenerStats; listenerStats.listener = listener; TransactionStats transactionStats; listenerStats.transactionStats.emplace(std::piecewise_construct, std::forward_as_tuple(callbackIds.begin(), callbackIds.end()), std::forward_as_tuple(transactionStats)); return listenerStats; } class BpTransactionCompletedListener : public SafeBpInterface<ITransactionCompletedListener> { public: explicit BpTransactionCompletedListener(const sp<IBinder>& impl) : SafeBpInterface<ITransactionCompletedListener>(impl, "BpTransactionCompletedListener") { } ~BpTransactionCompletedListener() override; void onTransactionCompleted(ListenerStats stats) override { callRemoteAsync<decltype(&ITransactionCompletedListener:: onTransactionCompleted)>(Tag::ON_TRANSACTION_COMPLETED, stats); } }; // Out-of-line virtual method definitions to trigger vtable emission in this translation unit (see // clang warning -Wweak-vtables) BpTransactionCompletedListener::~BpTransactionCompletedListener() = default; IMPLEMENT_META_INTERFACE(TransactionCompletedListener, "android.gui.ITransactionComposerListener"); status_t BnTransactionCompletedListener::onTransact(uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { if (code < IBinder::FIRST_CALL_TRANSACTION || code > static_cast<uint32_t>(Tag::LAST)) { return BBinder::onTransact(code, data, reply, flags); } auto tag = static_cast<Tag>(code); switch (tag) { case Tag::ON_TRANSACTION_COMPLETED: return callLocalAsync(data, reply, &ITransactionCompletedListener::onTransactionCompleted); } } }; // namespace android
libs/gui/LayerState.cpp +19 −0 Original line number Diff line number Diff line Loading @@ -80,6 +80,13 @@ status_t layer_state_t::write(Parcel& output) const memcpy(output.writeInplace(16 * sizeof(float)), colorTransform.asArray(), 16 * sizeof(float)); if (output.writeVectorSize(listenerCallbacks) == NO_ERROR) { for (const auto& [listener, callbackIds] : listenerCallbacks) { output.writeStrongBinder(IInterface::asBinder(listener)); output.writeInt64Vector(callbackIds); } } return NO_ERROR; } Loading Loading @@ -135,6 +142,14 @@ status_t layer_state_t::read(const Parcel& input) colorTransform = mat4(static_cast<const float*>(input.readInplace(16 * sizeof(float)))); int32_t listenersSize = input.readInt32(); for (int32_t i = 0; i < listenersSize; i++) { auto listener = interface_cast<ITransactionCompletedListener>(input.readStrongBinder()); std::vector<CallbackId> callbackIds; input.readInt64Vector(&callbackIds); listenerCallbacks.emplace_back(listener, callbackIds); } return NO_ERROR; } Loading Loading @@ -323,6 +338,10 @@ void layer_state_t::merge(const layer_state_t& other) { what |= eColorTransformChanged; colorTransform = other.colorTransform; } if (other.what & eListenerCallbacksChanged) { what |= eListenerCallbacksChanged; listenerCallbacks = other.listenerCallbacks; } if ((other.what & what) != other.what) { ALOGE("Unmerged SurfaceComposer Transaction properties. LayerState::merge needs updating? " Loading