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 | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 39 | using ContiguousArrayAllocator = T* (*)(void* arrayData, size_t length); |
| 40 | |
| 41 | template <typename T> |
| 42 | using ArrayAllocator = bool (*)(void* arrayData, size_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 | |
| 48 | template <typename T> |
| 49 | binder_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). |
| 69 | template <> |
| 70 | binder_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 | |
| 90 | template <typename T> |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 91 | binder_status_t ReadArray(const AParcel* parcel, void* arrayData, |
| 92 | ContiguousArrayAllocator<T> allocator) { |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 93 | 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 Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 101 | T* array = allocator(arrayData, length); |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 102 | if (length == 0) return STATUS_OK; |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 103 | 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) |
| 117 | template <> |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 118 | binder_status_t ReadArray<char16_t>(const AParcel* parcel, void* arrayData, |
| 119 | ContiguousArrayAllocator<char16_t> allocator) { |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 120 | 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 Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 128 | char16_t* array = allocator(arrayData, length); |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 129 | if (length == 0) return STATUS_OK; |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 130 | 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 | |
| 144 | template <typename T> |
Steven Moreland | 16e1eae | 2018-11-01 09:51:53 -0700 | [diff] [blame^] | 145 | binder_status_t WriteArray(AParcel* parcel, const void* arrayData, size_t length, |
| 146 | ArrayGetter<T> getter, status_t (Parcel::*write)(T)) { |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 147 | 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 | |
| 163 | template <typename T> |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 164 | binder_status_t ReadArray(const AParcel* parcel, void* arrayData, ArrayAllocator<T> allocator, |
| 165 | ArraySetter<T> setter, status_t (Parcel::*read)(T*) const) { |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 166 | 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 Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 174 | if (!allocator(arrayData, length)) return STATUS_NO_MEMORY; |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 175 | |
| 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 Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 181 | setter(arrayData, i, readTarget); |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 182 | } |
| 183 | |
| 184 | return STATUS_OK; |
| 185 | } |
| 186 | |
Steven Moreland | 9b80e28 | 2018-09-19 13:57:23 -0700 | [diff] [blame] | 187 | void AParcel_delete(AParcel* parcel) { |
| 188 | delete parcel; |
Steven Moreland | caa776c | 2018-09-04 13:48:11 -0700 | [diff] [blame] | 189 | } |
| 190 | |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 191 | binder_status_t AParcel_writeStrongBinder(AParcel* parcel, AIBinder* binder) { |
Steven Moreland | c0e46d3 | 2018-09-12 15:40:49 -0700 | [diff] [blame] | 192 | sp<IBinder> writeBinder = binder != nullptr ? binder->getBinder() : nullptr; |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 193 | return parcel->get()->writeStrongBinder(writeBinder); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 194 | } |
| 195 | binder_status_t AParcel_readStrongBinder(const AParcel* parcel, AIBinder** binder) { |
| 196 | sp<IBinder> readBinder = nullptr; |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 197 | status_t status = parcel->get()->readStrongBinder(&readBinder); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 198 | if (status != STATUS_OK) { |
| 199 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 200 | } |
Steven Moreland | 9496895 | 2018-09-05 14:42:59 -0700 | [diff] [blame] | 201 | sp<AIBinder> ret = ABpBinder::lookupOrCreateFromBinder(readBinder); |
Steven Moreland | 71cddc3 | 2018-08-30 23:39:22 -0700 | [diff] [blame] | 202 | AIBinder_incStrong(ret.get()); |
| 203 | *binder = ret.get(); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 204 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 205 | } |
| 206 | binder_status_t AParcel_readNullableStrongBinder(const AParcel* parcel, AIBinder** binder) { |
| 207 | sp<IBinder> readBinder = nullptr; |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 208 | status_t status = parcel->get()->readNullableStrongBinder(&readBinder); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 209 | if (status != STATUS_OK) { |
| 210 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 211 | } |
Steven Moreland | 9496895 | 2018-09-05 14:42:59 -0700 | [diff] [blame] | 212 | sp<AIBinder> ret = ABpBinder::lookupOrCreateFromBinder(readBinder); |
Steven Moreland | 71cddc3 | 2018-08-30 23:39:22 -0700 | [diff] [blame] | 213 | AIBinder_incStrong(ret.get()); |
| 214 | *binder = ret.get(); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 215 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 216 | } |
Steven Moreland | 063f236 | 2018-10-18 12:49:11 -0700 | [diff] [blame] | 217 | |
| 218 | binder_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 | |
| 229 | binder_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 Moreland | 9a51db8 | 2018-09-14 10:59:35 -0700 | [diff] [blame] | 239 | binder_status_t AParcel_writeStatusHeader(AParcel* parcel, const AStatus* status) { |
| 240 | return PruneStatusT(status->get()->writeToParcel(parcel->get())); |
| 241 | } |
| 242 | binder_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 Moreland | c1a11b8 | 2018-10-29 18:47:23 -0700 | [diff] [blame] | 245 | if (ret == STATUS_OK) { |
Steven Moreland | 9a51db8 | 2018-09-14 10:59:35 -0700 | [diff] [blame] | 246 | *status = new AStatus(std::move(bstatus)); |
| 247 | } |
Steven Moreland | c1a11b8 | 2018-10-29 18:47:23 -0700 | [diff] [blame] | 248 | return PruneStatusT(ret); |
Steven Moreland | 9a51db8 | 2018-09-14 10:59:35 -0700 | [diff] [blame] | 249 | } |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 250 | |
Steven Moreland | 7b06f59 | 2018-10-03 19:25:32 -0700 | [diff] [blame] | 251 | binder_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 Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 276 | binder_status_t AParcel_readString(const AParcel* parcel, AParcel_stringAllocator allocator, |
| 277 | void* stringData) { |
Steven Moreland | 7b06f59 | 2018-10-03 19:25:32 -0700 | [diff] [blame] | 278 | 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 Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 299 | char* str8 = allocator(stringData, len8); |
Steven Moreland | 7b06f59 | 2018-10-03 19:25:32 -0700 | [diff] [blame] | 300 | |
| 301 | if (str8 == nullptr) { |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 302 | LOG(WARNING) << __func__ << ": AParcel_stringAllocator failed to allocate."; |
Steven Moreland | 7b06f59 | 2018-10-03 19:25:32 -0700 | [diff] [blame] | 303 | return STATUS_NO_MEMORY; |
| 304 | } |
| 305 | |
| 306 | utf16_to_utf8(str16, len16, str8, len8); |
| 307 | |
| 308 | return STATUS_OK; |
| 309 | } |
| 310 | |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 311 | // See gen_parcel_helper.py. These auto-generated read/write methods use the same types for |
| 312 | // libbinder and this library. |
| 313 | // @START |
| 314 | binder_status_t AParcel_writeInt32(AParcel* parcel, int32_t value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 315 | status_t status = parcel->get()->writeInt32(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 316 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 317 | } |
| 318 | |
| 319 | binder_status_t AParcel_writeUint32(AParcel* parcel, uint32_t value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 320 | status_t status = parcel->get()->writeUint32(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 321 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 322 | } |
| 323 | |
| 324 | binder_status_t AParcel_writeInt64(AParcel* parcel, int64_t value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 325 | status_t status = parcel->get()->writeInt64(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 326 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 327 | } |
| 328 | |
| 329 | binder_status_t AParcel_writeUint64(AParcel* parcel, uint64_t value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 330 | status_t status = parcel->get()->writeUint64(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 331 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 332 | } |
| 333 | |
| 334 | binder_status_t AParcel_writeFloat(AParcel* parcel, float value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 335 | status_t status = parcel->get()->writeFloat(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 336 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 337 | } |
| 338 | |
| 339 | binder_status_t AParcel_writeDouble(AParcel* parcel, double value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 340 | status_t status = parcel->get()->writeDouble(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 341 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 342 | } |
| 343 | |
| 344 | binder_status_t AParcel_writeBool(AParcel* parcel, bool value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 345 | status_t status = parcel->get()->writeBool(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 346 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 347 | } |
| 348 | |
| 349 | binder_status_t AParcel_writeChar(AParcel* parcel, char16_t value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 350 | status_t status = parcel->get()->writeChar(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 351 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 352 | } |
| 353 | |
| 354 | binder_status_t AParcel_writeByte(AParcel* parcel, int8_t value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 355 | status_t status = parcel->get()->writeByte(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 356 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 357 | } |
| 358 | |
| 359 | binder_status_t AParcel_readInt32(const AParcel* parcel, int32_t* value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 360 | status_t status = parcel->get()->readInt32(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 361 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 362 | } |
| 363 | |
| 364 | binder_status_t AParcel_readUint32(const AParcel* parcel, uint32_t* value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 365 | status_t status = parcel->get()->readUint32(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 366 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 367 | } |
| 368 | |
| 369 | binder_status_t AParcel_readInt64(const AParcel* parcel, int64_t* value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 370 | status_t status = parcel->get()->readInt64(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 371 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 372 | } |
| 373 | |
| 374 | binder_status_t AParcel_readUint64(const AParcel* parcel, uint64_t* value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 375 | status_t status = parcel->get()->readUint64(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 376 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 377 | } |
| 378 | |
| 379 | binder_status_t AParcel_readFloat(const AParcel* parcel, float* value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 380 | status_t status = parcel->get()->readFloat(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 381 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 382 | } |
| 383 | |
| 384 | binder_status_t AParcel_readDouble(const AParcel* parcel, double* value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 385 | status_t status = parcel->get()->readDouble(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 386 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 387 | } |
| 388 | |
| 389 | binder_status_t AParcel_readBool(const AParcel* parcel, bool* value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 390 | status_t status = parcel->get()->readBool(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 391 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 392 | } |
| 393 | |
| 394 | binder_status_t AParcel_readChar(const AParcel* parcel, char16_t* value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 395 | status_t status = parcel->get()->readChar(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 396 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 397 | } |
| 398 | |
| 399 | binder_status_t AParcel_readByte(const AParcel* parcel, int8_t* value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 400 | status_t status = parcel->get()->readByte(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 401 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 402 | } |
| 403 | |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 404 | binder_status_t AParcel_writeInt32Array(AParcel* parcel, const int32_t* value, size_t length) { |
| 405 | return WriteArray<int32_t>(parcel, value, length); |
| 406 | } |
| 407 | |
| 408 | binder_status_t AParcel_writeUint32Array(AParcel* parcel, const uint32_t* value, size_t length) { |
| 409 | return WriteArray<uint32_t>(parcel, value, length); |
| 410 | } |
| 411 | |
| 412 | binder_status_t AParcel_writeInt64Array(AParcel* parcel, const int64_t* value, size_t length) { |
| 413 | return WriteArray<int64_t>(parcel, value, length); |
| 414 | } |
| 415 | |
| 416 | binder_status_t AParcel_writeUint64Array(AParcel* parcel, const uint64_t* value, size_t length) { |
| 417 | return WriteArray<uint64_t>(parcel, value, length); |
| 418 | } |
| 419 | |
| 420 | binder_status_t AParcel_writeFloatArray(AParcel* parcel, const float* value, size_t length) { |
| 421 | return WriteArray<float>(parcel, value, length); |
| 422 | } |
| 423 | |
| 424 | binder_status_t AParcel_writeDoubleArray(AParcel* parcel, const double* value, size_t length) { |
| 425 | return WriteArray<double>(parcel, value, length); |
| 426 | } |
| 427 | |
Steven Moreland | 16e1eae | 2018-11-01 09:51:53 -0700 | [diff] [blame^] | 428 | binder_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 Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 431 | } |
| 432 | |
| 433 | binder_status_t AParcel_writeCharArray(AParcel* parcel, const char16_t* value, size_t length) { |
| 434 | return WriteArray<char16_t>(parcel, value, length); |
| 435 | } |
| 436 | |
| 437 | binder_status_t AParcel_writeByteArray(AParcel* parcel, const int8_t* value, size_t length) { |
| 438 | return WriteArray<int8_t>(parcel, value, length); |
| 439 | } |
| 440 | |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 441 | binder_status_t AParcel_readInt32Array(const AParcel* parcel, void* arrayData, |
| 442 | AParcel_int32Allocator allocator) { |
| 443 | return ReadArray<int32_t>(parcel, arrayData, allocator); |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 444 | } |
| 445 | |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 446 | binder_status_t AParcel_readUint32Array(const AParcel* parcel, void* arrayData, |
| 447 | AParcel_uint32Allocator allocator) { |
| 448 | return ReadArray<uint32_t>(parcel, arrayData, allocator); |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 449 | } |
| 450 | |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 451 | binder_status_t AParcel_readInt64Array(const AParcel* parcel, void* arrayData, |
| 452 | AParcel_int64Allocator allocator) { |
| 453 | return ReadArray<int64_t>(parcel, arrayData, allocator); |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 454 | } |
| 455 | |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 456 | binder_status_t AParcel_readUint64Array(const AParcel* parcel, void* arrayData, |
| 457 | AParcel_uint64Allocator allocator) { |
| 458 | return ReadArray<uint64_t>(parcel, arrayData, allocator); |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 459 | } |
| 460 | |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 461 | binder_status_t AParcel_readFloatArray(const AParcel* parcel, void* arrayData, |
| 462 | AParcel_floatAllocator allocator) { |
| 463 | return ReadArray<float>(parcel, arrayData, allocator); |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 464 | } |
| 465 | |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 466 | binder_status_t AParcel_readDoubleArray(const AParcel* parcel, void* arrayData, |
| 467 | AParcel_doubleAllocator allocator) { |
| 468 | return ReadArray<double>(parcel, arrayData, allocator); |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 469 | } |
| 470 | |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 471 | binder_status_t AParcel_readBoolArray(const AParcel* parcel, void* arrayData, |
| 472 | AParcel_boolAllocator allocator, |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 473 | AParcel_boolArraySetter setter) { |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 474 | return ReadArray<bool>(parcel, arrayData, allocator, setter, &Parcel::readBool); |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 475 | } |
| 476 | |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 477 | binder_status_t AParcel_readCharArray(const AParcel* parcel, void* arrayData, |
| 478 | AParcel_charAllocator allocator) { |
| 479 | return ReadArray<char16_t>(parcel, arrayData, allocator); |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 480 | } |
| 481 | |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame] | 482 | binder_status_t AParcel_readByteArray(const AParcel* parcel, void* arrayData, |
| 483 | AParcel_byteAllocator allocator) { |
| 484 | return ReadArray<int8_t>(parcel, arrayData, allocator); |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 485 | } |
| 486 | |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 487 | // @END |