Make SurfaceControl parcelable (2/2)
Bug: 69145041
Test: Send SurfaceControl over binder
Change-Id: I47aa4a4bb39fab3ed4d1d30d4e472de7cbc5ca38
diff --git a/libs/gui/SurfaceControl.cpp b/libs/gui/SurfaceControl.cpp
index f6a2b8f..f5fb8ac 100644
--- a/libs/gui/SurfaceControl.cpp
+++ b/libs/gui/SurfaceControl.cpp
@@ -166,5 +166,28 @@
return mClient;
}
+void SurfaceControl::writeToParcel(Parcel* parcel)
+{
+ parcel->writeStrongBinder(ISurfaceComposerClient::asBinder(mClient->getClient()));
+ parcel->writeStrongBinder(mHandle);
+ parcel->writeStrongBinder(IGraphicBufferProducer::asBinder(mGraphicBufferProducer));
+}
+
+sp<SurfaceControl> SurfaceControl::readFromParcel(Parcel* parcel)
+{
+ sp<IBinder> client = parcel->readStrongBinder();
+ sp<IBinder> handle = parcel->readStrongBinder();
+ if (client == nullptr || handle == nullptr)
+ {
+ ALOGE("Invalid parcel");
+ return nullptr;
+ }
+ sp<IBinder> gbp;
+ parcel->readNullableStrongBinder(&gbp);
+ return new SurfaceControl(new SurfaceComposerClient(
+ interface_cast<ISurfaceComposerClient>(client)),
+ handle.get(), interface_cast<IGraphicBufferProducer>(gbp));
+}
+
// ----------------------------------------------------------------------------
}; // namespace android