Loading libs/binder/BackendUnifiedServiceManager.cpp +16 −1 Original line number Diff line number Diff line Loading @@ -321,6 +321,20 @@ Status BackendUnifiedServiceManager::toBinderService(const ::std::string& name, createServiceWithMetadata(nullptr, false)); return Status::ok(); } // Pre-flight check to handle transient connection errors. os::ParcelFileDescriptor pfd; if (Status status = accessor->addConnection(&pfd); !status.isOk()) { if (status.serviceSpecificErrorCode() == IAccessor::ERROR_FAILED_TO_CONNECT_TO_SOCKET) { ALOGW("Accessor failed with transient error, returning null to retry: %s", status.toString8().c_str()); *_out = os::Service::make<os::Service::Tag::serviceWithMetadata>( createServiceWithMetadata(nullptr, false)); return Status::ok(); } ALOGE("Failed to add connection via accessor: %s", status.toString8().c_str()); return status; } auto request = [=] { os::ParcelFileDescriptor fd; Status ret = accessor->addConnection(&fd); Loading @@ -332,7 +346,8 @@ Status BackendUnifiedServiceManager::toBinderService(const ::std::string& name, } }; auto session = RpcSession::make(); status_t status = session->setupPreconnectedClient(base::unique_fd{}, request); status_t status = session->setupPreconnectedClient(base::unique_fd(pfd.release()), request); if (status != OK) { ALOGE("Failed to set up preconnected binder RPC client: %s", statusToString(status).c_str()); Loading libs/binder/RpcTransportUtils.h +7 −5 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #include <binder/unique_fd.h> #include <poll.h> #include "Constants.h" #include "FdTrigger.h" #include "RpcState.h" Loading Loading @@ -60,8 +61,9 @@ status_t interruptableReadOrWrite( return OK; } // size to break up message - this is not reset for this read/write operation. constexpr size_t kChunkMax = 65536; // We should never break up a message by default, but we do reduce chunk size on // ENOMEM conditions. constexpr size_t kChunkMax = binder::kRpcTransactionLimitBytes; const size_t kChunkMin = getpagesize(); // typical allocated granularity for sockets size_t chunkSize = kChunkMax; Loading @@ -81,9 +83,9 @@ status_t interruptableReadOrWrite( // This block dynamically adjusts packet sizes down to work around a // limitation in the vsock driver where large packets are sometimes // dropped (b/419364025 b/399469406 b/421244320). // TODO: only apply this workaround on vsock ??? // TODO: fix vsock // dropped (b/419364025 b/399469406 b/421244320), though since this is // fixed, it's only used in ENOMEM conditions to try to allocate // smaller packets. { size_t chunkRemaining = chunkSize; int i = 0; Loading libs/gui/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -385,6 +385,7 @@ cc_library_shared { }, cflags: [ "-DANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION", "-Wthread-safety", ], } Loading libs/gui/BufferQueueProducer.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -1553,7 +1553,7 @@ status_t BufferQueueProducer::disconnect(int api, DisconnectMode mode) { IInterface::asBinder(mCore->mLinkedToDeath); // This can fail if we're here because of the death // notification, but we just ignore it token->unlinkToDeath(static_cast<IBinder::DeathRecipient*>(this)); token->unlinkToDeath(wp<IBinder::DeathRecipient>::fromExisting(this)); } #endif mCore->mSharedBufferSlot = Loading libs/gui/Choreographer.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -155,7 +155,7 @@ void Choreographer::postFrameCallbackDelayed(AChoreographer_frameCallback cb, if (std::this_thread::get_id() != mThreadId) { if (mLooper != nullptr) { Message m{MSG_SCHEDULE_VSYNC}; mLooper->sendMessage(this, m); mLooper->sendMessage(sp<Choreographer>::fromExisting(this), m); } else { scheduleVsync(); } Loading @@ -165,7 +165,7 @@ void Choreographer::postFrameCallbackDelayed(AChoreographer_frameCallback cb, } else { if (mLooper != nullptr) { Message m{MSG_SCHEDULE_CALLBACKS}; mLooper->sendMessageDelayed(delay, this, m); mLooper->sendMessageDelayed(delay, sp<Choreographer>::fromExisting(this), m); } else { scheduleCallbacks(); } Loading Loading @@ -229,7 +229,7 @@ void Choreographer::unregisterRefreshRateCallback(AChoreographer_refreshRateCall void Choreographer::scheduleLatestConfigRequest() { if (mLooper != nullptr) { Message m{MSG_HANDLE_REFRESH_RATE_UPDATES}; mLooper->sendMessage(this, m); mLooper->sendMessage(sp<Choreographer>::fromExisting(this), m); } else { // If the looper thread is detached from Choreographer, then refresh rate // changes will be handled in AChoreographer_handlePendingEvents, so we Loading Loading
libs/binder/BackendUnifiedServiceManager.cpp +16 −1 Original line number Diff line number Diff line Loading @@ -321,6 +321,20 @@ Status BackendUnifiedServiceManager::toBinderService(const ::std::string& name, createServiceWithMetadata(nullptr, false)); return Status::ok(); } // Pre-flight check to handle transient connection errors. os::ParcelFileDescriptor pfd; if (Status status = accessor->addConnection(&pfd); !status.isOk()) { if (status.serviceSpecificErrorCode() == IAccessor::ERROR_FAILED_TO_CONNECT_TO_SOCKET) { ALOGW("Accessor failed with transient error, returning null to retry: %s", status.toString8().c_str()); *_out = os::Service::make<os::Service::Tag::serviceWithMetadata>( createServiceWithMetadata(nullptr, false)); return Status::ok(); } ALOGE("Failed to add connection via accessor: %s", status.toString8().c_str()); return status; } auto request = [=] { os::ParcelFileDescriptor fd; Status ret = accessor->addConnection(&fd); Loading @@ -332,7 +346,8 @@ Status BackendUnifiedServiceManager::toBinderService(const ::std::string& name, } }; auto session = RpcSession::make(); status_t status = session->setupPreconnectedClient(base::unique_fd{}, request); status_t status = session->setupPreconnectedClient(base::unique_fd(pfd.release()), request); if (status != OK) { ALOGE("Failed to set up preconnected binder RPC client: %s", statusToString(status).c_str()); Loading
libs/binder/RpcTransportUtils.h +7 −5 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #include <binder/unique_fd.h> #include <poll.h> #include "Constants.h" #include "FdTrigger.h" #include "RpcState.h" Loading Loading @@ -60,8 +61,9 @@ status_t interruptableReadOrWrite( return OK; } // size to break up message - this is not reset for this read/write operation. constexpr size_t kChunkMax = 65536; // We should never break up a message by default, but we do reduce chunk size on // ENOMEM conditions. constexpr size_t kChunkMax = binder::kRpcTransactionLimitBytes; const size_t kChunkMin = getpagesize(); // typical allocated granularity for sockets size_t chunkSize = kChunkMax; Loading @@ -81,9 +83,9 @@ status_t interruptableReadOrWrite( // This block dynamically adjusts packet sizes down to work around a // limitation in the vsock driver where large packets are sometimes // dropped (b/419364025 b/399469406 b/421244320). // TODO: only apply this workaround on vsock ??? // TODO: fix vsock // dropped (b/419364025 b/399469406 b/421244320), though since this is // fixed, it's only used in ENOMEM conditions to try to allocate // smaller packets. { size_t chunkRemaining = chunkSize; int i = 0; Loading
libs/gui/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -385,6 +385,7 @@ cc_library_shared { }, cflags: [ "-DANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION", "-Wthread-safety", ], } Loading
libs/gui/BufferQueueProducer.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -1553,7 +1553,7 @@ status_t BufferQueueProducer::disconnect(int api, DisconnectMode mode) { IInterface::asBinder(mCore->mLinkedToDeath); // This can fail if we're here because of the death // notification, but we just ignore it token->unlinkToDeath(static_cast<IBinder::DeathRecipient*>(this)); token->unlinkToDeath(wp<IBinder::DeathRecipient>::fromExisting(this)); } #endif mCore->mSharedBufferSlot = Loading
libs/gui/Choreographer.cpp +3 −3 Original line number Diff line number Diff line Loading @@ -155,7 +155,7 @@ void Choreographer::postFrameCallbackDelayed(AChoreographer_frameCallback cb, if (std::this_thread::get_id() != mThreadId) { if (mLooper != nullptr) { Message m{MSG_SCHEDULE_VSYNC}; mLooper->sendMessage(this, m); mLooper->sendMessage(sp<Choreographer>::fromExisting(this), m); } else { scheduleVsync(); } Loading @@ -165,7 +165,7 @@ void Choreographer::postFrameCallbackDelayed(AChoreographer_frameCallback cb, } else { if (mLooper != nullptr) { Message m{MSG_SCHEDULE_CALLBACKS}; mLooper->sendMessageDelayed(delay, this, m); mLooper->sendMessageDelayed(delay, sp<Choreographer>::fromExisting(this), m); } else { scheduleCallbacks(); } Loading Loading @@ -229,7 +229,7 @@ void Choreographer::unregisterRefreshRateCallback(AChoreographer_refreshRateCall void Choreographer::scheduleLatestConfigRequest() { if (mLooper != nullptr) { Message m{MSG_HANDLE_REFRESH_RATE_UPDATES}; mLooper->sendMessage(this, m); mLooper->sendMessage(sp<Choreographer>::fromExisting(this), m); } else { // If the looper thread is detached from Choreographer, then refresh rate // changes will be handled in AChoreographer_handlePendingEvents, so we Loading