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> |
| 18 | #include "AParcel_internal.h" |
| 19 | |
| 20 | #include "AIBinder_internal.h" |
| 21 | |
| 22 | #include <binder/Parcel.h> |
| 23 | |
| 24 | using ::android::IBinder; |
| 25 | using ::android::Parcel; |
| 26 | using ::android::sp; |
| 27 | |
| 28 | binder_status_t AParcel_writeStrongBinder(AParcel* parcel, AIBinder* binder) { |
| 29 | return (*parcel)->writeStrongBinder(binder->getBinder()); |
| 30 | } |
| 31 | binder_status_t AParcel_readStrongBinder(const AParcel* parcel, AIBinder** binder) { |
| 32 | sp<IBinder> readBinder = nullptr; |
| 33 | binder_status_t status = (*parcel)->readStrongBinder(&readBinder); |
| 34 | if (status != EX_NONE) { |
| 35 | return status; |
| 36 | } |
Steven Moreland | 71cddc3 | 2018-08-30 23:39:22 -0700 | [diff] [blame^] | 37 | sp<AIBinder> ret = ABpBinder::fromBinder(readBinder); |
| 38 | AIBinder_incStrong(ret.get()); |
| 39 | *binder = ret.get(); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 40 | return status; |
| 41 | } |
| 42 | binder_status_t AParcel_readNullableStrongBinder(const AParcel* parcel, AIBinder** binder) { |
| 43 | sp<IBinder> readBinder = nullptr; |
| 44 | binder_status_t status = (*parcel)->readNullableStrongBinder(&readBinder); |
| 45 | if (status != EX_NONE) { |
| 46 | return status; |
| 47 | } |
Steven Moreland | 71cddc3 | 2018-08-30 23:39:22 -0700 | [diff] [blame^] | 48 | sp<AIBinder> ret = ABpBinder::fromBinder(readBinder); |
| 49 | AIBinder_incStrong(ret.get()); |
| 50 | *binder = ret.get(); |
Steven Moreland | 2e87adc | 2018-08-20 19:47:00 -0700 | [diff] [blame] | 51 | return status; |
| 52 | } |
| 53 | |
| 54 | // See gen_parcel_helper.py. These auto-generated read/write methods use the same types for |
| 55 | // libbinder and this library. |
| 56 | // @START |
| 57 | binder_status_t AParcel_writeInt32(AParcel* parcel, int32_t value) { |
| 58 | return (*parcel)->writeInt32(value); |
| 59 | } |
| 60 | |
| 61 | binder_status_t AParcel_writeUint32(AParcel* parcel, uint32_t value) { |
| 62 | return (*parcel)->writeUint32(value); |
| 63 | } |
| 64 | |
| 65 | binder_status_t AParcel_writeInt64(AParcel* parcel, int64_t value) { |
| 66 | return (*parcel)->writeInt64(value); |
| 67 | } |
| 68 | |
| 69 | binder_status_t AParcel_writeUint64(AParcel* parcel, uint64_t value) { |
| 70 | return (*parcel)->writeUint64(value); |
| 71 | } |
| 72 | |
| 73 | binder_status_t AParcel_writeFloat(AParcel* parcel, float value) { |
| 74 | return (*parcel)->writeFloat(value); |
| 75 | } |
| 76 | |
| 77 | binder_status_t AParcel_writeDouble(AParcel* parcel, double value) { |
| 78 | return (*parcel)->writeDouble(value); |
| 79 | } |
| 80 | |
| 81 | binder_status_t AParcel_writeBool(AParcel* parcel, bool value) { |
| 82 | return (*parcel)->writeBool(value); |
| 83 | } |
| 84 | |
| 85 | binder_status_t AParcel_writeChar(AParcel* parcel, char16_t value) { |
| 86 | return (*parcel)->writeChar(value); |
| 87 | } |
| 88 | |
| 89 | binder_status_t AParcel_writeByte(AParcel* parcel, int8_t value) { |
| 90 | return (*parcel)->writeByte(value); |
| 91 | } |
| 92 | |
| 93 | binder_status_t AParcel_readInt32(const AParcel* parcel, int32_t* value) { |
| 94 | return (*parcel)->readInt32(value); |
| 95 | } |
| 96 | |
| 97 | binder_status_t AParcel_readUint32(const AParcel* parcel, uint32_t* value) { |
| 98 | return (*parcel)->readUint32(value); |
| 99 | } |
| 100 | |
| 101 | binder_status_t AParcel_readInt64(const AParcel* parcel, int64_t* value) { |
| 102 | return (*parcel)->readInt64(value); |
| 103 | } |
| 104 | |
| 105 | binder_status_t AParcel_readUint64(const AParcel* parcel, uint64_t* value) { |
| 106 | return (*parcel)->readUint64(value); |
| 107 | } |
| 108 | |
| 109 | binder_status_t AParcel_readFloat(const AParcel* parcel, float* value) { |
| 110 | return (*parcel)->readFloat(value); |
| 111 | } |
| 112 | |
| 113 | binder_status_t AParcel_readDouble(const AParcel* parcel, double* value) { |
| 114 | return (*parcel)->readDouble(value); |
| 115 | } |
| 116 | |
| 117 | binder_status_t AParcel_readBool(const AParcel* parcel, bool* value) { |
| 118 | return (*parcel)->readBool(value); |
| 119 | } |
| 120 | |
| 121 | binder_status_t AParcel_readChar(const AParcel* parcel, char16_t* value) { |
| 122 | return (*parcel)->readChar(value); |
| 123 | } |
| 124 | |
| 125 | binder_status_t AParcel_readByte(const AParcel* parcel, int8_t* value) { |
| 126 | return (*parcel)->readByte(value); |
| 127 | } |
| 128 | |
| 129 | // @END |