Loading libs/binder/ProcessState.cpp +0 −5 Original line number Diff line number Diff line Loading @@ -320,11 +320,6 @@ sp<IBinder> ProcessState::getStrongProxyForHandle(int32_t handle) // // Note that this is not race-free if the context manager // dies while this code runs. // // TODO: add a driver API to wait for context manager, or // stop special casing handle 0 for context manager and add // a driver API to get a handle to the context manager with // proper reference counting. IPCThreadState* ipc = IPCThreadState::self(); Loading libs/binder/rust/binder_tokio/lib.rs +22 −1 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ //! [`Tokio`]: crate::Tokio use binder::public_api::{BinderAsyncPool, BoxFuture, Strong}; use binder::{FromIBinder, StatusCode}; use binder::{FromIBinder, StatusCode, BinderAsyncRuntime}; use std::future::Future; /// Retrieve an existing service for a particular interface, sleeping for a few Loading Loading @@ -120,3 +120,24 @@ impl BinderAsyncPool for Tokio { } } } /// Wrapper around Tokio runtime types for providing a runtime to a binder server. pub struct TokioRuntime<R>(pub R); impl BinderAsyncRuntime for TokioRuntime<tokio::runtime::Runtime> { fn block_on<F: Future>(&self, future: F) -> F::Output { self.0.block_on(future) } } impl BinderAsyncRuntime for TokioRuntime<std::sync::Arc<tokio::runtime::Runtime>> { fn block_on<F: Future>(&self, future: F) -> F::Output { self.0.block_on(future) } } impl BinderAsyncRuntime for TokioRuntime<tokio::runtime::Handle> { fn block_on<F: Future>(&self, future: F) -> F::Output { self.0.block_on(future) } } libs/binder/rust/src/binder_async.rs +6 −0 Original line number Diff line number Diff line Loading @@ -53,3 +53,9 @@ pub trait BinderAsyncPool { B: Send + 'a, E: From<crate::StatusCode>; } /// A runtime for executing an async binder server. pub trait BinderAsyncRuntime { /// Block on the provided future, running it to completion and returning its output. fn block_on<F: Future>(&self, future: F) -> F::Output; } libs/binder/rust/src/lib.rs +1 −1 Original line number Diff line number Diff line Loading @@ -112,7 +112,7 @@ pub use crate::binder::{ Stability, Strong, ToAsyncInterface, ToSyncInterface, TransactionCode, TransactionFlags, Weak, FIRST_CALL_TRANSACTION, FLAG_CLEAR_BUF, FLAG_ONEWAY, FLAG_PRIVATE_LOCAL, LAST_CALL_TRANSACTION, }; pub use crate::binder_async::{BoxFuture, BinderAsyncPool}; pub use crate::binder_async::{BoxFuture, BinderAsyncPool, BinderAsyncRuntime}; pub use error::{status_t, ExceptionCode, Result, Status, StatusCode}; pub use native::{add_service, force_lazy_services_persist, is_handling_transaction, register_lazy_service, Binder}; pub use parcel::{BorrowedParcel, Parcel}; Loading libs/gui/LayerState.cpp +30 −27 Original line number Diff line number Diff line Loading @@ -153,7 +153,8 @@ status_t layer_state_t::write(Parcel& output) const SAFE_PARCEL(output.writeBool, isTrustedOverlay); SAFE_PARCEL(output.writeUint32, static_cast<uint32_t>(dropInputMode)); SAFE_PARCEL(bufferData.write, output); SAFE_PARCEL(output.writeNullableParcelable, bufferData ? std::make_optional<BufferData>(*bufferData) : std::nullopt); return NO_ERROR; } Loading Loading @@ -263,7 +264,9 @@ status_t layer_state_t::read(const Parcel& input) uint32_t mode; SAFE_PARCEL(input.readUint32, &mode); dropInputMode = static_cast<gui::DropInputMode>(mode); SAFE_PARCEL(bufferData.read, input); std::optional<BufferData> tmpBufferData; SAFE_PARCEL(input.readParcelable, &tmpBufferData); bufferData = tmpBufferData ? std::make_shared<BufferData>(*tmpBufferData) : nullptr; return NO_ERROR; } Loading Loading @@ -518,7 +521,7 @@ bool layer_state_t::hasBufferChanges() const { } bool layer_state_t::hasValidBuffer() const { return bufferData.buffer || bufferData.cachedBuffer.isValid(); return bufferData && (bufferData->buffer || bufferData->cachedBuffer.isValid()); } status_t layer_state_t::matrix22_t::write(Parcel& output) const { Loading Loading @@ -681,64 +684,64 @@ ReleaseCallbackId BufferData::generateReleaseCallbackId() const { return {buffer->getId(), frameNumber}; } status_t BufferData::write(Parcel& output) const { SAFE_PARCEL(output.writeInt32, flags.get()); status_t BufferData::writeToParcel(Parcel* output) const { SAFE_PARCEL(output->writeInt32, flags.get()); if (buffer) { SAFE_PARCEL(output.writeBool, true); SAFE_PARCEL(output.write, *buffer); SAFE_PARCEL(output->writeBool, true); SAFE_PARCEL(output->write, *buffer); } else { SAFE_PARCEL(output.writeBool, false); SAFE_PARCEL(output->writeBool, false); } if (acquireFence) { SAFE_PARCEL(output.writeBool, true); SAFE_PARCEL(output.write, *acquireFence); SAFE_PARCEL(output->writeBool, true); SAFE_PARCEL(output->write, *acquireFence); } else { SAFE_PARCEL(output.writeBool, false); SAFE_PARCEL(output->writeBool, false); } SAFE_PARCEL(output.writeUint64, frameNumber); SAFE_PARCEL(output.writeStrongBinder, IInterface::asBinder(releaseBufferListener)); SAFE_PARCEL(output.writeStrongBinder, releaseBufferEndpoint); SAFE_PARCEL(output->writeUint64, frameNumber); SAFE_PARCEL(output->writeStrongBinder, IInterface::asBinder(releaseBufferListener)); SAFE_PARCEL(output->writeStrongBinder, releaseBufferEndpoint); SAFE_PARCEL(output.writeStrongBinder, cachedBuffer.token.promote()); SAFE_PARCEL(output.writeUint64, cachedBuffer.id); SAFE_PARCEL(output->writeStrongBinder, cachedBuffer.token.promote()); SAFE_PARCEL(output->writeUint64, cachedBuffer.id); return NO_ERROR; } status_t BufferData::read(const Parcel& input) { status_t BufferData::readFromParcel(const Parcel* input) { int32_t tmpInt32; SAFE_PARCEL(input.readInt32, &tmpInt32); SAFE_PARCEL(input->readInt32, &tmpInt32); flags = Flags<BufferDataChange>(tmpInt32); bool tmpBool = false; SAFE_PARCEL(input.readBool, &tmpBool); SAFE_PARCEL(input->readBool, &tmpBool); if (tmpBool) { buffer = new GraphicBuffer(); SAFE_PARCEL(input.read, *buffer); SAFE_PARCEL(input->read, *buffer); } SAFE_PARCEL(input.readBool, &tmpBool); SAFE_PARCEL(input->readBool, &tmpBool); if (tmpBool) { acquireFence = new Fence(); SAFE_PARCEL(input.read, *acquireFence); SAFE_PARCEL(input->read, *acquireFence); } SAFE_PARCEL(input.readUint64, &frameNumber); SAFE_PARCEL(input->readUint64, &frameNumber); sp<IBinder> tmpBinder = nullptr; SAFE_PARCEL(input.readNullableStrongBinder, &tmpBinder); SAFE_PARCEL(input->readNullableStrongBinder, &tmpBinder); if (tmpBinder) { releaseBufferListener = checked_interface_cast<ITransactionCompletedListener>(tmpBinder); } SAFE_PARCEL(input.readNullableStrongBinder, &releaseBufferEndpoint); SAFE_PARCEL(input->readNullableStrongBinder, &releaseBufferEndpoint); tmpBinder = nullptr; SAFE_PARCEL(input.readNullableStrongBinder, &tmpBinder); SAFE_PARCEL(input->readNullableStrongBinder, &tmpBinder); cachedBuffer.token = tmpBinder; SAFE_PARCEL(input.readUint64, &cachedBuffer.id); SAFE_PARCEL(input->readUint64, &cachedBuffer.id); return NO_ERROR; } Loading Loading
libs/binder/ProcessState.cpp +0 −5 Original line number Diff line number Diff line Loading @@ -320,11 +320,6 @@ sp<IBinder> ProcessState::getStrongProxyForHandle(int32_t handle) // // Note that this is not race-free if the context manager // dies while this code runs. // // TODO: add a driver API to wait for context manager, or // stop special casing handle 0 for context manager and add // a driver API to get a handle to the context manager with // proper reference counting. IPCThreadState* ipc = IPCThreadState::self(); Loading
libs/binder/rust/binder_tokio/lib.rs +22 −1 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ //! [`Tokio`]: crate::Tokio use binder::public_api::{BinderAsyncPool, BoxFuture, Strong}; use binder::{FromIBinder, StatusCode}; use binder::{FromIBinder, StatusCode, BinderAsyncRuntime}; use std::future::Future; /// Retrieve an existing service for a particular interface, sleeping for a few Loading Loading @@ -120,3 +120,24 @@ impl BinderAsyncPool for Tokio { } } } /// Wrapper around Tokio runtime types for providing a runtime to a binder server. pub struct TokioRuntime<R>(pub R); impl BinderAsyncRuntime for TokioRuntime<tokio::runtime::Runtime> { fn block_on<F: Future>(&self, future: F) -> F::Output { self.0.block_on(future) } } impl BinderAsyncRuntime for TokioRuntime<std::sync::Arc<tokio::runtime::Runtime>> { fn block_on<F: Future>(&self, future: F) -> F::Output { self.0.block_on(future) } } impl BinderAsyncRuntime for TokioRuntime<tokio::runtime::Handle> { fn block_on<F: Future>(&self, future: F) -> F::Output { self.0.block_on(future) } }
libs/binder/rust/src/binder_async.rs +6 −0 Original line number Diff line number Diff line Loading @@ -53,3 +53,9 @@ pub trait BinderAsyncPool { B: Send + 'a, E: From<crate::StatusCode>; } /// A runtime for executing an async binder server. pub trait BinderAsyncRuntime { /// Block on the provided future, running it to completion and returning its output. fn block_on<F: Future>(&self, future: F) -> F::Output; }
libs/binder/rust/src/lib.rs +1 −1 Original line number Diff line number Diff line Loading @@ -112,7 +112,7 @@ pub use crate::binder::{ Stability, Strong, ToAsyncInterface, ToSyncInterface, TransactionCode, TransactionFlags, Weak, FIRST_CALL_TRANSACTION, FLAG_CLEAR_BUF, FLAG_ONEWAY, FLAG_PRIVATE_LOCAL, LAST_CALL_TRANSACTION, }; pub use crate::binder_async::{BoxFuture, BinderAsyncPool}; pub use crate::binder_async::{BoxFuture, BinderAsyncPool, BinderAsyncRuntime}; pub use error::{status_t, ExceptionCode, Result, Status, StatusCode}; pub use native::{add_service, force_lazy_services_persist, is_handling_transaction, register_lazy_service, Binder}; pub use parcel::{BorrowedParcel, Parcel}; Loading
libs/gui/LayerState.cpp +30 −27 Original line number Diff line number Diff line Loading @@ -153,7 +153,8 @@ status_t layer_state_t::write(Parcel& output) const SAFE_PARCEL(output.writeBool, isTrustedOverlay); SAFE_PARCEL(output.writeUint32, static_cast<uint32_t>(dropInputMode)); SAFE_PARCEL(bufferData.write, output); SAFE_PARCEL(output.writeNullableParcelable, bufferData ? std::make_optional<BufferData>(*bufferData) : std::nullopt); return NO_ERROR; } Loading Loading @@ -263,7 +264,9 @@ status_t layer_state_t::read(const Parcel& input) uint32_t mode; SAFE_PARCEL(input.readUint32, &mode); dropInputMode = static_cast<gui::DropInputMode>(mode); SAFE_PARCEL(bufferData.read, input); std::optional<BufferData> tmpBufferData; SAFE_PARCEL(input.readParcelable, &tmpBufferData); bufferData = tmpBufferData ? std::make_shared<BufferData>(*tmpBufferData) : nullptr; return NO_ERROR; } Loading Loading @@ -518,7 +521,7 @@ bool layer_state_t::hasBufferChanges() const { } bool layer_state_t::hasValidBuffer() const { return bufferData.buffer || bufferData.cachedBuffer.isValid(); return bufferData && (bufferData->buffer || bufferData->cachedBuffer.isValid()); } status_t layer_state_t::matrix22_t::write(Parcel& output) const { Loading Loading @@ -681,64 +684,64 @@ ReleaseCallbackId BufferData::generateReleaseCallbackId() const { return {buffer->getId(), frameNumber}; } status_t BufferData::write(Parcel& output) const { SAFE_PARCEL(output.writeInt32, flags.get()); status_t BufferData::writeToParcel(Parcel* output) const { SAFE_PARCEL(output->writeInt32, flags.get()); if (buffer) { SAFE_PARCEL(output.writeBool, true); SAFE_PARCEL(output.write, *buffer); SAFE_PARCEL(output->writeBool, true); SAFE_PARCEL(output->write, *buffer); } else { SAFE_PARCEL(output.writeBool, false); SAFE_PARCEL(output->writeBool, false); } if (acquireFence) { SAFE_PARCEL(output.writeBool, true); SAFE_PARCEL(output.write, *acquireFence); SAFE_PARCEL(output->writeBool, true); SAFE_PARCEL(output->write, *acquireFence); } else { SAFE_PARCEL(output.writeBool, false); SAFE_PARCEL(output->writeBool, false); } SAFE_PARCEL(output.writeUint64, frameNumber); SAFE_PARCEL(output.writeStrongBinder, IInterface::asBinder(releaseBufferListener)); SAFE_PARCEL(output.writeStrongBinder, releaseBufferEndpoint); SAFE_PARCEL(output->writeUint64, frameNumber); SAFE_PARCEL(output->writeStrongBinder, IInterface::asBinder(releaseBufferListener)); SAFE_PARCEL(output->writeStrongBinder, releaseBufferEndpoint); SAFE_PARCEL(output.writeStrongBinder, cachedBuffer.token.promote()); SAFE_PARCEL(output.writeUint64, cachedBuffer.id); SAFE_PARCEL(output->writeStrongBinder, cachedBuffer.token.promote()); SAFE_PARCEL(output->writeUint64, cachedBuffer.id); return NO_ERROR; } status_t BufferData::read(const Parcel& input) { status_t BufferData::readFromParcel(const Parcel* input) { int32_t tmpInt32; SAFE_PARCEL(input.readInt32, &tmpInt32); SAFE_PARCEL(input->readInt32, &tmpInt32); flags = Flags<BufferDataChange>(tmpInt32); bool tmpBool = false; SAFE_PARCEL(input.readBool, &tmpBool); SAFE_PARCEL(input->readBool, &tmpBool); if (tmpBool) { buffer = new GraphicBuffer(); SAFE_PARCEL(input.read, *buffer); SAFE_PARCEL(input->read, *buffer); } SAFE_PARCEL(input.readBool, &tmpBool); SAFE_PARCEL(input->readBool, &tmpBool); if (tmpBool) { acquireFence = new Fence(); SAFE_PARCEL(input.read, *acquireFence); SAFE_PARCEL(input->read, *acquireFence); } SAFE_PARCEL(input.readUint64, &frameNumber); SAFE_PARCEL(input->readUint64, &frameNumber); sp<IBinder> tmpBinder = nullptr; SAFE_PARCEL(input.readNullableStrongBinder, &tmpBinder); SAFE_PARCEL(input->readNullableStrongBinder, &tmpBinder); if (tmpBinder) { releaseBufferListener = checked_interface_cast<ITransactionCompletedListener>(tmpBinder); } SAFE_PARCEL(input.readNullableStrongBinder, &releaseBufferEndpoint); SAFE_PARCEL(input->readNullableStrongBinder, &releaseBufferEndpoint); tmpBinder = nullptr; SAFE_PARCEL(input.readNullableStrongBinder, &tmpBinder); SAFE_PARCEL(input->readNullableStrongBinder, &tmpBinder); cachedBuffer.token = tmpBinder; SAFE_PARCEL(input.readUint64, &cachedBuffer.id); SAFE_PARCEL(input->readUint64, &cachedBuffer.id); return NO_ERROR; } Loading