Skip to content

Commit 12f83cf

Browse files
waghpawanGerrit Code Review
authored andcommitted
Merge "Revert^3 "Move tracing calls to libbinder_ndk"" into main
2 parents 95583c2 + 00f5a99 commit 12f83cf

12 files changed

Lines changed: 4 additions & 260 deletions

File tree

libs/binder/OS.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ namespace android::binder::os {
2727
LIBBINDER_EXPORTED void trace_begin(uint64_t tag, const char* name);
2828
LIBBINDER_EXPORTED void trace_end(uint64_t tag);
2929
LIBBINDER_EXPORTED void trace_int(uint64_t tag, const char* name, int32_t value);
30-
LIBBINDER_EXPORTED uint64_t get_trace_enabled_tags();
3130

3231
status_t setNonBlocking(borrowed_fd fd);
3332

libs/binder/OS_android.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@ void trace_int(uint64_t tag, const char* name, int32_t value) {
4848
atrace_int(tag, name, value);
4949
}
5050

51-
uint64_t get_trace_enabled_tags() {
52-
return atrace_enabled_tags;
53-
}
54-
5551
} // namespace os
5652

5753
// Legacy trace symbol. To be removed once all of downstream rebuilds.

libs/binder/OS_non_android_linux.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@ void trace_end(uint64_t) {}
4141

4242
void trace_int(uint64_t, const char*, int32_t) {}
4343

44-
uint64_t get_trace_enabled_tags() {
45-
return 0;
46-
}
47-
4844
uint64_t GetThreadId() {
4945
return syscall(__NR_gettid);
5046
}

libs/binder/include/binder/Trace.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ namespace os {
4242
void trace_begin(uint64_t tag, const char* name);
4343
void trace_end(uint64_t tag);
4444
void trace_int(uint64_t tag, const char* name, int32_t value);
45-
uint64_t get_trace_enabled_tags();
4645
} // namespace os
4746

