Steven Moreland | 2648d20 | 2018-08-28 01:23:02 -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 | /** |
| 18 | * @addtogroup NdkBinder |
| 19 | * @{ |
| 20 | */ |
| 21 | |
| 22 | /** |
| 23 | * @file binder_auto_utils.h |
Elliott Hughes | 0556547 | 2019-10-29 08:59:39 -0700 | [diff] [blame] | 24 | * @brief These objects provide a more C++-like thin interface to the binder. |
Steven Moreland | 2648d20 | 2018-08-28 01:23:02 -0700 | [diff] [blame] | 25 | */ |
| 26 | |
| 27 | #pragma once |
| 28 | |
| 29 | #include <android/binder_ibinder.h> |
| 30 | #include <android/binder_parcel.h> |
| 31 | #include <android/binder_status.h> |
| 32 | |
Steven Moreland | e97106a | 2018-10-08 17:53:48 -0700 | [diff] [blame] | 33 | #include <assert.h> |
Steven Moreland | 86ae9e7 | 2018-11-05 11:12:40 -0800 | [diff] [blame] | 34 | |
Steven Moreland | 063f236 | 2018-10-18 12:49:11 -0700 | [diff] [blame] | 35 | #include <unistd.h> |
Steven Moreland | 2648d20 | 2018-08-28 01:23:02 -0700 | [diff] [blame] | 36 | #include <cstddef> |
Steven Moreland | 7477216 | 2019-12-11 16:42:43 -0800 | [diff] [blame] | 37 | #include <string> |
Steven Moreland | 2648d20 | 2018-08-28 01:23:02 -0700 | [diff] [blame] | 38 | |
Steven Moreland | 8b4f48a | 2018-10-08 14:30:42 -0700 | [diff] [blame] | 39 | namespace ndk { |
Steven Moreland | 2648d20 | 2018-08-28 01:23:02 -0700 | [diff] [blame] | 40 | |
| 41 | /** |
| 42 | * Represents one strong pointer to an AIBinder object. |
| 43 | */ |
Steven Moreland | 8b4f48a | 2018-10-08 14:30:42 -0700 | [diff] [blame] | 44 | class SpAIBinder { |
Steven Moreland | 6cf66ac | 2018-11-02 18:14:54 -0700 | [diff] [blame] | 45 | public: |
Steven Moreland | 2648d20 | 2018-08-28 01:23:02 -0700 | [diff] [blame] | 46 | /** |
| 47 | * Takes ownership of one strong refcount of binder. |
| 48 | */ |
Steven Moreland | 8b4f48a | 2018-10-08 14:30:42 -0700 | [diff] [blame] | 49 | explicit SpAIBinder(AIBinder* binder = nullptr) : mBinder(binder) {} |
Steven Moreland | 2648d20 | 2018-08-28 01:23:02 -0700 | [diff] [blame] | 50 | |
| 51 | /** |
Steven Moreland | 8b4f48a | 2018-10-08 14:30:42 -0700 | [diff] [blame] | 52 | * Convenience operator for implicitly constructing an SpAIBinder from nullptr. This is not |
Steven Moreland | 2648d20 | 2018-08-28 01:23:02 -0700 | [diff] [blame] | 53 | * explicit because it is not taking ownership of anything. |
| 54 | */ |
Chih-Hung Hsieh | 5ca1ea4 | 2018-12-20 15:42:22 -0800 | [diff] [blame] | 55 | SpAIBinder(std::nullptr_t) : SpAIBinder() {} // NOLINT(google-explicit-constructor) |
Steven Moreland | 2648d20 | 2018-08-28 01:23:02 -0700 | [diff] [blame] | 56 | |
| 57 | /** |
| 58 | * This will delete the underlying object if it exists. See operator=. |
| 59 | */ |
Steven Moreland | 8b4f48a | 2018-10-08 14:30:42 -0700 | [diff] [blame] | 60 | SpAIBinder(const SpAIBinder& other) { *this = other; } |
Steven Moreland | 2648d20 | 2018-08-28 01:23:02 -0700 | [diff] [blame] | 61 | |
| 62 | /** |
| 63 | * This deletes the underlying object if it exists. See set. |
| 64 | */ |
Steven Moreland | 8b4f48a | 2018-10-08 14:30:42 -0700 | [diff] [blame] | 65 | ~SpAIBinder() { set(nullptr); } |
Steven Moreland | 2648d20 | 2018-08-28 01:23:02 -0700 | [diff] [blame] | 66 | |
| 67 | /** |
| 68 | * This takes ownership of a binder from another AIBinder object but it does not affect the |
| 69 | * ownership of that other object. |
| 70 | */ |
Steven Moreland | 8b4f48a | 2018-10-08 14:30:42 -0700 | [diff] [blame] | 71 | SpAIBinder& operator=(const SpAIBinder& other) { |
Steven Moreland | 2648d20 | 2018-08-28 01:23:02 -0700 | [diff] [blame] | 72 | AIBinder_incStrong(other.mBinder); |
| 73 | set(other.mBinder); |
| 74 | return *this; |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Takes ownership of one strong refcount of binder |
| 79 | */ |
| 80 | void set(AIBinder* binder) { |
Steven Moreland | e97106a | 2018-10-08 17:53:48 -0700 | [diff] [blame] | 81 | AIBinder* old = *const_cast<AIBinder* volatile*>(&mBinder); |
| 82 | if (old != nullptr) AIBinder_decStrong(old); |
| 83 | if (old != *const_cast<AIBinder* volatile*>(&mBinder)) { |
| 84 | __assert(__FILE__, __LINE__, "Race detected."); |
| 85 | } |
Steven Moreland | 2648d20 | 2018-08-28 01:23:02 -0700 | [diff] [blame] | 86 | mBinder = binder; |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * This returns the underlying binder object for transactions. If it is used to create another |
Steven Moreland | 8b4f48a | 2018-10-08 14:30:42 -0700 | [diff] [blame] | 91 | * SpAIBinder object, it should first be incremented. |
Steven Moreland | 2648d20 | 2018-08-28 01:23:02 -0700 | [diff] [blame] | 92 | */ |
| 93 | AIBinder* get() const { return mBinder; } |
| 94 | |
| 95 | /** |
| 96 | * This allows the value in this class to be set from beneath it. If you call this method and |
| 97 | * then change the value of T*, you must take ownership of the value you are replacing and add |
| 98 | * ownership to the object that is put in here. |
| 99 | * |
| 100 | * Recommended use is like this: |
Steven Moreland | 8b4f48a | 2018-10-08 14:30:42 -0700 | [diff] [blame] | 101 | * SpAIBinder a; // will be nullptr |
Steven Moreland | 2648d20 | 2018-08-28 01:23:02 -0700 | [diff] [blame] | 102 | * SomeInitFunction(a.getR()); // value is initialized with refcount |
| 103 | * |
| 104 | * Other usecases are discouraged. |
| 105 | * |
| 106 | */ |
| 107 | AIBinder** getR() { return &mBinder; } |
| 108 | |
Steven Moreland | 6cf66ac | 2018-11-02 18:14:54 -0700 | [diff] [blame] | 109 | private: |
Steven Moreland | 2648d20 | 2018-08-28 01:23:02 -0700 | [diff] [blame] | 110 | AIBinder* mBinder = nullptr; |
| 111 | }; |
| 112 | |
Steven Moreland | 26c4df1 | 2019-01-30 12:29:53 -0800 | [diff] [blame] | 113 | namespace impl { |
| 114 | |
Steven Moreland | 2648d20 | 2018-08-28 01:23:02 -0700 | [diff] [blame] | 115 | /** |
| 116 | * This baseclass owns a single object, used to make various classes RAII. |
| 117 | */ |
Steven Moreland | 063f236 | 2018-10-18 12:49:11 -0700 | [diff] [blame] | 118 | template <typename T, typename R, R (*Destroy)(T), T DEFAULT> |
Steven Moreland | 1630c19 | 2018-10-09 11:54:52 -0700 | [diff] [blame] | 119 | class ScopedAResource { |
Steven Moreland | 6cf66ac | 2018-11-02 18:14:54 -0700 | [diff] [blame] | 120 | public: |
Steven Moreland | 2648d20 | 2018-08-28 01:23:02 -0700 | [diff] [blame] | 121 | /** |
| 122 | * Takes ownership of t. |
| 123 | */ |
Steven Moreland | 063f236 | 2018-10-18 12:49:11 -0700 | [diff] [blame] | 124 | explicit ScopedAResource(T t = DEFAULT) : mT(t) {} |
Steven Moreland | 2648d20 | 2018-08-28 01:23:02 -0700 | [diff] [blame] | 125 | |
| 126 | /** |
| 127 | * This deletes the underlying object if it exists. See set. |
| 128 | */ |
Steven Moreland | 063f236 | 2018-10-18 12:49:11 -0700 | [diff] [blame] | 129 | ~ScopedAResource() { set(DEFAULT); } |
Steven Moreland | 2648d20 | 2018-08-28 01:23:02 -0700 | [diff] [blame] | 130 | |
| 131 | /** |
| 132 | * Takes ownership of t. |
| 133 | */ |
Steven Moreland | 063f236 | 2018-10-18 12:49:11 -0700 | [diff] [blame] | 134 | void set(T t) { |
Steven Moreland | 2648d20 | 2018-08-28 01:23:02 -0700 | [diff] [blame] | 135 | Destroy(mT); |
| 136 | mT = t; |
| 137 | } |
| 138 | |
| 139 | /** |
| 140 | * This returns the underlying object to be modified but does not affect ownership. |
| 141 | */ |
Steven Moreland | 063f236 | 2018-10-18 12:49:11 -0700 | [diff] [blame] | 142 | T get() { return mT; } |
Steven Moreland | 2648d20 | 2018-08-28 01:23:02 -0700 | [diff] [blame] | 143 | |
| 144 | /** |
| 145 | * This returns the const underlying object but does not affect ownership. |
| 146 | */ |
Steven Moreland | 063f236 | 2018-10-18 12:49:11 -0700 | [diff] [blame] | 147 | const T get() const { return mT; } |
Steven Moreland | 2648d20 | 2018-08-28 01:23:02 -0700 | [diff] [blame] | 148 | |
| 149 | /** |
| 150 | * This allows the value in this class to be set from beneath it. If you call this method and |
| 151 | * then change the value of T*, you must take ownership of the value you are replacing and add |
| 152 | * ownership to the object that is put in here. |
| 153 | * |
| 154 | * Recommended use is like this: |
Steven Moreland | 1630c19 | 2018-10-09 11:54:52 -0700 | [diff] [blame] | 155 | * ScopedAResource<T> a; // will be nullptr |
Steven Moreland | 2648d20 | 2018-08-28 01:23:02 -0700 | [diff] [blame] | 156 | * SomeInitFunction(a.getR()); // value is initialized with refcount |
| 157 | * |
| 158 | * Other usecases are discouraged. |
| 159 | * |
| 160 | */ |
Steven Moreland | 063f236 | 2018-10-18 12:49:11 -0700 | [diff] [blame] | 161 | T* getR() { return &mT; } |
Steven Moreland | 2648d20 | 2018-08-28 01:23:02 -0700 | [diff] [blame] | 162 | |
Steven Moreland | d329d05 | 2019-11-05 18:28:47 -0800 | [diff] [blame] | 163 | // copy-constructing/assignment is disallowed |
Steven Moreland | 1630c19 | 2018-10-09 11:54:52 -0700 | [diff] [blame] | 164 | ScopedAResource(const ScopedAResource&) = delete; |
| 165 | ScopedAResource& operator=(const ScopedAResource&) = delete; |
Steven Moreland | 2648d20 | 2018-08-28 01:23:02 -0700 | [diff] [blame] | 166 | |
Steven Moreland | d329d05 | 2019-11-05 18:28:47 -0800 | [diff] [blame] | 167 | // move-constructing/assignment is okay |
Steven Moreland | cd056e4 | 2018-12-11 11:31:12 -0800 | [diff] [blame] | 168 | ScopedAResource(ScopedAResource&& other) : mT(std::move(other.mT)) { other.mT = DEFAULT; } |
Steven Moreland | d329d05 | 2019-11-05 18:28:47 -0800 | [diff] [blame] | 169 | ScopedAResource& operator=(ScopedAResource&& other) { |
| 170 | set(other.mT); |
| 171 | other.mT = DEFAULT; |
| 172 | return *this; |
| 173 | } |
Steven Moreland | 2648d20 | 2018-08-28 01:23:02 -0700 | [diff] [blame] | 174 | |
Steven Moreland | 6cf66ac | 2018-11-02 18:14:54 -0700 | [diff] [blame] | 175 | private: |
Steven Moreland | 063f236 | 2018-10-18 12:49:11 -0700 | [diff] [blame] | 176 | T mT; |
Steven Moreland | 2648d20 | 2018-08-28 01:23:02 -0700 | [diff] [blame] | 177 | }; |
| 178 | |
Steven Moreland | 26c4df1 | 2019-01-30 12:29:53 -0800 | [diff] [blame] | 179 | } // namespace impl |
| 180 | |
Steven Moreland | 2648d20 | 2018-08-28 01:23:02 -0700 | [diff] [blame] | 181 | /** |
| 182 | * Convenience wrapper. See AParcel. |
| 183 | */ |
Steven Moreland | 26c4df1 | 2019-01-30 12:29:53 -0800 | [diff] [blame] | 184 | class ScopedAParcel : public impl::ScopedAResource<AParcel*, void, AParcel_delete, nullptr> { |
Steven Moreland | 6cf66ac | 2018-11-02 18:14:54 -0700 | [diff] [blame] | 185 | public: |
Steven Moreland | 2648d20 | 2018-08-28 01:23:02 -0700 | [diff] [blame] | 186 | /** |
| 187 | * Takes ownership of a. |
| 188 | */ |
Steven Moreland | 1630c19 | 2018-10-09 11:54:52 -0700 | [diff] [blame] | 189 | explicit ScopedAParcel(AParcel* a = nullptr) : ScopedAResource(a) {} |
Steven Moreland | 8b4f48a | 2018-10-08 14:30:42 -0700 | [diff] [blame] | 190 | ~ScopedAParcel() {} |
| 191 | ScopedAParcel(ScopedAParcel&&) = default; |
Devin Moore | 02686ea | 2020-07-28 18:44:23 -0700 | [diff] [blame^] | 192 | ScopedAParcel& operator=(ScopedAParcel&&) = default; |
Steven Moreland | 2648d20 | 2018-08-28 01:23:02 -0700 | [diff] [blame] | 193 | }; |
| 194 | |
| 195 | /** |
| 196 | * Convenience wrapper. See AStatus. |
| 197 | */ |
Steven Moreland | 26c4df1 | 2019-01-30 12:29:53 -0800 | [diff] [blame] | 198 | class ScopedAStatus : public impl::ScopedAResource<AStatus*, void, AStatus_delete, nullptr> { |
Steven Moreland | 6cf66ac | 2018-11-02 18:14:54 -0700 | [diff] [blame] | 199 | public: |
Steven Moreland | 2648d20 | 2018-08-28 01:23:02 -0700 | [diff] [blame] | 200 | /** |
| 201 | * Takes ownership of a. |
| 202 | */ |
Steven Moreland | 1630c19 | 2018-10-09 11:54:52 -0700 | [diff] [blame] | 203 | explicit ScopedAStatus(AStatus* a = nullptr) : ScopedAResource(a) {} |
Steven Moreland | 8b4f48a | 2018-10-08 14:30:42 -0700 | [diff] [blame] | 204 | ~ScopedAStatus() {} |
| 205 | ScopedAStatus(ScopedAStatus&&) = default; |
Steven Moreland | d329d05 | 2019-11-05 18:28:47 -0800 | [diff] [blame] | 206 | ScopedAStatus& operator=(ScopedAStatus&&) = default; |
Steven Moreland | 2648d20 | 2018-08-28 01:23:02 -0700 | [diff] [blame] | 207 | |
| 208 | /** |
| 209 | * See AStatus_isOk. |
| 210 | */ |
Steven Moreland | 190f4f2 | 2019-10-16 16:27:26 -0700 | [diff] [blame] | 211 | bool isOk() const { return get() != nullptr && AStatus_isOk(get()); } |
| 212 | |
| 213 | /** |
| 214 | * See AStatus_getExceptionCode |
| 215 | */ |
| 216 | binder_exception_t getExceptionCode() const { return AStatus_getExceptionCode(get()); } |
| 217 | |
| 218 | /** |
| 219 | * See AStatus_getServiceSpecificError |
| 220 | */ |
| 221 | int32_t getServiceSpecificError() const { return AStatus_getServiceSpecificError(get()); } |
| 222 | |
| 223 | /** |
| 224 | * See AStatus_getStatus |
| 225 | */ |
| 226 | binder_status_t getStatus() const { return AStatus_getStatus(get()); } |
Steven Moreland | 9450a48 | 2018-11-15 15:17:53 -0800 | [diff] [blame] | 227 | |
| 228 | /** |
Steven Moreland | 0977367 | 2019-10-30 16:59:06 -0700 | [diff] [blame] | 229 | * See AStatus_getMessage |
| 230 | */ |
| 231 | const char* getMessage() const { return AStatus_getMessage(get()); } |
| 232 | |
Steven Moreland | 7477216 | 2019-12-11 16:42:43 -0800 | [diff] [blame] | 233 | std::string getDescription() const { |
| 234 | const char* cStr = AStatus_getDescription(get()); |
| 235 | std::string ret = cStr; |
| 236 | AStatus_deleteDescription(cStr); |
| 237 | return ret; |
| 238 | } |
| 239 | |
Steven Moreland | 0977367 | 2019-10-30 16:59:06 -0700 | [diff] [blame] | 240 | /** |
| 241 | * Convenience methods for creating scoped statuses. |
Steven Moreland | 9450a48 | 2018-11-15 15:17:53 -0800 | [diff] [blame] | 242 | */ |
| 243 | static ScopedAStatus ok() { return ScopedAStatus(AStatus_newOk()); } |
Steven Moreland | 0977367 | 2019-10-30 16:59:06 -0700 | [diff] [blame] | 244 | static ScopedAStatus fromExceptionCode(binder_exception_t exception) { |
| 245 | return ScopedAStatus(AStatus_fromExceptionCode(exception)); |
| 246 | } |
| 247 | static ScopedAStatus fromExceptionCodeWithMessage(binder_exception_t exception, |
| 248 | const char* message) { |
| 249 | return ScopedAStatus(AStatus_fromExceptionCodeWithMessage(exception, message)); |
| 250 | } |
| 251 | static ScopedAStatus fromServiceSpecificError(int32_t serviceSpecific) { |
| 252 | return ScopedAStatus(AStatus_fromServiceSpecificError(serviceSpecific)); |
| 253 | } |
| 254 | static ScopedAStatus fromServiceSpecificErrorWithMessage(int32_t serviceSpecific, |
| 255 | const char* message) { |
| 256 | return ScopedAStatus(AStatus_fromServiceSpecificErrorWithMessage(serviceSpecific, message)); |
| 257 | } |
| 258 | static ScopedAStatus fromStatus(binder_status_t status) { |
| 259 | return ScopedAStatus(AStatus_fromStatus(status)); |
| 260 | } |
Steven Moreland | 2648d20 | 2018-08-28 01:23:02 -0700 | [diff] [blame] | 261 | }; |
| 262 | |
| 263 | /** |
| 264 | * Convenience wrapper. See AIBinder_DeathRecipient. |
| 265 | */ |
Steven Moreland | 8b4f48a | 2018-10-08 14:30:42 -0700 | [diff] [blame] | 266 | class ScopedAIBinder_DeathRecipient |
Steven Moreland | 26c4df1 | 2019-01-30 12:29:53 -0800 | [diff] [blame] | 267 | : public impl::ScopedAResource<AIBinder_DeathRecipient*, void, AIBinder_DeathRecipient_delete, |
| 268 | nullptr> { |
Steven Moreland | 6cf66ac | 2018-11-02 18:14:54 -0700 | [diff] [blame] | 269 | public: |
Steven Moreland | 2648d20 | 2018-08-28 01:23:02 -0700 | [diff] [blame] | 270 | /** |
| 271 | * Takes ownership of a. |
| 272 | */ |
Steven Moreland | 1630c19 | 2018-10-09 11:54:52 -0700 | [diff] [blame] | 273 | explicit ScopedAIBinder_DeathRecipient(AIBinder_DeathRecipient* a = nullptr) |
Steven Moreland | 6cf66ac | 2018-11-02 18:14:54 -0700 | [diff] [blame] | 274 | : ScopedAResource(a) {} |
Steven Moreland | 8b4f48a | 2018-10-08 14:30:42 -0700 | [diff] [blame] | 275 | ~ScopedAIBinder_DeathRecipient() {} |
| 276 | ScopedAIBinder_DeathRecipient(ScopedAIBinder_DeathRecipient&&) = default; |
Devin Moore | 02686ea | 2020-07-28 18:44:23 -0700 | [diff] [blame^] | 277 | ScopedAIBinder_DeathRecipient& operator=(ScopedAIBinder_DeathRecipient&&) = default; |
Steven Moreland | 2648d20 | 2018-08-28 01:23:02 -0700 | [diff] [blame] | 278 | }; |
| 279 | |
| 280 | /** |
| 281 | * Convenience wrapper. See AIBinder_Weak. |
| 282 | */ |
Steven Moreland | 063f236 | 2018-10-18 12:49:11 -0700 | [diff] [blame] | 283 | class ScopedAIBinder_Weak |
Steven Moreland | 26c4df1 | 2019-01-30 12:29:53 -0800 | [diff] [blame] | 284 | : public impl::ScopedAResource<AIBinder_Weak*, void, AIBinder_Weak_delete, nullptr> { |
Steven Moreland | 6cf66ac | 2018-11-02 18:14:54 -0700 | [diff] [blame] | 285 | public: |
Steven Moreland | 2648d20 | 2018-08-28 01:23:02 -0700 | [diff] [blame] | 286 | /** |
| 287 | * Takes ownership of a. |
| 288 | */ |
Steven Moreland | 1630c19 | 2018-10-09 11:54:52 -0700 | [diff] [blame] | 289 | explicit ScopedAIBinder_Weak(AIBinder_Weak* a = nullptr) : ScopedAResource(a) {} |
Steven Moreland | 8b4f48a | 2018-10-08 14:30:42 -0700 | [diff] [blame] | 290 | ~ScopedAIBinder_Weak() {} |
| 291 | ScopedAIBinder_Weak(ScopedAIBinder_Weak&&) = default; |
Devin Moore | 02686ea | 2020-07-28 18:44:23 -0700 | [diff] [blame^] | 292 | ScopedAIBinder_Weak& operator=(ScopedAIBinder_Weak&&) = default; |
Steven Moreland | 2648d20 | 2018-08-28 01:23:02 -0700 | [diff] [blame] | 293 | |
| 294 | /** |
| 295 | * See AIBinder_Weak_promote. |
| 296 | */ |
Steven Moreland | 8b4f48a | 2018-10-08 14:30:42 -0700 | [diff] [blame] | 297 | SpAIBinder promote() { return SpAIBinder(AIBinder_Weak_promote(get())); } |
Steven Moreland | 2648d20 | 2018-08-28 01:23:02 -0700 | [diff] [blame] | 298 | }; |
| 299 | |
Steven Moreland | 063f236 | 2018-10-18 12:49:11 -0700 | [diff] [blame] | 300 | /** |
| 301 | * Convenience wrapper for a file descriptor. |
| 302 | */ |
Steven Moreland | 26c4df1 | 2019-01-30 12:29:53 -0800 | [diff] [blame] | 303 | class ScopedFileDescriptor : public impl::ScopedAResource<int, int, close, -1> { |
Steven Moreland | 6cf66ac | 2018-11-02 18:14:54 -0700 | [diff] [blame] | 304 | public: |
Steven Moreland | 063f236 | 2018-10-18 12:49:11 -0700 | [diff] [blame] | 305 | /** |
| 306 | * Takes ownership of a. |
| 307 | */ |
| 308 | explicit ScopedFileDescriptor(int a = -1) : ScopedAResource(a) {} |
| 309 | ~ScopedFileDescriptor() {} |
| 310 | ScopedFileDescriptor(ScopedFileDescriptor&&) = default; |
Devin Moore | 02686ea | 2020-07-28 18:44:23 -0700 | [diff] [blame^] | 311 | ScopedFileDescriptor& operator=(ScopedFileDescriptor&&) = default; |
Steven Moreland | 063f236 | 2018-10-18 12:49:11 -0700 | [diff] [blame] | 312 | }; |
| 313 | |
Steven Moreland | 6cf66ac | 2018-11-02 18:14:54 -0700 | [diff] [blame] | 314 | } // namespace ndk |
Steven Moreland | 2648d20 | 2018-08-28 01:23:02 -0700 | [diff] [blame] | 315 | |
Steven Moreland | 2648d20 | 2018-08-28 01:23:02 -0700 | [diff] [blame] | 316 | /** @} */ |