Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 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 <android/binder_parcel.h> |
Steven Moreland | 4d5ad49 | 2018-09-13 12:49:16 -0700 | [diff] [blame] | 18 | #include "parcel_internal.h" |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 19 | |
Steven Moreland | 4d5ad49 | 2018-09-13 12:49:16 -0700 | [diff] [blame] | 20 | #include "ibinder_internal.h" |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 21 | #include "status_internal.h" |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 22 | |
Steven Moreland | 7b06f59 | 2018-10-03 19:25:32 -0700 | [diff] [blame] | 23 | #include <limits> |
| 24 | |
| 25 | #include <android-base/logging.h> |
Steven Moreland | 063f236 | 2018-10-18 12:49:11 -0700 | [diff] [blame] | 26 | #include <android-base/unique_fd.h> |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 27 | #include <binder/Parcel.h> |
Steven Moreland | 063f236 | 2018-10-18 12:49:11 -0700 | [diff] [blame] | 28 | #include <binder/ParcelFileDescriptor.h> |
Steven Moreland | 7b06f59 | 2018-10-03 19:25:32 -0700 | [diff] [blame] | 29 | #include <utils/Unicode.h> |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 30 | |
| 31 | using ::android::IBinder; |
| 32 | using ::android::Parcel; |
| 33 | using ::android::sp; |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 34 | using ::android::status_t; |
Steven Moreland | 063f236 | 2018-10-18 12:49:11 -0700 | [diff] [blame] | 35 | using ::android::base::unique_fd; |
| 36 | using ::android::os::ParcelFileDescriptor; |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 37 | |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 38 | template <typename T> |
Steven Moreland | 01ebcf7 | 2018-11-15 15:06:26 -0800 | [diff] [blame] | 39 | using ContiguousArrayAllocator = bool (*)(void* arrayData, int32_t length, T** outBuffer); |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 40 | |
| 41 | template <typename T> |
Steven Moreland | 01ebcf7 | 2018-11-15 15:06:26 -0800 | [diff] [blame] | 42 | using ArrayAllocator = bool (*)(void* arrayData, int32_t length); |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 43 | template <typename T> |
| 44 | using ArrayGetter = T (*)(const void* arrayData, size_t index); |
| 45 | template <typename T> |
| 46 | using ArraySetter = void (*)(void* arrayData, size_t index, T value); |
| 47 | |
Steven Moreland | 01ebcf7 | 2018-11-15 15:06:26 -0800 | [diff] [blame] | 48 | binder_status_t WriteAndValidateArraySize(AParcel* parcel, bool isNullArray, int32_t length) { |
| 49 | // only -1 can be used to represent a null array |
| 50 | if (length < -1) return STATUS_BAD_VALUE; |
| 51 | |
| 52 | if (!isNullArray && length < 0) { |
| 53 | LOG(ERROR) << __func__ << ": null array must be used with length == -1."; |
| 54 | return STATUS_BAD_VALUE; |
| 55 | } |
| 56 | if (isNullArray && length > 0) { |
| 57 | LOG(ERROR) << __func__ << ": null buffer cannot be for size " << length << " array."; |
| 58 | return STATUS_BAD_VALUE; |
| 59 | } |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 60 | |
| 61 | Parcel* rawParcel = parcel->get(); |
| 62 | |
| 63 | status_t status = rawParcel->writeInt32(static_cast<int32_t>(length)); |
| 64 | if (status != STATUS_OK) return PruneStatusT(status); |
| 65 | |
Steven Moreland | 01ebcf7 | 2018-11-15 15:06:26 -0800 | [diff] [blame] | 66 | return STATUS_OK; |
| 67 | } |
| 68 | |
| 69 | template <typename T> |
| 70 | binder_status_t WriteArray(AParcel* parcel, const T* array, int32_t length) { |
| 71 | binder_status_t status = WriteAndValidateArraySize(parcel, array == nullptr, length); |
| 72 | if (status != STATUS_OK) return status; |
| 73 | if (length <= 0) return STATUS_OK; |
| 74 | |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 75 | int32_t size = 0; |
| 76 | if (__builtin_smul_overflow(sizeof(T), length, &size)) return STATUS_NO_MEMORY; |
| 77 | |
Steven Moreland | 01ebcf7 | 2018-11-15 15:06:26 -0800 | [diff] [blame] | 78 | void* const data = parcel->get()->writeInplace(size); |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 79 | if (data == nullptr) return STATUS_NO_MEMORY; |
| 80 | |
| 81 | memcpy(data, array, size); |
| 82 | |
| 83 | return STATUS_OK; |
| 84 | } |
| 85 | |
| 86 | // Each element in a char16_t array is converted to an int32_t (not packed). |
| 87 | template <> |
Steven Moreland | 01ebcf7 | 2018-11-15 15:06:26 -0800 | [diff] [blame] | 88 | binder_status_t WriteArray<char16_t>(AParcel* parcel, const char16_t* array, int32_t length) { |
| 89 | binder_status_t status = WriteAndValidateArraySize(parcel, array == nullptr, length); |
| 90 | if (status != STATUS_OK) return status; |
| 91 | if (length <= 0) return STATUS_OK; |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 92 | |
| 93 | int32_t size = 0; |
| 94 | if (__builtin_smul_overflow(sizeof(char16_t), length, &size)) return STATUS_NO_MEMORY; |
| 95 | |
Steven Moreland | 01ebcf7 | 2018-11-15 15:06:26 -0800 | [diff] [blame] | 96 | Parcel* rawParcel = parcel->get(); |
| 97 | |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 98 | for (int32_t i = 0; i < length; i++) { |
| 99 | status = rawParcel->writeChar(array[i]); |
| 100 | |
| 101 | if (status != STATUS_OK) return PruneStatusT(status); |
| 102 | } |
| 103 | |
| 104 | return STATUS_OK; |
| 105 | } |
| 106 | |
| 107 | template <typename T> |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 108 | binder_status_t ReadArray(const AParcel* parcel, void* arrayData, |
| 109 | ContiguousArrayAllocator<T> allocator) { |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 110 | const Parcel* rawParcel = parcel->get(); |
| 111 | |
| 112 | int32_t length; |
| 113 | status_t status = rawParcel->readInt32(&length); |
| 114 | |
| 115 | if (status != STATUS_OK) return PruneStatusT(status); |
Steven Moreland | 01ebcf7 | 2018-11-15 15:06:26 -0800 | [diff] [blame] | 116 | if (length < -1) return STATUS_BAD_VALUE; |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 117 | |
Steven Moreland | 01ebcf7 | 2018-11-15 15:06:26 -0800 | [diff] [blame] | 118 | T* array; |
| 119 | if (!allocator(arrayData, length, &array)) return STATUS_NO_MEMORY; |
| 120 | |
| 121 | if (length <= 0) return STATUS_OK; |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 122 | if (array == nullptr) return STATUS_NO_MEMORY; |
| 123 | |
| 124 | int32_t size = 0; |
| 125 | if (__builtin_smul_overflow(sizeof(T), length, &size)) return STATUS_NO_MEMORY; |
| 126 | |
| 127 | const void* data = rawParcel->readInplace(size); |
| 128 | if (data == nullptr) return STATUS_NO_MEMORY; |
| 129 | |
| 130 | memcpy(array, data, size); |
| 131 | |
| 132 | return STATUS_OK; |
| 133 | } |
| 134 | |
| 135 | // Each element in a char16_t array is converted to an int32_t (not packed) |
| 136 | template <> |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 137 | binder_status_t ReadArray<char16_t>(const AParcel* parcel, void* arrayData, |
| 138 | ContiguousArrayAllocator<char16_t> allocator) { |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 139 | const Parcel* rawParcel = parcel->get(); |
| 140 | |
| 141 | int32_t length; |
| 142 | status_t status = rawParcel->readInt32(&length); |
| 143 | |
| 144 | if (status != STATUS_OK) return PruneStatusT(status); |
Steven Moreland | 01ebcf7 | 2018-11-15 15:06:26 -0800 | [diff] [blame] | 145 | if (length < -1) return STATUS_BAD_VALUE; |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 146 | |
Steven Moreland | 01ebcf7 | 2018-11-15 15:06:26 -0800 | [diff] [blame] | 147 | char16_t* array; |
| 148 | if (!allocator(arrayData, length, &array)) return STATUS_NO_MEMORY; |
| 149 | |
| 150 | if (length <= 0) return STATUS_OK; |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 151 | if (array == nullptr) return STATUS_NO_MEMORY; |
| 152 | |
| 153 | int32_t size = 0; |
| 154 | if (__builtin_smul_overflow(sizeof(char16_t), length, &size)) return STATUS_NO_MEMORY; |
| 155 | |
| 156 | for (int32_t i = 0; i < length; i++) { |
| 157 | status = rawParcel->readChar(array + i); |
| 158 | |
| 159 | if (status != STATUS_OK) return PruneStatusT(status); |
| 160 | } |
| 161 | |
| 162 | return STATUS_OK; |
| 163 | } |
| 164 | |
| 165 | template <typename T> |
Steven Moreland | 01ebcf7 | 2018-11-15 15:06:26 -0800 | [diff] [blame] | 166 | binder_status_t WriteArray(AParcel* parcel, const void* arrayData, int32_t length, |
Steven Moreland | 16e1eae | 2018-11-01 09:51:53 -0700 | [diff] [blame] | 167 | ArrayGetter<T> getter, status_t (Parcel::*write)(T)) { |
Steven Moreland | 01ebcf7 | 2018-11-15 15:06:26 -0800 | [diff] [blame] | 168 | // we have no clue if arrayData represents a null object or not, we can only infer from length |
| 169 | bool arrayIsNull = length < 0; |
| 170 | binder_status_t status = WriteAndValidateArraySize(parcel, arrayIsNull, length); |
| 171 | if (status != STATUS_OK) return status; |
| 172 | if (length <= 0) return STATUS_OK; |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 173 | |
| 174 | Parcel* rawParcel = parcel->get(); |
| 175 | |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 176 | for (size_t i = 0; i < length; i++) { |
| 177 | status = (rawParcel->*write)(getter(arrayData, i)); |
| 178 | |
| 179 | if (status != STATUS_OK) return PruneStatusT(status); |
| 180 | } |
| 181 | |
| 182 | return STATUS_OK; |
| 183 | } |
| 184 | |
| 185 | template <typename T> |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 186 | binder_status_t ReadArray(const AParcel* parcel, void* arrayData, ArrayAllocator<T> allocator, |
| 187 | ArraySetter<T> setter, status_t (Parcel::*read)(T*) const) { |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 188 | const Parcel* rawParcel = parcel->get(); |
| 189 | |
| 190 | int32_t length; |
| 191 | status_t status = rawParcel->readInt32(&length); |
| 192 | |
| 193 | if (status != STATUS_OK) return PruneStatusT(status); |
Steven Moreland | 01ebcf7 | 2018-11-15 15:06:26 -0800 | [diff] [blame] | 194 | if (length < -1) return STATUS_BAD_VALUE; |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 195 | |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 196 | if (!allocator(arrayData, length)) return STATUS_NO_MEMORY; |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 197 | |
Steven Moreland | 01ebcf7 | 2018-11-15 15:06:26 -0800 | [diff] [blame] | 198 | if (length <= 0) return STATUS_OK; |
| 199 | |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 200 | for (size_t i = 0; i < length; i++) { |
| 201 | T readTarget; |
| 202 | status = (rawParcel->*read)(&readTarget); |
| 203 | if (status != STATUS_OK) return PruneStatusT(status); |
| 204 | |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 205 | setter(arrayData, i, readTarget); |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | return STATUS_OK; |
| 209 | } |
| 210 | |
Steven Moreland | 9b80e28 | 2018-09-19 13:57:23 -0700 | [diff] [blame] | 211 | void AParcel_delete(AParcel* parcel) { |
| 212 | delete parcel; |
Steven Moreland | caa776c | 2018-09-04 13:48:11 -0700 | [diff] [blame] | 213 | } |
| 214 | |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 215 | binder_status_t AParcel_writeStrongBinder(AParcel* parcel, AIBinder* binder) { |
Steven Moreland | c0e46d3 | 2018-09-12 15:40:49 -0700 | [diff] [blame] | 216 | sp<IBinder> writeBinder = binder != nullptr ? binder->getBinder() : nullptr; |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 217 | return parcel->get()->writeStrongBinder(writeBinder); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 218 | } |
| 219 | binder_status_t AParcel_readStrongBinder(const AParcel* parcel, AIBinder** binder) { |
| 220 | sp<IBinder> readBinder = nullptr; |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 221 | status_t status = parcel->get()->readNullableStrongBinder(&readBinder); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 222 | if (status != STATUS_OK) { |
| 223 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 224 | } |
Steven Moreland | 9496895 | 2018-09-05 14:42:59 -0700 | [diff] [blame] | 225 | sp<AIBinder> ret = ABpBinder::lookupOrCreateFromBinder(readBinder); |
Steven Moreland | 71cddc3 | 2018-08-30 23:39:22 -0700 | [diff] [blame] | 226 | AIBinder_incStrong(ret.get()); |
| 227 | *binder = ret.get(); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 228 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 229 | } |
Steven Moreland | 063f236 | 2018-10-18 12:49:11 -0700 | [diff] [blame] | 230 | |
| 231 | binder_status_t AParcel_writeParcelFileDescriptor(AParcel* parcel, int fd) { |
Steven Moreland | 4ce59c7 | 2018-11-16 15:21:15 -0800 | [diff] [blame^] | 232 | std::unique_ptr<ParcelFileDescriptor> parcelFd; |
Steven Moreland | 063f236 | 2018-10-18 12:49:11 -0700 | [diff] [blame] | 233 | |
Steven Moreland | 4ce59c7 | 2018-11-16 15:21:15 -0800 | [diff] [blame^] | 234 | if (fd < 0) { |
| 235 | if (fd != -1) { |
| 236 | return STATUS_UNKNOWN_ERROR; |
| 237 | } |
| 238 | // parcelFd = nullptr |
| 239 | } else { // fd >= 0 |
| 240 | parcelFd = std::make_unique<ParcelFileDescriptor>(unique_fd(fd)); |
| 241 | } |
| 242 | |
| 243 | status_t status = parcel->get()->writeNullableParcelable(parcelFd); |
Steven Moreland | 063f236 | 2018-10-18 12:49:11 -0700 | [diff] [blame] | 244 | |
| 245 | // ownership is retained by caller |
Steven Moreland | 4ce59c7 | 2018-11-16 15:21:15 -0800 | [diff] [blame^] | 246 | if (parcelFd != nullptr) { |
| 247 | (void)parcelFd->release().release(); |
| 248 | } |
Steven Moreland | 063f236 | 2018-10-18 12:49:11 -0700 | [diff] [blame] | 249 | |
| 250 | return PruneStatusT(status); |
| 251 | } |
| 252 | |
| 253 | binder_status_t AParcel_readParcelFileDescriptor(const AParcel* parcel, int* fd) { |
Steven Moreland | 4ce59c7 | 2018-11-16 15:21:15 -0800 | [diff] [blame^] | 254 | std::unique_ptr<ParcelFileDescriptor> parcelFd; |
| 255 | |
Steven Moreland | 063f236 | 2018-10-18 12:49:11 -0700 | [diff] [blame] | 256 | status_t status = parcel->get()->readParcelable(&parcelFd); |
| 257 | if (status != STATUS_OK) return PruneStatusT(status); |
| 258 | |
Steven Moreland | 4ce59c7 | 2018-11-16 15:21:15 -0800 | [diff] [blame^] | 259 | if (parcelFd) { |
| 260 | *fd = parcelFd->release().release(); |
| 261 | } else { |
| 262 | *fd = -1; |
| 263 | } |
| 264 | |
Steven Moreland | 063f236 | 2018-10-18 12:49:11 -0700 | [diff] [blame] | 265 | return STATUS_OK; |
| 266 | } |
| 267 | |
Steven Moreland | 9a51db8 | 2018-09-14 10:59:35 -0700 | [diff] [blame] | 268 | binder_status_t AParcel_writeStatusHeader(AParcel* parcel, const AStatus* status) { |
| 269 | return PruneStatusT(status->get()->writeToParcel(parcel->get())); |
| 270 | } |
| 271 | binder_status_t AParcel_readStatusHeader(const AParcel* parcel, AStatus** status) { |
| 272 | ::android::binder::Status bstatus; |
| 273 | binder_status_t ret = PruneStatusT(bstatus.readFromParcel(*parcel->get())); |
Steven Moreland | c1a11b8 | 2018-10-29 18:47:23 -0700 | [diff] [blame] | 274 | if (ret == STATUS_OK) { |
Steven Moreland | 9a51db8 | 2018-09-14 10:59:35 -0700 | [diff] [blame] | 275 | *status = new AStatus(std::move(bstatus)); |
| 276 | } |
Steven Moreland | c1a11b8 | 2018-10-29 18:47:23 -0700 | [diff] [blame] | 277 | return PruneStatusT(ret); |
Steven Moreland | 9a51db8 | 2018-09-14 10:59:35 -0700 | [diff] [blame] | 278 | } |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 279 | |
Steven Moreland | b4e1461 | 2018-11-14 17:25:45 -0800 | [diff] [blame] | 280 | binder_status_t AParcel_writeString(AParcel* parcel, const char* string, int32_t length) { |
| 281 | if (string == nullptr) { |
| 282 | if (length != -1) { |
| 283 | LOG(WARNING) << __func__ << ": null string must be used with length == -1."; |
| 284 | return STATUS_BAD_VALUE; |
| 285 | } |
Steven Moreland | 7b06f59 | 2018-10-03 19:25:32 -0700 | [diff] [blame] | 286 | |
Steven Moreland | b4e1461 | 2018-11-14 17:25:45 -0800 | [diff] [blame] | 287 | status_t err = parcel->get()->writeInt32(-1); |
| 288 | return PruneStatusT(err); |
| 289 | } |
| 290 | |
| 291 | if (length < 0) { |
| 292 | LOG(WARNING) << __func__ << ": Negative string length: " << length; |
| 293 | return STATUS_BAD_VALUE; |
| 294 | } |
| 295 | |
| 296 | const uint8_t* str8 = (uint8_t*)string; |
Steven Moreland | 7b06f59 | 2018-10-03 19:25:32 -0700 | [diff] [blame] | 297 | const ssize_t len16 = utf8_to_utf16_length(str8, length); |
| 298 | |
| 299 | if (len16 < 0 || len16 >= std::numeric_limits<int32_t>::max()) { |
| 300 | LOG(WARNING) << __func__ << ": Invalid string length: " << len16; |
| 301 | return STATUS_BAD_VALUE; |
| 302 | } |
| 303 | |
| 304 | status_t err = parcel->get()->writeInt32(len16); |
| 305 | if (err) { |
| 306 | return PruneStatusT(err); |
| 307 | } |
| 308 | |
| 309 | void* str16 = parcel->get()->writeInplace((len16 + 1) * sizeof(char16_t)); |
| 310 | if (str16 == nullptr) { |
| 311 | return STATUS_NO_MEMORY; |
| 312 | } |
| 313 | |
| 314 | utf8_to_utf16(str8, length, (char16_t*)str16, (size_t)len16 + 1); |
| 315 | |
| 316 | return STATUS_OK; |
| 317 | } |
| 318 | |
Steven Moreland | 07fb9c9 | 2018-11-01 17:14:29 -0700 | [diff] [blame] | 319 | binder_status_t AParcel_readString(const AParcel* parcel, void* stringData, |
| 320 | AParcel_stringAllocator allocator) { |
Steven Moreland | 7b06f59 | 2018-10-03 19:25:32 -0700 | [diff] [blame] | 321 | size_t len16; |
| 322 | const char16_t* str16 = parcel->get()->readString16Inplace(&len16); |
| 323 | |
| 324 | if (str16 == nullptr) { |
Steven Moreland | b4e1461 | 2018-11-14 17:25:45 -0800 | [diff] [blame] | 325 | if (allocator(stringData, -1, nullptr)) { |
| 326 | return STATUS_OK; |
| 327 | } |
| 328 | |
Steven Moreland | 7b06f59 | 2018-10-03 19:25:32 -0700 | [diff] [blame] | 329 | return STATUS_UNEXPECTED_NULL; |
| 330 | } |
| 331 | |
| 332 | ssize_t len8; |
| 333 | |
| 334 | if (len16 == 0) { |
| 335 | len8 = 1; |
| 336 | } else { |
| 337 | len8 = utf16_to_utf8_length(str16, len16) + 1; |
| 338 | } |
| 339 | |
Steven Moreland | 07fb9c9 | 2018-11-01 17:14:29 -0700 | [diff] [blame] | 340 | if (len8 <= 0 || len8 > std::numeric_limits<int32_t>::max()) { |
Steven Moreland | 7b06f59 | 2018-10-03 19:25:32 -0700 | [diff] [blame] | 341 | LOG(WARNING) << __func__ << ": Invalid string length: " << len8; |
| 342 | return STATUS_BAD_VALUE; |
| 343 | } |
| 344 | |
Steven Moreland | b4e1461 | 2018-11-14 17:25:45 -0800 | [diff] [blame] | 345 | char* str8; |
| 346 | bool success = allocator(stringData, len8, &str8); |
Steven Moreland | 7b06f59 | 2018-10-03 19:25:32 -0700 | [diff] [blame] | 347 | |
Steven Moreland | b4e1461 | 2018-11-14 17:25:45 -0800 | [diff] [blame] | 348 | if (!success || str8 == nullptr) { |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 349 | LOG(WARNING) << __func__ << ": AParcel_stringAllocator failed to allocate."; |
Steven Moreland | 7b06f59 | 2018-10-03 19:25:32 -0700 | [diff] [blame] | 350 | return STATUS_NO_MEMORY; |
| 351 | } |
| 352 | |
| 353 | utf16_to_utf8(str16, len16, str8, len8); |
| 354 | |
| 355 | return STATUS_OK; |
| 356 | } |
| 357 | |
Steven Moreland | b4e1461 | 2018-11-14 17:25:45 -0800 | [diff] [blame] | 358 | binder_status_t AParcel_writeStringArray(AParcel* parcel, const void* arrayData, int32_t length, |
Steven Moreland | 07fb9c9 | 2018-11-01 17:14:29 -0700 | [diff] [blame] | 359 | AParcel_stringArrayElementGetter getter) { |
Steven Moreland | 01ebcf7 | 2018-11-15 15:06:26 -0800 | [diff] [blame] | 360 | // we have no clue if arrayData represents a null object or not, we can only infer from length |
| 361 | bool arrayIsNull = length < 0; |
| 362 | binder_status_t status = WriteAndValidateArraySize(parcel, arrayIsNull, length); |
| 363 | if (status != STATUS_OK) return status; |
| 364 | if (length <= 0) return STATUS_OK; |
Steven Moreland | 07fb9c9 | 2018-11-01 17:14:29 -0700 | [diff] [blame] | 365 | |
| 366 | for (size_t i = 0; i < length; i++) { |
| 367 | size_t length = 0; |
| 368 | const char* str = getter(arrayData, i, &length); |
Steven Moreland | b4e1461 | 2018-11-14 17:25:45 -0800 | [diff] [blame] | 369 | if (str == nullptr && length != -1) return STATUS_BAD_VALUE; |
Steven Moreland | 07fb9c9 | 2018-11-01 17:14:29 -0700 | [diff] [blame] | 370 | |
| 371 | binder_status_t status = AParcel_writeString(parcel, str, length); |
| 372 | if (status != STATUS_OK) return status; |
| 373 | } |
| 374 | |
| 375 | return STATUS_OK; |
| 376 | } |
| 377 | |
| 378 | // This implements AParcel_stringAllocator for a string using an array, index, and element |
| 379 | // allocator. |
| 380 | struct StringArrayElementAllocationAdapter { |
Steven Moreland | 6cf66ac | 2018-11-02 18:14:54 -0700 | [diff] [blame] | 381 | void* arrayData; // stringData from the NDK |
| 382 | size_t index; // index into the string array |
Steven Moreland | 07fb9c9 | 2018-11-01 17:14:29 -0700 | [diff] [blame] | 383 | AParcel_stringArrayElementAllocator elementAllocator; |
| 384 | |
Steven Moreland | b4e1461 | 2018-11-14 17:25:45 -0800 | [diff] [blame] | 385 | static bool Allocator(void* stringData, int32_t length, char** buffer) { |
Steven Moreland | 07fb9c9 | 2018-11-01 17:14:29 -0700 | [diff] [blame] | 386 | StringArrayElementAllocationAdapter* adapter = |
| 387 | static_cast<StringArrayElementAllocationAdapter*>(stringData); |
Steven Moreland | b4e1461 | 2018-11-14 17:25:45 -0800 | [diff] [blame] | 388 | return adapter->elementAllocator(adapter->arrayData, adapter->index, length, buffer); |
Steven Moreland | 07fb9c9 | 2018-11-01 17:14:29 -0700 | [diff] [blame] | 389 | } |
| 390 | }; |
| 391 | |
| 392 | binder_status_t AParcel_readStringArray(const AParcel* parcel, void* arrayData, |
| 393 | AParcel_stringArrayAllocator allocator, |
| 394 | AParcel_stringArrayElementAllocator elementAllocator) { |
| 395 | const Parcel* rawParcel = parcel->get(); |
| 396 | |
| 397 | int32_t length; |
| 398 | status_t status = rawParcel->readInt32(&length); |
| 399 | |
| 400 | if (status != STATUS_OK) return PruneStatusT(status); |
Steven Moreland | b4e1461 | 2018-11-14 17:25:45 -0800 | [diff] [blame] | 401 | if (length < -1) return STATUS_BAD_VALUE; |
Steven Moreland | 07fb9c9 | 2018-11-01 17:14:29 -0700 | [diff] [blame] | 402 | |
| 403 | if (!allocator(arrayData, length)) return STATUS_NO_MEMORY; |
| 404 | |
Steven Moreland | b4e1461 | 2018-11-14 17:25:45 -0800 | [diff] [blame] | 405 | if (length == -1) return STATUS_OK; // null string array |
| 406 | |
Steven Moreland | 07fb9c9 | 2018-11-01 17:14:29 -0700 | [diff] [blame] | 407 | StringArrayElementAllocationAdapter adapter{ |
| 408 | .arrayData = arrayData, |
| 409 | .index = 0, |
| 410 | .elementAllocator = elementAllocator, |
| 411 | }; |
| 412 | |
| 413 | for (; adapter.index < length; adapter.index++) { |
Steven Moreland | b4e1461 | 2018-11-14 17:25:45 -0800 | [diff] [blame] | 414 | binder_status_t status = AParcel_readString(parcel, static_cast<void*>(&adapter), |
| 415 | StringArrayElementAllocationAdapter::Allocator); |
| 416 | |
| 417 | if (status != STATUS_OK) return status; |
Steven Moreland | 07fb9c9 | 2018-11-01 17:14:29 -0700 | [diff] [blame] | 418 | } |
| 419 | |
| 420 | return STATUS_OK; |
| 421 | } |
| 422 | |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 423 | // See gen_parcel_helper.py. These auto-generated read/write methods use the same types for |
| 424 | // libbinder and this library. |
| 425 | // @START |
| 426 | binder_status_t AParcel_writeInt32(AParcel* parcel, int32_t value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 427 | status_t status = parcel->get()->writeInt32(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 428 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 429 | } |
| 430 | |
| 431 | binder_status_t AParcel_writeUint32(AParcel* parcel, uint32_t value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 432 | status_t status = parcel->get()->writeUint32(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 433 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 434 | } |
| 435 | |
| 436 | binder_status_t AParcel_writeInt64(AParcel* parcel, int64_t value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 437 | status_t status = parcel->get()->writeInt64(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 438 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 439 | } |
| 440 | |
| 441 | binder_status_t AParcel_writeUint64(AParcel* parcel, uint64_t value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 442 | status_t status = parcel->get()->writeUint64(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 443 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 444 | } |
| 445 | |
| 446 | binder_status_t AParcel_writeFloat(AParcel* parcel, float value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 447 | status_t status = parcel->get()->writeFloat(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 448 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 449 | } |
| 450 | |
| 451 | binder_status_t AParcel_writeDouble(AParcel* parcel, double value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 452 | status_t status = parcel->get()->writeDouble(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 453 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 454 | } |
| 455 | |
| 456 | binder_status_t AParcel_writeBool(AParcel* parcel, bool value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 457 | status_t status = parcel->get()->writeBool(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 458 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 459 | } |
| 460 | |
| 461 | binder_status_t AParcel_writeChar(AParcel* parcel, char16_t value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 462 | status_t status = parcel->get()->writeChar(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 463 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 464 | } |
| 465 | |
| 466 | binder_status_t AParcel_writeByte(AParcel* parcel, int8_t value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 467 | status_t status = parcel->get()->writeByte(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 468 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 469 | } |
| 470 | |
| 471 | binder_status_t AParcel_readInt32(const AParcel* parcel, int32_t* value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 472 | status_t status = parcel->get()->readInt32(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 473 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 474 | } |
| 475 | |
| 476 | binder_status_t AParcel_readUint32(const AParcel* parcel, uint32_t* value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 477 | status_t status = parcel->get()->readUint32(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 478 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 479 | } |
| 480 | |
| 481 | binder_status_t AParcel_readInt64(const AParcel* parcel, int64_t* value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 482 | status_t status = parcel->get()->readInt64(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 483 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 484 | } |
| 485 | |
| 486 | binder_status_t AParcel_readUint64(const AParcel* parcel, uint64_t* value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 487 | status_t status = parcel->get()->readUint64(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 488 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 489 | } |
| 490 | |
| 491 | binder_status_t AParcel_readFloat(const AParcel* parcel, float* value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 492 | status_t status = parcel->get()->readFloat(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 493 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 494 | } |
| 495 | |
| 496 | binder_status_t AParcel_readDouble(const AParcel* parcel, double* value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 497 | status_t status = parcel->get()->readDouble(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 498 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 499 | } |
| 500 | |
| 501 | binder_status_t AParcel_readBool(const AParcel* parcel, bool* value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 502 | status_t status = parcel->get()->readBool(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 503 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 504 | } |
| 505 | |
| 506 | binder_status_t AParcel_readChar(const AParcel* parcel, char16_t* value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 507 | status_t status = parcel->get()->readChar(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 508 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 509 | } |
| 510 | |
| 511 | binder_status_t AParcel_readByte(const AParcel* parcel, int8_t* value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 512 | status_t status = parcel->get()->readByte(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 513 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 514 | } |
| 515 | |
Steven Moreland | 01ebcf7 | 2018-11-15 15:06:26 -0800 | [diff] [blame] | 516 | binder_status_t AParcel_writeInt32Array(AParcel* parcel, const int32_t* arrayData, int32_t length) { |
Steven Moreland | e3d0958 | 2018-11-02 19:29:36 -0700 | [diff] [blame] | 517 | return WriteArray<int32_t>(parcel, arrayData, length); |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 518 | } |
| 519 | |
Steven Moreland | e3d0958 | 2018-11-02 19:29:36 -0700 | [diff] [blame] | 520 | binder_status_t AParcel_writeUint32Array(AParcel* parcel, const uint32_t* arrayData, |
Steven Moreland | 01ebcf7 | 2018-11-15 15:06:26 -0800 | [diff] [blame] | 521 | int32_t length) { |
Steven Moreland | e3d0958 | 2018-11-02 19:29:36 -0700 | [diff] [blame] | 522 | return WriteArray<uint32_t>(parcel, arrayData, length); |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 523 | } |
| 524 | |
Steven Moreland | 01ebcf7 | 2018-11-15 15:06:26 -0800 | [diff] [blame] | 525 | binder_status_t AParcel_writeInt64Array(AParcel* parcel, const int64_t* arrayData, int32_t length) { |
Steven Moreland | e3d0958 | 2018-11-02 19:29:36 -0700 | [diff] [blame] | 526 | return WriteArray<int64_t>(parcel, arrayData, length); |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 527 | } |
| 528 | |
Steven Moreland | e3d0958 | 2018-11-02 19:29:36 -0700 | [diff] [blame] | 529 | binder_status_t AParcel_writeUint64Array(AParcel* parcel, const uint64_t* arrayData, |
Steven Moreland | 01ebcf7 | 2018-11-15 15:06:26 -0800 | [diff] [blame] | 530 | int32_t length) { |
Steven Moreland | e3d0958 | 2018-11-02 19:29:36 -0700 | [diff] [blame] | 531 | return WriteArray<uint64_t>(parcel, arrayData, length); |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 532 | } |
| 533 | |
Steven Moreland | 01ebcf7 | 2018-11-15 15:06:26 -0800 | [diff] [blame] | 534 | binder_status_t AParcel_writeFloatArray(AParcel* parcel, const float* arrayData, int32_t length) { |
Steven Moreland | e3d0958 | 2018-11-02 19:29:36 -0700 | [diff] [blame] | 535 | return WriteArray<float>(parcel, arrayData, length); |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 536 | } |
| 537 | |
Steven Moreland | 01ebcf7 | 2018-11-15 15:06:26 -0800 | [diff] [blame] | 538 | binder_status_t AParcel_writeDoubleArray(AParcel* parcel, const double* arrayData, int32_t length) { |
Steven Moreland | e3d0958 | 2018-11-02 19:29:36 -0700 | [diff] [blame] | 539 | return WriteArray<double>(parcel, arrayData, length); |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 540 | } |
| 541 | |
Steven Moreland | 01ebcf7 | 2018-11-15 15:06:26 -0800 | [diff] [blame] | 542 | binder_status_t AParcel_writeBoolArray(AParcel* parcel, const void* arrayData, int32_t length, |
Steven Moreland | 16e1eae | 2018-11-01 09:51:53 -0700 | [diff] [blame] | 543 | AParcel_boolArrayGetter getter) { |
| 544 | return WriteArray<bool>(parcel, arrayData, length, getter, &Parcel::writeBool); |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 545 | } |
| 546 | |
Steven Moreland | 01ebcf7 | 2018-11-15 15:06:26 -0800 | [diff] [blame] | 547 | binder_status_t AParcel_writeCharArray(AParcel* parcel, const char16_t* arrayData, int32_t length) { |
Steven Moreland | e3d0958 | 2018-11-02 19:29:36 -0700 | [diff] [blame] | 548 | return WriteArray<char16_t>(parcel, arrayData, length); |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 549 | } |
| 550 | |
Steven Moreland | 01ebcf7 | 2018-11-15 15:06:26 -0800 | [diff] [blame] | 551 | binder_status_t AParcel_writeByteArray(AParcel* parcel, const int8_t* arrayData, int32_t length) { |
Steven Moreland | e3d0958 | 2018-11-02 19:29:36 -0700 | [diff] [blame] | 552 | return WriteArray<int8_t>(parcel, arrayData, length); |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 553 | } |
| 554 | |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 555 | binder_status_t AParcel_readInt32Array(const AParcel* parcel, void* arrayData, |
Steven Moreland | 9ac9dca | 2018-11-01 10:07:31 -0700 | [diff] [blame] | 556 | AParcel_int32ArrayAllocator allocator) { |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 557 | return ReadArray<int32_t>(parcel, arrayData, allocator); |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 558 | } |
| 559 | |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 560 | binder_status_t AParcel_readUint32Array(const AParcel* parcel, void* arrayData, |
Steven Moreland | 9ac9dca | 2018-11-01 10:07:31 -0700 | [diff] [blame] | 561 | AParcel_uint32ArrayAllocator allocator) { |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 562 | return ReadArray<uint32_t>(parcel, arrayData, allocator); |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 563 | } |
| 564 | |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 565 | binder_status_t AParcel_readInt64Array(const AParcel* parcel, void* arrayData, |
Steven Moreland | 9ac9dca | 2018-11-01 10:07:31 -0700 | [diff] [blame] | 566 | AParcel_int64ArrayAllocator allocator) { |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 567 | return ReadArray<int64_t>(parcel, arrayData, allocator); |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 568 | } |
| 569 | |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 570 | binder_status_t AParcel_readUint64Array(const AParcel* parcel, void* arrayData, |
Steven Moreland | 9ac9dca | 2018-11-01 10:07:31 -0700 | [diff] [blame] | 571 | AParcel_uint64ArrayAllocator allocator) { |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 572 | return ReadArray<uint64_t>(parcel, arrayData, allocator); |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 573 | } |
| 574 | |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 575 | binder_status_t AParcel_readFloatArray(const AParcel* parcel, void* arrayData, |
Steven Moreland | 9ac9dca | 2018-11-01 10:07:31 -0700 | [diff] [blame] | 576 | AParcel_floatArrayAllocator allocator) { |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 577 | return ReadArray<float>(parcel, arrayData, allocator); |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 578 | } |
| 579 | |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 580 | binder_status_t AParcel_readDoubleArray(const AParcel* parcel, void* arrayData, |
Steven Moreland | 9ac9dca | 2018-11-01 10:07:31 -0700 | [diff] [blame] | 581 | AParcel_doubleArrayAllocator allocator) { |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 582 | return ReadArray<double>(parcel, arrayData, allocator); |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 583 | } |
| 584 | |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 585 | binder_status_t AParcel_readBoolArray(const AParcel* parcel, void* arrayData, |
Steven Moreland | 9ac9dca | 2018-11-01 10:07:31 -0700 | [diff] [blame] | 586 | AParcel_boolArrayAllocator allocator, |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 587 | AParcel_boolArraySetter setter) { |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 588 | return ReadArray<bool>(parcel, arrayData, allocator, setter, &Parcel::readBool); |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 589 | } |
| 590 | |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 591 | binder_status_t AParcel_readCharArray(const AParcel* parcel, void* arrayData, |
Steven Moreland | 9ac9dca | 2018-11-01 10:07:31 -0700 | [diff] [blame] | 592 | AParcel_charArrayAllocator allocator) { |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 593 | return ReadArray<char16_t>(parcel, arrayData, allocator); |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 594 | } |
| 595 | |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 596 | binder_status_t AParcel_readByteArray(const AParcel* parcel, void* arrayData, |
Steven Moreland | 9ac9dca | 2018-11-01 10:07:31 -0700 | [diff] [blame] | 597 | AParcel_byteArrayAllocator allocator) { |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 598 | return ReadArray<int8_t>(parcel, arrayData, allocator); |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 599 | } |
| 600 | |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 601 | // @END |