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