From f3cf4bcfa2c558f03e178f7044d3cb12fa0e73ed Mon Sep 17 00:00:00 2001 From: Jorim Jaggi Date: Thu, 30 Nov 2017 14:19:23 +0100 Subject: Make SurfaceControl parcelable (2/2) Bug: 69145041 Test: Send SurfaceControl over binder Change-Id: I47aa4a4bb39fab3ed4d1d30d4e472de7cbc5ca38 --- libs/gui/SurfaceControl.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'libs/gui/SurfaceControl.cpp') diff --git a/libs/gui/SurfaceControl.cpp b/libs/gui/SurfaceControl.cpp index f6a2b8fed6..f5fb8acf44 100644 --- a/libs/gui/SurfaceControl.cpp +++ b/libs/gui/SurfaceControl.cpp @@ -166,5 +166,28 @@ sp SurfaceControl::getClient() const return mClient; } +void SurfaceControl::writeToParcel(Parcel* parcel) +{ + parcel->writeStrongBinder(ISurfaceComposerClient::asBinder(mClient->getClient())); + parcel->writeStrongBinder(mHandle); + parcel->writeStrongBinder(IGraphicBufferProducer::asBinder(mGraphicBufferProducer)); +} + +sp SurfaceControl::readFromParcel(Parcel* parcel) +{ + sp client = parcel->readStrongBinder(); + sp handle = parcel->readStrongBinder(); + if (client == nullptr || handle == nullptr) + { + ALOGE("Invalid parcel"); + return nullptr; + } + sp gbp; + parcel->readNullableStrongBinder(&gbp); + return new SurfaceControl(new SurfaceComposerClient( + interface_cast(client)), + handle.get(), interface_cast(gbp)); +} + // ---------------------------------------------------------------------------- }; // namespace android -- cgit v1.2.3-59-g8ed1b