diff options
author | Nirav Atre | 2018-06-08 18:51:29 -0500 |
---|---|---|
committer | Nirav Atre | 2018-06-26 17:42:54 -0500 |
commit | b418616ea468da83886c19c26528961ddc99a773 (patch) | |
tree | e9211e380e02407a9def2fbbdb9e156529172b79 /tests | |
parent | 485c5cd192e6466a9c840aaaad54ebac373d6c18 (diff) | |
download | platform-hardware-interfaces-b418616ea468da83886c19c26528961ddc99a773.tar.gz platform-hardware-interfaces-b418616ea468da83886c19c26528961ddc99a773.tar.xz platform-hardware-interfaces-b418616ea468da83886c19c26528961ddc99a773.zip |
Test HAL for HIDL safe_union construct
This change implements a basic HAL and server-side functionality to test
the HIDL implementation of safe unions.
Bug: 79878527
Test: Ran make, new tests in hidl_test/ pass successfully (included in a
separate CL).
Change-Id: Ia420137bc1dc0a188e04176081c7f5418e74449c
Diffstat (limited to 'tests')
-rw-r--r-- | tests/safeunion/1.0/.hidl_for_test | 0 | ||||
-rw-r--r-- | tests/safeunion/1.0/Android.bp | 21 | ||||
-rw-r--r-- | tests/safeunion/1.0/ISafeUnion.hal | 38 | ||||
-rw-r--r-- | tests/safeunion/1.0/default/Android.bp | 21 | ||||
-rw-r--r-- | tests/safeunion/1.0/default/SafeUnion.cpp | 204 | ||||
-rw-r--r-- | tests/safeunion/1.0/default/SafeUnion.h | 68 | ||||
-rw-r--r-- | tests/safeunion/1.0/types.hal | 67 |
7 files changed, 419 insertions, 0 deletions
diff --git a/tests/safeunion/1.0/.hidl_for_test b/tests/safeunion/1.0/.hidl_for_test new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/tests/safeunion/1.0/.hidl_for_test | |||
diff --git a/tests/safeunion/1.0/Android.bp b/tests/safeunion/1.0/Android.bp new file mode 100644 index 00000000..5082f472 --- /dev/null +++ b/tests/safeunion/1.0/Android.bp | |||
@@ -0,0 +1,21 @@ | |||
1 | // This file is autogenerated by hidl-gen -Landroidbp. | ||
2 | |||
3 | hidl_interface { | ||
4 | name: "android.hardware.tests.safeunion@1.0", | ||
5 | root: "android.hardware", | ||
6 | srcs: [ | ||
7 | "types.hal", | ||
8 | "ISafeUnion.hal", | ||
9 | ], | ||
10 | interfaces: [ | ||
11 | "android.hidl.base@1.0", | ||
12 | ], | ||
13 | types: [ | ||
14 | "EmptySafeUnion", | ||
15 | "SmallSafeUnion", | ||
16 | "LargeSafeUnion", | ||
17 | "MiscTypesSafeUnion", | ||
18 | ], | ||
19 | gen_java: false, | ||
20 | } | ||
21 | |||
diff --git a/tests/safeunion/1.0/ISafeUnion.hal b/tests/safeunion/1.0/ISafeUnion.hal new file mode 100644 index 00000000..91d8b8cd --- /dev/null +++ b/tests/safeunion/1.0/ISafeUnion.hal | |||
@@ -0,0 +1,38 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2018 The Android Open Source Project | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | package android.hardware.tests.safeunion@1.0; | ||
18 | |||
19 | interface ISafeUnion { | ||
20 | newLargeSafeUnion() generates (LargeSafeUnion myUnion); | ||
21 | setA(LargeSafeUnion myUnion, int8_t a) generates (LargeSafeUnion myUnion); | ||
22 | setB(LargeSafeUnion myUnion, uint16_t b) generates (LargeSafeUnion myUnion); | ||
23 | setC(LargeSafeUnion myUnion, int32_t c) generates (LargeSafeUnion myUnion); | ||
24 | setD(LargeSafeUnion myUnion, uint64_t d) generates (LargeSafeUnion myUnion); | ||
25 | setE(LargeSafeUnion myUnion, int8_t[13] e) generates (LargeSafeUnion myUnion); | ||
26 | setF(LargeSafeUnion myUnion, int64_t[5] f) generates (LargeSafeUnion myUnion); | ||
27 | setG(LargeSafeUnion myUnion, string g) generates (LargeSafeUnion myUnion); | ||
28 | setH(LargeSafeUnion myUnion, vec<bool> h) generates (LargeSafeUnion myUnion); | ||
29 | setI(LargeSafeUnion myUnion, vec<uint64_t> i) generates (LargeSafeUnion myUnion); | ||
30 | setJ(LargeSafeUnion myUnion, J j) generates (LargeSafeUnion myUnion); | ||
31 | setK(LargeSafeUnion myUnion, K k) generates (LargeSafeUnion myUnion); | ||
32 | setL(LargeSafeUnion myUnion, SmallSafeUnion l) generates (LargeSafeUnion myUnion); | ||
33 | |||
34 | newMiscTypesSafeUnion() generates (MiscTypesSafeUnion myUnion); | ||
35 | setMiscA(MiscTypesSafeUnion myUnion, memory a) generates (MiscTypesSafeUnion myUnion); | ||
36 | setMiscB(MiscTypesSafeUnion myUnion, handle b) generates (MiscTypesSafeUnion myUnion); | ||
37 | setMiscC(MiscTypesSafeUnion myUnion, bitfield<BitField> c) generates (MiscTypesSafeUnion myUnion); | ||
38 | }; | ||
diff --git a/tests/safeunion/1.0/default/Android.bp b/tests/safeunion/1.0/default/Android.bp new file mode 100644 index 00000000..fc2443e7 --- /dev/null +++ b/tests/safeunion/1.0/default/Android.bp | |||
@@ -0,0 +1,21 @@ | |||
1 | cc_library { | ||
2 | name: "android.hardware.tests.safeunion@1.0-impl", | ||
3 | defaults: ["hidl_defaults"], | ||
4 | relative_install_path: "hw", | ||
5 | srcs: [ | ||
6 | "SafeUnion.cpp", | ||
7 | ], | ||
8 | shared_libs: [ | ||
9 | "libbase", | ||
10 | "libcutils", | ||
11 | "libhidlbase", | ||
12 | "libhidltransport", | ||
13 | "libhwbinder", | ||
14 | "liblog", | ||
15 | "libutils", | ||
16 | ], | ||
17 | |||
18 | // These are static libs only for testing purposes and portability. Shared | ||
19 | // libs should be used on device. | ||
20 | static_libs: ["android.hardware.tests.safeunion@1.0"], | ||
21 | } | ||
diff --git a/tests/safeunion/1.0/default/SafeUnion.cpp b/tests/safeunion/1.0/default/SafeUnion.cpp new file mode 100644 index 00000000..d968987f --- /dev/null +++ b/tests/safeunion/1.0/default/SafeUnion.cpp | |||
@@ -0,0 +1,204 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2018 The Android Open Source Project | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #include "SafeUnion.h" | ||
18 | #include <android-base/logging.h> | ||
19 | |||
20 | namespace android { | ||
21 | namespace hardware { | ||
22 | namespace tests { | ||
23 | namespace safeunion { | ||
24 | namespace V1_0 { | ||
25 | namespace implementation { | ||
26 | |||
27 | // Methods from ::android::hardware::tests::safeunion::V1_0::ISafeUnion follow. | ||
28 | Return<void> SafeUnion::newLargeSafeUnion(newLargeSafeUnion_cb _hidl_cb) { | ||
29 | LOG(INFO) << "SERVER(SafeUnion) newLargeSafeUnion()"; | ||
30 | |||
31 | LargeSafeUnion ret; | ||
32 | _hidl_cb(ret); | ||
33 | return Void(); | ||
34 | } | ||
35 | |||
36 | Return<void> SafeUnion::setA(const LargeSafeUnion& myUnion, int8_t a, setA_cb _hidl_cb) { | ||
37 | LOG(INFO) << "SERVER(SafeUnion) setA(myUnion, " << a << ")"; | ||
38 | |||
39 | LargeSafeUnion myNewUnion = myUnion; | ||
40 | myNewUnion.a(a); | ||
41 | |||
42 | _hidl_cb(myNewUnion); | ||
43 | return Void(); | ||
44 | } | ||
45 | |||
46 | Return<void> SafeUnion::setB(const LargeSafeUnion& myUnion, uint16_t b, setB_cb _hidl_cb) { | ||
47 | LOG(INFO) << "SERVER(SafeUnion) setB(myUnion, " << b << ")"; | ||
48 | |||
49 | LargeSafeUnion myNewUnion = myUnion; | ||
50 | myNewUnion.b(b); | ||
51 | |||
52 | _hidl_cb(myNewUnion); | ||
53 | return Void(); | ||
54 | } | ||
55 | |||
56 | Return<void> SafeUnion::setC(const LargeSafeUnion& myUnion, int32_t c, setC_cb _hidl_cb) { | ||
57 | LOG(INFO) << "SERVER(SafeUnion) setC(myUnion, " << c << ")"; | ||
58 | |||
59 | LargeSafeUnion myNewUnion = myUnion; | ||
60 | myNewUnion.c(c); | ||
61 | |||
62 | _hidl_cb(myNewUnion); | ||
63 | return Void(); | ||
64 | } | ||
65 | |||
66 | Return<void> SafeUnion::setD(const LargeSafeUnion& myUnion, uint64_t d, setD_cb _hidl_cb) { | ||
67 | LOG(INFO) << "SERVER(SafeUnion) setD(myUnion, " << d << ")"; | ||
68 | |||
69 | LargeSafeUnion myNewUnion = myUnion; | ||
70 | myNewUnion.d(d); | ||
71 | |||
72 | _hidl_cb(myNewUnion); | ||
73 | return Void(); | ||
74 | } | ||
75 | |||
76 | Return<void> SafeUnion::setE(const ::android::hardware::tests::safeunion::V1_0::LargeSafeUnion& myUnion, const hidl_array<int8_t, 13>& e, setE_cb _hidl_cb) { | ||
77 | LOG(INFO) << "SERVER(SafeUnion) setE(myUnion, " << toString(e) << ")"; | ||
78 | |||
79 | LargeSafeUnion myNewUnion = myUnion; | ||
80 | myNewUnion.e(e); | ||
81 | |||
82 | _hidl_cb(myNewUnion); | ||
83 | return Void(); | ||
84 | } | ||
85 | |||
86 | Return<void> SafeUnion::setF(const ::android::hardware::tests::safeunion::V1_0::LargeSafeUnion& myUnion, const hidl_array<int64_t, 5>& f, setF_cb _hidl_cb) { | ||
87 | LOG(INFO) << "SERVER(SafeUnion) setF(myUnion, " << toString(f) << ")"; | ||
88 | |||
89 | LargeSafeUnion myNewUnion = myUnion; | ||
90 | myNewUnion.f(f); | ||
91 | |||
92 | _hidl_cb(myNewUnion); | ||
93 | return Void(); | ||
94 | } | ||
95 | |||
96 | Return<void> SafeUnion::setG(const ::android::hardware::tests::safeunion::V1_0::LargeSafeUnion& myUnion, const hidl_string& g, setG_cb _hidl_cb) { | ||
97 | LOG(INFO) << "SERVER(SafeUnion) setG(myUnion, " << toString(g) << ")"; | ||
98 | |||
99 | LargeSafeUnion myNewUnion = myUnion; | ||
100 | myNewUnion.g(g); | ||
101 | |||
102 | _hidl_cb(myNewUnion); | ||
103 | return Void(); | ||
104 | } | ||
105 | |||
106 | Return<void> SafeUnion::setH(const ::android::hardware::tests::safeunion::V1_0::LargeSafeUnion& myUnion, const hidl_vec<bool>& h, setH_cb _hidl_cb) { | ||
107 | LOG(INFO) << "SERVER(SafeUnion) setH(myUnion, " << toString(h) << ")"; | ||
108 | |||
109 | LargeSafeUnion myNewUnion = myUnion; | ||
110 | myNewUnion.h(h); | ||
111 | |||
112 | _hidl_cb(myNewUnion); | ||
113 | return Void(); | ||
114 | } | ||
115 | |||
116 | Return<void> SafeUnion::setI(const ::android::hardware::tests::safeunion::V1_0::LargeSafeUnion& myUnion, const hidl_vec<uint64_t>& i, setI_cb _hidl_cb) { | ||
117 | LOG(INFO) << "SERVER(SafeUnion) setI(myUnion, " << toString(i) << ")"; | ||
118 | |||
119 | LargeSafeUnion myNewUnion = myUnion; | ||
120 | myNewUnion.i(i); | ||
121 | |||
122 | _hidl_cb(myNewUnion); | ||
123 | return Void(); | ||
124 | } | ||
125 | |||
126 | Return<void> SafeUnion::setJ(const ::android::hardware::tests::safeunion::V1_0::LargeSafeUnion& myUnion, const J& j, setJ_cb _hidl_cb) { | ||
127 | LOG(INFO) << "SERVER(SafeUnion) setJ(myUnion, " << toString(j) << ")"; | ||
128 | |||
129 | LargeSafeUnion myNewUnion = myUnion; | ||
130 | myNewUnion.j(j); | ||
131 | |||
132 | _hidl_cb(myNewUnion); | ||
133 | return Void(); | ||
134 | } | ||
135 | |||
136 | Return<void> SafeUnion::setK(const ::android::hardware::tests::safeunion::V1_0::LargeSafeUnion& myUnion, const LargeSafeUnion::K& k, setK_cb _hidl_cb) { | ||
137 | LOG(INFO) << "SERVER(SafeUnion) setK(myUnion, " << toString(k) << ")"; | ||
138 | |||
139 | LargeSafeUnion myNewUnion = myUnion; | ||
140 | myNewUnion.k(k); | ||
141 | |||
142 | _hidl_cb(myNewUnion); | ||
143 | return Void(); | ||
144 | } | ||
145 | |||
146 | Return<void> SafeUnion::setL(const ::android::hardware::tests::safeunion::V1_0::LargeSafeUnion& myUnion, const ::android::hardware::tests::safeunion::V1_0::SmallSafeUnion& l, setL_cb _hidl_cb) { | ||
147 | LOG(INFO) << "SERVER(SafeUnion) setL(myUnion, " << toString(l) << ")"; | ||
148 | |||
149 | LargeSafeUnion myNewUnion = myUnion; | ||
150 | myNewUnion.l(l); | ||
151 | |||
152 | _hidl_cb(myNewUnion); | ||
153 | return Void(); | ||
154 | } | ||
155 | |||
156 | Return<void> SafeUnion::newMiscTypesSafeUnion(newMiscTypesSafeUnion_cb _hidl_cb) { | ||
157 | LOG(INFO) << "SERVER(SafeUnion) newMiscTypesSafeUnion()"; | ||
158 | |||
159 | MiscTypesSafeUnion ret; | ||
160 | _hidl_cb(ret); | ||
161 | return Void(); | ||
162 | } | ||
163 | |||
164 | Return<void> SafeUnion::setMiscA(const ::android::hardware::tests::safeunion::V1_0::MiscTypesSafeUnion& myUnion, const hidl_memory& a, setMiscA_cb _hidl_cb) { | ||
165 | LOG(INFO) << "SERVER(SafeUnion) setMiscA(myUnion, " << toString(a) << ")"; | ||
166 | |||
167 | MiscTypesSafeUnion myNewUnion = myUnion; | ||
168 | myNewUnion.a(a); | ||
169 | |||
170 | _hidl_cb(myNewUnion); | ||
171 | return Void(); | ||
172 | } | ||
173 | |||
174 | Return<void> SafeUnion::setMiscB(const ::android::hardware::tests::safeunion::V1_0::MiscTypesSafeUnion& myUnion, const hidl_handle& b, setMiscB_cb _hidl_cb) { | ||
175 | LOG(INFO) << "SERVER(SafeUnion) setMiscB(myUnion, " << toString(b) << ")"; | ||
176 | |||
177 | MiscTypesSafeUnion myNewUnion = myUnion; | ||
178 | myNewUnion.b(b); | ||
179 | |||
180 | _hidl_cb(myNewUnion); | ||
181 | return Void(); | ||
182 | } | ||
183 | |||
184 | Return<void> SafeUnion::setMiscC(const ::android::hardware::tests::safeunion::V1_0::MiscTypesSafeUnion& myUnion, hidl_bitfield<BitField> c, setMiscC_cb _hidl_cb) { | ||
185 | LOG(INFO) << "SERVER(SafeUnion) setMiscC(myUnion, " << c << ")"; | ||
186 | |||
187 | MiscTypesSafeUnion myNewUnion = myUnion; | ||
188 | myNewUnion.c(c); | ||
189 | |||
190 | _hidl_cb(myNewUnion); | ||
191 | return Void(); | ||
192 | } | ||
193 | |||
194 | |||
195 | ISafeUnion* HIDL_FETCH_ISafeUnion(const char* /* name */) { | ||
196 | return new SafeUnion(); | ||
197 | } | ||
198 | |||
199 | } // namespace implementation | ||
200 | } // namespace V1_0 | ||
201 | } // namespace safeunion | ||
202 | } // namespace tests | ||
203 | } // namespace hardware | ||
204 | } // namespace android | ||
diff --git a/tests/safeunion/1.0/default/SafeUnion.h b/tests/safeunion/1.0/default/SafeUnion.h new file mode 100644 index 00000000..6b9997a4 --- /dev/null +++ b/tests/safeunion/1.0/default/SafeUnion.h | |||
@@ -0,0 +1,68 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2018 The Android Open Source Project | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #ifndef ANDROID_HARDWARE_TESTS_SAFEUNION_V1_0_SAFEUNION_H | ||
18 | #define ANDROID_HARDWARE_TESTS_SAFEUNION_V1_0_SAFEUNION_H | ||
19 | |||
20 | #include <android/hardware/tests/safeunion/1.0/ISafeUnion.h> | ||
21 | #include <hidl/MQDescriptor.h> | ||
22 | #include <hidl/Status.h> | ||
23 | |||
24 | namespace android { | ||
25 | namespace hardware { | ||
26 | namespace tests { | ||
27 | namespace safeunion { | ||
28 | namespace V1_0 { | ||
29 | namespace implementation { | ||
30 | |||
31 | using ::android::hardware::Return; | ||
32 | using ::android::hardware::Void; | ||
33 | using ::android::hardware::tests::safeunion::V1_0::SmallSafeUnion; | ||
34 | using ::android::hardware::tests::safeunion::V1_0::LargeSafeUnion; | ||
35 | using ::android::hardware::tests::safeunion::V1_0::MiscTypesSafeUnion; | ||
36 | |||
37 | struct SafeUnion : public ISafeUnion { | ||
38 | // Methods from ::android::hardware::tests::safeunion::V1_0::ISafeUnion follow. | ||
39 | Return<void> newLargeSafeUnion(newLargeSafeUnion_cb _hidl_cb) override; | ||
40 | Return<void> setA(const LargeSafeUnion& myUnion, int8_t a, setA_cb _hidl_cb) override; | ||
41 | Return<void> setB(const LargeSafeUnion& myUnion, uint16_t b, setB_cb _hidl_cb) override; | ||
42 | Return<void> setC(const LargeSafeUnion& myUnion, int32_t c, setC_cb _hidl_cb) override; | ||
43 | Return<void> setD(const LargeSafeUnion& myUnion, uint64_t d, setD_cb _hidl_cb) override; | ||
44 | Return<void> setE(const LargeSafeUnion& myUnion, const hidl_array<int8_t, 13>& e, setE_cb _hidl_cb) override; | ||
45 | Return<void> setF(const LargeSafeUnion& myUnion, const hidl_array<int64_t, 5>& f, setF_cb _hidl_cb) override; | ||
46 | Return<void> setG(const LargeSafeUnion& myUnion, const hidl_string& g, setG_cb _hidl_cb) override; | ||
47 | Return<void> setH(const LargeSafeUnion& myUnion, const hidl_vec<bool>& h, setH_cb _hidl_cb) override; | ||
48 | Return<void> setI(const LargeSafeUnion& myUnion, const hidl_vec<uint64_t>& i, setI_cb _hidl_cb) override; | ||
49 | Return<void> setJ(const LargeSafeUnion& myUnion, const J& j, setJ_cb _hidl_cb) override; | ||
50 | Return<void> setK(const LargeSafeUnion& myUnion, const LargeSafeUnion::K& k, setK_cb _hidl_cb) override; | ||
51 | Return<void> setL(const LargeSafeUnion& myUnion, const SmallSafeUnion& l, setL_cb _hidl_cb) override; | ||
52 | |||
53 | Return<void> newMiscTypesSafeUnion(newMiscTypesSafeUnion_cb _hidl_cb) override; | ||
54 | Return<void> setMiscA(const ::android::hardware::tests::safeunion::V1_0::MiscTypesSafeUnion& myUnion, const hidl_memory& a, setMiscA_cb _hidl_cb) override; | ||
55 | Return<void> setMiscB(const ::android::hardware::tests::safeunion::V1_0::MiscTypesSafeUnion& myUnion, const hidl_handle& b, setMiscB_cb _hidl_cb) override; | ||
56 | Return<void> setMiscC(const ::android::hardware::tests::safeunion::V1_0::MiscTypesSafeUnion& myUnion, hidl_bitfield<BitField> c, setMiscC_cb _hidl_cb) override; | ||
57 | }; | ||
58 | |||
59 | extern "C" ISafeUnion* HIDL_FETCH_ISafeUnion(const char* name); | ||
60 | |||
61 | } // namespace implementation | ||
62 | } // namespace V1_0 | ||
63 | } // namespace safeunion | ||
64 | } // namespace tests | ||
65 | } // namespace hardware | ||
66 | } // namespace android | ||
67 | |||
68 | #endif // ANDROID_HARDWARE_TESTS_SAFEUNION_V1_0_SAFEUNION_H | ||
diff --git a/tests/safeunion/1.0/types.hal b/tests/safeunion/1.0/types.hal new file mode 100644 index 00000000..a70079d7 --- /dev/null +++ b/tests/safeunion/1.0/types.hal | |||
@@ -0,0 +1,67 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2018 The Android Open Source Project | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | package android.hardware.tests.safeunion@1.0; | ||
18 | |||
19 | enum BitField : uint8_t { | ||
20 | V0 = 1 << 0, | ||
21 | V1 = 1 << 1, | ||
22 | V2 = 1 << 2, | ||
23 | V3 = 1 << 3, | ||
24 | }; | ||
25 | |||
26 | struct J { | ||
27 | vec<uint32_t> j1; | ||
28 | uint8_t[65] j2; | ||
29 | string j3; | ||
30 | }; | ||
31 | |||
32 | safe_union EmptySafeUnion { | ||
33 | }; | ||
34 | |||
35 | safe_union SmallSafeUnion { | ||
36 | uint8_t a; | ||
37 | }; | ||
38 | |||
39 | safe_union LargeSafeUnion { | ||
40 | int8_t a; | ||
41 | uint16_t b; | ||
42 | int32_t c; | ||
43 | uint64_t d; | ||
44 | |||
45 | int8_t[13] e; | ||
46 | int64_t[5] f; | ||
47 | |||
48 | string g; | ||
49 | vec<bool> h; | ||
50 | vec<uint64_t> i; | ||
51 | |||
52 | J j; | ||
53 | struct K { | ||
54 | uint8_t k1; | ||
55 | uint64_t k2; | ||
56 | } k; | ||
57 | |||
58 | SmallSafeUnion l; | ||
59 | }; | ||
60 | |||
61 | // TODO(b/110269925): Test more HIDL types. Missing: | ||
62 | // death_recipient, fmq_{sync,unsync}, pointer, ref. | ||
63 | safe_union MiscTypesSafeUnion { | ||
64 | memory a; | ||
65 | handle b; | ||
66 | bitfield<BitField> c; | ||
67 | }; | ||