4847
class LIBBINDER_EXPORTED ScopedTrace {

libs/binder/ndk/ibinder.cpp

Lines changed: 1 addition & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@
1818
#include <android/binder_ibinder_platform.h>
1919
#include <android/binder_stability.h>
2020
#include <android/binder_status.h>
21-
#include <binder/Functional.h>
2221
#include <binder/IPCThreadState.h>
2322
#include <binder/IResultReceiver.h>
24-
#include <binder/Trace.h>
2523
#if __has_include(<private/android_filesystem_config.h>)
2624
#include <private/android_filesystem_config.h>
2725
#endif
@@ -42,23 +40,6 @@ using ::android::statusToString;
4240
using ::android::String16;
4341
using ::android::String8;
4442
using ::android::wp;
45-
using ::android::binder::impl::make_scope_guard;
46-
using ::android::binder::impl::scope_guard;
47-
using ::android::binder::os::get_trace_enabled_tags;
48-
using ::android::binder::os::trace_begin;
49-
using ::android::binder::os::trace_end;
50-
51-
// transaction codes for getInterfaceHash and getInterfaceVersion are defined
52-
// in file : system/tools/aidl/aidl.cpp
53-
static constexpr int kGetInterfaceVersionId = 0x00fffffe;
54-
static const char* kInterfaceVersion = "getInterfaceVersion";
55-
static constexpr int kGetInterfaceHashId = 0x00fffffd;
56-
static const char* kInterfaceHash = "getInterfaceHash";
57-
static const char* kNdkTrace = "AIDL::ndk::";
58-
static const char* kServerTrace = "::server";
59-
static const char* kClientTrace = "::client";
60-
static const char* kSeparator = "::";
61-
static const char* kUnknownCode = "Unknown_Transaction_Code:";
6243

6344
namespace ABBinderTag {
6445

@@ -109,51 +90,6 @@ static std::string SanitizeString(const String16& str) {
10990
return sanitized;
11091
}
11192

112-
const std::string getMethodName(const AIBinder_Class* clazz, transaction_code_t code) {
113-
// TODO(b/150155678) - Move getInterfaceHash and getInterfaceVersion to libbinder and remove
114-
// hardcoded cases.
115-
if (code <= clazz->getTransactionCodeToFunctionLength() && code >= FIRST_CALL_TRANSACTION) {
116-
// Codes have FIRST_CALL_TRANSACTION as added offset. Subtract to access function name
117-
return clazz->getFunctionName(code);
118-
} else if (code == kGetInterfaceVersionId) {
119-
return kInterfaceVersion;
120-
} else if (code == kGetInterfaceHashId) {
121-
return kInterfaceHash;
122-
}
123-
return kUnknownCode + std::to_string(code);
124-
}
125-
126-
const std::string getTraceSectionName(const AIBinder_Class* clazz, transaction_code_t code,
127-
bool isServer) {
128-
if (clazz == nullptr) {
129-
ALOGE("class associated with binder is null. Class is needed to add trace with interface "
130-
"name and function name");
131-
return kNdkTrace;
132-
}
133-
134-
const std::string descriptor = clazz->getInterfaceDescriptorUtf8();
135-
const std::string methodName = getMethodName(clazz, code);
136-
137-
size_t traceSize =
138-
strlen(kNdkTrace) + descriptor.size() + strlen(kSeparator) + methodName.size();
139-
traceSize += isServer ? strlen(kServerTrace) : strlen(kClientTrace);
140-
141-
std::string trace;
142-
// reserve to avoid repeated allocations
143-
trace.reserve(traceSize);
144-
145-
trace += kNdkTrace;
146-
trace += clazz->getInterfaceDescriptorUtf8();
147-
trace += kSeparator;
148-
trace += methodName;
149-
trace += isServer ? kServerTrace : kClientTrace;
150-
151-
LOG_ALWAYS_FATAL_IF(trace.size() != traceSize, "Trace size mismatch. Expected %zu, got %zu",
152-
traceSize, trace.size());
153-
154-
return trace;
155-
}
156-
15793
bool AIBinder::associateClass(const AIBinder_Class* clazz) {
15894
if (clazz == nullptr) return false;
15995

@@ -267,17 +203,6 @@ status_t ABBinder::dump(int fd, const ::android::Vector<String16>& args) {
267203

268204
status_t ABBinder::onTransact(transaction_code_t code, const Parcel& data, Parcel* reply,
269205
binder_flags_t flags) {
270-
std::string sectionName;
271-
bool tracingEnabled = get_trace_enabled_tags() & ATRACE_TAG_AIDL;
272-
if (tracingEnabled) {
273-
sectionName = getTraceSectionName(getClass(), code, true /*isServer*/);
274-
trace_begin(ATRACE_TAG_AIDL, sectionName.c_str());
275-
}
276-
277-
scope_guard guard = make_scope_guard([&]() {
278-
if (tracingEnabled) trace_end(ATRACE_TAG_AIDL);
279-
});
280-
281206
if (isUserCommand(code)) {
282207
if (getClass()->writeHeader && !data.checkInterface(this)) {
283208
return STATUS_BAD_TYPE;
@@ -460,31 +385,6 @@ AIBinder_Class::AIBinder_Class(const char* interfaceDescriptor, AIBinder_Class_o
460385
mInterfaceDescriptor(interfaceDescriptor),
461386
mWideInterfaceDescriptor(interfaceDescriptor) {}
462387

463-
bool AIBinder_Class::setTransactionCodeMap(const char** transactionCodeMap, size_t length) {
464-
if (mTransactionCodeToFunction != nullptr) {
465-
ALOGE("mTransactionCodeToFunction is already set!");
466-
return false;
467-
}
468-
mTransactionCodeToFunction = transactionCodeMap;
469-
mTransactionCodeToFunctionLength = length;
470-
return true;
471-
}
472-
473-
const char* AIBinder_Class::getFunctionName(transaction_code_t code) const {
474-
if (mTransactionCodeToFunction == nullptr) {
475-
ALOGE("mTransactionCodeToFunction is not set!");
476-
return nullptr;
477-
}
478-
479-
if (code < FIRST_CALL_TRANSACTION ||
480-
code - FIRST_CALL_TRANSACTION >= mTransactionCodeToFunctionLength) {
481-
ALOGE("Function name for requested code not found!");
482-
return nullptr;
483-
}
484-
485-
return mTransactionCodeToFunction[code - FIRST_CALL_TRANSACTION];
486-
}
487-
488388
AIBinder_Class* AIBinder_Class_define(const char* interfaceDescriptor,
489389
AIBinder_Class_onCreate onCreate,
490390
AIBinder_Class_onDestroy onDestroy,
@@ -504,24 +404,6 @@ void AIBinder_Class_setOnDump(AIBinder_Class* clazz, AIBinder_onDump onDump) {
504404
clazz->onDump = onDump;
505405
}
506406

507-
void AIBinder_Class_setTransactionCodeToFunctionNameMap(AIBinder_Class* clazz,
508-
const char** transactionCodeToFunction,
509-
size_t length) {
510-
LOG_ALWAYS_FATAL_IF(clazz == nullptr || transactionCodeToFunction == nullptr,
511-
"Valid clazz and transactionCodeToFunction are needed to set code to "
512-
"function mapping.");
513-
LOG_ALWAYS_FATAL_IF(!clazz->setTransactionCodeMap(transactionCodeToFunction, length),
514-
"Failed to set transactionCodeToFunction to clazz! Is "
515-
"transactionCodeToFunction already set?");
516-
}
517-
518-
const char* AIBinder_Class_getFunctionName(AIBinder_Class* clazz, transaction_code_t code) {
519-
LOG_ALWAYS_FATAL_IF(
520-
clazz == nullptr,
521-
"Valid clazz is needed to get function name for requested transaction code");
522-
return clazz->getFunctionName(code);
523-
}
524-
525407
void AIBinder_Class_disableInterfaceTokenHeader(AIBinder_Class* clazz) {
526408
LOG_ALWAYS_FATAL_IF(clazz == nullptr, "disableInterfaceTokenHeader requires non-null clazz");
527409

@@ -852,19 +734,6 @@ static void DestroyParcel(AParcel** parcel) {
852734

853735
binder_status_t AIBinder_transact(AIBinder* binder, transaction_code_t code, AParcel** in,
854736
AParcel** out, binder_flags_t flags) {
855-
const AIBinder_Class* clazz = binder ? binder->getClass() : nullptr;
856-
857-
std::string sectionName;
858-
bool tracingEnabled = get_trace_enabled_tags() & ATRACE_TAG_AIDL;
859-
if (tracingEnabled) {
860-
sectionName = getTraceSectionName(clazz, code, false /*isServer*/);
861-
trace_begin(ATRACE_TAG_AIDL, sectionName.c_str());
862-
}
863-
864-
scope_guard guard = make_scope_guard([&]() {
865-
if (tracingEnabled) trace_end(ATRACE_TAG_AIDL);
866-
});
867-
868737
if (in == nullptr) {
869738
ALOGE("%s: requires non-null in parameter", __func__);
870739
return STATUS_UNEXPECTED_NULL;
@@ -1003,4 +872,4 @@ void AIBinder_setInheritRt(AIBinder* binder, bool inheritRt) {
1003872
"AIBinder_setInheritRt must be called on a local binder");
1004873

1005874
localBinder->setInheritRt(inheritRt);
1006-
}
875+
}

libs/binder/ndk/ibinder_internal.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,6 @@ struct AIBinder_Class {
132132

133133
const ::android::String16& getInterfaceDescriptor() const { return mWideInterfaceDescriptor; }
134134
const char* getInterfaceDescriptorUtf8() const { return mInterfaceDescriptor.c_str(); }
135-
bool setTransactionCodeMap(const char** transactionCodeMap, size_t transactionCodeMapSize);
136-
const char* getFunctionName(transaction_code_t code) const;
137-
size_t getTransactionCodeToFunctionLength() const { return mTransactionCodeToFunctionLength; }
138135

139136
// whether a transaction header should be written
140137
bool writeHeader = true;
@@ -154,10 +151,6 @@ struct AIBinder_Class {
154151
// This must be a String16 since BBinder virtual getInterfaceDescriptor returns a reference to
155152
// one.
156153
const ::android::String16 mWideInterfaceDescriptor;
157-
// Array which holds names of the functions
158-
const char** mTransactionCodeToFunction = nullptr;
159-
// length of mmTransactionCodeToFunctionLength array
160-
size_t mTransactionCodeToFunctionLength = 0;
161154
};
162155

163156
// Ownership is like this (when linked to death):

libs/binder/ndk/include_cpp/android/binder_interface_utils.h

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,6 @@
3030
#include <android/binder_auto_utils.h>
3131
#include <android/binder_ibinder.h>
3232

33-
#if defined(__ANDROID_VENDOR__)
34-
#include <android/llndk-versioning.h>
35-
#elif !defined(API_LEVEL_AT_LEAST)
36-
#if defined(__BIONIC__)
37-
#define API_LEVEL_AT_LEAST(sdk_api_level, vendor_api_level) \
38-
(__builtin_available(android sdk_api_level, *))
39-
#else
40-
#define API_LEVEL_AT_LEAST(sdk_api_level, vendor_api_level) (true)
41-
#endif // __BIONIC__
42-
#endif // __ANDROID_VENDOR__
43-
4433
#if __has_include(<android/binder_shell.h>)
4534
#include <android/binder_shell.h>
4635
#define HAS_BINDER_SHELL_COMMAND
@@ -175,8 +164,7 @@ class ICInterface : public SharedRefBase {
175164
* Helper method to create a class
176165
*/
177166
static inline AIBinder_Class* defineClass(const char* interfaceDescriptor,
178-
AIBinder_Class_onTransact onTransact,
179-
const char** codeToFunction, size_t functionCount);
167+
AIBinder_Class_onTransact onTransact);
180168

181169
private:
182170
class ICInterfaceData {
@@ -267,8 +255,7 @@ std::shared_ptr<ICInterface> ICInterface::asInterface(AIBinder* binder) {
267255
}
268256

269257
AIBinder_Class* ICInterface::defineClass(const char* interfaceDescriptor,
270-
AIBinder_Class_onTransact onTransact,
271-
const char** codeToFunction, size_t functionCount) {
258+
AIBinder_Class_onTransact onTransact) {
272259
AIBinder_Class* clazz = AIBinder_Class_define(interfaceDescriptor, ICInterfaceData::onCreate,
273260
ICInterfaceData::onDestroy, onTransact);
274261
if (clazz == nullptr) {
@@ -287,17 +274,6 @@ AIBinder_Class* ICInterface::defineClass(const char* interfaceDescriptor,
287274
AIBinder_Class_setHandleShellCommand(clazz, ICInterfaceData::handleShellCommand);
288275
}
289276
#endif
290-
291-
// TODO(b/368559337): fix versioning on product partition
292-
#if !defined(__ANDROID_PRODUCT__) && \
293-
(defined(__ANDROID_UNAVAILABLE_SYMBOLS_ARE_WEAK__) || __ANDROID_API__ >= 36)
294-
if API_LEVEL_AT_LEAST (36, 202504) {
295-
AIBinder_Class_setTransactionCodeToFunctionNameMap(clazz, codeToFunction, functionCount);
296-
}
297-
#else
298-
(void)codeToFunction;
299-
(void)functionCount;
300-
#endif // defined(__ANDROID_UNAVAILABLE_SYMBOLS_ARE_WEAK__) || __ANDROID_API__ >= 36
301277
return clazz;
302278
}
303279

libs/binder/ndk/include_ndk/android/binder_ibinder.h

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -218,50 +218,6 @@ typedef binder_status_t (*AIBinder_onDump)(AIBinder* binder, int fd, const char*
218218
*/
219219
void AIBinder_Class_setOnDump(AIBinder_Class* clazz, AIBinder_onDump onDump) __INTRODUCED_IN(29);
220220

221-
/**
222-
* Associates a mapping of transaction codes(transaction_code_t) to function names for the given
223-
* class.
224-
*
225-
* Trace messages will use the provided names instead of bare integer codes when set. If not set by
226-
* this function, trace messages will only be identified by the bare code. This should be called one
227-
* time during clazz initialization. clazz and transactionCodeToFunctionMap should have same
228-
* lifetime. Resetting/clearing the transactionCodeToFunctionMap is not allowed.
229-
*
230-
* Available since API level 36.
231-
*
232-
* \param clazz class which should use this transaction to code function map.
233-
* \param transactionCodeToFunctionMap array of function names indexed by transaction code.
234-
* Transaction codes start from 1, functions with transaction code 1 will correspond to index 0 in
235-
* transactionCodeToFunctionMap. When defining methods, transaction codes are expected to be
236-
* contiguous, and this is required for maximum memory efficiency.
237-
* You can use nullptr if certain transaction codes are not used. Lifetime should be same as clazz.
238-
* \param length number of elements in the transactionCodeToFunctionMap
239-
*
240-
* \return true if setting codeToFunction to clazz is successful. return false if clazz or
241-
* codeToFunction is nullptr.
242-
*/
243-
void AIBinder_Class_setTransactionCodeToFunctionNameMap(AIBinder_Class* clazz,
244-
const char** transactionCodeToFunctionMap,
245-
size_t length) __INTRODUCED_IN(36);
246-
247-
/**
248-
* Get function name associated with transaction code for given class
249-
*
250-
* This function returns function name associated with provided transaction code for given class.
251-
* AIBinder_Class_setTransactionCodeToFunctionNameMap should be called first to associate function
252-
* to transaction code mapping.
253-
*
254-
* Available since API level 36.
255-
*
256-
* \param clazz class for which function name is requested
257-
* \param transactionCode transaction_code_t for which function name is requested.
258-
*
259-
* \return function name in form of const char* if transaction code is valid for given class.
260-
* if transaction code is invalid or transactionCodeToFunctionMap is not set, nullptr is returned
261-
*/
262-
const char* AIBinder_Class_getFunctionName(AIBinder_Class* clazz, transaction_code_t code)
263-
__INTRODUCED_IN(36);
264-
265221
/**
266222
* This tells users of this class not to use a transaction header. By default, libbinder_ndk users
267223
* read/write transaction headers implicitly (in the SDK, this must be manually written by

libs/binder/ndk/libbinder_ndk.map.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,6 @@ LIBBINDER_NDK35 { # introduced=VanillaIceCream
250250

251251
LIBBINDER_NDK36 { # introduced=36
252252
global:
253-
AIBinder_Class_setTransactionCodeToFunctionNameMap;
254-
AIBinder_Class_setTransactionCodeToFunctionNameMap; # llndk=202504
255-
AIBinder_Class_getFunctionName;
256-
AIBinder_Class_getFunctionName; # llndk=202504
257253
ABinderRpc_registerAccessorProvider; # systemapi
258254
ABinderRpc_unregisterAccessorProvider; # systemapi
259255
ABinderRpc_Accessor_new; # systemapi

0 commit comments

Comments
 (0)