blob: cf5942059a71442f441ca4057965006ba036324b [file] [log] [blame]
Steven Moreland2e87adc2018-08-20 19:47:00 -07001/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include <android/binder_ibinder.h>
Steven Moreland2f405f52020-07-08 22:24:29 +000018#include <android/binder_ibinder_platform.h>
Steven Moreland46b5fea2019-10-15 11:22:18 -070019#include <android/binder_stability.h>
Steven Moreland2e87adc2018-08-20 19:47:00 -070020#include <android/binder_status.h>
Steven Morelandf3034b02018-11-12 17:37:46 -080021#include <binder/IPCThreadState.h>
Ruchir Rastogicc7a7462020-01-31 14:29:15 -080022#include <binder/IResultReceiver.h>
Tomasz Wasilczykb8ebcca2023-10-09 19:54:20 +000023#if __has_include(<private/android_filesystem_config.h>)
Ruchir Rastogicc7a7462020-01-31 14:29:15 -080024#include <private/android_filesystem_config.h>
Tomasz Wasilczykb8ebcca2023-10-09 19:54:20 +000025#endif
Steven Moreland2e87adc2018-08-20 19:47:00 -070026
Andrei Homescu38eafb72024-03-22 22:38:08 +000027#include "../BuildFlags.h"
Steven Moreland39fdec92022-08-27 00:27:37 +000028#include "ibinder_internal.h"
29#include "parcel_internal.h"
30#include "status_internal.h"
31
Steven Moreland901c7452018-09-04 16:17:28 -070032using DeathRecipient = ::android::IBinder::DeathRecipient;
33
Steven Moreland2e87adc2018-08-20 19:47:00 -070034using ::android::IBinder;
Ruchir Rastogicc7a7462020-01-31 14:29:15 -080035using ::android::IResultReceiver;
Steven Moreland2e87adc2018-08-20 19:47:00 -070036using ::android::Parcel;
37using ::android::sp;
Steven Moreland5d62e442018-09-13 15:01:02 -070038using ::android::status_t;
Steven Moreland009fc1a2022-06-10 17:24:25 +000039using ::android::statusToString;
Steven Moreland2e87adc2018-08-20 19:47:00 -070040using ::android::String16;
Steven Morelanda194c452019-03-04 16:47:07 -080041using ::android::String8;
Steven Moreland2e87adc2018-08-20 19:47:00 -070042using ::android::wp;
43
Steven Moreland71cddc32018-08-30 23:39:22 -070044namespace ABBinderTag {
45
46static const void* kId = "ABBinder";
47static void* kValue = static_cast<void*>(new bool{true});
Andrei Homescu40dbf252024-03-28 21:19:42 +000048void clean(const void* /*id*/, void* /*obj*/, void* /*cookie*/) {
49 /* do nothing */
50}
Steven Moreland71cddc32018-08-30 23:39:22 -070051
52static void attach(const sp<IBinder>& binder) {
Tomasz Wasilczyke3de8802023-11-01 11:05:27 -070053 auto alreadyAttached = binder->attachObject(kId, kValue, nullptr /*cookie*/, clean);
54 LOG_ALWAYS_FATAL_IF(alreadyAttached != nullptr, "can only attach once");
Steven Moreland71cddc32018-08-30 23:39:22 -070055}
56static bool has(const sp<IBinder>& binder) {
57 return binder != nullptr && binder->findObject(kId) == kValue;
58}
59
Steven Moreland6cf66ac2018-11-02 18:14:54 -070060} // namespace ABBinderTag
Steven Moreland71cddc32018-08-30 23:39:22 -070061
Steven Moreland94968952018-09-05 14:42:59 -070062namespace ABpBinderTag {
63
Steven Moreland94968952018-09-05 14:42:59 -070064static const void* kId = "ABpBinder";
65struct Value {
66 wp<ABpBinder> binder;
67};
68void clean(const void* id, void* obj, void* cookie) {
Steven Moreland3acd4902022-07-26 18:29:58 +000069 // be weary of leaks!
Tomasz Wasilczyke3de8802023-11-01 11:05:27 -070070 // ALOGI("Deleting an ABpBinder");
Steven Moreland3acd4902022-07-26 18:29:58 +000071
Tomasz Wasilczyke3de8802023-11-01 11:05:27 -070072 LOG_ALWAYS_FATAL_IF(id != kId, "%p %p %p", id, obj, cookie);
Steven Moreland94968952018-09-05 14:42:59 -070073
74 delete static_cast<Value*>(obj);
Andrei Homescu40dbf252024-03-28 21:19:42 +000075}
Steven Moreland94968952018-09-05 14:42:59 -070076
Steven Moreland6cf66ac2018-11-02 18:14:54 -070077} // namespace ABpBinderTag
Steven Moreland94968952018-09-05 14:42:59 -070078
Steven Moreland2e87adc2018-08-20 19:47:00 -070079AIBinder::AIBinder(const AIBinder_Class* clazz) : mClazz(clazz) {}
80AIBinder::~AIBinder() {}
81
Steven Moreland94a76792022-12-21 01:20:06 +000082// b/175635923 libcxx causes "implicit-conversion" with a string with invalid char
83static std::string SanitizeString(const String16& str) {
84 std::string sanitized{String8(str)};
85 for (auto& c : sanitized) {
86 if (!isprint(c)) {
87 c = '?';
88 }
89 }
90 return sanitized;
91}
92
93bool AIBinder::associateClass(const AIBinder_Class* clazz) {
94 if (clazz == nullptr) return false;
95
96 // If mClazz is non-null, this must have been called and cached
97 // already. So, we can safely call this first. Due to the implementation
98 // of getInterfaceDescriptor (at time of writing), two simultaneous calls
99 // may lead to extra binder transactions, but this is expected to be
100 // exceedingly rare. Once we have a binder, when we get it again later,
101 // we won't make another binder transaction here.
102 const String16& descriptor = getBinder()->getInterfaceDescriptor();
103 const String16& newDescriptor = clazz->getInterfaceDescriptor();
104
Andrei Homescu9556bb12020-09-21 16:59:45 -0700105 std::lock_guard<std::mutex> lock(mClazzMutex);
Steven Moreland71cddc32018-08-30 23:39:22 -0700106 if (mClazz == clazz) return true;
Steven Moreland2e87adc2018-08-20 19:47:00 -0700107
Steven Morelandfaf25a42022-12-21 02:21:36 +0000108 // If this is an ABpBinder, the first class object becomes the canonical one. The implication
109 // of this is that no API can require a proxy information to get information on how to behave.
110 // from the class itself - which should only store the interface descriptor. The functionality
111 // should be implemented by adding AIBinder_* APIs to set values on binders themselves, by
112 // setting things on AIBinder_Class which get transferred along with the binder, so that they
113 // can be read along with the BpBinder, or by modifying APIs directly (e.g. an option in
114 // onTransact).
115 //
116 // While this check is required to support linkernamespaces, one downside of it is that
117 // you may parcel code to communicate between things in the same process. However, comms
118 // between linkernamespaces like this already happen for cross-language calls like Java<->C++
119 // or Rust<->Java, and there are good stability guarantees here. This interacts with
120 // binder Stability checks exactly like any other in-process call. The stability is known
121 // to the IBinder object, so that it doesn't matter if a class object comes from
122 // a different stability level.
123 if (mClazz != nullptr && !asABpBinder()) {
Steven Moreland63872b52020-10-02 19:28:23 +0000124 const String16& currentDescriptor = mClazz->getInterfaceDescriptor();
Steven Moreland2e87adc2018-08-20 19:47:00 -0700125 if (newDescriptor == currentDescriptor) {
Tomasz Wasilczyke3de8802023-11-01 11:05:27 -0700126 ALOGE("Class descriptors '%s' match during associateClass, but they are different class"
127 " objects (%p vs %p). Class descriptor collision?",
128 String8(currentDescriptor).c_str(), clazz, mClazz);
Steven Moreland71cddc32018-08-30 23:39:22 -0700129 } else {
Tomasz Wasilczyke3de8802023-11-01 11:05:27 -0700130 ALOGE("%s: Class cannot be associated on object which already has a class. "
131 "Trying to associate to '%s' but already set to '%s'.",
132 __func__, String8(newDescriptor).c_str(), String8(currentDescriptor).c_str());
Steven Moreland2e87adc2018-08-20 19:47:00 -0700133 }
134
Steven Moreland71cddc32018-08-30 23:39:22 -0700135 // always a failure because we know mClazz != clazz
136 return false;
Steven Moreland2e87adc2018-08-20 19:47:00 -0700137 }
138
Steven Moreland94a76792022-12-21 01:20:06 +0000139 // This will always be an O(n) comparison, but it's expected to be extremely rare.
140 // since it's an error condition. Do the comparison after we take the lock and
141 // check the pointer equality fast path. By always taking the lock, it's also
142 // more flake-proof. However, the check is not dependent on the lock.
Steven Moreland418914a2023-06-28 21:47:14 +0000143 if (descriptor != newDescriptor && !(asABpBinder() && asABpBinder()->isServiceFuzzing())) {
Steven Moreland640c4092020-07-08 00:19:58 +0000144 if (getBinder()->isBinderAlive()) {
Tomasz Wasilczyke3de8802023-11-01 11:05:27 -0700145 ALOGE("%s: Expecting binder to have class '%s' but descriptor is actually '%s'.",
146 __func__, String8(newDescriptor).c_str(), SanitizeString(descriptor).c_str());
Steven Moreland640c4092020-07-08 00:19:58 +0000147 } else {
148 // b/155793159
Tomasz Wasilczyke3de8802023-11-01 11:05:27 -0700149 ALOGE("%s: Cannot associate class '%s' to dead binder with cached descriptor '%s'.",
150 __func__, String8(newDescriptor).c_str(), SanitizeString(descriptor).c_str());
Steven Moreland640c4092020-07-08 00:19:58 +0000151 }
Steven Moreland71cddc32018-08-30 23:39:22 -0700152 return false;
Steven Moreland2e87adc2018-08-20 19:47:00 -0700153 }
154
Steven Morelandfaf25a42022-12-21 02:21:36 +0000155 // A local binder being set for the first time OR
156 // ignoring a proxy binder which is set multiple time, by considering the first
157 // associated class as the canonical one.
158 if (mClazz == nullptr) {
159 mClazz = clazz;
160 }
161
Steven Moreland94a76792022-12-21 01:20:06 +0000162 return true;
Steven Moreland2e87adc2018-08-20 19:47:00 -0700163}
164
165ABBinder::ABBinder(const AIBinder_Class* clazz, void* userData)
Steven Moreland6cf66ac2018-11-02 18:14:54 -0700166 : AIBinder(clazz), BBinder(), mUserData(userData) {
Tomasz Wasilczyke3de8802023-11-01 11:05:27 -0700167 LOG_ALWAYS_FATAL_IF(clazz == nullptr, "clazz == nullptr");
Steven Moreland2e87adc2018-08-20 19:47:00 -0700168}
169ABBinder::~ABBinder() {
170 getClass()->onDestroy(mUserData);
171}
172
173const String16& ABBinder::getInterfaceDescriptor() const {
174 return getClass()->getInterfaceDescriptor();
175}
176
Steven Morelanda194c452019-03-04 16:47:07 -0800177status_t ABBinder::dump(int fd, const ::android::Vector<String16>& args) {
178 AIBinder_onDump onDump = getClass()->onDump;
179
180 if (onDump == nullptr) {
181 return STATUS_OK;
182 }
183
184 // technically UINT32_MAX would be okay here, but INT32_MAX is expected since this may be
185 // null in Java
186 if (args.size() > INT32_MAX) {
Tomasz Wasilczyke3de8802023-11-01 11:05:27 -0700187 ALOGE("ABBinder::dump received too many arguments: %zu", args.size());
Steven Morelanda194c452019-03-04 16:47:07 -0800188 return STATUS_BAD_VALUE;
189 }
190
191 std::vector<String8> utf8Args; // owns memory of utf8s
192 utf8Args.reserve(args.size());
193 std::vector<const char*> utf8Pointers; // what can be passed over NDK API
194 utf8Pointers.reserve(args.size());
195
196 for (size_t i = 0; i < args.size(); i++) {
197 utf8Args.push_back(String8(args[i]));
198 utf8Pointers.push_back(utf8Args[i].c_str());
199 }
200
201 return onDump(this, fd, utf8Pointers.data(), utf8Pointers.size());
202}
203
Steven Moreland5d62e442018-09-13 15:01:02 -0700204status_t ABBinder::onTransact(transaction_code_t code, const Parcel& data, Parcel* reply,
205 binder_flags_t flags) {
Steven Moreland2e87adc2018-08-20 19:47:00 -0700206 if (isUserCommand(code)) {
Steven Morelandf3ed8062021-08-27 14:31:14 -0700207 if (getClass()->writeHeader && !data.checkInterface(this)) {
Steven Moreland9d089af2018-09-18 08:58:09 -0700208 return STATUS_BAD_TYPE;
Steven Moreland2e87adc2018-08-20 19:47:00 -0700209 }
210
211 const AParcel in = AParcel::readOnly(this, &data);
212 AParcel out = AParcel(this, reply, false /*owns*/);
213
Steven Moreland5d62e442018-09-13 15:01:02 -0700214 binder_status_t status = getClass()->onTransact(this, code, &in, &out);
215 return PruneStatusT(status);
Steven Moreland88234072020-08-06 19:32:45 +0000216 } else if (code == SHELL_COMMAND_TRANSACTION && getClass()->handleShellCommand != nullptr) {
Andrei Homescu38eafb72024-03-22 22:38:08 +0000217 if constexpr (!android::kEnableKernelIpc) {
218 // Non-IPC builds do not have getCallingUid(),
219 // so we have no way of authenticating the caller
220 return STATUS_PERMISSION_DENIED;
221 }
222
Ruchir Rastogicc7a7462020-01-31 14:29:15 -0800223 int in = data.readFileDescriptor();
224 int out = data.readFileDescriptor();
225 int err = data.readFileDescriptor();
226
227 int argc = data.readInt32();
228 std::vector<String8> utf8Args; // owns memory of utf8s
229 std::vector<const char*> utf8Pointers; // what can be passed over NDK API
230 for (int i = 0; i < argc && data.dataAvail() > 0; i++) {
231 utf8Args.push_back(String8(data.readString16()));
232 utf8Pointers.push_back(utf8Args[i].c_str());
233 }
234
235 data.readStrongBinder(); // skip over the IShellCallback
236 sp<IResultReceiver> resultReceiver = IResultReceiver::asInterface(data.readStrongBinder());
237
238 // Shell commands should only be callable by ADB.
239 uid_t uid = AIBinder_getCallingUid();
Tomasz Wasilczykb8ebcca2023-10-09 19:54:20 +0000240 if (uid != 0 /* root */
241#ifdef AID_SHELL
242 && uid != AID_SHELL
243#endif
244 ) {
Ruchir Rastogicc7a7462020-01-31 14:29:15 -0800245 if (resultReceiver != nullptr) {
246 resultReceiver->send(-1);
247 }
248 return STATUS_PERMISSION_DENIED;
249 }
250
251 // Check that the file descriptors are valid.
252 if (in == STATUS_BAD_TYPE || out == STATUS_BAD_TYPE || err == STATUS_BAD_TYPE) {
253 if (resultReceiver != nullptr) {
254 resultReceiver->send(-1);
255 }
256 return STATUS_BAD_VALUE;
257 }
258
259 binder_status_t status = getClass()->handleShellCommand(
260 this, in, out, err, utf8Pointers.data(), utf8Pointers.size());
261 if (resultReceiver != nullptr) {
262 resultReceiver->send(status);
263 }
264 return status;
Steven Moreland2e87adc2018-08-20 19:47:00 -0700265 } else {
266 return BBinder::onTransact(code, data, reply, flags);
267 }
268}
269
Steven Moreland71cddc32018-08-30 23:39:22 -0700270ABpBinder::ABpBinder(const ::android::sp<::android::IBinder>& binder)
Steven Moreland3acd4902022-07-26 18:29:58 +0000271 : AIBinder(nullptr /*clazz*/), mRemote(binder) {
Tomasz Wasilczyke3de8802023-11-01 11:05:27 -0700272 LOG_ALWAYS_FATAL_IF(binder == nullptr, "binder == nullptr");
Steven Moreland2e87adc2018-08-20 19:47:00 -0700273}
274ABpBinder::~ABpBinder() {}
275
Steven Moreland94968952018-09-05 14:42:59 -0700276sp<AIBinder> ABpBinder::lookupOrCreateFromBinder(const ::android::sp<::android::IBinder>& binder) {
Steven Moreland71cddc32018-08-30 23:39:22 -0700277 if (binder == nullptr) {
278 return nullptr;
279 }
280 if (ABBinderTag::has(binder)) {
281 return static_cast<ABBinder*>(binder.get());
282 }
Steven Moreland94968952018-09-05 14:42:59 -0700283
Steven Moreland91a96b62021-06-30 23:07:13 +0000284 // The following code ensures that for a given binder object (remote or local), if it is not an
285 // ABBinder then at most one ABpBinder object exists in a given process representing it.
286
Steven Moreland1f1bed62021-06-25 21:50:50 +0000287 auto* value = static_cast<ABpBinderTag::Value*>(binder->findObject(ABpBinderTag::kId));
Steven Moreland94968952018-09-05 14:42:59 -0700288 if (value == nullptr) {
289 value = new ABpBinderTag::Value;
Steven Moreland1f1bed62021-06-25 21:50:50 +0000290 auto oldValue = static_cast<ABpBinderTag::Value*>(
291 binder->attachObject(ABpBinderTag::kId, static_cast<void*>(value),
292 nullptr /*cookie*/, ABpBinderTag::clean));
293
294 // allocated by another thread
295 if (oldValue) {
296 delete value;
297 value = oldValue;
298 }
Steven Moreland94968952018-09-05 14:42:59 -0700299 }
300
Steven Moreland1f1bed62021-06-25 21:50:50 +0000301 sp<ABpBinder> ret;
302 binder->withLock([&]() {
303 ret = value->binder.promote();
304 if (ret == nullptr) {
305 ret = sp<ABpBinder>::make(binder);
306 value->binder = ret;
307 }
308 });
Steven Moreland94968952018-09-05 14:42:59 -0700309
310 return ret;
Steven Moreland71cddc32018-08-30 23:39:22 -0700311}
312
Steven Moreland2e87adc2018-08-20 19:47:00 -0700313struct AIBinder_Weak {
314 wp<AIBinder> binder;
315};
316AIBinder_Weak* AIBinder_Weak_new(AIBinder* binder) {
Steven Moreland5ccb70f2018-09-04 16:30:21 -0700317 if (binder == nullptr) {
318 return nullptr;
319 }
320
Steven Moreland2e87adc2018-08-20 19:47:00 -0700321 return new AIBinder_Weak{wp<AIBinder>(binder)};
322}
Steven Moreland9b80e282018-09-19 13:57:23 -0700323void AIBinder_Weak_delete(AIBinder_Weak* weakBinder) {
324 delete weakBinder;
Steven Moreland2e87adc2018-08-20 19:47:00 -0700325}
326AIBinder* AIBinder_Weak_promote(AIBinder_Weak* weakBinder) {
Steven Moreland5ccb70f2018-09-04 16:30:21 -0700327 if (weakBinder == nullptr) {
328 return nullptr;
329 }
330
Steven Moreland2e87adc2018-08-20 19:47:00 -0700331 sp<AIBinder> binder = weakBinder->binder.promote();
332 AIBinder_incStrong(binder.get());
333 return binder.get();
334}
335
Steven Morelandc70e0122021-01-08 02:44:53 +0000336AIBinder_Weak* AIBinder_Weak_clone(const AIBinder_Weak* weak) {
337 if (weak == nullptr) {
338 return nullptr;
339 }
340
341 return new AIBinder_Weak{weak->binder};
342}
343
344bool AIBinder_lt(const AIBinder* lhs, const AIBinder* rhs) {
345 if (lhs == nullptr || rhs == nullptr) return lhs < rhs;
346
347 return const_cast<AIBinder*>(lhs)->getBinder() < const_cast<AIBinder*>(rhs)->getBinder();
348}
349
350bool AIBinder_Weak_lt(const AIBinder_Weak* lhs, const AIBinder_Weak* rhs) {
351 if (lhs == nullptr || rhs == nullptr) return lhs < rhs;
352
353 return lhs->binder < rhs->binder;
354}
355
Steven Morelandfaf25a42022-12-21 02:21:36 +0000356// WARNING: When multiple classes exist with the same interface descriptor in different
357// linkernamespaces, the first one to be associated with mClazz becomes the canonical one
358// and the only requirement on this is that the interface descriptors match. If this
359// is an ABpBinder, no other state can be referenced from mClazz.
Steven Moreland2e87adc2018-08-20 19:47:00 -0700360AIBinder_Class::AIBinder_Class(const char* interfaceDescriptor, AIBinder_Class_onCreate onCreate,
361 AIBinder_Class_onDestroy onDestroy,
362 AIBinder_Class_onTransact onTransact)
Steven Moreland6cf66ac2018-11-02 18:14:54 -0700363 : onCreate(onCreate),
364 onDestroy(onDestroy),
365 onTransact(onTransact),
Stephen Crane8fde87f2020-11-17 15:06:11 -0800366 mInterfaceDescriptor(interfaceDescriptor),
367 mWideInterfaceDescriptor(interfaceDescriptor) {}
Steven Moreland2e87adc2018-08-20 19:47:00 -0700368
369AIBinder_Class* AIBinder_Class_define(const char* interfaceDescriptor,
370 AIBinder_Class_onCreate onCreate,
371 AIBinder_Class_onDestroy onDestroy,
372 AIBinder_Class_onTransact onTransact) {
373 if (interfaceDescriptor == nullptr || onCreate == nullptr || onDestroy == nullptr ||
374 onTransact == nullptr) {
375 return nullptr;
376 }
377
378 return new AIBinder_Class(interfaceDescriptor, onCreate, onDestroy, onTransact);
379}
380
Steven Morelanda194c452019-03-04 16:47:07 -0800381void AIBinder_Class_setOnDump(AIBinder_Class* clazz, AIBinder_onDump onDump) {
Tomasz Wasilczyke3de8802023-11-01 11:05:27 -0700382 LOG_ALWAYS_FATAL_IF(clazz == nullptr, "setOnDump requires non-null clazz");
Steven Morelanda194c452019-03-04 16:47:07 -0800383
384 // this is required to be called before instances are instantiated
385 clazz->onDump = onDump;
386}
387
Steven Morelandf3ed8062021-08-27 14:31:14 -0700388void AIBinder_Class_disableInterfaceTokenHeader(AIBinder_Class* clazz) {
Tomasz Wasilczyke3de8802023-11-01 11:05:27 -0700389 LOG_ALWAYS_FATAL_IF(clazz == nullptr, "disableInterfaceTokenHeader requires non-null clazz");
Steven Morelandf3ed8062021-08-27 14:31:14 -0700390
391 clazz->writeHeader = false;
392}
393
Ruchir Rastogicc7a7462020-01-31 14:29:15 -0800394void AIBinder_Class_setHandleShellCommand(AIBinder_Class* clazz,
395 AIBinder_handleShellCommand handleShellCommand) {
Tomasz Wasilczyke3de8802023-11-01 11:05:27 -0700396 LOG_ALWAYS_FATAL_IF(clazz == nullptr, "setHandleShellCommand requires non-null clazz");
Ruchir Rastogicc7a7462020-01-31 14:29:15 -0800397
398 clazz->handleShellCommand = handleShellCommand;
399}
400
Stephen Crane8fde87f2020-11-17 15:06:11 -0800401const char* AIBinder_Class_getDescriptor(const AIBinder_Class* clazz) {
Tomasz Wasilczyke3de8802023-11-01 11:05:27 -0700402 LOG_ALWAYS_FATAL_IF(clazz == nullptr, "getDescriptor requires non-null clazz");
Stephen Crane8fde87f2020-11-17 15:06:11 -0800403
404 return clazz->getInterfaceDescriptorUtf8();
405}
406
Alice Ryhlea9d9d22021-08-27 07:51:30 +0000407AIBinder_DeathRecipient::TransferDeathRecipient::~TransferDeathRecipient() {
408 if (mOnUnlinked != nullptr) {
409 mOnUnlinked(mCookie);
410 }
411}
412
Steven Moreland901c7452018-09-04 16:17:28 -0700413void AIBinder_DeathRecipient::TransferDeathRecipient::binderDied(const wp<IBinder>& who) {
Tomasz Wasilczyke3de8802023-11-01 11:05:27 -0700414 LOG_ALWAYS_FATAL_IF(who != mWho, "%p (%p) vs %p (%p)", who.unsafe_get(), who.get_refs(),
415 mWho.unsafe_get(), mWho.get_refs());
Steven Moreland901c7452018-09-04 16:17:28 -0700416
417 mOnDied(mCookie);
Steven Moreland64127ca2019-03-13 09:25:44 -0700418
419 sp<AIBinder_DeathRecipient> recipient = mParentRecipient.promote();
420 sp<IBinder> strongWho = who.promote();
421
422 // otherwise this will be cleaned up later with pruneDeadTransferEntriesLocked
423 if (recipient != nullptr && strongWho != nullptr) {
424 status_t result = recipient->unlinkToDeath(strongWho, mCookie);
425 if (result != ::android::DEAD_OBJECT) {
Tomasz Wasilczyke3de8802023-11-01 11:05:27 -0700426 ALOGW("Unlinking to dead binder resulted in: %d", result);
Steven Moreland64127ca2019-03-13 09:25:44 -0700427 }
428 }
429
Steven Moreland901c7452018-09-04 16:17:28 -0700430 mWho = nullptr;
431}
432
433AIBinder_DeathRecipient::AIBinder_DeathRecipient(AIBinder_DeathRecipient_onBinderDied onDied)
Alice Ryhlea9d9d22021-08-27 07:51:30 +0000434 : mOnDied(onDied), mOnUnlinked(nullptr) {
Tomasz Wasilczyke3de8802023-11-01 11:05:27 -0700435 LOG_ALWAYS_FATAL_IF(onDied == nullptr, "onDied == nullptr");
Steven Moreland901c7452018-09-04 16:17:28 -0700436}
437
Steven Moreland64127ca2019-03-13 09:25:44 -0700438void AIBinder_DeathRecipient::pruneDeadTransferEntriesLocked() {
439 mDeathRecipients.erase(std::remove_if(mDeathRecipients.begin(), mDeathRecipients.end(),
440 [](const sp<TransferDeathRecipient>& tdr) {
441 return tdr->getWho() == nullptr;
442 }),
443 mDeathRecipients.end());
444}
445
Jiyong Park4f97a8c2020-11-16 18:11:14 +0900446binder_status_t AIBinder_DeathRecipient::linkToDeath(const sp<IBinder>& binder, void* cookie) {
Tomasz Wasilczyke3de8802023-11-01 11:05:27 -0700447 LOG_ALWAYS_FATAL_IF(binder == nullptr, "binder == nullptr");
Steven Moreland901c7452018-09-04 16:17:28 -0700448
449 std::lock_guard<std::mutex> l(mDeathRecipientsMutex);
450
451 sp<TransferDeathRecipient> recipient =
Alice Ryhlea9d9d22021-08-27 07:51:30 +0000452 new TransferDeathRecipient(binder, cookie, this, mOnDied, mOnUnlinked);
Steven Moreland901c7452018-09-04 16:17:28 -0700453
Steven Moreland64127ca2019-03-13 09:25:44 -0700454 status_t status = binder->linkToDeath(recipient, cookie, 0 /*flags*/);
Steven Moreland5d62e442018-09-13 15:01:02 -0700455 if (status != STATUS_OK) {
Alice Ryhlea9d9d22021-08-27 07:51:30 +0000456 // When we failed to link, the destructor of TransferDeathRecipient runs here, which
457 // ensures that mOnUnlinked is called before we return with an error from this method.
Steven Moreland5d62e442018-09-13 15:01:02 -0700458 return PruneStatusT(status);
Steven Moreland901c7452018-09-04 16:17:28 -0700459 }
460
461 mDeathRecipients.push_back(recipient);
Steven Moreland64127ca2019-03-13 09:25:44 -0700462
463 pruneDeadTransferEntriesLocked();
Steven Moreland5d62e442018-09-13 15:01:02 -0700464 return STATUS_OK;
Steven Moreland901c7452018-09-04 16:17:28 -0700465}
466
Jiyong Park4f97a8c2020-11-16 18:11:14 +0900467binder_status_t AIBinder_DeathRecipient::unlinkToDeath(const sp<IBinder>& binder, void* cookie) {
Tomasz Wasilczyke3de8802023-11-01 11:05:27 -0700468 LOG_ALWAYS_FATAL_IF(binder == nullptr, "binder == nullptr");
Steven Moreland901c7452018-09-04 16:17:28 -0700469
470 std::lock_guard<std::mutex> l(mDeathRecipientsMutex);
471
472 for (auto it = mDeathRecipients.rbegin(); it != mDeathRecipients.rend(); ++it) {
473 sp<TransferDeathRecipient> recipient = *it;
474
Steven Moreland64127ca2019-03-13 09:25:44 -0700475 if (recipient->getCookie() == cookie && recipient->getWho() == binder) {
Steven Moreland901c7452018-09-04 16:17:28 -0700476 mDeathRecipients.erase(it.base() - 1);
477
Steven Moreland64127ca2019-03-13 09:25:44 -0700478 status_t status = binder->unlinkToDeath(recipient, cookie, 0 /*flags*/);
Steven Moreland5d62e442018-09-13 15:01:02 -0700479 if (status != ::android::OK) {
Tomasz Wasilczyke3de8802023-11-01 11:05:27 -0700480 ALOGE("%s: removed reference to death recipient but unlink failed: %s", __func__,
481 statusToString(status).c_str());
Steven Moreland901c7452018-09-04 16:17:28 -0700482 }
Steven Moreland5d62e442018-09-13 15:01:02 -0700483 return PruneStatusT(status);
Steven Moreland901c7452018-09-04 16:17:28 -0700484 }
485 }
486
Steven Moreland5d62e442018-09-13 15:01:02 -0700487 return STATUS_NAME_NOT_FOUND;
Steven Moreland901c7452018-09-04 16:17:28 -0700488}
489
Alice Ryhlea9d9d22021-08-27 07:51:30 +0000490void AIBinder_DeathRecipient::setOnUnlinked(AIBinder_DeathRecipient_onBinderUnlinked onUnlinked) {
491 mOnUnlinked = onUnlinked;
492}
493
Steven Moreland901c7452018-09-04 16:17:28 -0700494// start of C-API methods
495
Steven Moreland2e87adc2018-08-20 19:47:00 -0700496AIBinder* AIBinder_new(const AIBinder_Class* clazz, void* args) {
497 if (clazz == nullptr) {
Tomasz Wasilczyke3de8802023-11-01 11:05:27 -0700498 ALOGE("%s: Must provide class to construct local binder.", __func__);
Steven Moreland2e87adc2018-08-20 19:47:00 -0700499 return nullptr;
500 }
501
502 void* userData = clazz->onCreate(args);
503
Steven Moreland71cddc32018-08-30 23:39:22 -0700504 sp<AIBinder> ret = new ABBinder(clazz, userData);
505 ABBinderTag::attach(ret->getBinder());
506
507 AIBinder_incStrong(ret.get());
508 return ret.get();
Steven Moreland2e87adc2018-08-20 19:47:00 -0700509}
510
Steven Moreland5ea54da2018-09-04 13:29:55 -0700511bool AIBinder_isRemote(const AIBinder* binder) {
Steven Moreland2e87adc2018-08-20 19:47:00 -0700512 if (binder == nullptr) {
Steven Moreland56f752a2018-11-05 17:23:37 -0800513 return false;
Steven Moreland2e87adc2018-08-20 19:47:00 -0700514 }
515
516 return binder->isRemote();
517}
518
Steven Moreland65867d72018-09-04 14:22:26 -0700519bool AIBinder_isAlive(const AIBinder* binder) {
520 if (binder == nullptr) {
521 return false;
522 }
523
524 return const_cast<AIBinder*>(binder)->getBinder()->isBinderAlive();
525}
526
527binder_status_t AIBinder_ping(AIBinder* binder) {
528 if (binder == nullptr) {
Steven Moreland5d62e442018-09-13 15:01:02 -0700529 return STATUS_UNEXPECTED_NULL;
Steven Moreland65867d72018-09-04 14:22:26 -0700530 }
531
Steven Moreland5d62e442018-09-13 15:01:02 -0700532 return PruneStatusT(binder->getBinder()->pingBinder());
Steven Moreland65867d72018-09-04 14:22:26 -0700533}
534
Steven Morelanda194c452019-03-04 16:47:07 -0800535binder_status_t AIBinder_dump(AIBinder* binder, int fd, const char** args, uint32_t numArgs) {
536 if (binder == nullptr) {
537 return STATUS_UNEXPECTED_NULL;
538 }
539
540 ABBinder* bBinder = binder->asABBinder();
541 if (bBinder != nullptr) {
542 AIBinder_onDump onDump = binder->getClass()->onDump;
543 if (onDump == nullptr) {
544 return STATUS_OK;
545 }
546 return PruneStatusT(onDump(bBinder, fd, args, numArgs));
547 }
548
549 ::android::Vector<String16> utf16Args;
550 utf16Args.setCapacity(numArgs);
551 for (uint32_t i = 0; i < numArgs; i++) {
552 utf16Args.push(String16(String8(args[i])));
553 }
554
555 status_t status = binder->getBinder()->dump(fd, utf16Args);
556 return PruneStatusT(status);
557}
558
Steven Moreland901c7452018-09-04 16:17:28 -0700559binder_status_t AIBinder_linkToDeath(AIBinder* binder, AIBinder_DeathRecipient* recipient,
560 void* cookie) {
561 if (binder == nullptr || recipient == nullptr) {
Tomasz Wasilczyke3de8802023-11-01 11:05:27 -0700562 ALOGE("%s: Must provide binder (%p) and recipient (%p)", __func__, binder, recipient);
Steven Moreland5d62e442018-09-13 15:01:02 -0700563 return STATUS_UNEXPECTED_NULL;
Steven Moreland901c7452018-09-04 16:17:28 -0700564 }
565
Steven Moreland5d62e442018-09-13 15:01:02 -0700566 // returns binder_status_t
Steven Moreland64127ca2019-03-13 09:25:44 -0700567 return recipient->linkToDeath(binder->getBinder(), cookie);
Steven Moreland901c7452018-09-04 16:17:28 -0700568}
569
570binder_status_t AIBinder_unlinkToDeath(AIBinder* binder, AIBinder_DeathRecipient* recipient,
571 void* cookie) {
572 if (binder == nullptr || recipient == nullptr) {
Tomasz Wasilczyke3de8802023-11-01 11:05:27 -0700573 ALOGE("%s: Must provide binder (%p) and recipient (%p)", __func__, binder, recipient);
Steven Moreland5d62e442018-09-13 15:01:02 -0700574 return STATUS_UNEXPECTED_NULL;
Steven Moreland901c7452018-09-04 16:17:28 -0700575 }
576
Steven Moreland5d62e442018-09-13 15:01:02 -0700577 // returns binder_status_t
Steven Moreland64127ca2019-03-13 09:25:44 -0700578 return recipient->unlinkToDeath(binder->getBinder(), cookie);
Steven Moreland901c7452018-09-04 16:17:28 -0700579}
580
Andrei Homescu40dbf252024-03-28 21:19:42 +0000581#ifdef BINDER_WITH_KERNEL_IPC
Steven Morelandf3034b02018-11-12 17:37:46 -0800582uid_t AIBinder_getCallingUid() {
583 return ::android::IPCThreadState::self()->getCallingUid();
584}
585
586pid_t AIBinder_getCallingPid() {
587 return ::android::IPCThreadState::self()->getCallingPid();
588}
589
Alice Ryhl59aeae82021-08-25 10:21:26 +0000590bool AIBinder_isHandlingTransaction() {
591 return ::android::IPCThreadState::self()->getServingStackPointer() != nullptr;
592}
Andrei Homescu40dbf252024-03-28 21:19:42 +0000593#endif
Alice Ryhl59aeae82021-08-25 10:21:26 +0000594
Steven Moreland2e87adc2018-08-20 19:47:00 -0700595void AIBinder_incStrong(AIBinder* binder) {
596 if (binder == nullptr) {
Steven Moreland2e87adc2018-08-20 19:47:00 -0700597 return;
598 }
599
600 binder->incStrong(nullptr);
601}
602void AIBinder_decStrong(AIBinder* binder) {
603 if (binder == nullptr) {
Tomasz Wasilczyke3de8802023-11-01 11:05:27 -0700604 ALOGE("%s: on null binder", __func__);
Steven Moreland2e87adc2018-08-20 19:47:00 -0700605 return;
606 }
607
608 binder->decStrong(nullptr);
609}
610int32_t AIBinder_debugGetRefCount(AIBinder* binder) {
611 if (binder == nullptr) {
Tomasz Wasilczyke3de8802023-11-01 11:05:27 -0700612 ALOGE("%s: on null binder", __func__);
Steven Moreland2e87adc2018-08-20 19:47:00 -0700613 return -1;
614 }
615
616 return binder->getStrongCount();
617}
618
Steven Moreland71cddc32018-08-30 23:39:22 -0700619bool AIBinder_associateClass(AIBinder* binder, const AIBinder_Class* clazz) {
620 if (binder == nullptr) {
621 return false;
Steven Moreland2e87adc2018-08-20 19:47:00 -0700622 }
623
Steven Moreland71cddc32018-08-30 23:39:22 -0700624 return binder->associateClass(clazz);
Steven Moreland2e87adc2018-08-20 19:47:00 -0700625}
626
627const AIBinder_Class* AIBinder_getClass(AIBinder* binder) {
628 if (binder == nullptr) {
629 return nullptr;
630 }
631
632 return binder->getClass();
633}
634
635void* AIBinder_getUserData(AIBinder* binder) {
636 if (binder == nullptr) {
637 return nullptr;
638 }
639
640 ABBinder* bBinder = binder->asABBinder();
641 if (bBinder == nullptr) {
642 return nullptr;
643 }
644
645 return bBinder->getUserData();
646}
647
648binder_status_t AIBinder_prepareTransaction(AIBinder* binder, AParcel** in) {
649 if (binder == nullptr || in == nullptr) {
Tomasz Wasilczyke3de8802023-11-01 11:05:27 -0700650 ALOGE("%s: requires non-null parameters binder (%p) and in (%p).", __func__, binder, in);
Steven Moreland5d62e442018-09-13 15:01:02 -0700651 return STATUS_UNEXPECTED_NULL;
Steven Moreland2e87adc2018-08-20 19:47:00 -0700652 }
653 const AIBinder_Class* clazz = binder->getClass();
654 if (clazz == nullptr) {
Tomasz Wasilczyke3de8802023-11-01 11:05:27 -0700655 ALOGE("%s: Class must be defined for a remote binder transaction. See "
656 "AIBinder_associateClass.",
657 __func__);
Steven Moreland5d62e442018-09-13 15:01:02 -0700658 return STATUS_INVALID_OPERATION;
Steven Moreland2e87adc2018-08-20 19:47:00 -0700659 }
660
661 *in = new AParcel(binder);
Steven Moreland1fda67b2021-04-02 18:35:50 +0000662 (*in)->get()->markForBinder(binder->getBinder());
663
Steven Morelandf3ed8062021-08-27 14:31:14 -0700664 status_t status = android::OK;
Steven Morelandfaf25a42022-12-21 02:21:36 +0000665
666 // note - this is the only read of a value in clazz, and it comes with a warning
667 // on the API itself. Do not copy this design. Instead, attach data in a new
668 // version of the prepareTransaction function.
Steven Morelandf3ed8062021-08-27 14:31:14 -0700669 if (clazz->writeHeader) {
670 status = (*in)->get()->writeInterfaceToken(clazz->getInterfaceDescriptor());
671 }
Steven Moreland5d62e442018-09-13 15:01:02 -0700672 binder_status_t ret = PruneStatusT(status);
673
674 if (ret != STATUS_OK) {
Steven Moreland2e87adc2018-08-20 19:47:00 -0700675 delete *in;
676 *in = nullptr;
677 }
678
Steven Moreland5d62e442018-09-13 15:01:02 -0700679 return ret;
Steven Moreland2e87adc2018-08-20 19:47:00 -0700680}
681
Steven Moreland9b80e282018-09-19 13:57:23 -0700682static void DestroyParcel(AParcel** parcel) {
683 delete *parcel;
684 *parcel = nullptr;
685}
686
Steven Moreland2e87adc2018-08-20 19:47:00 -0700687binder_status_t AIBinder_transact(AIBinder* binder, transaction_code_t code, AParcel** in,
688 AParcel** out, binder_flags_t flags) {
689 if (in == nullptr) {
Tomasz Wasilczyke3de8802023-11-01 11:05:27 -0700690 ALOGE("%s: requires non-null in parameter", __func__);
Steven Moreland5d62e442018-09-13 15:01:02 -0700691 return STATUS_UNEXPECTED_NULL;
Steven Moreland2e87adc2018-08-20 19:47:00 -0700692 }
693
Steven Morelandcaa776c2018-09-04 13:48:11 -0700694 using AutoParcelDestroyer = std::unique_ptr<AParcel*, void (*)(AParcel**)>;
Steven Moreland2e87adc2018-08-20 19:47:00 -0700695 // This object is the input to the transaction. This function takes ownership of it and deletes
696 // it.
Steven Moreland9b80e282018-09-19 13:57:23 -0700697 AutoParcelDestroyer forIn(in, DestroyParcel);
Steven Moreland2e87adc2018-08-20 19:47:00 -0700698
699 if (!isUserCommand(code)) {
Tomasz Wasilczyke3de8802023-11-01 11:05:27 -0700700 ALOGE("%s: Only user-defined transactions can be made from the NDK, but requested: %d",
701 __func__, code);
Steven Moreland5d62e442018-09-13 15:01:02 -0700702 return STATUS_UNKNOWN_TRANSACTION;
Steven Moreland2e87adc2018-08-20 19:47:00 -0700703 }
704
Steven Morelandf183fdd2020-10-27 00:12:12 +0000705 constexpr binder_flags_t kAllFlags = FLAG_PRIVATE_VENDOR | FLAG_ONEWAY | FLAG_CLEAR_BUF;
Steven Moreland46b5fea2019-10-15 11:22:18 -0700706 if ((flags & ~kAllFlags) != 0) {
Tomasz Wasilczyke3de8802023-11-01 11:05:27 -0700707 ALOGE("%s: Unrecognized flags sent: %d", __func__, flags);
Steven Moreland5d62e442018-09-13 15:01:02 -0700708 return STATUS_BAD_VALUE;
Steven Moreland2e87adc2018-08-20 19:47:00 -0700709 }
710
711 if (binder == nullptr || *in == nullptr || out == nullptr) {
Tomasz Wasilczyke3de8802023-11-01 11:05:27 -0700712 ALOGE("%s: requires non-null parameters binder (%p), in (%p), and out (%p).", __func__,
713 binder, in, out);
Steven Moreland5d62e442018-09-13 15:01:02 -0700714 return STATUS_UNEXPECTED_NULL;
Steven Moreland2e87adc2018-08-20 19:47:00 -0700715 }
716
717 if ((*in)->getBinder() != binder) {
Tomasz Wasilczyke3de8802023-11-01 11:05:27 -0700718 ALOGE("%s: parcel is associated with binder object %p but called with %p", __func__, binder,
719 (*in)->getBinder());
Steven Moreland5d62e442018-09-13 15:01:02 -0700720 return STATUS_BAD_VALUE;
Steven Moreland2e87adc2018-08-20 19:47:00 -0700721 }
722
723 *out = new AParcel(binder);
724
Steven Morelandf18615b2018-09-14 11:43:06 -0700725 status_t status = binder->getBinder()->transact(code, *(*in)->get(), (*out)->get(), flags);
Steven Moreland5d62e442018-09-13 15:01:02 -0700726 binder_status_t ret = PruneStatusT(status);
Steven Moreland2e87adc2018-08-20 19:47:00 -0700727
Steven Moreland5d62e442018-09-13 15:01:02 -0700728 if (ret != STATUS_OK) {
Steven Moreland2e87adc2018-08-20 19:47:00 -0700729 delete *out;
730 *out = nullptr;
731 }
732
Steven Moreland5d62e442018-09-13 15:01:02 -0700733 return ret;
Steven Moreland2e87adc2018-08-20 19:47:00 -0700734}
Steven Moreland901c7452018-09-04 16:17:28 -0700735
736AIBinder_DeathRecipient* AIBinder_DeathRecipient_new(
737 AIBinder_DeathRecipient_onBinderDied onBinderDied) {
738 if (onBinderDied == nullptr) {
Tomasz Wasilczyke3de8802023-11-01 11:05:27 -0700739 ALOGE("%s: requires non-null onBinderDied parameter.", __func__);
Steven Moreland901c7452018-09-04 16:17:28 -0700740 return nullptr;
741 }
Steven Moreland64127ca2019-03-13 09:25:44 -0700742 auto ret = new AIBinder_DeathRecipient(onBinderDied);
743 ret->incStrong(nullptr);
744 return ret;
Steven Moreland901c7452018-09-04 16:17:28 -0700745}
746
Alice Ryhlea9d9d22021-08-27 07:51:30 +0000747void AIBinder_DeathRecipient_setOnUnlinked(AIBinder_DeathRecipient* recipient,
748 AIBinder_DeathRecipient_onBinderUnlinked onUnlinked) {
749 if (recipient == nullptr) {
750 return;
751 }
752
753 recipient->setOnUnlinked(onUnlinked);
754}
755
Steven Moreland9b80e282018-09-19 13:57:23 -0700756void AIBinder_DeathRecipient_delete(AIBinder_DeathRecipient* recipient) {
Steven Moreland64127ca2019-03-13 09:25:44 -0700757 if (recipient == nullptr) {
758 return;
759 }
760
761 recipient->decStrong(nullptr);
Steven Moreland901c7452018-09-04 16:17:28 -0700762}
Steven Morelandea14ef22019-08-20 10:50:08 -0700763
764binder_status_t AIBinder_getExtension(AIBinder* binder, AIBinder** outExt) {
765 if (binder == nullptr || outExt == nullptr) {
766 if (outExt != nullptr) {
767 *outExt = nullptr;
768 }
769 return STATUS_UNEXPECTED_NULL;
770 }
771
772 sp<IBinder> ext;
773 status_t res = binder->getBinder()->getExtension(&ext);
774
775 if (res != android::OK) {
776 *outExt = nullptr;
777 return PruneStatusT(res);
778 }
779
780 sp<AIBinder> ret = ABpBinder::lookupOrCreateFromBinder(ext);
781 if (ret != nullptr) ret->incStrong(binder);
782
783 *outExt = ret.get();
784 return STATUS_OK;
785}
786
787binder_status_t AIBinder_setExtension(AIBinder* binder, AIBinder* ext) {
788 if (binder == nullptr || ext == nullptr) {
789 return STATUS_UNEXPECTED_NULL;
790 }
791
792 ABBinder* rawBinder = binder->asABBinder();
793 if (rawBinder == nullptr) {
794 return STATUS_INVALID_OPERATION;
795 }
796
797 rawBinder->setExtension(ext->getBinder());
798 return STATUS_OK;
799}
Steven Moreland2f405f52020-07-08 22:24:29 +0000800
801// platform methods follow
802
803void AIBinder_setRequestingSid(AIBinder* binder, bool requestingSid) {
804 ABBinder* localBinder = binder->asABBinder();
Tomasz Wasilczyke3de8802023-11-01 11:05:27 -0700805 LOG_ALWAYS_FATAL_IF(localBinder == nullptr,
806 "AIBinder_setRequestingSid must be called on a local binder");
Steven Moreland2f405f52020-07-08 22:24:29 +0000807
808 localBinder->setRequestingSid(requestingSid);
809}
810
Andrei Homescu40dbf252024-03-28 21:19:42 +0000811#ifdef BINDER_WITH_KERNEL_IPC
Steven Moreland2f405f52020-07-08 22:24:29 +0000812const char* AIBinder_getCallingSid() {
813 return ::android::IPCThreadState::self()->getCallingSid();
814}
Andrei Homescu40dbf252024-03-28 21:19:42 +0000815#endif
Steven Morelandb2de9532020-05-29 21:44:41 +0000816
Ady Abraham96174ac2021-10-15 11:02:03 -0700817void AIBinder_setMinSchedulerPolicy(AIBinder* binder, int policy, int priority) {
818 binder->asABBinder()->setMinSchedulerPolicy(policy, priority);
819}
Steven Moreland454a26a2021-12-14 01:26:21 +0000820
821void AIBinder_setInheritRt(AIBinder* binder, bool inheritRt) {
822 ABBinder* localBinder = binder->asABBinder();
Tomasz Wasilczyke3de8802023-11-01 11:05:27 -0700823 LOG_ALWAYS_FATAL_IF(localBinder == nullptr,
824 "AIBinder_setInheritRt must be called on a local binder");
Steven Moreland454a26a2021-12-14 01:26:21 +0000825
826 localBinder->setInheritRt(inheritRt);
827}