blob: ec7b22d1584bf43a318bf4b7218b31e2807899fc [file] [log] [blame]
Steven Moreland2e87adc2018-08-20 19:47:00 -07001/*
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 <android/binder_parcel.h>
Steven Moreland4d5ad492018-09-13 12:49:16 -070018#include "parcel_internal.h"
Steven Moreland2e87adc2018-08-20 19:47:00 -070019
Steven Moreland4d5ad492018-09-13 12:49:16 -070020#include "ibinder_internal.h"
Steven Moreland5d62e442018-09-13 15:01:02 -070021#include "status_internal.h"
Steven Moreland2e87adc2018-08-20 19:47:00 -070022
Steven Moreland7b06f592018-10-03 19:25:32 -070023#include <limits>
24
25#include <android-base/logging.h>
Steven Moreland063f2362018-10-18 12:49:11 -070026#include <android-base/unique_fd.h>
Steven Moreland2e87adc2018-08-20 19:47:00 -070027#include <binder/Parcel.h>
Steven Moreland063f2362018-10-18 12:49:11 -070028#include <binder/ParcelFileDescriptor.h>
Steven Moreland7b06f592018-10-03 19:25:32 -070029#include <utils/Unicode.h>
Steven Moreland2e87adc2018-08-20 19:47:00 -070030
31using ::android::IBinder;
32using ::android::Parcel;
33using ::android::sp;
Steven Moreland5d62e442018-09-13 15:01:02 -070034using ::android::status_t;
Steven Moreland063f2362018-10-18 12:49:11 -070035using ::android::base::unique_fd;
36using ::android::os::ParcelFileDescriptor;
Steven Moreland2e87adc2018-08-20 19:47:00 -070037
Steven Morelanda8845662018-10-12 11:53:03 -070038template <typename T>
Steven Moreland71872f82018-10-29 11:46:56 -070039using ContiguousArrayAllocator = T* (*)(void* arrayData, size_t length);
40
41template <typename T>
42using ArrayAllocator = bool (*)(void* arrayData, size_t length);
Steven Morelanda8845662018-10-12 11:53:03 -070043template <typename T>
44using ArrayGetter = T (*)(const void* arrayData, size_t index);
45template <typename T>
46using ArraySetter = void (*)(void* arrayData, size_t index, T value);
47
48template <typename T>
49binder_status_t WriteArray(AParcel* parcel, const T* array, size_t length) {
50 if (length > std::numeric_limits<int32_t>::max()) return STATUS_BAD_VALUE;
51
52 Parcel* rawParcel = parcel->get();
53
54 status_t status = rawParcel->writeInt32(static_cast<int32_t>(length));
55 if (status != STATUS_OK) return PruneStatusT(status);
56
57 int32_t size = 0;
58 if (__builtin_smul_overflow(sizeof(T), length, &size)) return STATUS_NO_MEMORY;
59
60 void* const data = rawParcel->writeInplace(size);
61 if (data == nullptr) return STATUS_NO_MEMORY;
62
63 memcpy(data, array, size);
64
65 return STATUS_OK;
66}
67
68// Each element in a char16_t array is converted to an int32_t (not packed).
69template <>
70binder_status_t WriteArray<char16_t>(AParcel* parcel, const char16_t* array, size_t length) {
71 if (length > std::numeric_limits<int32_t>::max()) return STATUS_BAD_VALUE;
72
73 Parcel* rawParcel = parcel->get();
74
75 status_t status = rawParcel->writeInt32(static_cast<int32_t>(length));
76 if (status != STATUS_OK) return PruneStatusT(status);
77
78 int32_t size = 0;
79 if (__builtin_smul_overflow(sizeof(char16_t), length, &size)) return STATUS_NO_MEMORY;
80
81 for (int32_t i = 0; i < length; i++) {
82 status = rawParcel->writeChar(array[i]);
83
84 if (status != STATUS_OK) return PruneStatusT(status);
85 }
86
87 return STATUS_OK;
88}
89
90template <typename T>
Steven Moreland71872f82018-10-29 11:46:56 -070091binder_status_t ReadArray(const AParcel* parcel, void* arrayData,
92 ContiguousArrayAllocator<T> allocator) {
Steven Morelanda8845662018-10-12 11:53:03 -070093 const Parcel* rawParcel = parcel->get();
94
95 int32_t length;
96 status_t status = rawParcel->readInt32(&length);
97
98 if (status != STATUS_OK) return PruneStatusT(status);
99 if (length < 0) return STATUS_UNEXPECTED_NULL;
100
Steven Moreland71872f82018-10-29 11:46:56 -0700101 T* array = allocator(arrayData, length);
Steven Morelanda8845662018-10-12 11:53:03 -0700102 if (length == 0) return STATUS_OK;
Steven Morelanda8845662018-10-12 11:53:03 -0700103 if (array == nullptr) return STATUS_NO_MEMORY;
104
105 int32_t size = 0;
106 if (__builtin_smul_overflow(sizeof(T), length, &size)) return STATUS_NO_MEMORY;
107
108 const void* data = rawParcel->readInplace(size);
109 if (data == nullptr) return STATUS_NO_MEMORY;
110
111 memcpy(array, data, size);
112
113 return STATUS_OK;
114}
115
116// Each element in a char16_t array is converted to an int32_t (not packed)
117template <>
Steven Moreland71872f82018-10-29 11:46:56 -0700118binder_status_t ReadArray<char16_t>(const AParcel* parcel, void* arrayData,
119 ContiguousArrayAllocator<char16_t> allocator) {
Steven Morelanda8845662018-10-12 11:53:03 -0700120 const Parcel* rawParcel = parcel->get();
121
122 int32_t length;
123 status_t status = rawParcel->readInt32(&length);
124
125 if (status != STATUS_OK) return PruneStatusT(status);
126 if (length < 0) return STATUS_UNEXPECTED_NULL;
127
Steven Moreland71872f82018-10-29 11:46:56 -0700128 char16_t* array = allocator(arrayData, length);
Steven Morelanda8845662018-10-12 11:53:03 -0700129 if (length == 0) return STATUS_OK;
Steven Morelanda8845662018-10-12 11:53:03 -0700130 if (array == nullptr) return STATUS_NO_MEMORY;
131
132 int32_t size = 0;
133 if (__builtin_smul_overflow(sizeof(char16_t), length, &size)) return STATUS_NO_MEMORY;
134
135 for (int32_t i = 0; i < length; i++) {
136 status = rawParcel->readChar(array + i);
137
138 if (status != STATUS_OK) return PruneStatusT(status);
139 }
140
141 return STATUS_OK;
142}
143
144template <typename T>
Steven Moreland16e1eae2018-11-01 09:51:53 -0700145binder_status_t WriteArray(AParcel* parcel, const void* arrayData, size_t length,
146 ArrayGetter<T> getter, status_t (Parcel::*write)(T)) {
Steven Morelanda8845662018-10-12 11:53:03 -0700147 if (length > std::numeric_limits<int32_t>::max()) return STATUS_BAD_VALUE;
148
149 Parcel* rawParcel = parcel->get();
150
151 status_t status = rawParcel->writeInt32(static_cast<int32_t>(length));
152 if (status != STATUS_OK) return PruneStatusT(status);
153
154 for (size_t i = 0; i < length; i++) {
155 status = (rawParcel->*write)(getter(arrayData, i));
156
157 if (status != STATUS_OK) return PruneStatusT(status);
158 }
159
160 return STATUS_OK;
161}
162
163template <typename T>
Steven Moreland71872f82018-10-29 11:46:56 -0700164binder_status_t ReadArray(const AParcel* parcel, void* arrayData, ArrayAllocator<T> allocator,
165 ArraySetter<T> setter, status_t (Parcel::*read)(T*) const) {
Steven Morelanda8845662018-10-12 11:53:03 -0700166 const Parcel* rawParcel = parcel->get();
167
168 int32_t length;
169 status_t status = rawParcel->readInt32(&length);
170
171 if (status != STATUS_OK) return PruneStatusT(status);
172 if (length < 0) return STATUS_UNEXPECTED_NULL;
173
Steven Moreland71872f82018-10-29 11:46:56 -0700174 if (!allocator(arrayData, length)) return STATUS_NO_MEMORY;
Steven Morelanda8845662018-10-12 11:53:03 -0700175
176 for (size_t i = 0; i < length; i++) {
177 T readTarget;
178 status = (rawParcel->*read)(&readTarget);
179 if (status != STATUS_OK) return PruneStatusT(status);
180
Steven Moreland71872f82018-10-29 11:46:56 -0700181 setter(arrayData, i, readTarget);
Steven Morelanda8845662018-10-12 11:53:03 -0700182 }
183
184 return STATUS_OK;
185}
186
Steven Moreland9b80e282018-09-19 13:57:23 -0700187void AParcel_delete(AParcel* parcel) {
188 delete parcel;
Steven Morelandcaa776c2018-09-04 13:48:11 -0700189}
190
Steven Moreland2e87adc2018-08-20 19:47:00 -0700191binder_status_t AParcel_writeStrongBinder(AParcel* parcel, AIBinder* binder) {
Steven Morelandc0e46d32018-09-12 15:40:49 -0700192 sp<IBinder> writeBinder = binder != nullptr ? binder->getBinder() : nullptr;
Steven Morelandf18615b2018-09-14 11:43:06 -0700193 return parcel->get()->writeStrongBinder(writeBinder);
Steven Moreland2e87adc2018-08-20 19:47:00 -0700194}
195binder_status_t AParcel_readStrongBinder(const AParcel* parcel, AIBinder** binder) {
196 sp<IBinder> readBinder = nullptr;
Steven Morelandf18615b2018-09-14 11:43:06 -0700197 status_t status = parcel->get()->readStrongBinder(&readBinder);
Steven Moreland5d62e442018-09-13 15:01:02 -0700198 if (status != STATUS_OK) {
199 return PruneStatusT(status);
Steven Moreland2e87adc2018-08-20 19:47:00 -0700200 }
Steven Moreland94968952018-09-05 14:42:59 -0700201 sp<AIBinder> ret = ABpBinder::lookupOrCreateFromBinder(readBinder);
Steven Moreland71cddc32018-08-30 23:39:22 -0700202 AIBinder_incStrong(ret.get());
203 *binder = ret.get();
Steven Moreland5d62e442018-09-13 15:01:02 -0700204 return PruneStatusT(status);
Steven Moreland2e87adc2018-08-20 19:47:00 -0700205}
206binder_status_t AParcel_readNullableStrongBinder(const AParcel* parcel, AIBinder** binder) {
207 sp<IBinder> readBinder = nullptr;
Steven Morelandf18615b2018-09-14 11:43:06 -0700208 status_t status = parcel->get()->readNullableStrongBinder(&readBinder);
Steven Moreland5d62e442018-09-13 15:01:02 -0700209 if (status != STATUS_OK) {
210 return PruneStatusT(status);
Steven Moreland2e87adc2018-08-20 19:47:00 -0700211 }
Steven Moreland94968952018-09-05 14:42:59 -0700212 sp<AIBinder> ret = ABpBinder::lookupOrCreateFromBinder(readBinder);
Steven Moreland71cddc32018-08-30 23:39:22 -0700213 AIBinder_incStrong(ret.get());
214 *binder = ret.get();
Steven Moreland5d62e442018-09-13 15:01:02 -0700215 return PruneStatusT(status);
Steven Moreland2e87adc2018-08-20 19:47:00 -0700216}
Steven Moreland063f2362018-10-18 12:49:11 -0700217
218binder_status_t AParcel_writeParcelFileDescriptor(AParcel* parcel, int fd) {
219 ParcelFileDescriptor parcelFd((unique_fd(fd)));
220
221 status_t status = parcel->get()->writeParcelable(parcelFd);
222
223 // ownership is retained by caller
224 (void)parcelFd.release().release();
225
226 return PruneStatusT(status);
227}
228
229binder_status_t AParcel_readParcelFileDescriptor(const AParcel* parcel, int* fd) {
230 ParcelFileDescriptor parcelFd;
231 // status_t status = parcelFd.readFromParcel(parcel->get());
232 status_t status = parcel->get()->readParcelable(&parcelFd);
233 if (status != STATUS_OK) return PruneStatusT(status);
234
235 *fd = parcelFd.release().release();
236 return STATUS_OK;
237}
238
Steven Moreland9a51db82018-09-14 10:59:35 -0700239binder_status_t AParcel_writeStatusHeader(AParcel* parcel, const AStatus* status) {
240 return PruneStatusT(status->get()->writeToParcel(parcel->get()));
241}
242binder_status_t AParcel_readStatusHeader(const AParcel* parcel, AStatus** status) {
243 ::android::binder::Status bstatus;
244 binder_status_t ret = PruneStatusT(bstatus.readFromParcel(*parcel->get()));
Steven Morelandc1a11b82018-10-29 18:47:23 -0700245 if (ret == STATUS_OK) {
Steven Moreland9a51db82018-09-14 10:59:35 -0700246 *status = new AStatus(std::move(bstatus));
247 }
Steven Morelandc1a11b82018-10-29 18:47:23 -0700248 return PruneStatusT(ret);
Steven Moreland9a51db82018-09-14 10:59:35 -0700249}
Steven Moreland2e87adc2018-08-20 19:47:00 -0700250
Steven Moreland7b06f592018-10-03 19:25:32 -0700251binder_status_t AParcel_writeString(AParcel* parcel, const char* string, size_t length) {
252 const uint8_t* str8 = (uint8_t*)string;
253
254 const ssize_t len16 = utf8_to_utf16_length(str8, length);
255
256 if (len16 < 0 || len16 >= std::numeric_limits<int32_t>::max()) {
257 LOG(WARNING) << __func__ << ": Invalid string length: " << len16;
258 return STATUS_BAD_VALUE;
259 }
260
261 status_t err = parcel->get()->writeInt32(len16);
262 if (err) {
263 return PruneStatusT(err);
264 }
265
266 void* str16 = parcel->get()->writeInplace((len16 + 1) * sizeof(char16_t));
267 if (str16 == nullptr) {
268 return STATUS_NO_MEMORY;
269 }
270
271 utf8_to_utf16(str8, length, (char16_t*)str16, (size_t)len16 + 1);
272
273 return STATUS_OK;
274}
275
Steven Moreland71872f82018-10-29 11:46:56 -0700276binder_status_t AParcel_readString(const AParcel* parcel, AParcel_stringAllocator allocator,
277 void* stringData) {
Steven Moreland7b06f592018-10-03 19:25:32 -0700278 size_t len16;
279 const char16_t* str16 = parcel->get()->readString16Inplace(&len16);
280
281 if (str16 == nullptr) {
282 LOG(WARNING) << __func__ << ": Failed to read string in place.";
283 return STATUS_UNEXPECTED_NULL;
284 }
285
286 ssize_t len8;
287
288 if (len16 == 0) {
289 len8 = 1;
290 } else {
291 len8 = utf16_to_utf8_length(str16, len16) + 1;
292 }
293
294 if (len8 <= 0 || len8 >= std::numeric_limits<int32_t>::max()) {
295 LOG(WARNING) << __func__ << ": Invalid string length: " << len8;
296 return STATUS_BAD_VALUE;
297 }
298
Steven Moreland71872f82018-10-29 11:46:56 -0700299 char* str8 = allocator(stringData, len8);
Steven Moreland7b06f592018-10-03 19:25:32 -0700300
301 if (str8 == nullptr) {
Steven Moreland71872f82018-10-29 11:46:56 -0700302 LOG(WARNING) << __func__ << ": AParcel_stringAllocator failed to allocate.";
Steven Moreland7b06f592018-10-03 19:25:32 -0700303 return STATUS_NO_MEMORY;
304 }
305
306 utf16_to_utf8(str16, len16, str8, len8);
307
308 return STATUS_OK;
309}
310
Steven Moreland2e87adc2018-08-20 19:47:00 -0700311// See gen_parcel_helper.py. These auto-generated read/write methods use the same types for
312// libbinder and this library.
313// @START
314binder_status_t AParcel_writeInt32(AParcel* parcel, int32_t value) {
Steven Morelandf18615b2018-09-14 11:43:06 -0700315 status_t status = parcel->get()->writeInt32(value);
Steven Moreland5d62e442018-09-13 15:01:02 -0700316 return PruneStatusT(status);
Steven Moreland2e87adc2018-08-20 19:47:00 -0700317}
318
319binder_status_t AParcel_writeUint32(AParcel* parcel, uint32_t value) {
Steven Morelandf18615b2018-09-14 11:43:06 -0700320 status_t status = parcel->get()->writeUint32(value);
Steven Moreland5d62e442018-09-13 15:01:02 -0700321 return PruneStatusT(status);
Steven Moreland2e87adc2018-08-20 19:47:00 -0700322}
323
324binder_status_t AParcel_writeInt64(AParcel* parcel, int64_t value) {
Steven Morelandf18615b2018-09-14 11:43:06 -0700325 status_t status = parcel->get()->writeInt64(value);
Steven Moreland5d62e442018-09-13 15:01:02 -0700326 return PruneStatusT(status);
Steven Moreland2e87adc2018-08-20 19:47:00 -0700327}
328
329binder_status_t AParcel_writeUint64(AParcel* parcel, uint64_t value) {
Steven Morelandf18615b2018-09-14 11:43:06 -0700330 status_t status = parcel->get()->writeUint64(value);
Steven Moreland5d62e442018-09-13 15:01:02 -0700331 return PruneStatusT(status);
Steven Moreland2e87adc2018-08-20 19:47:00 -0700332}
333
334binder_status_t AParcel_writeFloat(AParcel* parcel, float value) {
Steven Morelandf18615b2018-09-14 11:43:06 -0700335 status_t status = parcel->get()->writeFloat(value);
Steven Moreland5d62e442018-09-13 15:01:02 -0700336 return PruneStatusT(status);
Steven Moreland2e87adc2018-08-20 19:47:00 -0700337}
338
339binder_status_t AParcel_writeDouble(AParcel* parcel, double value) {
Steven Morelandf18615b2018-09-14 11:43:06 -0700340 status_t status = parcel->get()->writeDouble(value);
Steven Moreland5d62e442018-09-13 15:01:02 -0700341 return PruneStatusT(status);
Steven Moreland2e87adc2018-08-20 19:47:00 -0700342}
343
344binder_status_t AParcel_writeBool(AParcel* parcel, bool value) {
Steven Morelandf18615b2018-09-14 11:43:06 -0700345 status_t status = parcel->get()->writeBool(value);
Steven Moreland5d62e442018-09-13 15:01:02 -0700346 return PruneStatusT(status);
Steven Moreland2e87adc2018-08-20 19:47:00 -0700347}
348
349binder_status_t AParcel_writeChar(AParcel* parcel, char16_t value) {
Steven Morelandf18615b2018-09-14 11:43:06 -0700350 status_t status = parcel->get()->writeChar(value);
Steven Moreland5d62e442018-09-13 15:01:02 -0700351 return PruneStatusT(status);
Steven Moreland2e87adc2018-08-20 19:47:00 -0700352}
353
354binder_status_t AParcel_writeByte(AParcel* parcel, int8_t value) {
Steven Morelandf18615b2018-09-14 11:43:06 -0700355 status_t status = parcel->get()->writeByte(value);
Steven Moreland5d62e442018-09-13 15:01:02 -0700356 return PruneStatusT(status);
Steven Moreland2e87adc2018-08-20 19:47:00 -0700357}
358
359binder_status_t AParcel_readInt32(const AParcel* parcel, int32_t* value) {
Steven Morelandf18615b2018-09-14 11:43:06 -0700360 status_t status = parcel->get()->readInt32(value);
Steven Moreland5d62e442018-09-13 15:01:02 -0700361 return PruneStatusT(status);
Steven Moreland2e87adc2018-08-20 19:47:00 -0700362}
363
364binder_status_t AParcel_readUint32(const AParcel* parcel, uint32_t* value) {
Steven Morelandf18615b2018-09-14 11:43:06 -0700365 status_t status = parcel->get()->readUint32(value);
Steven Moreland5d62e442018-09-13 15:01:02 -0700366 return PruneStatusT(status);
Steven Moreland2e87adc2018-08-20 19:47:00 -0700367}
368
369binder_status_t AParcel_readInt64(const AParcel* parcel, int64_t* value) {
Steven Morelandf18615b2018-09-14 11:43:06 -0700370 status_t status = parcel->get()->readInt64(value);
Steven Moreland5d62e442018-09-13 15:01:02 -0700371 return PruneStatusT(status);
Steven Moreland2e87adc2018-08-20 19:47:00 -0700372}
373
374binder_status_t AParcel_readUint64(const AParcel* parcel, uint64_t* value) {
Steven Morelandf18615b2018-09-14 11:43:06 -0700375 status_t status = parcel->get()->readUint64(value);
Steven Moreland5d62e442018-09-13 15:01:02 -0700376 return PruneStatusT(status);
Steven Moreland2e87adc2018-08-20 19:47:00 -0700377}
378
379binder_status_t AParcel_readFloat(const AParcel* parcel, float* value) {
Steven Morelandf18615b2018-09-14 11:43:06 -0700380 status_t status = parcel->get()->readFloat(value);
Steven Moreland5d62e442018-09-13 15:01:02 -0700381 return PruneStatusT(status);
Steven Moreland2e87adc2018-08-20 19:47:00 -0700382}
383
384binder_status_t AParcel_readDouble(const AParcel* parcel, double* value) {
Steven Morelandf18615b2018-09-14 11:43:06 -0700385 status_t status = parcel->get()->readDouble(value);
Steven Moreland5d62e442018-09-13 15:01:02 -0700386 return PruneStatusT(status);
Steven Moreland2e87adc2018-08-20 19:47:00 -0700387}
388
389binder_status_t AParcel_readBool(const AParcel* parcel, bool* value) {
Steven Morelandf18615b2018-09-14 11:43:06 -0700390 status_t status = parcel->get()->readBool(value);
Steven Moreland5d62e442018-09-13 15:01:02 -0700391 return PruneStatusT(status);
Steven Moreland2e87adc2018-08-20 19:47:00 -0700392}
393
394binder_status_t AParcel_readChar(const AParcel* parcel, char16_t* value) {
Steven Morelandf18615b2018-09-14 11:43:06 -0700395 status_t status = parcel->get()->readChar(value);
Steven Moreland5d62e442018-09-13 15:01:02 -0700396 return PruneStatusT(status);
Steven Moreland2e87adc2018-08-20 19:47:00 -0700397}
398
399binder_status_t AParcel_readByte(const AParcel* parcel, int8_t* value) {
Steven Morelandf18615b2018-09-14 11:43:06 -0700400 status_t status = parcel->get()->readByte(value);
Steven Moreland5d62e442018-09-13 15:01:02 -0700401 return PruneStatusT(status);
Steven Moreland2e87adc2018-08-20 19:47:00 -0700402}
403
Steven Morelanda8845662018-10-12 11:53:03 -0700404binder_status_t AParcel_writeInt32Array(AParcel* parcel, const int32_t* value, size_t length) {
405 return WriteArray<int32_t>(parcel, value, length);
406}
407
408binder_status_t AParcel_writeUint32Array(AParcel* parcel, const uint32_t* value, size_t length) {
409 return WriteArray<uint32_t>(parcel, value, length);
410}
411
412binder_status_t AParcel_writeInt64Array(AParcel* parcel, const int64_t* value, size_t length) {
413 return WriteArray<int64_t>(parcel, value, length);
414}
415
416binder_status_t AParcel_writeUint64Array(AParcel* parcel, const uint64_t* value, size_t length) {
417 return WriteArray<uint64_t>(parcel, value, length);
418}
419
420binder_status_t AParcel_writeFloatArray(AParcel* parcel, const float* value, size_t length) {
421 return WriteArray<float>(parcel, value, length);
422}
423
424binder_status_t AParcel_writeDoubleArray(AParcel* parcel, const double* value, size_t length) {
425 return WriteArray<double>(parcel, value, length);
426}
427
Steven Moreland16e1eae2018-11-01 09:51:53 -0700428binder_status_t AParcel_writeBoolArray(AParcel* parcel, const void* arrayData, size_t length,
429 AParcel_boolArrayGetter getter) {
430 return WriteArray<bool>(parcel, arrayData, length, getter, &Parcel::writeBool);
Steven Morelanda8845662018-10-12 11:53:03 -0700431}
432
433binder_status_t AParcel_writeCharArray(AParcel* parcel, const char16_t* value, size_t length) {
434 return WriteArray<char16_t>(parcel, value, length);
435}
436
437binder_status_t AParcel_writeByteArray(AParcel* parcel, const int8_t* value, size_t length) {
438 return WriteArray<int8_t>(parcel, value, length);
439}
440
Steven Moreland71872f82018-10-29 11:46:56 -0700441binder_status_t AParcel_readInt32Array(const AParcel* parcel, void* arrayData,
442 AParcel_int32Allocator allocator) {
443 return ReadArray<int32_t>(parcel, arrayData, allocator);
Steven Morelanda8845662018-10-12 11:53:03 -0700444}
445
Steven Moreland71872f82018-10-29 11:46:56 -0700446binder_status_t AParcel_readUint32Array(const AParcel* parcel, void* arrayData,
447 AParcel_uint32Allocator allocator) {
448 return ReadArray<uint32_t>(parcel, arrayData, allocator);
Steven Morelanda8845662018-10-12 11:53:03 -0700449}
450
Steven Moreland71872f82018-10-29 11:46:56 -0700451binder_status_t AParcel_readInt64Array(const AParcel* parcel, void* arrayData,
452 AParcel_int64Allocator allocator) {
453 return ReadArray<int64_t>(parcel, arrayData, allocator);
Steven Morelanda8845662018-10-12 11:53:03 -0700454}
455
Steven Moreland71872f82018-10-29 11:46:56 -0700456binder_status_t AParcel_readUint64Array(const AParcel* parcel, void* arrayData,
457 AParcel_uint64Allocator allocator) {
458 return ReadArray<uint64_t>(parcel, arrayData, allocator);
Steven Morelanda8845662018-10-12 11:53:03 -0700459}
460
Steven Moreland71872f82018-10-29 11:46:56 -0700461binder_status_t AParcel_readFloatArray(const AParcel* parcel, void* arrayData,
462 AParcel_floatAllocator allocator) {
463 return ReadArray<float>(parcel, arrayData, allocator);
Steven Morelanda8845662018-10-12 11:53:03 -0700464}
465
Steven Moreland71872f82018-10-29 11:46:56 -0700466binder_status_t AParcel_readDoubleArray(const AParcel* parcel, void* arrayData,
467 AParcel_doubleAllocator allocator) {
468 return ReadArray<double>(parcel, arrayData, allocator);
Steven Morelanda8845662018-10-12 11:53:03 -0700469}
470
Steven Moreland71872f82018-10-29 11:46:56 -0700471binder_status_t AParcel_readBoolArray(const AParcel* parcel, void* arrayData,
472 AParcel_boolAllocator allocator,
Steven Morelanda8845662018-10-12 11:53:03 -0700473 AParcel_boolArraySetter setter) {
Steven Moreland71872f82018-10-29 11:46:56 -0700474 return ReadArray<bool>(parcel, arrayData, allocator, setter, &Parcel::readBool);
Steven Morelanda8845662018-10-12 11:53:03 -0700475}
476
Steven Moreland71872f82018-10-29 11:46:56 -0700477binder_status_t AParcel_readCharArray(const AParcel* parcel, void* arrayData,
478 AParcel_charAllocator allocator) {
479 return ReadArray<char16_t>(parcel, arrayData, allocator);
Steven Morelanda8845662018-10-12 11:53:03 -0700480}
481
Steven Moreland71872f82018-10-29 11:46:56 -0700482binder_status_t AParcel_readByteArray(const AParcel* parcel, void* arrayData,
483 AParcel_byteAllocator allocator) {
484 return ReadArray<int8_t>(parcel, arrayData, allocator);
Steven Morelanda8845662018-10-12 11:53:03 -0700485}
486
Steven Moreland2e87adc2018-08-20 19:47:00 -0700487// @END