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 | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 26 | #include <binder/Parcel.h> |
Steven Moreland | 7b06f59 | 2018-10-03 19:25:32 -0700 | [diff] [blame] | 27 | #include <utils/Unicode.h> |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 28 | |
| 29 | using ::android::IBinder; |
| 30 | using ::android::Parcel; |
| 31 | using ::android::sp; |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 32 | using ::android::status_t; |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 33 | |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 34 | template <typename T> |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame^] | 35 | using ContiguousArrayAllocator = T* (*)(void* arrayData, size_t length); |
| 36 | |
| 37 | template <typename T> |
| 38 | using ArrayAllocator = bool (*)(void* arrayData, size_t length); |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 39 | template <typename T> |
| 40 | using ArrayGetter = T (*)(const void* arrayData, size_t index); |
| 41 | template <typename T> |
| 42 | using ArraySetter = void (*)(void* arrayData, size_t index, T value); |
| 43 | |
| 44 | template <typename T> |
| 45 | binder_status_t WriteArray(AParcel* parcel, const T* array, size_t length) { |
| 46 | if (length > std::numeric_limits<int32_t>::max()) return STATUS_BAD_VALUE; |
| 47 | |
| 48 | Parcel* rawParcel = parcel->get(); |
| 49 | |
| 50 | status_t status = rawParcel->writeInt32(static_cast<int32_t>(length)); |
| 51 | if (status != STATUS_OK) return PruneStatusT(status); |
| 52 | |
| 53 | int32_t size = 0; |
| 54 | if (__builtin_smul_overflow(sizeof(T), length, &size)) return STATUS_NO_MEMORY; |
| 55 | |
| 56 | void* const data = rawParcel->writeInplace(size); |
| 57 | if (data == nullptr) return STATUS_NO_MEMORY; |
| 58 | |
| 59 | memcpy(data, array, size); |
| 60 | |
| 61 | return STATUS_OK; |
| 62 | } |
| 63 | |
| 64 | // Each element in a char16_t array is converted to an int32_t (not packed). |
| 65 | template <> |
| 66 | binder_status_t WriteArray<char16_t>(AParcel* parcel, const char16_t* array, size_t length) { |
| 67 | if (length > std::numeric_limits<int32_t>::max()) return STATUS_BAD_VALUE; |
| 68 | |
| 69 | Parcel* rawParcel = parcel->get(); |
| 70 | |
| 71 | status_t status = rawParcel->writeInt32(static_cast<int32_t>(length)); |
| 72 | if (status != STATUS_OK) return PruneStatusT(status); |
| 73 | |
| 74 | int32_t size = 0; |
| 75 | if (__builtin_smul_overflow(sizeof(char16_t), length, &size)) return STATUS_NO_MEMORY; |
| 76 | |
| 77 | for (int32_t i = 0; i < length; i++) { |
| 78 | status = rawParcel->writeChar(array[i]); |
| 79 | |
| 80 | if (status != STATUS_OK) return PruneStatusT(status); |
| 81 | } |
| 82 | |
| 83 | return STATUS_OK; |
| 84 | } |
| 85 | |
| 86 | template <typename T> |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame^] | 87 | binder_status_t ReadArray(const AParcel* parcel, void* arrayData, |
| 88 | ContiguousArrayAllocator<T> allocator) { |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 89 | const Parcel* rawParcel = parcel->get(); |
| 90 | |
| 91 | int32_t length; |
| 92 | status_t status = rawParcel->readInt32(&length); |
| 93 | |
| 94 | if (status != STATUS_OK) return PruneStatusT(status); |
| 95 | if (length < 0) return STATUS_UNEXPECTED_NULL; |
| 96 | |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame^] | 97 | T* array = allocator(arrayData, length); |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 98 | if (length == 0) return STATUS_OK; |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 99 | if (array == nullptr) return STATUS_NO_MEMORY; |
| 100 | |
| 101 | int32_t size = 0; |
| 102 | if (__builtin_smul_overflow(sizeof(T), length, &size)) return STATUS_NO_MEMORY; |
| 103 | |
| 104 | const void* data = rawParcel->readInplace(size); |
| 105 | if (data == nullptr) return STATUS_NO_MEMORY; |
| 106 | |
| 107 | memcpy(array, data, size); |
| 108 | |
| 109 | return STATUS_OK; |
| 110 | } |
| 111 | |
| 112 | // Each element in a char16_t array is converted to an int32_t (not packed) |
| 113 | template <> |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame^] | 114 | binder_status_t ReadArray<char16_t>(const AParcel* parcel, void* arrayData, |
| 115 | ContiguousArrayAllocator<char16_t> allocator) { |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 116 | const Parcel* rawParcel = parcel->get(); |
| 117 | |
| 118 | int32_t length; |
| 119 | status_t status = rawParcel->readInt32(&length); |
| 120 | |
| 121 | if (status != STATUS_OK) return PruneStatusT(status); |
| 122 | if (length < 0) return STATUS_UNEXPECTED_NULL; |
| 123 | |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame^] | 124 | char16_t* array = allocator(arrayData, length); |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 125 | if (length == 0) return STATUS_OK; |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 126 | if (array == nullptr) return STATUS_NO_MEMORY; |
| 127 | |
| 128 | int32_t size = 0; |
| 129 | if (__builtin_smul_overflow(sizeof(char16_t), length, &size)) return STATUS_NO_MEMORY; |
| 130 | |
| 131 | for (int32_t i = 0; i < length; i++) { |
| 132 | status = rawParcel->readChar(array + i); |
| 133 | |
| 134 | if (status != STATUS_OK) return PruneStatusT(status); |
| 135 | } |
| 136 | |
| 137 | return STATUS_OK; |
| 138 | } |
| 139 | |
| 140 | template <typename T> |
| 141 | binder_status_t WriteArray(AParcel* parcel, const void* arrayData, ArrayGetter<T> getter, |
| 142 | size_t length, status_t (Parcel::*write)(T)) { |
| 143 | if (length > std::numeric_limits<int32_t>::max()) return STATUS_BAD_VALUE; |
| 144 | |
| 145 | Parcel* rawParcel = parcel->get(); |
| 146 | |
| 147 | status_t status = rawParcel->writeInt32(static_cast<int32_t>(length)); |
| 148 | if (status != STATUS_OK) return PruneStatusT(status); |
| 149 | |
| 150 | for (size_t i = 0; i < length; i++) { |
| 151 | status = (rawParcel->*write)(getter(arrayData, i)); |
| 152 | |
| 153 | if (status != STATUS_OK) return PruneStatusT(status); |
| 154 | } |
| 155 | |
| 156 | return STATUS_OK; |
| 157 | } |
| 158 | |
| 159 | template <typename T> |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame^] | 160 | binder_status_t ReadArray(const AParcel* parcel, void* arrayData, ArrayAllocator<T> allocator, |
| 161 | ArraySetter<T> setter, status_t (Parcel::*read)(T*) const) { |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 162 | const Parcel* rawParcel = parcel->get(); |
| 163 | |
| 164 | int32_t length; |
| 165 | status_t status = rawParcel->readInt32(&length); |
| 166 | |
| 167 | if (status != STATUS_OK) return PruneStatusT(status); |
| 168 | if (length < 0) return STATUS_UNEXPECTED_NULL; |
| 169 | |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame^] | 170 | if (!allocator(arrayData, length)) return STATUS_NO_MEMORY; |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 171 | |
| 172 | for (size_t i = 0; i < length; i++) { |
| 173 | T readTarget; |
| 174 | status = (rawParcel->*read)(&readTarget); |
| 175 | if (status != STATUS_OK) return PruneStatusT(status); |
| 176 | |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame^] | 177 | setter(arrayData, i, readTarget); |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 178 | } |
| 179 | |
| 180 | return STATUS_OK; |
| 181 | } |
| 182 | |
Steven Moreland | 9b80e28 | 2018-09-19 13:57:23 -0700 | [diff] [blame] | 183 | void AParcel_delete(AParcel* parcel) { |
| 184 | delete parcel; |
Steven Moreland | caa776c | 2018-09-04 13:48:11 -0700 | [diff] [blame] | 185 | } |
| 186 | |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 187 | binder_status_t AParcel_writeStrongBinder(AParcel* parcel, AIBinder* binder) { |
Steven Moreland | c0e46d3 | 2018-09-12 15:40:49 -0700 | [diff] [blame] | 188 | sp<IBinder> writeBinder = binder != nullptr ? binder->getBinder() : nullptr; |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 189 | return parcel->get()->writeStrongBinder(writeBinder); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 190 | } |
| 191 | binder_status_t AParcel_readStrongBinder(const AParcel* parcel, AIBinder** binder) { |
| 192 | sp<IBinder> readBinder = nullptr; |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 193 | status_t status = parcel->get()->readStrongBinder(&readBinder); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 194 | if (status != STATUS_OK) { |
| 195 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 196 | } |
Steven Moreland | 9496895 | 2018-09-05 14:42:59 -0700 | [diff] [blame] | 197 | sp<AIBinder> ret = ABpBinder::lookupOrCreateFromBinder(readBinder); |
Steven Moreland | 71cddc3 | 2018-08-30 23:39:22 -0700 | [diff] [blame] | 198 | AIBinder_incStrong(ret.get()); |
| 199 | *binder = ret.get(); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 200 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 201 | } |
| 202 | binder_status_t AParcel_readNullableStrongBinder(const AParcel* parcel, AIBinder** binder) { |
| 203 | sp<IBinder> readBinder = nullptr; |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 204 | status_t status = parcel->get()->readNullableStrongBinder(&readBinder); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 205 | if (status != STATUS_OK) { |
| 206 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 207 | } |
Steven Moreland | 9496895 | 2018-09-05 14:42:59 -0700 | [diff] [blame] | 208 | sp<AIBinder> ret = ABpBinder::lookupOrCreateFromBinder(readBinder); |
Steven Moreland | 71cddc3 | 2018-08-30 23:39:22 -0700 | [diff] [blame] | 209 | AIBinder_incStrong(ret.get()); |
| 210 | *binder = ret.get(); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 211 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 212 | } |
Steven Moreland | 9a51db8 | 2018-09-14 10:59:35 -0700 | [diff] [blame] | 213 | binder_status_t AParcel_writeStatusHeader(AParcel* parcel, const AStatus* status) { |
| 214 | return PruneStatusT(status->get()->writeToParcel(parcel->get())); |
| 215 | } |
| 216 | binder_status_t AParcel_readStatusHeader(const AParcel* parcel, AStatus** status) { |
| 217 | ::android::binder::Status bstatus; |
| 218 | binder_status_t ret = PruneStatusT(bstatus.readFromParcel(*parcel->get())); |
| 219 | if (ret == EX_NONE) { |
| 220 | *status = new AStatus(std::move(bstatus)); |
| 221 | } |
| 222 | return ret; |
| 223 | } |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 224 | |
Steven Moreland | 7b06f59 | 2018-10-03 19:25:32 -0700 | [diff] [blame] | 225 | binder_status_t AParcel_writeString(AParcel* parcel, const char* string, size_t length) { |
| 226 | const uint8_t* str8 = (uint8_t*)string; |
| 227 | |
| 228 | const ssize_t len16 = utf8_to_utf16_length(str8, length); |
| 229 | |
| 230 | if (len16 < 0 || len16 >= std::numeric_limits<int32_t>::max()) { |
| 231 | LOG(WARNING) << __func__ << ": Invalid string length: " << len16; |
| 232 | return STATUS_BAD_VALUE; |
| 233 | } |
| 234 | |
| 235 | status_t err = parcel->get()->writeInt32(len16); |
| 236 | if (err) { |
| 237 | return PruneStatusT(err); |
| 238 | } |
| 239 | |
| 240 | void* str16 = parcel->get()->writeInplace((len16 + 1) * sizeof(char16_t)); |
| 241 | if (str16 == nullptr) { |
| 242 | return STATUS_NO_MEMORY; |
| 243 | } |
| 244 | |
| 245 | utf8_to_utf16(str8, length, (char16_t*)str16, (size_t)len16 + 1); |
| 246 | |
| 247 | return STATUS_OK; |
| 248 | } |
| 249 | |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame^] | 250 | binder_status_t AParcel_readString(const AParcel* parcel, AParcel_stringAllocator allocator, |
| 251 | void* stringData) { |
Steven Moreland | 7b06f59 | 2018-10-03 19:25:32 -0700 | [diff] [blame] | 252 | size_t len16; |
| 253 | const char16_t* str16 = parcel->get()->readString16Inplace(&len16); |
| 254 | |
| 255 | if (str16 == nullptr) { |
| 256 | LOG(WARNING) << __func__ << ": Failed to read string in place."; |
| 257 | return STATUS_UNEXPECTED_NULL; |
| 258 | } |
| 259 | |
| 260 | ssize_t len8; |
| 261 | |
| 262 | if (len16 == 0) { |
| 263 | len8 = 1; |
| 264 | } else { |
| 265 | len8 = utf16_to_utf8_length(str16, len16) + 1; |
| 266 | } |
| 267 | |
| 268 | if (len8 <= 0 || len8 >= std::numeric_limits<int32_t>::max()) { |
| 269 | LOG(WARNING) << __func__ << ": Invalid string length: " << len8; |
| 270 | return STATUS_BAD_VALUE; |
| 271 | } |
| 272 | |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame^] | 273 | char* str8 = allocator(stringData, len8); |
Steven Moreland | 7b06f59 | 2018-10-03 19:25:32 -0700 | [diff] [blame] | 274 | |
| 275 | if (str8 == nullptr) { |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame^] | 276 | LOG(WARNING) << __func__ << ": AParcel_stringAllocator failed to allocate."; |
Steven Moreland | 7b06f59 | 2018-10-03 19:25:32 -0700 | [diff] [blame] | 277 | return STATUS_NO_MEMORY; |
| 278 | } |
| 279 | |
| 280 | utf16_to_utf8(str16, len16, str8, len8); |
| 281 | |
| 282 | return STATUS_OK; |
| 283 | } |
| 284 | |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 285 | // See gen_parcel_helper.py. These auto-generated read/write methods use the same types for |
| 286 | // libbinder and this library. |
| 287 | // @START |
| 288 | binder_status_t AParcel_writeInt32(AParcel* parcel, int32_t value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 289 | status_t status = parcel->get()->writeInt32(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 290 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 291 | } |
| 292 | |
| 293 | binder_status_t AParcel_writeUint32(AParcel* parcel, uint32_t value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 294 | status_t status = parcel->get()->writeUint32(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 295 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 296 | } |
| 297 | |
| 298 | binder_status_t AParcel_writeInt64(AParcel* parcel, int64_t value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 299 | status_t status = parcel->get()->writeInt64(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 300 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 301 | } |
| 302 | |
| 303 | binder_status_t AParcel_writeUint64(AParcel* parcel, uint64_t value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 304 | status_t status = parcel->get()->writeUint64(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 305 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 306 | } |
| 307 | |
| 308 | binder_status_t AParcel_writeFloat(AParcel* parcel, float value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 309 | status_t status = parcel->get()->writeFloat(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 310 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 311 | } |
| 312 | |
| 313 | binder_status_t AParcel_writeDouble(AParcel* parcel, double value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 314 | status_t status = parcel->get()->writeDouble(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 315 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 316 | } |
| 317 | |
| 318 | binder_status_t AParcel_writeBool(AParcel* parcel, bool value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 319 | status_t status = parcel->get()->writeBool(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 320 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 321 | } |
| 322 | |
| 323 | binder_status_t AParcel_writeChar(AParcel* parcel, char16_t value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 324 | status_t status = parcel->get()->writeChar(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 325 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 326 | } |
| 327 | |
| 328 | binder_status_t AParcel_writeByte(AParcel* parcel, int8_t value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 329 | status_t status = parcel->get()->writeByte(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 330 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 331 | } |
| 332 | |
| 333 | binder_status_t AParcel_readInt32(const AParcel* parcel, int32_t* value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 334 | status_t status = parcel->get()->readInt32(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 335 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 336 | } |
| 337 | |
| 338 | binder_status_t AParcel_readUint32(const AParcel* parcel, uint32_t* value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 339 | status_t status = parcel->get()->readUint32(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 340 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 341 | } |
| 342 | |
| 343 | binder_status_t AParcel_readInt64(const AParcel* parcel, int64_t* value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 344 | status_t status = parcel->get()->readInt64(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 345 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 346 | } |
| 347 | |
| 348 | binder_status_t AParcel_readUint64(const AParcel* parcel, uint64_t* value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 349 | status_t status = parcel->get()->readUint64(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 350 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 351 | } |
| 352 | |
| 353 | binder_status_t AParcel_readFloat(const AParcel* parcel, float* value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 354 | status_t status = parcel->get()->readFloat(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 355 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 356 | } |
| 357 | |
| 358 | binder_status_t AParcel_readDouble(const AParcel* parcel, double* value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 359 | status_t status = parcel->get()->readDouble(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 360 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 361 | } |
| 362 | |
| 363 | binder_status_t AParcel_readBool(const AParcel* parcel, bool* value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 364 | status_t status = parcel->get()->readBool(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 365 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 366 | } |
| 367 | |
| 368 | binder_status_t AParcel_readChar(const AParcel* parcel, char16_t* value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 369 | status_t status = parcel->get()->readChar(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 370 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 371 | } |
| 372 | |
| 373 | binder_status_t AParcel_readByte(const AParcel* parcel, int8_t* value) { |
Steven Moreland | f18615b | 2018-09-14 11:43:06 -0700 | [diff] [blame] | 374 | status_t status = parcel->get()->readByte(value); |
Steven Moreland | 5d62e44 | 2018-09-13 15:01:02 -0700 | [diff] [blame] | 375 | return PruneStatusT(status); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 376 | } |
| 377 | |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 378 | binder_status_t AParcel_writeInt32Array(AParcel* parcel, const int32_t* value, size_t length) { |
| 379 | return WriteArray<int32_t>(parcel, value, length); |
| 380 | } |
| 381 | |
| 382 | binder_status_t AParcel_writeUint32Array(AParcel* parcel, const uint32_t* value, size_t length) { |
| 383 | return WriteArray<uint32_t>(parcel, value, length); |
| 384 | } |
| 385 | |
| 386 | binder_status_t AParcel_writeInt64Array(AParcel* parcel, const int64_t* value, size_t length) { |
| 387 | return WriteArray<int64_t>(parcel, value, length); |
| 388 | } |
| 389 | |
| 390 | binder_status_t AParcel_writeUint64Array(AParcel* parcel, const uint64_t* value, size_t length) { |
| 391 | return WriteArray<uint64_t>(parcel, value, length); |
| 392 | } |
| 393 | |
| 394 | binder_status_t AParcel_writeFloatArray(AParcel* parcel, const float* value, size_t length) { |
| 395 | return WriteArray<float>(parcel, value, length); |
| 396 | } |
| 397 | |
| 398 | binder_status_t AParcel_writeDoubleArray(AParcel* parcel, const double* value, size_t length) { |
| 399 | return WriteArray<double>(parcel, value, length); |
| 400 | } |
| 401 | |
| 402 | binder_status_t AParcel_writeBoolArray(AParcel* parcel, const void* arrayData, |
| 403 | AParcel_boolArrayGetter getter, size_t length) { |
| 404 | return WriteArray<bool>(parcel, arrayData, getter, length, &Parcel::writeBool); |
| 405 | } |
| 406 | |
| 407 | binder_status_t AParcel_writeCharArray(AParcel* parcel, const char16_t* value, size_t length) { |
| 408 | return WriteArray<char16_t>(parcel, value, length); |
| 409 | } |
| 410 | |
| 411 | binder_status_t AParcel_writeByteArray(AParcel* parcel, const int8_t* value, size_t length) { |
| 412 | return WriteArray<int8_t>(parcel, value, length); |
| 413 | } |
| 414 | |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame^] | 415 | binder_status_t AParcel_readInt32Array(const AParcel* parcel, void* arrayData, |
| 416 | AParcel_int32Allocator allocator) { |
| 417 | return ReadArray<int32_t>(parcel, arrayData, allocator); |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 418 | } |
| 419 | |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame^] | 420 | binder_status_t AParcel_readUint32Array(const AParcel* parcel, void* arrayData, |
| 421 | AParcel_uint32Allocator allocator) { |
| 422 | return ReadArray<uint32_t>(parcel, arrayData, allocator); |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 423 | } |
| 424 | |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame^] | 425 | binder_status_t AParcel_readInt64Array(const AParcel* parcel, void* arrayData, |
| 426 | AParcel_int64Allocator allocator) { |
| 427 | return ReadArray<int64_t>(parcel, arrayData, allocator); |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 428 | } |
| 429 | |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame^] | 430 | binder_status_t AParcel_readUint64Array(const AParcel* parcel, void* arrayData, |
| 431 | AParcel_uint64Allocator allocator) { |
| 432 | return ReadArray<uint64_t>(parcel, arrayData, allocator); |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 433 | } |
| 434 | |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame^] | 435 | binder_status_t AParcel_readFloatArray(const AParcel* parcel, void* arrayData, |
| 436 | AParcel_floatAllocator allocator) { |
| 437 | return ReadArray<float>(parcel, arrayData, allocator); |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 438 | } |
| 439 | |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame^] | 440 | binder_status_t AParcel_readDoubleArray(const AParcel* parcel, void* arrayData, |
| 441 | AParcel_doubleAllocator allocator) { |
| 442 | return ReadArray<double>(parcel, arrayData, allocator); |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 443 | } |
| 444 | |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame^] | 445 | binder_status_t AParcel_readBoolArray(const AParcel* parcel, void* arrayData, |
| 446 | AParcel_boolAllocator allocator, |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 447 | AParcel_boolArraySetter setter) { |
Steven Moreland | 71872f8 | 2018-10-29 11:46:56 -0700 | [diff] [blame^] | 448 | return ReadArray<bool>(parcel, arrayData, allocator, setter, &Parcel::readBool); |
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_readCharArray(const AParcel* parcel, void* arrayData, |
| 452 | AParcel_charAllocator allocator) { |
| 453 | return ReadArray<char16_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_readByteArray(const AParcel* parcel, void* arrayData, |
| 457 | AParcel_byteAllocator allocator) { |
| 458 | return ReadArray<int8_t>(parcel, arrayData, allocator); |
Steven Moreland | a884566 | 2018-10-12 11:53:03 -0700 | [diff] [blame] | 459 | } |
| 460 | |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 461 | // @END |