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 /**
18  * @addtogroup NdkBinder
19  * @{
20  */
21 
22 /**
23  * @file binder_parcel.h
24  * @brief A collection of data that can be sent as a single packet.
25  */
26 
27 #pragma once
28 
29 #include <stdbool.h>
30 #include <stddef.h>
31 #include <sys/cdefs.h>
32 
33 #include <android/binder_status.h>
34 
35 struct AIBinder;
36 typedef struct AIBinder AIBinder;
37 
38 __BEGIN_DECLS
39 #if __ANDROID_API__ >= 29
40 
41 /**
42  * This object represents a package of data that can be sent between processes. When transacting, an
43  * instance of it is automatically created to be used for the transaction. When two processes use
44  * binder to communicate, they must agree on a format of this parcel to be used in order to transfer
45  * data. This is usually done in an IDL (see AIDL, specificially).
46  */
47 struct AParcel;
48 typedef struct AParcel AParcel;
49 
50 /**
51  * Cleans up a parcel.
52  *
53  * Available since API level 29.
54  *
55  * \param parcel A parcel returned by AIBinder_prepareTransaction or AIBinder_transact when a
56  * transaction is being aborted.
57  */
58 void AParcel_delete(AParcel* parcel) __INTRODUCED_IN(29);
59 
60 /**
61  * Sets the position within the parcel.
62  *
63  * Available since API level 29.
64  *
65  * \param parcel The parcel of which to set the position.
66  * \param position Position of the parcel to set. This must be a value returned by
67  * AParcel_getDataPosition. Positions are constant for a given parcel between processes.
68  *
69  * \return STATUS_OK on success. If position is negative, then STATUS_BAD_VALUE will be returned.
70  */
71 binder_status_t AParcel_setDataPosition(const AParcel* parcel, int32_t position)
72         __INTRODUCED_IN(29);
73 
74 /**
75  * Gets the current position within the parcel.
76  *
77  * Available since API level 29.
78  *
79  * \param parcel The parcel of which to get the position.
80  *
81  * \return The size of the parcel. This will always be greater than 0. The values returned by this
82  * function before and after calling various reads and writes are not defined. Only the delta
83  * between two positions between a specific sequence of calls is defined. For instance, if position
84  * is X, writeBool is called, and then position is Y, readBool can be called from position X will
85  * return the same value, and then position will be Y.
86  */
87 int32_t AParcel_getDataPosition(const AParcel* parcel) __INTRODUCED_IN(29);
88 
89 /**
90  * This is called to allocate a buffer for a C-style string (null-terminated). The returned buffer
91  * should be at least length bytes. This includes space for a null terminator. For a string, length
92  * will always be strictly less than or equal to the maximum size that can be held in a size_t and
93  * will always be greater than 0. However, if a 'null' string is being read, length will be -1.
94  *
95  * See also AParcel_readString.
96  *
97  * If allocation fails, null should be returned.
98  *
99  * \param stringData some external representation of a string
100  * \param length the length of the buffer needed to fill (including the null-terminator)
101  * \param buffer a buffer of size 'length' or null if allocation failed.
102  *
103  * \return true if the allocation succeeded, false otherwise. If length is -1, a true return here
104  * means that a 'null' value (or equivalent) was successfully stored.
105  */
106 typedef bool (*AParcel_stringAllocator)(void* stringData, int32_t length, char** buffer);
107 
108 /**
109  * This is called to allocate an array of size 'length'. If length is -1, then a 'null' array (or
110  * equivalent) should be created.
111  *
112  * See also AParcel_readStringArray
113  *
114  * \param arrayData some external representation of an array
115  * \param length the length to allocate this array to
116  *
117  * \return true if allocation succeeded. If length is -1, a true return here means that a 'null'
118  * value (or equivalent) was successfully stored.
119  */
120 typedef bool (*AParcel_stringArrayAllocator)(void* arrayData, int32_t length);
121 
122 /**
123  * This is called to allocate a string inside of an array that was allocated by an
124  * AParcel_stringArrayAllocator.
125  *
126  * The index returned will always be within the range [0, length of arrayData). The returned buffer
127  * should be at least length bytes. This includes space for a null-terminator. For a string, length
128  * will always be strictly less than or equal to the maximum size that can be held in a size_t and
129  * will always be greater than 0. However, if a 'null' string is being read, length will be -1.
130  *
131  * See also AParcel_readStringArray
132  *
133  * \param arrayData some external representation of an array.
134  * \param index the index at which a string should be allocated.
135  * \param length the length of the string to be allocated at this index. See also
136  * AParcel_stringAllocator. This includes the length required for a null-terminator.
137  * \param buffer a buffer of size 'length' or null if allocation failed.
138  *
139  * \return true if the allocation succeeded, false otherwise. If length is -1, a true return here
140  * means that a 'null' value (or equivalent) was successfully stored.
141  */
142 typedef bool (*AParcel_stringArrayElementAllocator)(void* arrayData, size_t index, int32_t length,
143                                                     char** buffer);
144 
145 /**
146  * This returns the length and buffer of an array at a specific index in an arrayData object.
147  *
148  * See also AParcel_writeStringArray
149  *
150  * \param arrayData some external representation of an array.
151  * \param index the index at which a string should be allocated.
152  * \param outLength an out parameter for the length of the string at the specified index. This
153  * should not include the length for a null-terminator if there is one. If the object at this index
154  * is 'null', then this should be set to -1.
155  *
156  * \param a buffer of size outLength or more representing the string at the provided index. This is
157  * not required to be null-terminated. If the object at index is null, then this should be null.
158  */
159 typedef const char* (*AParcel_stringArrayElementGetter)(const void* arrayData, size_t index,
160                                                         int32_t* outLength);
161 
162 /**
163  * This is called to allocate an array of size 'length'. If length is -1, then a 'null' array (or
164  * equivalent) should be created.
165  *
166  * See also AParcel_readParcelableArray
167  *
168  * \param arrayData some external representation of an array
169  * \param length the length to allocate this array to
170  *
171  * \return true if allocation succeeded. If length is -1, a true return here means that a 'null'
172  * value (or equivalent) was successfully stored.
173  */
174 typedef bool (*AParcel_parcelableArrayAllocator)(void* arrayData, int32_t length);
175 
176 /**
177  * This is called to parcel the underlying data from an arrayData object at index.
178  *
179  * See also AParcel_writeParcelableArray
180  *
181  * \param parcel parcel to write the parcelable to
182  * \param arrayData some external representation of an array of parcelables (a user-defined type).
183  * \param index the index of the value to be retrieved.
184  *
185  * \return status (usually returned from other parceling functions). STATUS_OK for success.
186  */
187 typedef binder_status_t (*AParcel_writeParcelableElement)(AParcel* parcel, const void* arrayData,
188                                                           size_t index);
189 
190 /**
191  * This is called to set an underlying value in an arrayData object at index.
192  *
193  * See also AParcel_readParcelableArray
194  *
195  * \param parcel parcel to read the parcelable from
196  * \param arrayData some external representation of an array of parcelables (a user-defined type).
197  * \param index the index of the value to be set.
198  *
199  * \return status (usually returned from other parceling functions). STATUS_OK for success.
200  */
201 typedef binder_status_t (*AParcel_readParcelableElement)(const AParcel* parcel, void* arrayData,
202                                                          size_t index);
203 
204 // @START-PRIMITIVE-VECTOR-GETTERS
205 /**
206  * This is called to get the underlying data from an arrayData object.
207  *
208  * The implementation of this function should allocate a contiguous array of size 'length' and
209  * return that underlying buffer to be filled out. If there is an error or length is 0, null may be
210  * returned. If length is -1, this should allocate some representation of a null array.
211  *
212  * See also AParcel_readInt32Array
213  *
214  * \param arrayData some external representation of an array of int32_t.
215  * \param length the length to allocate arrayData to.
216  * \param outBuffer a buffer of int32_t of size 'length' (if length is >= 0, if length is 0, this
217  * may be nullptr).
218  *
219  * \return whether or not the allocation was successful (or whether a null array is represented when
220  * length is -1).
221  */
222 typedef bool (*AParcel_int32ArrayAllocator)(void* arrayData, int32_t length, int32_t** outBuffer);
223 
224 /**
225  * This is called to get the underlying data from an arrayData object.
226  *
227  * The implementation of this function should allocate a contiguous array of size 'length' and
228  * return that underlying buffer to be filled out. If there is an error or length is 0, null may be
229  * returned. If length is -1, this should allocate some representation of a null array.
230  *
231  * See also AParcel_readUint32Array
232  *
233  * \param arrayData some external representation of an array of uint32_t.
234  * \param length the length to allocate arrayData to.
235  * \param outBuffer a buffer of uint32_t of size 'length' (if length is >= 0, if length is 0, this
236  * may be nullptr).
237  *
238  * \return whether or not the allocation was successful (or whether a null array is represented when
239  * length is -1).
240  */
241 typedef bool (*AParcel_uint32ArrayAllocator)(void* arrayData, int32_t length, uint32_t** outBuffer);
242 
243 /**
244  * This is called to get the underlying data from an arrayData object.
245  *
246  * The implementation of this function should allocate a contiguous array of size 'length' and
247  * return that underlying buffer to be filled out. If there is an error or length is 0, null may be
248  * returned. If length is -1, this should allocate some representation of a null array.
249  *
250  * See also AParcel_readInt64Array
251  *
252  * \param arrayData some external representation of an array of int64_t.
253  * \param length the length to allocate arrayData to.
254  * \param outBuffer a buffer of int64_t of size 'length' (if length is >= 0, if length is 0, this
255  * may be nullptr).
256  *
257  * \return whether or not the allocation was successful (or whether a null array is represented when
258  * length is -1).
259  */
260 typedef bool (*AParcel_int64ArrayAllocator)(void* arrayData, int32_t length, int64_t** outBuffer);
261 
262 /**
263  * This is called to get the underlying data from an arrayData object.
264  *
265  * The implementation of this function should allocate a contiguous array of size 'length' and
266  * return that underlying buffer to be filled out. If there is an error or length is 0, null may be
267  * returned. If length is -1, this should allocate some representation of a null array.
268  *
269  * See also AParcel_readUint64Array
270  *
271  * \param arrayData some external representation of an array of uint64_t.
272  * \param length the length to allocate arrayData to.
273  * \param outBuffer a buffer of uint64_t of size 'length' (if length is >= 0, if length is 0, this
274  * may be nullptr).
275  *
276  * \return whether or not the allocation was successful (or whether a null array is represented when
277  * length is -1).
278  */
279 typedef bool (*AParcel_uint64ArrayAllocator)(void* arrayData, int32_t length, uint64_t** outBuffer);
280 
281 /**
282  * This is called to get the underlying data from an arrayData object.
283  *
284  * The implementation of this function should allocate a contiguous array of size 'length' and
285  * return that underlying buffer to be filled out. If there is an error or length is 0, null may be
286  * returned. If length is -1, this should allocate some representation of a null array.
287  *
288  * See also AParcel_readFloatArray
289  *
290  * \param arrayData some external representation of an array of float.
291  * \param length the length to allocate arrayData to.
292  * \param outBuffer a buffer of float of size 'length' (if length is >= 0, if length is 0, this may
293  * be nullptr).
294  *
295  * \return whether or not the allocation was successful (or whether a null array is represented when
296  * length is -1).
297  */
298 typedef bool (*AParcel_floatArrayAllocator)(void* arrayData, int32_t length, float** outBuffer);
299 
300 /**
301  * This is called to get the underlying data from an arrayData object.
302  *
303  * The implementation of this function should allocate a contiguous array of size 'length' and
304  * return that underlying buffer to be filled out. If there is an error or length is 0, null may be
305  * returned. If length is -1, this should allocate some representation of a null array.
306  *
307  * See also AParcel_readDoubleArray
308  *
309  * \param arrayData some external representation of an array of double.
310  * \param length the length to allocate arrayData to.
311  * \param outBuffer a buffer of double of size 'length' (if length is >= 0, if length is 0, this may
312  * be nullptr).
313  *
314  * \return whether or not the allocation was successful (or whether a null array is represented when
315  * length is -1).
316  */
317 typedef bool (*AParcel_doubleArrayAllocator)(void* arrayData, int32_t length, double** outBuffer);
318 
319 /**
320  * This allocates an array of size 'length' inside of arrayData and returns whether or not there was
321  * a success. If length is -1, then this should allocate some representation of a null array.
322  *
323  * See also AParcel_readBoolArray
324  *
325  * \param arrayData some external representation of an array of bool.
326  * \param length the length to allocate arrayData to (or -1 if this represents a null array).
327  *
328  * \return whether the allocation succeeded.
329  */
330 typedef bool (*AParcel_boolArrayAllocator)(void* arrayData, int32_t length);
331 
332 /**
333  * This is called to get the underlying data from an arrayData object at index.
334  *
335  * See also AParcel_writeBoolArray
336  *
337  * \param arrayData some external representation of an array of bool.
338  * \param index the index of the value to be retrieved.
339  *
340  * \return the value of the array at index index.
341  */
342 typedef bool (*AParcel_boolArrayGetter)(const void* arrayData, size_t index);
343 
344 /**
345  * This is called to set an underlying value in an arrayData object at index.
346  *
347  * See also AParcel_readBoolArray
348  *
349  * \param arrayData some external representation of an array of bool.
350  * \param index the index of the value to be set.
351  * \param value the value to set at index index.
352  */
353 typedef void (*AParcel_boolArraySetter)(void* arrayData, size_t index, bool value);
354 
355 /**
356  * This is called to get the underlying data from an arrayData object.
357  *
358  * The implementation of this function should allocate a contiguous array of size 'length' and
359  * return that underlying buffer to be filled out. If there is an error or length is 0, null may be
360  * returned. If length is -1, this should allocate some representation of a null array.
361  *
362  * See also AParcel_readCharArray
363  *
364  * \param arrayData some external representation of an array of char16_t.
365  * \param length the length to allocate arrayData to.
366  * \param outBuffer a buffer of char16_t of size 'length' (if length is >= 0, if length is 0, this
367  * may be nullptr).
368  *
369  * \return whether or not the allocation was successful (or whether a null array is represented when
370  * length is -1).
371  */
372 typedef bool (*AParcel_charArrayAllocator)(void* arrayData, int32_t length, char16_t** outBuffer);
373 
374 /**
375  * This is called to get the underlying data from an arrayData object.
376  *
377  * The implementation of this function should allocate a contiguous array of size 'length' and
378  * return that underlying buffer to be filled out. If there is an error or length is 0, null may be
379  * returned. If length is -1, this should allocate some representation of a null array.
380  *
381  * See also AParcel_readByteArray
382  *
383  * \param arrayData some external representation of an array of int8_t.
384  * \param length the length to allocate arrayData to.
385  * \param outBuffer a buffer of int8_t of size 'length' (if length is >= 0, if length is 0, this may
386  * be nullptr).
387  *
388  * \return whether or not the allocation was successful (or whether a null array is represented when
389  * length is -1).
390  */
391 typedef bool (*AParcel_byteArrayAllocator)(void* arrayData, int32_t length, int8_t** outBuffer);
392 
393 // @END-PRIMITIVE-VECTOR-GETTERS
394 
395 /**
396  * Writes an AIBinder to the next location in a non-null parcel. Can be null. This does not take any
397  * refcounts of ownership of the binder from the client.
398  *
399  * Available since API level 29.
400  *
401  * \param parcel the parcel to write to.
402  * \param binder the value to write to the parcel.
403  *
404  * \return STATUS_OK on successful write.
405  */
406 binder_status_t AParcel_writeStrongBinder(AParcel* parcel, AIBinder* binder) __INTRODUCED_IN(29);
407 
408 /**
409  * Reads an AIBinder from the next location in a non-null parcel. One strong ref-count of ownership
410  * is passed to the caller of this function.
411  *
412  * Available since API level 29.
413  *
414  * \param parcel the parcel to read from.
415  * \param binder the out parameter for what is read from the parcel. This may be null.
416  *
417  * \return STATUS_OK on successful write.
418  */
419 binder_status_t AParcel_readStrongBinder(const AParcel* parcel, AIBinder** binder)
420         __INTRODUCED_IN(29);
421 
422 /**
423  * Writes a file descriptor to the next location in a non-null parcel. This does not take ownership
424  * of fd.
425  *
426  * This corresponds to the SDK's android.os.ParcelFileDescriptor.
427  *
428  * Available since API level 29.
429  *
430  * \param parcel the parcel to write to.
431  * \param fd the value to write to the parcel (-1 to represent a null ParcelFileDescriptor).
432  *
433  * \return STATUS_OK on successful write.
434  */
435 binder_status_t AParcel_writeParcelFileDescriptor(AParcel* parcel, int fd) __INTRODUCED_IN(29);
436 
437 /**
438  * Reads an int from the next location in a non-null parcel.
439  *
440  * The returned fd must be closed.
441  *
442  * This corresponds to the SDK's android.os.ParcelFileDescriptor.
443  *
444  * Available since API level 29.
445  *
446  * \param parcel the parcel to read from.
447  * \param fd the out parameter for what is read from the parcel (or -1 to represent a null
448  * ParcelFileDescriptor)
449  *
450  * \return STATUS_OK on successful write.
451  */
452 binder_status_t AParcel_readParcelFileDescriptor(const AParcel* parcel, int* fd)
453         __INTRODUCED_IN(29);
454 
455 /**
456  * Writes an AStatus object to the next location in a non-null parcel.
457  *
458  * If the status is considered to be a low-level status and has no additional information other
459  * than a binder_status_t (for instance, if it is created with AStatus_fromStatus), then that
460  * status will be returned from this method and nothing will be written to the parcel. If either
461  * this happens or if writing the status object itself fails, the return value from this function
462  * should be propagated to the client, and AParcel_readStatusHeader shouldn't be called.
463  *
464  * Available since API level 29.
465  *
466  * \param parcel the parcel to write to.
467  * \param status the value to write to the parcel.
468  *
469  * \return STATUS_OK on successful write.
470  */
471 binder_status_t AParcel_writeStatusHeader(AParcel* parcel, const AStatus* status)
472         __INTRODUCED_IN(29);
473 
474 /**
475  * Reads an AStatus from the next location in a non-null parcel. Ownership is passed to the caller
476  * of this function.
477  *
478  * Available since API level 29.
479  *
480  * \param parcel the parcel to read from.
481  * \param status the out parameter for what is read from the parcel.
482  *
483  * \return STATUS_OK on successful write.
484  */
485 binder_status_t AParcel_readStatusHeader(const AParcel* parcel, AStatus** status)
486         __INTRODUCED_IN(29);
487 
488 /**
489  * Writes utf-8 string value to the next location in a non-null parcel.
490  *
491  * If length is -1, and string is nullptr, this will write a 'null' string to the parcel.
492  *
493  * Available since API level 29.
494  *
495  * \param parcel the parcel to write to.
496  * \param string the null-terminated string to write to the parcel, at least of size 'length'.
497  * \param length the length of the string to be written.
498  *
499  * \return STATUS_OK on successful write.
500  */
501 binder_status_t AParcel_writeString(AParcel* parcel, const char* string, int32_t length)
502         __INTRODUCED_IN(29);
503 
504 /**
505  * Reads and allocates utf-8 string value from the next location in a non-null parcel.
506  *
507  * Data is passed to the string allocator once the string size is known. This size includes the
508  * space for the null-terminator of this string. This allocator returns a buffer which is used as
509  * the output buffer from this read. If there is a 'null' string on the binder buffer, the allocator
510  * will be called with length -1.
511  *
512  * Available since API level 29.
513  *
514  * \param parcel the parcel to read from.
515  * \param stringData some external representation of a string.
516  * \param allocator allocator that will be called once the size of the string is known.
517  *
518  * \return STATUS_OK on successful write.
519  */
520 binder_status_t AParcel_readString(const AParcel* parcel, void* stringData,
521                                    AParcel_stringAllocator allocator) __INTRODUCED_IN(29);
522 
523 /**
524  * Writes utf-8 string array data to the next location in a non-null parcel.
525  *
526  * length is the length of the array. AParcel_stringArrayElementGetter will be called for all
527  * indices in range [0, length) with the arrayData provided here. The string length and buffer
528  * returned from this function will be used to fill out the data from the parcel. If length is -1,
529  * this will write a 'null' string array to the binder buffer.
530  *
531  * Available since API level 29.
532  *
533  * \param parcel the parcel to write to.
534  * \param arrayData some external representation of an array.
535  * \param length the length of the array to be written.
536  * \param getter the callback that will be called for every index of the array to retrieve the
537  * corresponding string buffer.
538  *
539  * \return STATUS_OK on successful write.
540  */
541 binder_status_t AParcel_writeStringArray(AParcel* parcel, const void* arrayData, int32_t length,
542                                          AParcel_stringArrayElementGetter getter)
543         __INTRODUCED_IN(29);
544 
545 /**
546  * Reads and allocates utf-8 string array value from the next location in a non-null parcel.
547  *
548  * First, AParcel_stringArrayAllocator will be called with the size of the array to be read where
549  * length is the length of the array to be read from the parcel. Then, for each index i in [0,
550  * length), AParcel_stringArrayElementAllocator will be called with the length of the string to be
551  * read from the parcel. The resultant buffer from each of these calls will be filled according to
552  * the contents of the string that is read. If the string array being read is 'null', this will
553  * instead just pass -1 to AParcel_stringArrayAllocator.
554  *
555  * Available since API level 29.
556  *
557  * \param parcel the parcel to read from.
558  * \param arrayData some external representation of an array.
559  * \param allocator the callback that will be called with arrayData once the size of the output
560  * array is known.
561  * \param elementAllocator the callback that will be called on every index of arrayData to allocate
562  * the string at that location.
563  *
564  * \return STATUS_OK on successful read.
565  */
566 binder_status_t AParcel_readStringArray(const AParcel* parcel, void* arrayData,
567                                         AParcel_stringArrayAllocator allocator,
568                                         AParcel_stringArrayElementAllocator elementAllocator)
569         __INTRODUCED_IN(29);
570 
571 /**
572  * Writes an array of parcelables (user-defined types) to the next location in a non-null parcel.
573  *
574  * Available since API level 29.
575  *
576  * \param parcel the parcel to write to.
577  * \param arrayData an array of size 'length' (or null if length is -1, may be null if length is 0).
578  * \param length the length of arrayData or -1 if this represents a null array.
579  * \param elementWriter function to be called for every array index to write the user-defined type
580  * at that location.
581  *
582  * \return STATUS_OK on successful write.
583  */
584 binder_status_t AParcel_writeParcelableArray(AParcel* parcel, const void* arrayData, int32_t length,
585                                              AParcel_writeParcelableElement elementWriter)
586         __INTRODUCED_IN(29);
587 
588 /**
589  * Reads an array of parcelables (user-defined types) from the next location in a non-null parcel.
590  *
591  * First, allocator will be called with the length of the array. If the allocation succeeds and the
592  * length is greater than zero, elementReader will be called for every index to read the
593  * corresponding parcelable.
594  *
595  * Available since API level 29.
596  *
597  * \param parcel the parcel to read from.
598  * \param arrayData some external representation of an array.
599  * \param allocator the callback that will be called to allocate the array.
600  * \param elementReader the callback that will be called to fill out individual elements.
601  *
602  * \return STATUS_OK on successful read.
603  */
604 binder_status_t AParcel_readParcelableArray(const AParcel* parcel, void* arrayData,
605                                             AParcel_parcelableArrayAllocator allocator,
606                                             AParcel_readParcelableElement elementReader)
607         __INTRODUCED_IN(29);
608 
609 // @START-PRIMITIVE-READ-WRITE
610 /**
611  * Writes int32_t value to the next location in a non-null parcel.
612  *
613  * Available since API level 29.
614  *
615  * \param parcel the parcel to write to.
616  * \param value the value to write to the parcel.
617  *
618  * \return STATUS_OK on successful write.
619  */
620 binder_status_t AParcel_writeInt32(AParcel* parcel, int32_t value) __INTRODUCED_IN(29);
621 
622 /**
623  * Writes uint32_t value to the next location in a non-null parcel.
624  *
625  * Available since API level 29.
626  *
627  * \param parcel the parcel to write to.
628  * \param value the value to write to the parcel.
629  *
630  * \return STATUS_OK on successful write.
631  */
632 binder_status_t AParcel_writeUint32(AParcel* parcel, uint32_t value) __INTRODUCED_IN(29);
633 
634 /**
635  * Writes int64_t value to the next location in a non-null parcel.
636  *
637  * Available since API level 29.
638  *
639  * \param parcel the parcel to write to.
640  * \param value the value to write to the parcel.
641  *
642  * \return STATUS_OK on successful write.
643  */
644 binder_status_t AParcel_writeInt64(AParcel* parcel, int64_t value) __INTRODUCED_IN(29);
645 
646 /**
647  * Writes uint64_t value to the next location in a non-null parcel.
648  *
649  * Available since API level 29.
650  *
651  * \param parcel the parcel to write to.
652  * \param value the value to write to the parcel.
653  *
654  * \return STATUS_OK on successful write.
655  */
656 binder_status_t AParcel_writeUint64(AParcel* parcel, uint64_t value) __INTRODUCED_IN(29);
657 
658 /**
659  * Writes float value to the next location in a non-null parcel.
660  *
661  * Available since API level 29.
662  *
663  * \param parcel the parcel to write to.
664  * \param value the value to write to the parcel.
665  *
666  * \return STATUS_OK on successful write.
667  */
668 binder_status_t AParcel_writeFloat(AParcel* parcel, float value) __INTRODUCED_IN(29);
669 
670 /**
671  * Writes double value to the next location in a non-null parcel.
672  *
673  * Available since API level 29.
674  *
675  * \param parcel the parcel to write to.
676  * \param value the value to write to the parcel.
677  *
678  * \return STATUS_OK on successful write.
679  */
680 binder_status_t AParcel_writeDouble(AParcel* parcel, double value) __INTRODUCED_IN(29);
681 
682 /**
683  * Writes bool value to the next location in a non-null parcel.
684  *
685  * Available since API level 29.
686  *
687  * \param parcel the parcel to write to.
688  * \param value the value to write to the parcel.
689  *
690  * \return STATUS_OK on successful write.
691  */
692 binder_status_t AParcel_writeBool(AParcel* parcel, bool value) __INTRODUCED_IN(29);
693 
694 /**
695  * Writes char16_t value to the next location in a non-null parcel.
696  *
697  * Available since API level 29.
698  *
699  * \param parcel the parcel to write to.
700  * \param value the value to write to the parcel.
701  *
702  * \return STATUS_OK on successful write.
703  */
704 binder_status_t AParcel_writeChar(AParcel* parcel, char16_t value) __INTRODUCED_IN(29);
705 
706 /**
707  * Writes int8_t value to the next location in a non-null parcel.
708  *
709  * Available since API level 29.
710  *
711  * \param parcel the parcel to write to.
712  * \param value the value to write to the parcel.
713  *
714  * \return STATUS_OK on successful write.
715  */
716 binder_status_t AParcel_writeByte(AParcel* parcel, int8_t value) __INTRODUCED_IN(29);
717 
718 /**
719  * Reads into int32_t value from the next location in a non-null parcel.
720  *
721  * Available since API level 29.
722  *
723  * \param parcel the parcel to read from.
724  * \param value the value to read from the parcel.
725  *
726  * \return STATUS_OK on successful read.
727  */
728 binder_status_t AParcel_readInt32(const AParcel* parcel, int32_t* value) __INTRODUCED_IN(29);
729 
730 /**
731  * Reads into uint32_t value from the next location in a non-null parcel.
732  *
733  * Available since API level 29.
734  *
735  * \param parcel the parcel to read from.
736  * \param value the value to read from the parcel.
737  *
738  * \return STATUS_OK on successful read.
739  */
740 binder_status_t AParcel_readUint32(const AParcel* parcel, uint32_t* value) __INTRODUCED_IN(29);
741 
742 /**
743  * Reads into int64_t value from the next location in a non-null parcel.
744  *
745  * Available since API level 29.
746  *
747  * \param parcel the parcel to read from.
748  * \param value the value to read from the parcel.
749  *
750  * \return STATUS_OK on successful read.
751  */
752 binder_status_t AParcel_readInt64(const AParcel* parcel, int64_t* value) __INTRODUCED_IN(29);
753 
754 /**
755  * Reads into uint64_t value from the next location in a non-null parcel.
756  *
757  * Available since API level 29.
758  *
759  * \param parcel the parcel to read from.
760  * \param value the value to read from the parcel.
761  *
762  * \return STATUS_OK on successful read.
763  */
764 binder_status_t AParcel_readUint64(const AParcel* parcel, uint64_t* value) __INTRODUCED_IN(29);
765 
766 /**
767  * Reads into float value from the next location in a non-null parcel.
768  *
769  * Available since API level 29.
770  *
771  * \param parcel the parcel to read from.
772  * \param value the value to read from the parcel.
773  *
774  * \return STATUS_OK on successful read.
775  */
776 binder_status_t AParcel_readFloat(const AParcel* parcel, float* value) __INTRODUCED_IN(29);
777 
778 /**
779  * Reads into double value from the next location in a non-null parcel.
780  *
781  * Available since API level 29.
782  *
783  * \param parcel the parcel to read from.
784  * \param value the value to read from the parcel.
785  *
786  * \return STATUS_OK on successful read.
787  */
788 binder_status_t AParcel_readDouble(const AParcel* parcel, double* value) __INTRODUCED_IN(29);
789 
790 /**
791  * Reads into bool value from the next location in a non-null parcel.
792  *
793  * Available since API level 29.
794  *
795  * \param parcel the parcel to read from.
796  * \param value the value to read from the parcel.
797  *
798  * \return STATUS_OK on successful read.
799  */
800 binder_status_t AParcel_readBool(const AParcel* parcel, bool* value) __INTRODUCED_IN(29);
801 
802 /**
803  * Reads into char16_t value from the next location in a non-null parcel.
804  *
805  * Available since API level 29.
806  *
807  * \param parcel the parcel to read from.
808  * \param value the value to read from the parcel.
809  *
810  * \return STATUS_OK on successful read.
811  */
812 binder_status_t AParcel_readChar(const AParcel* parcel, char16_t* value) __INTRODUCED_IN(29);
813 
814 /**
815  * Reads into int8_t value from the next location in a non-null parcel.
816  *
817  * Available since API level 29.
818  *
819  * \param parcel the parcel to read from.
820  * \param value the value to read from the parcel.
821  *
822  * \return STATUS_OK on successful read.
823  */
824 binder_status_t AParcel_readByte(const AParcel* parcel, int8_t* value) __INTRODUCED_IN(29);
825 
826 /**
827  * Writes an array of int32_t to the next location in a non-null parcel.
828  *
829  * Available since API level 29.
830  *
831  * \param parcel the parcel to write to.
832  * \param arrayData an array of size 'length' (or null if length is -1, may be null if length is 0).
833  * \param length the length of arrayData or -1 if this represents a null array.
834  *
835  * \return STATUS_OK on successful write.
836  */
837 binder_status_t AParcel_writeInt32Array(AParcel* parcel, const int32_t* arrayData, int32_t length)
838         __INTRODUCED_IN(29);
839 
840 /**
841  * Writes an array of uint32_t to the next location in a non-null parcel.
842  *
843  * Available since API level 29.
844  *
845  * \param parcel the parcel to write to.
846  * \param arrayData an array of size 'length' (or null if length is -1, may be null if length is 0).
847  * \param length the length of arrayData or -1 if this represents a null array.
848  *
849  * \return STATUS_OK on successful write.
850  */
851 binder_status_t AParcel_writeUint32Array(AParcel* parcel, const uint32_t* arrayData, int32_t length)
852         __INTRODUCED_IN(29);
853 
854 /**
855  * Writes an array of int64_t to the next location in a non-null parcel.
856  *
857  * Available since API level 29.
858  *
859  * \param parcel the parcel to write to.
860  * \param arrayData an array of size 'length' (or null if length is -1, may be null if length is 0).
861  * \param length the length of arrayData or -1 if this represents a null array.
862  *
863  * \return STATUS_OK on successful write.
864  */
865 binder_status_t AParcel_writeInt64Array(AParcel* parcel, const int64_t* arrayData, int32_t length)
866         __INTRODUCED_IN(29);
867 
868 /**
869  * Writes an array of uint64_t to the next location in a non-null parcel.
870  *
871  * Available since API level 29.
872  *
873  * \param parcel the parcel to write to.
874  * \param arrayData an array of size 'length' (or null if length is -1, may be null if length is 0).
875  * \param length the length of arrayData or -1 if this represents a null array.
876  *
877  * \return STATUS_OK on successful write.
878  */
879 binder_status_t AParcel_writeUint64Array(AParcel* parcel, const uint64_t* arrayData, int32_t length)
880         __INTRODUCED_IN(29);
881 
882 /**
883  * Writes an array of float to the next location in a non-null parcel.
884  *
885  * Available since API level 29.
886  *
887  * \param parcel the parcel to write to.
888  * \param arrayData an array of size 'length' (or null if length is -1, may be null if length is 0).
889  * \param length the length of arrayData or -1 if this represents a null array.
890  *
891  * \return STATUS_OK on successful write.
892  */
893 binder_status_t AParcel_writeFloatArray(AParcel* parcel, const float* arrayData, int32_t length)
894         __INTRODUCED_IN(29);
895 
896 /**
897  * Writes an array of double to the next location in a non-null parcel.
898  *
899  * Available since API level 29.
900  *
901  * \param parcel the parcel to write to.
902  * \param arrayData an array of size 'length' (or null if length is -1, may be null if length is 0).
903  * \param length the length of arrayData or -1 if this represents a null array.
904  *
905  * \return STATUS_OK on successful write.
906  */
907 binder_status_t AParcel_writeDoubleArray(AParcel* parcel, const double* arrayData, int32_t length)
908         __INTRODUCED_IN(29);
909 
910 /**
911  * Writes an array of bool to the next location in a non-null parcel.
912  *
913  * getter(arrayData, i) will be called for each i in [0, length) in order to get the underlying
914  * values to write to the parcel.
915  *
916  * Available since API level 29.
917  *
918  * \param parcel the parcel to write to.
919  * \param arrayData some external representation of an array.
920  * \param length the length of arrayData (or -1 if this represents a null array).
921  * \param getter the callback to retrieve data at specific locations in the array.
922  *
923  * \return STATUS_OK on successful write.
924  */
925 binder_status_t AParcel_writeBoolArray(AParcel* parcel, const void* arrayData, int32_t length,
926                                        AParcel_boolArrayGetter getter) __INTRODUCED_IN(29);
927 
928 /**
929  * Writes an array of char16_t to the next location in a non-null parcel.
930  *
931  * Available since API level 29.
932  *
933  * \param parcel the parcel to write to.
934  * \param arrayData an array of size 'length' (or null if length is -1, may be null if length is 0).
935  * \param length the length of arrayData or -1 if this represents a null array.
936  *
937  * \return STATUS_OK on successful write.
938  */
939 binder_status_t AParcel_writeCharArray(AParcel* parcel, const char16_t* arrayData, int32_t length)
940         __INTRODUCED_IN(29);
941 
942 /**
943  * Writes an array of int8_t to the next location in a non-null parcel.
944  *
945  * Available since API level 29.
946  *
947  * \param parcel the parcel to write to.
948  * \param arrayData an array of size 'length' (or null if length is -1, may be null if length is 0).
949  * \param length the length of arrayData or -1 if this represents a null array.
950  *
951  * \return STATUS_OK on successful write.
952  */
953 binder_status_t AParcel_writeByteArray(AParcel* parcel, const int8_t* arrayData, int32_t length)
954         __INTRODUCED_IN(29);
955 
956 /**
957  * Reads an array of int32_t from the next location in a non-null parcel.
958  *
959  * First, allocator will be called with the length of the array. If the allocation succeeds and the
960  * length is greater than zero, the buffer returned by the allocator will be filled with the
961  * corresponding data
962  *
963  * Available since API level 29.
964  *
965  * \param parcel the parcel to read from.
966  * \param arrayData some external representation of an array.
967  * \param allocator the callback that will be called to allocate the array.
968  *
969  * \return STATUS_OK on successful read.
970  */
971 binder_status_t AParcel_readInt32Array(const AParcel* parcel, void* arrayData,
972                                        AParcel_int32ArrayAllocator allocator) __INTRODUCED_IN(29);
973 
974 /**
975  * Reads an array of uint32_t from the next location in a non-null parcel.
976  *
977  * First, allocator will be called with the length of the array. If the allocation succeeds and the
978  * length is greater than zero, the buffer returned by the allocator will be filled with the
979  * corresponding data
980  *
981  * Available since API level 29.
982  *
983  * \param parcel the parcel to read from.
984  * \param arrayData some external representation of an array.
985  * \param allocator the callback that will be called to allocate the array.
986  *
987  * \return STATUS_OK on successful read.
988  */
989 binder_status_t AParcel_readUint32Array(const AParcel* parcel, void* arrayData,
990                                         AParcel_uint32ArrayAllocator allocator) __INTRODUCED_IN(29);
991 
992 /**
993  * Reads an array of int64_t from the next location in a non-null parcel.
994  *
995  * First, allocator will be called with the length of the array. If the allocation succeeds and the
996  * length is greater than zero, the buffer returned by the allocator will be filled with the
997  * corresponding data
998  *
999  * Available since API level 29.
1000  *
1001  * \param parcel the parcel to read from.
1002  * \param arrayData some external representation of an array.
1003  * \param allocator the callback that will be called to allocate the array.
1004  *
1005  * \return STATUS_OK on successful read.
1006  */
1007 binder_status_t AParcel_readInt64Array(const AParcel* parcel, void* arrayData,
1008                                        AParcel_int64ArrayAllocator allocator) __INTRODUCED_IN(29);
1009 
1010 /**
1011  * Reads an array of uint64_t from the next location in a non-null parcel.
1012  *
1013  * First, allocator will be called with the length of the array. If the allocation succeeds and the
1014  * length is greater than zero, the buffer returned by the allocator will be filled with the
1015  * corresponding data
1016  *
1017  * Available since API level 29.
1018  *
1019  * \param parcel the parcel to read from.
1020  * \param arrayData some external representation of an array.
1021  * \param allocator the callback that will be called to allocate the array.
1022  *
1023  * \return STATUS_OK on successful read.
1024  */
1025 binder_status_t AParcel_readUint64Array(const AParcel* parcel, void* arrayData,
1026                                         AParcel_uint64ArrayAllocator allocator) __INTRODUCED_IN(29);
1027 
1028 /**
1029  * Reads an array of float from the next location in a non-null parcel.
1030  *
1031  * First, allocator will be called with the length of the array. If the allocation succeeds and the
1032  * length is greater than zero, the buffer returned by the allocator will be filled with the
1033  * corresponding data
1034  *
1035  * Available since API level 29.
1036  *
1037  * \param parcel the parcel to read from.
1038  * \param arrayData some external representation of an array.
1039  * \param allocator the callback that will be called to allocate the array.
1040  *
1041  * \return STATUS_OK on successful read.
1042  */
1043 binder_status_t AParcel_readFloatArray(const AParcel* parcel, void* arrayData,
1044                                        AParcel_floatArrayAllocator allocator) __INTRODUCED_IN(29);
1045 
1046 /**
1047  * Reads an array of double from the next location in a non-null parcel.
1048  *
1049  * First, allocator will be called with the length of the array. If the allocation succeeds and the
1050  * length is greater than zero, the buffer returned by the allocator will be filled with the
1051  * corresponding data
1052  *
1053  * Available since API level 29.
1054  *
1055  * \param parcel the parcel to read from.
1056  * \param arrayData some external representation of an array.
1057  * \param allocator the callback that will be called to allocate the array.
1058  *
1059  * \return STATUS_OK on successful read.
1060  */
1061 binder_status_t AParcel_readDoubleArray(const AParcel* parcel, void* arrayData,
1062                                         AParcel_doubleArrayAllocator allocator) __INTRODUCED_IN(29);
1063 
1064 /**
1065  * Reads an array of bool from the next location in a non-null parcel.
1066  *
1067  * First, allocator will be called with the length of the array. Then, for every i in [0, length),
1068  * setter(arrayData, i, x) will be called where x is the value at the associated index.
1069  *
1070  * Available since API level 29.
1071  *
1072  * \param parcel the parcel to read from.
1073  * \param arrayData some external representation of an array.
1074  * \param allocator the callback that will be called to allocate the array.
1075  * \param setter the callback that will be called to set a value at a specific location in the
1076  * array.
1077  *
1078  * \return STATUS_OK on successful read.
1079  */
1080 binder_status_t AParcel_readBoolArray(const AParcel* parcel, void* arrayData,
1081                                       AParcel_boolArrayAllocator allocator,
1082                                       AParcel_boolArraySetter setter) __INTRODUCED_IN(29);
1083 
1084 /**
1085  * Reads an array of char16_t from the next location in a non-null parcel.
1086  *
1087  * First, allocator will be called with the length of the array. If the allocation succeeds and the
1088  * length is greater than zero, the buffer returned by the allocator will be filled with the
1089  * corresponding data
1090  *
1091  * Available since API level 29.
1092  *
1093  * \param parcel the parcel to read from.
1094  * \param arrayData some external representation of an array.
1095  * \param allocator the callback that will be called to allocate the array.
1096  *
1097  * \return STATUS_OK on successful read.
1098  */
1099 binder_status_t AParcel_readCharArray(const AParcel* parcel, void* arrayData,
1100                                       AParcel_charArrayAllocator allocator) __INTRODUCED_IN(29);
1101 
1102 /**
1103  * Reads an array of int8_t from the next location in a non-null parcel.
1104  *
1105  * First, allocator will be called with the length of the array. If the allocation succeeds and the
1106  * length is greater than zero, the buffer returned by the allocator will be filled with the
1107  * corresponding data
1108  *
1109  * Available since API level 29.
1110  *
1111  * \param parcel the parcel to read from.
1112  * \param arrayData some external representation of an array.
1113  * \param allocator the callback that will be called to allocate the array.
1114  *
1115  * \return STATUS_OK on successful read.
1116  */
1117 binder_status_t AParcel_readByteArray(const AParcel* parcel, void* arrayData,
1118                                       AParcel_byteArrayAllocator allocator) __INTRODUCED_IN(29);
1119 
1120 // @END-PRIMITIVE-READ-WRITE
1121 
1122 #endif  //__ANDROID_API__ >= 29
1123 __END_DECLS
1124 
1125 /** @} */
1126