Merge "Add support for nested parcel" into main
diff --git a/example/android/binder_nested_parcel.ditto b/example/android/binder_nested_parcel.ditto
new file mode 100644
index 0000000..6541eeb
--- /dev/null
+++ b/example/android/binder_nested_parcel.ditto
@@ -0,0 +1,28 @@
+main: {
+ binder_request: {
+ generic_service: {
+ name: "package",
+ # getServiceInfo
+ code: 14,
+ # component
+ parcel_input: [{
+ type: PARCEL,
+ nested_parcel : {
+ parcel_inputs: [
+ # package name
+ {
+ type: STRING_16,
+ data: "com.google.android.apps.wallpaper"
+ },
+ # class name
+ {
+ type: STRING_16,
+ data: "com.google.android.apps.wallpaper.backdrop.BackdropRotationTask"
+ }
+ ]
+ }
+ }]
+ },
+ }
+},
+global {}
\ No newline at end of file
diff --git a/schema/benchmark.proto b/schema/benchmark.proto
index 166b7f8..a17ec4d 100644
--- a/schema/benchmark.proto
+++ b/schema/benchmark.proto
@@ -41,6 +41,9 @@
};
message GenericService {
message ParcelInput {
+ message NestedParcel {
+ repeated ParcelInput parcel_inputs = 1;
+ }
enum Type {
// Write the 32-bit integer into the send parcel.
I32 = 0;
@@ -58,17 +61,20 @@
// Write a file descriptor for the file with given path into the send
// parcel.
FD_PATH = 6;
- // Data: FD number
- // Write the file descriptor into the send parcel.
- FD = 8;
// Data: File name
// Write an ashmem file descriptor for a region containing the data
// from file the given path into the send parcel.
ASHMEM_FD_PATH = 7;
+ // Data: FD number
+ // Write the file descriptor into the send parcel.
+ FD = 8;
+ // Parcel input that is nested inside.
+ PARCEL = 9;
}
optional Type type = 1;
oneof data_oneof {
string data = 2;
+ NestedParcel nested_parcel = 3;
}
}
optional string name = 1;
diff --git a/src/binder_request.cpp b/src/binder_request.cpp
index 321c926..37c4f27 100644
--- a/src/binder_request.cpp
+++ b/src/binder_request.cpp
@@ -181,6 +181,23 @@
}
break;
}
+ case dittosuiteproto::BinderRequest_GenericService_ParcelInput_Type_PARCEL: {
+ int res = 0;
+ auto inputs = it.nested_parcel().parcel_inputs();
+ if (inputs.size() == 0) {
+ // Null parcelable flag.
+ res = parcel.writeInt32(0);
+ } else {
+ // Non-Null parcelable flag.
+ res = parcel.writeInt32(1);
+ if (res < 0) return res;
+ res = ParseParcelString(it.nested_parcel().parcel_inputs(), parcel);
+ }
+ if (res < 0) {
+ return res;
+ }
+ break;
+ }
default:
break;
}