The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2005 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 | #define LOG_TAG "BpBinder" |
| 18 | //#define LOG_NDEBUG 0 |
| 19 | |
Mathias Agopian | c5b2c0b | 2009-05-19 19:08:10 -0700 | [diff] [blame] | 20 | #include <binder/BpBinder.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 21 | |
Mathias Agopian | c5b2c0b | 2009-05-19 19:08:10 -0700 | [diff] [blame] | 22 | #include <binder/IPCThreadState.h> |
Dianne Hackborn | 23eb1e2 | 2015-10-07 17:35:27 -0700 | [diff] [blame] | 23 | #include <binder/IResultReceiver.h> |
Steven Moreland | bdb53ab | 2021-05-05 17:57:41 +0000 | [diff] [blame] | 24 | #include <binder/RpcSession.h> |
Steven Moreland | 6e5a775 | 2019-08-05 20:30:14 -0700 | [diff] [blame] | 25 | #include <binder/Stability.h> |
Michael Wachenschwanz | d296d0c | 2017-08-15 00:57:14 -0700 | [diff] [blame] | 26 | #include <cutils/compiler.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 27 | #include <utils/Log.h> |
| 28 | |
| 29 | #include <stdio.h> |
| 30 | |
Steve Block | 6807e59 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 31 | //#undef ALOGV |
| 32 | //#define ALOGV(...) fprintf(stderr, __VA_ARGS__) |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 33 | |
| 34 | namespace android { |
| 35 | |
| 36 | // --------------------------------------------------------------------------- |
| 37 | |
Michael Wachenschwanz | d296d0c | 2017-08-15 00:57:14 -0700 | [diff] [blame] | 38 | Mutex BpBinder::sTrackingLock; |
Martijn Coenen | a8d509d | 2021-09-03 18:06:24 +0200 | [diff] [blame^] | 39 | std::unordered_map<int32_t, uint32_t> BpBinder::sTrackingMap; |
| 40 | std::unordered_map<int32_t, uint32_t> BpBinder::sLastLimitCallbackMap; |
Michael Wachenschwanz | d296d0c | 2017-08-15 00:57:14 -0700 | [diff] [blame] | 41 | int BpBinder::sNumTrackedUids = 0; |
| 42 | std::atomic_bool BpBinder::sCountByUidEnabled(false); |
| 43 | binder_proxy_limit_callback BpBinder::sLimitCallback; |
| 44 | bool BpBinder::sBinderProxyThrottleCreate = false; |
| 45 | |
| 46 | // Arbitrarily high value that probably distinguishes a bad behaving app |
| 47 | uint32_t BpBinder::sBinderProxyCountHighWatermark = 2500; |
| 48 | // Another arbitrary value a binder count needs to drop below before another callback will be called |
| 49 | uint32_t BpBinder::sBinderProxyCountLowWatermark = 2000; |
| 50 | |
Martijn Coenen | a8d509d | 2021-09-03 18:06:24 +0200 | [diff] [blame^] | 51 | // Once the limit has been exceeded, keep calling the limit callback for every this many new proxies |
| 52 | // created over the limit. |
| 53 | constexpr uint32_t REPEAT_LIMIT_CALLBACK_INTERVAL = 1000; |
| 54 | |
Michael Wachenschwanz | d296d0c | 2017-08-15 00:57:14 -0700 | [diff] [blame] | 55 | enum { |
Michael Wachenschwanz | 74d967a | 2018-05-15 15:03:57 -0700 | [diff] [blame] | 56 | LIMIT_REACHED_MASK = 0x80000000, // A flag denoting that the limit has been reached |
Michael Wachenschwanz | d296d0c | 2017-08-15 00:57:14 -0700 | [diff] [blame] | 57 | COUNTING_VALUE_MASK = 0x7FFFFFFF, // A mask of the remaining bits for the count value |
| 58 | }; |
| 59 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 60 | BpBinder::ObjectManager::ObjectManager() |
| 61 | { |
| 62 | } |
| 63 | |
| 64 | BpBinder::ObjectManager::~ObjectManager() |
| 65 | { |
| 66 | kill(); |
| 67 | } |
| 68 | |
Steven Moreland | 63a2d51 | 2021-06-25 01:10:15 +0000 | [diff] [blame] | 69 | void* BpBinder::ObjectManager::attach(const void* objectID, void* object, void* cleanupCookie, |
| 70 | IBinder::object_cleanup_func func) { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 71 | entry_t e; |
| 72 | e.object = object; |
| 73 | e.cleanupCookie = cleanupCookie; |
| 74 | e.func = func; |
| 75 | |
Steven Moreland | 63a2d51 | 2021-06-25 01:10:15 +0000 | [diff] [blame] | 76 | if (ssize_t idx = mObjects.indexOfKey(objectID); idx >= 0) { |
| 77 | ALOGI("Trying to attach object ID %p to binder ObjectManager %p with object %p, but object " |
| 78 | "ID already in use", |
| 79 | objectID, this, object); |
| 80 | return mObjects[idx].object; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | mObjects.add(objectID, e); |
Steven Moreland | 63a2d51 | 2021-06-25 01:10:15 +0000 | [diff] [blame] | 84 | return nullptr; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 85 | } |
| 86 | |
| 87 | void* BpBinder::ObjectManager::find(const void* objectID) const |
| 88 | { |
| 89 | const ssize_t i = mObjects.indexOfKey(objectID); |
Yi Kong | fdd8da9 | 2018-06-07 17:52:27 -0700 | [diff] [blame] | 90 | if (i < 0) return nullptr; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 91 | return mObjects.valueAt(i).object; |
| 92 | } |
| 93 | |
Steven Moreland | 63a2d51 | 2021-06-25 01:10:15 +0000 | [diff] [blame] | 94 | void* BpBinder::ObjectManager::detach(const void* objectID) { |
| 95 | ssize_t idx = mObjects.indexOfKey(objectID); |
| 96 | if (idx < 0) return nullptr; |
| 97 | void* value = mObjects[idx].object; |
| 98 | mObjects.removeItemsAt(idx, 1); |
| 99 | return value; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | void BpBinder::ObjectManager::kill() |
| 103 | { |
| 104 | const size_t N = mObjects.size(); |
Mark Salyzyn | d4ecccf | 2014-05-30 16:35:57 -0700 | [diff] [blame] | 105 | ALOGV("Killing %zu objects in manager %p", N, this); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 106 | for (size_t i=0; i<N; i++) { |
| 107 | const entry_t& e = mObjects.valueAt(i); |
Yi Kong | fdd8da9 | 2018-06-07 17:52:27 -0700 | [diff] [blame] | 108 | if (e.func != nullptr) { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 109 | e.func(mObjects.keyAt(i), e.object, e.cleanupCookie); |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | mObjects.clear(); |
| 114 | } |
| 115 | |
| 116 | // --------------------------------------------------------------------------- |
| 117 | |
Steven Moreland | 1a3a8ef | 2021-04-02 02:52:46 +0000 | [diff] [blame] | 118 | sp<BpBinder> BpBinder::create(int32_t handle) { |
Michael Wachenschwanz | d296d0c | 2017-08-15 00:57:14 -0700 | [diff] [blame] | 119 | int32_t trackedUid = -1; |
| 120 | if (sCountByUidEnabled) { |
Michael Wachenschwanz | d296d0c | 2017-08-15 00:57:14 -0700 | [diff] [blame] | 121 | trackedUid = IPCThreadState::self()->getCallingUid(); |
| 122 | AutoMutex _l(sTrackingLock); |
Michael Wachenschwanz | 74d967a | 2018-05-15 15:03:57 -0700 | [diff] [blame] | 123 | uint32_t trackedValue = sTrackingMap[trackedUid]; |
| 124 | if (CC_UNLIKELY(trackedValue & LIMIT_REACHED_MASK)) { |
Michael Wachenschwanz | d296d0c | 2017-08-15 00:57:14 -0700 | [diff] [blame] | 125 | if (sBinderProxyThrottleCreate) { |
Michael Wachenschwanz | 74d967a | 2018-05-15 15:03:57 -0700 | [diff] [blame] | 126 | return nullptr; |
Michael Wachenschwanz | d296d0c | 2017-08-15 00:57:14 -0700 | [diff] [blame] | 127 | } |
Martijn Coenen | a8d509d | 2021-09-03 18:06:24 +0200 | [diff] [blame^] | 128 | trackedValue = trackedValue & COUNTING_VALUE_MASK; |
| 129 | uint32_t lastLimitCallbackAt = sLastLimitCallbackMap[trackedUid]; |
| 130 | |
| 131 | if (trackedValue > lastLimitCallbackAt && |
| 132 | (trackedValue - lastLimitCallbackAt > REPEAT_LIMIT_CALLBACK_INTERVAL)) { |
| 133 | ALOGE("Still too many binder proxy objects sent to uid %d from uid %d (%d proxies " |
| 134 | "held)", |
| 135 | getuid(), trackedUid, trackedValue); |
| 136 | if (sLimitCallback) sLimitCallback(trackedUid); |
| 137 | sLastLimitCallbackMap[trackedUid] = trackedValue; |
| 138 | } |
Michael Wachenschwanz | d296d0c | 2017-08-15 00:57:14 -0700 | [diff] [blame] | 139 | } else { |
Michael Wachenschwanz | 74d967a | 2018-05-15 15:03:57 -0700 | [diff] [blame] | 140 | if ((trackedValue & COUNTING_VALUE_MASK) >= sBinderProxyCountHighWatermark) { |
| 141 | ALOGE("Too many binder proxy objects sent to uid %d from uid %d (%d proxies held)", |
| 142 | getuid(), trackedUid, trackedValue); |
| 143 | sTrackingMap[trackedUid] |= LIMIT_REACHED_MASK; |
| 144 | if (sLimitCallback) sLimitCallback(trackedUid); |
Martijn Coenen | a8d509d | 2021-09-03 18:06:24 +0200 | [diff] [blame^] | 145 | sLastLimitCallbackMap[trackedUid] = trackedValue & COUNTING_VALUE_MASK; |
Michael Wachenschwanz | 74d967a | 2018-05-15 15:03:57 -0700 | [diff] [blame] | 146 | if (sBinderProxyThrottleCreate) { |
| 147 | ALOGI("Throttling binder proxy creates from uid %d in uid %d until binder proxy" |
| 148 | " count drops below %d", |
| 149 | trackedUid, getuid(), sBinderProxyCountLowWatermark); |
| 150 | return nullptr; |
| 151 | } |
| 152 | } |
Michael Wachenschwanz | d296d0c | 2017-08-15 00:57:14 -0700 | [diff] [blame] | 153 | } |
Michael Wachenschwanz | 74d967a | 2018-05-15 15:03:57 -0700 | [diff] [blame] | 154 | sTrackingMap[trackedUid]++; |
Michael Wachenschwanz | d296d0c | 2017-08-15 00:57:14 -0700 | [diff] [blame] | 155 | } |
Steven Moreland | 1a3a8ef | 2021-04-02 02:52:46 +0000 | [diff] [blame] | 156 | return sp<BpBinder>::make(BinderHandle{handle}, trackedUid); |
Michael Wachenschwanz | d296d0c | 2017-08-15 00:57:14 -0700 | [diff] [blame] | 157 | } |
| 158 | |
Steven Moreland | bdb53ab | 2021-05-05 17:57:41 +0000 | [diff] [blame] | 159 | sp<BpBinder> BpBinder::create(const sp<RpcSession>& session, const RpcAddress& address) { |
| 160 | LOG_ALWAYS_FATAL_IF(session == nullptr, "BpBinder::create null session"); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 161 | |
Steven Moreland | 5553ac4 | 2020-11-11 02:14:45 +0000 | [diff] [blame] | 162 | // These are not currently tracked, since there is no UID or other |
| 163 | // identifier to track them with. However, if similar functionality is |
Steven Moreland | bdb53ab | 2021-05-05 17:57:41 +0000 | [diff] [blame] | 164 | // needed, session objects keep track of all BpBinder objects on a |
| 165 | // per-session basis. |
Steven Moreland | 5553ac4 | 2020-11-11 02:14:45 +0000 | [diff] [blame] | 166 | |
Steven Moreland | bdb53ab | 2021-05-05 17:57:41 +0000 | [diff] [blame] | 167 | return sp<BpBinder>::make(RpcHandle{session, address}); |
Steven Moreland | 5553ac4 | 2020-11-11 02:14:45 +0000 | [diff] [blame] | 168 | } |
| 169 | |
| 170 | BpBinder::BpBinder(Handle&& handle) |
| 171 | : mStability(0), |
| 172 | mHandle(handle), |
| 173 | mAlive(true), |
| 174 | mObitsSent(false), |
| 175 | mObituaries(nullptr), |
| 176 | mTrackedUid(-1) { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 177 | extendObjectLifetime(OBJECT_LIFETIME_WEAK); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 178 | } |
| 179 | |
Steven Moreland | 5553ac4 | 2020-11-11 02:14:45 +0000 | [diff] [blame] | 180 | BpBinder::BpBinder(BinderHandle&& handle, int32_t trackedUid) : BpBinder(Handle(handle)) { |
| 181 | mTrackedUid = trackedUid; |
| 182 | |
| 183 | ALOGV("Creating BpBinder %p handle %d\n", this, this->binderHandle()); |
| 184 | |
| 185 | IPCThreadState::self()->incWeakHandle(this->binderHandle(), this); |
| 186 | } |
| 187 | |
Steven Moreland | bdb53ab | 2021-05-05 17:57:41 +0000 | [diff] [blame] | 188 | BpBinder::BpBinder(RpcHandle&& handle) : BpBinder(Handle(handle)) { |
| 189 | LOG_ALWAYS_FATAL_IF(rpcSession() == nullptr, "BpBinder created w/o session object"); |
Steven Moreland | 5553ac4 | 2020-11-11 02:14:45 +0000 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | bool BpBinder::isRpcBinder() const { |
Steven Moreland | bdb53ab | 2021-05-05 17:57:41 +0000 | [diff] [blame] | 193 | return std::holds_alternative<RpcHandle>(mHandle); |
Steven Moreland | 5553ac4 | 2020-11-11 02:14:45 +0000 | [diff] [blame] | 194 | } |
| 195 | |
| 196 | const RpcAddress& BpBinder::rpcAddress() const { |
Steven Moreland | bdb53ab | 2021-05-05 17:57:41 +0000 | [diff] [blame] | 197 | return std::get<RpcHandle>(mHandle).address; |
Steven Moreland | 5553ac4 | 2020-11-11 02:14:45 +0000 | [diff] [blame] | 198 | } |
| 199 | |
Steven Moreland | bdb53ab | 2021-05-05 17:57:41 +0000 | [diff] [blame] | 200 | const sp<RpcSession>& BpBinder::rpcSession() const { |
| 201 | return std::get<RpcHandle>(mHandle).session; |
Steven Moreland | 5553ac4 | 2020-11-11 02:14:45 +0000 | [diff] [blame] | 202 | } |
| 203 | |
| 204 | int32_t BpBinder::binderHandle() const { |
| 205 | return std::get<BinderHandle>(mHandle).handle; |
Steven Moreland | 85180c0 | 2019-07-16 14:24:20 -0700 | [diff] [blame] | 206 | } |
| 207 | |
Devin Moore | f6f2e64 | 2021-08-05 19:03:47 +0000 | [diff] [blame] | 208 | std::optional<int32_t> BpBinder::getDebugBinderHandle() const { |
| 209 | if (!isRpcBinder()) { |
| 210 | return binderHandle(); |
| 211 | } else { |
| 212 | return std::nullopt; |
| 213 | } |
| 214 | } |
| 215 | |
Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 216 | bool BpBinder::isDescriptorCached() const { |
| 217 | Mutex::Autolock _l(mLock); |
| 218 | return mDescriptorCache.size() ? true : false; |
| 219 | } |
| 220 | |
| 221 | const String16& BpBinder::getInterfaceDescriptor() const |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 222 | { |
Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 223 | if (isDescriptorCached() == false) { |
Steven Moreland | 1a3a8ef | 2021-04-02 02:52:46 +0000 | [diff] [blame] | 224 | sp<BpBinder> thiz = sp<BpBinder>::fromExisting(const_cast<BpBinder*>(this)); |
Steven Moreland | 4cf688f | 2021-03-31 01:48:58 +0000 | [diff] [blame] | 225 | |
| 226 | Parcel data; |
| 227 | data.markForBinder(thiz); |
| 228 | Parcel reply; |
Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 229 | // do the IPC without a lock held. |
Steven Moreland | 4cf688f | 2021-03-31 01:48:58 +0000 | [diff] [blame] | 230 | status_t err = thiz->transact(INTERFACE_TRANSACTION, data, &reply); |
Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 231 | if (err == NO_ERROR) { |
| 232 | String16 res(reply.readString16()); |
| 233 | Mutex::Autolock _l(mLock); |
| 234 | // mDescriptorCache could have been assigned while the lock was |
| 235 | // released. |
| 236 | if (mDescriptorCache.size() == 0) |
| 237 | mDescriptorCache = res; |
| 238 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 239 | } |
Mark Salyzyn | d4ecccf | 2014-05-30 16:35:57 -0700 | [diff] [blame] | 240 | |
Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 241 | // we're returning a reference to a non-static object here. Usually this |
Mark Salyzyn | d4ecccf | 2014-05-30 16:35:57 -0700 | [diff] [blame] | 242 | // is not something smart to do, however, with binder objects it is |
Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 243 | // (usually) safe because they are reference-counted. |
Mark Salyzyn | d4ecccf | 2014-05-30 16:35:57 -0700 | [diff] [blame] | 244 | |
Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 245 | return mDescriptorCache; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 246 | } |
| 247 | |
| 248 | bool BpBinder::isBinderAlive() const |
| 249 | { |
Steven Moreland | 06074d8 | 2020-03-05 23:16:51 +0000 | [diff] [blame] | 250 | return mAlive != 0; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 251 | } |
| 252 | |
| 253 | status_t BpBinder::pingBinder() |
| 254 | { |
Steven Moreland | 5553ac4 | 2020-11-11 02:14:45 +0000 | [diff] [blame] | 255 | Parcel data; |
Steven Moreland | 1a3a8ef | 2021-04-02 02:52:46 +0000 | [diff] [blame] | 256 | data.markForBinder(sp<BpBinder>::fromExisting(this)); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 257 | Parcel reply; |
Steven Moreland | 5553ac4 | 2020-11-11 02:14:45 +0000 | [diff] [blame] | 258 | return transact(PING_TRANSACTION, data, &reply); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 259 | } |
| 260 | |
| 261 | status_t BpBinder::dump(int fd, const Vector<String16>& args) |
| 262 | { |
| 263 | Parcel send; |
| 264 | Parcel reply; |
| 265 | send.writeFileDescriptor(fd); |
| 266 | const size_t numArgs = args.size(); |
| 267 | send.writeInt32(numArgs); |
| 268 | for (size_t i = 0; i < numArgs; i++) { |
| 269 | send.writeString16(args[i]); |
| 270 | } |
| 271 | status_t err = transact(DUMP_TRANSACTION, send, &reply); |
| 272 | return err; |
| 273 | } |
| 274 | |
Jiyong Park | b86c866 | 2018-10-29 23:01:57 +0900 | [diff] [blame] | 275 | // NOLINTNEXTLINE(google-default-arguments) |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 276 | status_t BpBinder::transact( |
| 277 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) |
| 278 | { |
| 279 | // Once a binder has died, it will never come back to life. |
| 280 | if (mAlive) { |
Steven Moreland | 46b5fea | 2019-10-15 11:22:18 -0700 | [diff] [blame] | 281 | bool privateVendor = flags & FLAG_PRIVATE_VENDOR; |
| 282 | // don't send userspace flags to the kernel |
| 283 | flags = flags & ~FLAG_PRIVATE_VENDOR; |
| 284 | |
Steven Moreland | 6e5a775 | 2019-08-05 20:30:14 -0700 | [diff] [blame] | 285 | // user transactions require a given stability level |
| 286 | if (code >= FIRST_CALL_TRANSACTION && code <= LAST_CALL_TRANSACTION) { |
| 287 | using android::internal::Stability; |
| 288 | |
Steven Moreland | 16a4106 | 2021-07-23 13:35:25 -0700 | [diff] [blame] | 289 | int16_t stability = Stability::getRepr(this); |
Steven Moreland | 89ddfc5 | 2020-11-13 02:39:26 +0000 | [diff] [blame] | 290 | Stability::Level required = privateVendor ? Stability::VENDOR |
| 291 | : Stability::getLocalLevel(); |
Steven Moreland | 6e5a775 | 2019-08-05 20:30:14 -0700 | [diff] [blame] | 292 | |
Steven Moreland | 16a4106 | 2021-07-23 13:35:25 -0700 | [diff] [blame] | 293 | if (CC_UNLIKELY(!Stability::check(stability, required))) { |
Steven Moreland | b269b58 | 2021-02-10 17:09:11 +0000 | [diff] [blame] | 294 | ALOGE("Cannot do a user transaction on a %s binder (%s) in a %s context.", |
Steven Moreland | 16a4106 | 2021-07-23 13:35:25 -0700 | [diff] [blame] | 295 | Stability::levelString(stability).c_str(), |
| 296 | String8(getInterfaceDescriptor()).c_str(), |
| 297 | Stability::levelString(required).c_str()); |
Steven Moreland | 6e5a775 | 2019-08-05 20:30:14 -0700 | [diff] [blame] | 298 | return BAD_TYPE; |
| 299 | } |
| 300 | } |
| 301 | |
Steven Moreland | 5553ac4 | 2020-11-11 02:14:45 +0000 | [diff] [blame] | 302 | status_t status; |
| 303 | if (CC_UNLIKELY(isRpcBinder())) { |
Steven Moreland | f517427 | 2021-05-25 00:39:28 +0000 | [diff] [blame] | 304 | status = rpcSession()->transact(sp<IBinder>::fromExisting(this), code, data, reply, |
| 305 | flags); |
Steven Moreland | 5553ac4 | 2020-11-11 02:14:45 +0000 | [diff] [blame] | 306 | } else { |
| 307 | status = IPCThreadState::self()->transact(binderHandle(), code, data, reply, flags); |
| 308 | } |
| 309 | |
Steven Moreland | 06074d8 | 2020-03-05 23:16:51 +0000 | [diff] [blame] | 310 | if (status == DEAD_OBJECT) mAlive = 0; |
Steven Moreland | a86a356 | 2019-08-01 23:28:34 +0000 | [diff] [blame] | 311 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 312 | return status; |
| 313 | } |
| 314 | |
| 315 | return DEAD_OBJECT; |
| 316 | } |
| 317 | |
Jiyong Park | b86c866 | 2018-10-29 23:01:57 +0900 | [diff] [blame] | 318 | // NOLINTNEXTLINE(google-default-arguments) |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 319 | status_t BpBinder::linkToDeath( |
| 320 | const sp<DeathRecipient>& recipient, void* cookie, uint32_t flags) |
| 321 | { |
Steven Moreland | 5553ac4 | 2020-11-11 02:14:45 +0000 | [diff] [blame] | 322 | if (isRpcBinder()) return UNKNOWN_TRANSACTION; |
| 323 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 324 | Obituary ob; |
| 325 | ob.recipient = recipient; |
| 326 | ob.cookie = cookie; |
| 327 | ob.flags = flags; |
| 328 | |
Yi Kong | fdd8da9 | 2018-06-07 17:52:27 -0700 | [diff] [blame] | 329 | LOG_ALWAYS_FATAL_IF(recipient == nullptr, |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 330 | "linkToDeath(): recipient must be non-NULL"); |
| 331 | |
| 332 | { |
| 333 | AutoMutex _l(mLock); |
| 334 | |
| 335 | if (!mObitsSent) { |
| 336 | if (!mObituaries) { |
| 337 | mObituaries = new Vector<Obituary>; |
| 338 | if (!mObituaries) { |
| 339 | return NO_MEMORY; |
| 340 | } |
Steven Moreland | 5553ac4 | 2020-11-11 02:14:45 +0000 | [diff] [blame] | 341 | ALOGV("Requesting death notification: %p handle %d\n", this, binderHandle()); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 342 | getWeakRefs()->incWeak(this); |
| 343 | IPCThreadState* self = IPCThreadState::self(); |
Steven Moreland | 5553ac4 | 2020-11-11 02:14:45 +0000 | [diff] [blame] | 344 | self->requestDeathNotification(binderHandle(), this); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 345 | self->flushCommands(); |
| 346 | } |
| 347 | ssize_t res = mObituaries->add(ob); |
| 348 | return res >= (ssize_t)NO_ERROR ? (status_t)NO_ERROR : res; |
| 349 | } |
| 350 | } |
| 351 | |
| 352 | return DEAD_OBJECT; |
| 353 | } |
| 354 | |
Jiyong Park | b86c866 | 2018-10-29 23:01:57 +0900 | [diff] [blame] | 355 | // NOLINTNEXTLINE(google-default-arguments) |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 356 | status_t BpBinder::unlinkToDeath( |
| 357 | const wp<DeathRecipient>& recipient, void* cookie, uint32_t flags, |
| 358 | wp<DeathRecipient>* outRecipient) |
| 359 | { |
Steven Moreland | 5553ac4 | 2020-11-11 02:14:45 +0000 | [diff] [blame] | 360 | if (isRpcBinder()) return UNKNOWN_TRANSACTION; |
| 361 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 362 | AutoMutex _l(mLock); |
| 363 | |
| 364 | if (mObitsSent) { |
| 365 | return DEAD_OBJECT; |
| 366 | } |
| 367 | |
| 368 | const size_t N = mObituaries ? mObituaries->size() : 0; |
| 369 | for (size_t i=0; i<N; i++) { |
| 370 | const Obituary& obit = mObituaries->itemAt(i); |
| 371 | if ((obit.recipient == recipient |
Yi Kong | fdd8da9 | 2018-06-07 17:52:27 -0700 | [diff] [blame] | 372 | || (recipient == nullptr && obit.cookie == cookie)) |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 373 | && obit.flags == flags) { |
Yi Kong | fdd8da9 | 2018-06-07 17:52:27 -0700 | [diff] [blame] | 374 | if (outRecipient != nullptr) { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 375 | *outRecipient = mObituaries->itemAt(i).recipient; |
| 376 | } |
| 377 | mObituaries->removeAt(i); |
| 378 | if (mObituaries->size() == 0) { |
Steven Moreland | 5553ac4 | 2020-11-11 02:14:45 +0000 | [diff] [blame] | 379 | ALOGV("Clearing death notification: %p handle %d\n", this, binderHandle()); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 380 | IPCThreadState* self = IPCThreadState::self(); |
Steven Moreland | 5553ac4 | 2020-11-11 02:14:45 +0000 | [diff] [blame] | 381 | self->clearDeathNotification(binderHandle(), this); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 382 | self->flushCommands(); |
| 383 | delete mObituaries; |
Yi Kong | fdd8da9 | 2018-06-07 17:52:27 -0700 | [diff] [blame] | 384 | mObituaries = nullptr; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 385 | } |
| 386 | return NO_ERROR; |
| 387 | } |
| 388 | } |
| 389 | |
| 390 | return NAME_NOT_FOUND; |
| 391 | } |
| 392 | |
| 393 | void BpBinder::sendObituary() |
| 394 | { |
Steven Moreland | 5553ac4 | 2020-11-11 02:14:45 +0000 | [diff] [blame] | 395 | LOG_ALWAYS_FATAL_IF(isRpcBinder(), "Cannot send obituary for remote binder."); |
| 396 | |
| 397 | ALOGV("Sending obituary for proxy %p handle %d, mObitsSent=%s\n", this, binderHandle(), |
| 398 | mObitsSent ? "true" : "false"); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 399 | |
Steven Moreland | 06074d8 | 2020-03-05 23:16:51 +0000 | [diff] [blame] | 400 | mAlive = 0; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 401 | if (mObitsSent) return; |
| 402 | |
| 403 | mLock.lock(); |
| 404 | Vector<Obituary>* obits = mObituaries; |
Yi Kong | fdd8da9 | 2018-06-07 17:52:27 -0700 | [diff] [blame] | 405 | if(obits != nullptr) { |
Steven Moreland | 5553ac4 | 2020-11-11 02:14:45 +0000 | [diff] [blame] | 406 | ALOGV("Clearing sent death notification: %p handle %d\n", this, binderHandle()); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 407 | IPCThreadState* self = IPCThreadState::self(); |
Steven Moreland | 5553ac4 | 2020-11-11 02:14:45 +0000 | [diff] [blame] | 408 | self->clearDeathNotification(binderHandle(), this); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 409 | self->flushCommands(); |
Yi Kong | fdd8da9 | 2018-06-07 17:52:27 -0700 | [diff] [blame] | 410 | mObituaries = nullptr; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 411 | } |
Steven Moreland | 06074d8 | 2020-03-05 23:16:51 +0000 | [diff] [blame] | 412 | mObitsSent = 1; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 413 | mLock.unlock(); |
| 414 | |
Mark Salyzyn | d4ecccf | 2014-05-30 16:35:57 -0700 | [diff] [blame] | 415 | ALOGV("Reporting death of proxy %p for %zu recipients\n", |
| 416 | this, obits ? obits->size() : 0U); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 417 | |
Yi Kong | fdd8da9 | 2018-06-07 17:52:27 -0700 | [diff] [blame] | 418 | if (obits != nullptr) { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 419 | const size_t N = obits->size(); |
| 420 | for (size_t i=0; i<N; i++) { |
| 421 | reportOneDeath(obits->itemAt(i)); |
| 422 | } |
| 423 | |
| 424 | delete obits; |
| 425 | } |
| 426 | } |
| 427 | |
| 428 | void BpBinder::reportOneDeath(const Obituary& obit) |
| 429 | { |
| 430 | sp<DeathRecipient> recipient = obit.recipient.promote(); |
Steve Block | 6807e59 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 431 | ALOGV("Reporting death to recipient: %p\n", recipient.get()); |
Yi Kong | fdd8da9 | 2018-06-07 17:52:27 -0700 | [diff] [blame] | 432 | if (recipient == nullptr) return; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 433 | |
Steven Moreland | 1a3a8ef | 2021-04-02 02:52:46 +0000 | [diff] [blame] | 434 | recipient->binderDied(wp<BpBinder>::fromExisting(this)); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 435 | } |
| 436 | |
Steven Moreland | 63a2d51 | 2021-06-25 01:10:15 +0000 | [diff] [blame] | 437 | void* BpBinder::attachObject(const void* objectID, void* object, void* cleanupCookie, |
| 438 | object_cleanup_func func) { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 439 | AutoMutex _l(mLock); |
Steve Block | 6807e59 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 440 | ALOGV("Attaching object %p to binder %p (manager=%p)", object, this, &mObjects); |
Steven Moreland | 63a2d51 | 2021-06-25 01:10:15 +0000 | [diff] [blame] | 441 | return mObjects.attach(objectID, object, cleanupCookie, func); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 442 | } |
| 443 | |
| 444 | void* BpBinder::findObject(const void* objectID) const |
| 445 | { |
| 446 | AutoMutex _l(mLock); |
| 447 | return mObjects.find(objectID); |
| 448 | } |
| 449 | |
Steven Moreland | 63a2d51 | 2021-06-25 01:10:15 +0000 | [diff] [blame] | 450 | void* BpBinder::detachObject(const void* objectID) { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 451 | AutoMutex _l(mLock); |
Steven Moreland | 63a2d51 | 2021-06-25 01:10:15 +0000 | [diff] [blame] | 452 | return mObjects.detach(objectID); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 453 | } |
| 454 | |
Steven Moreland | 9e759e8 | 2021-06-25 21:30:23 +0000 | [diff] [blame] | 455 | void BpBinder::withLock(const std::function<void()>& doWithLock) { |
| 456 | AutoMutex _l(mLock); |
| 457 | doWithLock(); |
| 458 | } |
| 459 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 460 | BpBinder* BpBinder::remoteBinder() |
| 461 | { |
| 462 | return this; |
| 463 | } |
| 464 | |
| 465 | BpBinder::~BpBinder() |
| 466 | { |
Steven Moreland | 5553ac4 | 2020-11-11 02:14:45 +0000 | [diff] [blame] | 467 | ALOGV("Destroying BpBinder %p handle %d\n", this, binderHandle()); |
| 468 | |
| 469 | if (CC_UNLIKELY(isRpcBinder())) return; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 470 | |
| 471 | IPCThreadState* ipc = IPCThreadState::self(); |
| 472 | |
Michael Wachenschwanz | d296d0c | 2017-08-15 00:57:14 -0700 | [diff] [blame] | 473 | if (mTrackedUid >= 0) { |
| 474 | AutoMutex _l(sTrackingLock); |
Michael Wachenschwanz | 74d967a | 2018-05-15 15:03:57 -0700 | [diff] [blame] | 475 | uint32_t trackedValue = sTrackingMap[mTrackedUid]; |
| 476 | if (CC_UNLIKELY((trackedValue & COUNTING_VALUE_MASK) == 0)) { |
Steven Moreland | 5553ac4 | 2020-11-11 02:14:45 +0000 | [diff] [blame] | 477 | ALOGE("Unexpected Binder Proxy tracking decrement in %p handle %d\n", this, |
| 478 | binderHandle()); |
Michael Wachenschwanz | d296d0c | 2017-08-15 00:57:14 -0700 | [diff] [blame] | 479 | } else { |
| 480 | if (CC_UNLIKELY( |
Michael Wachenschwanz | 74d967a | 2018-05-15 15:03:57 -0700 | [diff] [blame] | 481 | (trackedValue & LIMIT_REACHED_MASK) && |
| 482 | ((trackedValue & COUNTING_VALUE_MASK) <= sBinderProxyCountLowWatermark) |
Michael Wachenschwanz | d296d0c | 2017-08-15 00:57:14 -0700 | [diff] [blame] | 483 | )) { |
Michael Wachenschwanz | 74d967a | 2018-05-15 15:03:57 -0700 | [diff] [blame] | 484 | ALOGI("Limit reached bit reset for uid %d (fewer than %d proxies from uid %d held)", |
Martijn Coenen | a8d509d | 2021-09-03 18:06:24 +0200 | [diff] [blame^] | 485 | getuid(), sBinderProxyCountLowWatermark, mTrackedUid); |
Michael Wachenschwanz | 74d967a | 2018-05-15 15:03:57 -0700 | [diff] [blame] | 486 | sTrackingMap[mTrackedUid] &= ~LIMIT_REACHED_MASK; |
Martijn Coenen | a8d509d | 2021-09-03 18:06:24 +0200 | [diff] [blame^] | 487 | sLastLimitCallbackMap.erase(mTrackedUid); |
Michael Wachenschwanz | d296d0c | 2017-08-15 00:57:14 -0700 | [diff] [blame] | 488 | } |
| 489 | if (--sTrackingMap[mTrackedUid] == 0) { |
| 490 | sTrackingMap.erase(mTrackedUid); |
| 491 | } |
| 492 | } |
| 493 | } |
| 494 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 495 | if (ipc) { |
Steven Moreland | 5553ac4 | 2020-11-11 02:14:45 +0000 | [diff] [blame] | 496 | ipc->expungeHandle(binderHandle(), this); |
| 497 | ipc->decWeakHandle(binderHandle()); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 498 | } |
| 499 | } |
| 500 | |
| 501 | void BpBinder::onFirstRef() |
| 502 | { |
Steven Moreland | 5553ac4 | 2020-11-11 02:14:45 +0000 | [diff] [blame] | 503 | ALOGV("onFirstRef BpBinder %p handle %d\n", this, binderHandle()); |
| 504 | if (CC_UNLIKELY(isRpcBinder())) return; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 505 | IPCThreadState* ipc = IPCThreadState::self(); |
Steven Moreland | 5553ac4 | 2020-11-11 02:14:45 +0000 | [diff] [blame] | 506 | if (ipc) ipc->incStrongHandle(binderHandle(), this); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 507 | } |
| 508 | |
Colin Cross | 6f4f3ab | 2014-02-05 17:42:44 -0800 | [diff] [blame] | 509 | void BpBinder::onLastStrongRef(const void* /*id*/) |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 510 | { |
Steven Moreland | 5553ac4 | 2020-11-11 02:14:45 +0000 | [diff] [blame] | 511 | ALOGV("onLastStrongRef BpBinder %p handle %d\n", this, binderHandle()); |
| 512 | if (CC_UNLIKELY(isRpcBinder())) { |
Steven Moreland | bdb53ab | 2021-05-05 17:57:41 +0000 | [diff] [blame] | 513 | (void)rpcSession()->sendDecStrong(rpcAddress()); |
Steven Moreland | 5553ac4 | 2020-11-11 02:14:45 +0000 | [diff] [blame] | 514 | return; |
| 515 | } |
Steve Block | 6807e59 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 516 | IF_ALOGV() { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 517 | printRefs(); |
| 518 | } |
| 519 | IPCThreadState* ipc = IPCThreadState::self(); |
Steven Moreland | 5553ac4 | 2020-11-11 02:14:45 +0000 | [diff] [blame] | 520 | if (ipc) ipc->decStrongHandle(binderHandle()); |
Steven Moreland | 80d2393 | 2019-06-07 12:43:27 -0700 | [diff] [blame] | 521 | |
| 522 | mLock.lock(); |
| 523 | Vector<Obituary>* obits = mObituaries; |
| 524 | if(obits != nullptr) { |
| 525 | if (!obits->isEmpty()) { |
Steven Moreland | 70fcb4e | 2019-12-13 17:28:58 -0800 | [diff] [blame] | 526 | ALOGI("onLastStrongRef automatically unlinking death recipients: %s", |
| 527 | mDescriptorCache.size() ? String8(mDescriptorCache).c_str() : "<uncached descriptor>"); |
Steven Moreland | 80d2393 | 2019-06-07 12:43:27 -0700 | [diff] [blame] | 528 | } |
| 529 | |
Steven Moreland | 5553ac4 | 2020-11-11 02:14:45 +0000 | [diff] [blame] | 530 | if (ipc) ipc->clearDeathNotification(binderHandle(), this); |
Steven Moreland | 80d2393 | 2019-06-07 12:43:27 -0700 | [diff] [blame] | 531 | mObituaries = nullptr; |
| 532 | } |
| 533 | mLock.unlock(); |
| 534 | |
| 535 | if (obits != nullptr) { |
| 536 | // XXX Should we tell any remaining DeathRecipient |
| 537 | // objects that the last strong ref has gone away, so they |
| 538 | // are no longer linked? |
| 539 | delete obits; |
| 540 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 541 | } |
| 542 | |
Colin Cross | 6f4f3ab | 2014-02-05 17:42:44 -0800 | [diff] [blame] | 543 | bool BpBinder::onIncStrongAttempted(uint32_t /*flags*/, const void* /*id*/) |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 544 | { |
Steven Moreland | 5553ac4 | 2020-11-11 02:14:45 +0000 | [diff] [blame] | 545 | // RPC binder doesn't currently support inc from weak binders |
| 546 | if (CC_UNLIKELY(isRpcBinder())) return false; |
| 547 | |
| 548 | ALOGV("onIncStrongAttempted BpBinder %p handle %d\n", this, binderHandle()); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 549 | IPCThreadState* ipc = IPCThreadState::self(); |
Steven Moreland | 5553ac4 | 2020-11-11 02:14:45 +0000 | [diff] [blame] | 550 | return ipc ? ipc->attemptIncStrongHandle(binderHandle()) == NO_ERROR : false; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 551 | } |
| 552 | |
Michael Wachenschwanz | d296d0c | 2017-08-15 00:57:14 -0700 | [diff] [blame] | 553 | uint32_t BpBinder::getBinderProxyCount(uint32_t uid) |
| 554 | { |
| 555 | AutoMutex _l(sTrackingLock); |
| 556 | auto it = sTrackingMap.find(uid); |
| 557 | if (it != sTrackingMap.end()) { |
| 558 | return it->second & COUNTING_VALUE_MASK; |
| 559 | } |
| 560 | return 0; |
| 561 | } |
| 562 | |
| 563 | void BpBinder::getCountByUid(Vector<uint32_t>& uids, Vector<uint32_t>& counts) |
| 564 | { |
| 565 | AutoMutex _l(sTrackingLock); |
| 566 | uids.setCapacity(sTrackingMap.size()); |
| 567 | counts.setCapacity(sTrackingMap.size()); |
| 568 | for (const auto& it : sTrackingMap) { |
| 569 | uids.push_back(it.first); |
| 570 | counts.push_back(it.second & COUNTING_VALUE_MASK); |
| 571 | } |
| 572 | } |
| 573 | |
| 574 | void BpBinder::enableCountByUid() { sCountByUidEnabled.store(true); } |
| 575 | void BpBinder::disableCountByUid() { sCountByUidEnabled.store(false); } |
| 576 | void BpBinder::setCountByUidEnabled(bool enable) { sCountByUidEnabled.store(enable); } |
| 577 | |
| 578 | void BpBinder::setLimitCallback(binder_proxy_limit_callback cb) { |
| 579 | AutoMutex _l(sTrackingLock); |
| 580 | sLimitCallback = cb; |
| 581 | } |
| 582 | |
| 583 | void BpBinder::setBinderProxyCountWatermarks(int high, int low) { |
| 584 | AutoMutex _l(sTrackingLock); |
| 585 | sBinderProxyCountHighWatermark = high; |
| 586 | sBinderProxyCountLowWatermark = low; |
| 587 | } |
| 588 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 589 | // --------------------------------------------------------------------------- |
| 590 | |
Steven Moreland | 61ff849 | 2019-09-26 16:05:45 -0700 | [diff] [blame] | 591 | } // namespace android |