GUI: Move Surface.aidl here and implement for native
- Move android/view/Surface.aidl parcelable definition from frameworks/base
- Implement matching native behavior to android.view.Surface parceling,
to enable use of android.view.Surface in generated native AIDL interfaces
Bug: 25091611
Change-Id: I87ffbb9a19c27a99ce0749d0ca1f17aaa6b3fe74
diff --git a/include/gui/Surface.h b/include/gui/Surface.h
index 3afdaae..9f51cdd 100644
--- a/include/gui/Surface.h
+++ b/include/gui/Surface.h
@@ -23,6 +23,8 @@
#include <ui/ANativeObjectBase.h>
#include <ui/Region.h>
+#include <binder/Parcelable.h>
+
#include <utils/RefBase.h>
#include <utils/threads.h>
#include <utils/KeyedVector.h>
@@ -348,6 +350,43 @@
bool mSharedBufferHasBeenQueued;
};
+namespace view {
+
+/**
+ * A simple holder for an IGraphicBufferProducer, to match the managed-side
+ * android.view.Surface parcelable behavior.
+ *
+ * This implements android/view/Surface.aidl
+ *
+ * TODO: Convert IGraphicBufferProducer into AIDL so that it can be directly
+ * used in managed Binder calls.
+ */
+class Surface : public Parcelable {
+ public:
+
+ String16 name;
+ sp<IGraphicBufferProducer> graphicBufferProducer;
+
+ virtual status_t writeToParcel(Parcel* parcel) const override;
+ virtual status_t readFromParcel(const Parcel* parcel) override;
+
+ // nameAlreadyWritten set to true by Surface.java, because it splits
+ // Parceling itself between managed and native code, so it only wants a part
+ // of the full parceling to happen on its native side.
+ status_t writeToParcel(Parcel* parcel, bool nameAlreadyWritten) const;
+
+ // nameAlreadyRead set to true by Surface.java, because it splits
+ // Parceling itself between managed and native code, so it only wants a part
+ // of the full parceling to happen on its native side.
+ status_t readFromParcel(const Parcel* parcel, bool nameAlreadyRead);
+
+ private:
+
+ static String16 readMaybeEmptyString16(const Parcel* parcel);
+};
+
+} // namespace view
+
}; // namespace android
#endif // ANDROID_GUI_SURFACE_H