xref: /aosp_15_r20/frameworks/native/libs/binder/OS_android.cpp (revision 38e8c45f13ce32b0dcecb25141ffecaf386fa17f)
1 /*
2  * Copyright (C) 2023 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 "OS.h"
18 
19 #include <android-base/threads.h>
20 #include <cutils/trace.h>
21 #include <utils/misc.h>
22 
23 namespace android::binder {
24 namespace os {
25 
GetThreadId()26 uint64_t GetThreadId() {
27 #ifdef BINDER_RPC_SINGLE_THREADED
28     return 0;
29 #else
30     return base::GetThreadId();
31 #endif
32 }
33 
report_sysprop_change()34 bool report_sysprop_change() {
35     android::report_sysprop_change();
36     return true;
37 }
38 
trace_begin(uint64_t tag,const char * name)39 void trace_begin(uint64_t tag, const char* name) {
40     atrace_begin(tag, name);
41 }
42 
trace_end(uint64_t tag)43 void trace_end(uint64_t tag) {
44     atrace_end(tag);
45 }
46 
trace_int(uint64_t tag,const char * name,int32_t value)47 void trace_int(uint64_t tag, const char* name, int32_t value) {
48     atrace_int(tag, name, value);
49 }
50 
get_trace_enabled_tags()51 uint64_t get_trace_enabled_tags() {
52     return atrace_enabled_tags;
53 }
54 
55 } // namespace os
56 
57 // Legacy trace symbol. To be removed once all of downstream rebuilds.
atrace_begin(uint64_t tag,const char * name)58 void atrace_begin(uint64_t tag, const char* name) {
59     os::trace_begin(tag, name);
60 }
61 
62 // Legacy trace symbol. To be removed once all of downstream rebuilds.
atrace_end(uint64_t tag)63 void atrace_end(uint64_t tag) {
64     os::trace_end(tag);
65 }
66 
67 } // namespace android::binder
68