Debian Codegraph @

libartpalette/system/palette_fake.cc

raw symbols SCIP
1 /*
2 * Copyright (C) 2019 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 "palette/palette.h"
18
19 #include <map>
20 #include <mutex>
21 #include <stdbool.h>
22
23 #include <android-base/logging.h>
24 #include <android-base/macros.h> // For ATTRIBUTE_UNUSED
25
26 #include "palette_system.h"
27
28 // Methods in version 1 API, corresponding to SDK level 31.
29
30 // Cached thread priority for testing. No thread priorities are ever affected.
31 static std::mutex g_tid_priority_map_mutex;
32 static std::map<int32_t, int32_t> g_tid_priority_map;
33
34 palette_status_t PaletteSchedSetPriority(int32_t tid, int32_t priority) {
35 if (priority < art::palette::kMinManagedThreadPriority ||
36 priority > art::palette::kMaxManagedThreadPriority) {
37 return PALETTE_STATUS_INVALID_ARGUMENT;
38 }
39 std::lock_guard guard(g_tid_priority_map_mutex);
40 g_tid_priority_map[tid] = priority;
41 return PALETTE_STATUS_OK;
42 }
43
44 palette_status_t PaletteSchedGetPriority(int32_t tid,
45 /*out*/int32_t* priority) {
46 std::lock_guard guard(g_tid_priority_map_mutex);
47 if (g_tid_priority_map.find(tid) == g_tid_priority_map.end()) {
48 g_tid_priority_map[tid] = art::palette::kNormalManagedThreadPriority;
49 }
50 *priority = g_tid_priority_map[tid];
51 return PALETTE_STATUS_OK;
52 }
53
54 palette_status_t PaletteWriteCrashThreadStacks(/*in*/ const char* stacks, size_t stacks_len) {
55 LOG(INFO) << std::string_view(stacks, stacks_len);
56 return PALETTE_STATUS_OK;
57 }
58
59 palette_status_t PaletteTraceEnabled(/*out*/bool* enabled) {
60 *enabled = false;
61 return PALETTE_STATUS_OK;
62 }
63
64 palette_status_t PaletteTraceBegin(const char* name ATTRIBUTE_UNUSED) {
65 return PALETTE_STATUS_OK;
66 }
67
68 palette_status_t PaletteTraceEnd() {
69 return PALETTE_STATUS_OK;
70 }
71
72 palette_status_t PaletteTraceIntegerValue(const char* name ATTRIBUTE_UNUSED,
73 int32_t value ATTRIBUTE_UNUSED) {
74 return PALETTE_STATUS_OK;
75 }
76
77 palette_status_t PaletteAshmemCreateRegion(const char* name ATTRIBUTE_UNUSED,
78 size_t size ATTRIBUTE_UNUSED,
79 int* fd) {
80 *fd = -1;
81 return PALETTE_STATUS_NOT_SUPPORTED;
82 }
83
84 palette_status_t PaletteAshmemSetProtRegion(int fd ATTRIBUTE_UNUSED,
85 int prot ATTRIBUTE_UNUSED) {
86 return PALETTE_STATUS_NOT_SUPPORTED;
87 }
88
89 palette_status_t PaletteCreateOdrefreshStagingDirectory(const char** staging_dir) {
90 *staging_dir = nullptr;
91 return PALETTE_STATUS_NOT_SUPPORTED;
92 }
93
94 palette_status_t PaletteShouldReportDex2oatCompilation(bool* value) {
95 *value = false;
96 return PALETTE_STATUS_OK;
97 }
98
99 palette_status_t PaletteNotifyStartDex2oatCompilation(int source_fd ATTRIBUTE_UNUSED,
100 int art_fd ATTRIBUTE_UNUSED,
101 int oat_fd ATTRIBUTE_UNUSED,
102 int vdex_fd ATTRIBUTE_UNUSED) {
103 return PALETTE_STATUS_OK;
104 }
105
106 palette_status_t PaletteNotifyEndDex2oatCompilation(int source_fd ATTRIBUTE_UNUSED,
107 int art_fd ATTRIBUTE_UNUSED,
108 int oat_fd ATTRIBUTE_UNUSED,
109 int vdex_fd ATTRIBUTE_UNUSED) {
110 return PALETTE_STATUS_OK;
111 }
112
113 palette_status_t PaletteNotifyDexFileLoaded(const char* path ATTRIBUTE_UNUSED) {
114 return PALETTE_STATUS_OK;
115 }
116
117 palette_status_t PaletteNotifyOatFileLoaded(const char* path ATTRIBUTE_UNUSED) {
118 return PALETTE_STATUS_OK;
119 }
120
121 palette_status_t PaletteShouldReportJniInvocations(bool* value) {
122 *value = false;
123 return PALETTE_STATUS_OK;
124 }
125
126 palette_status_t PaletteNotifyBeginJniInvocation(JNIEnv* env ATTRIBUTE_UNUSED) {
127 return PALETTE_STATUS_OK;
128 }
129
130 palette_status_t PaletteNotifyEndJniInvocation(JNIEnv* env ATTRIBUTE_UNUSED) {
131 return PALETTE_STATUS_OK;
132 }
133
134 // Methods in version 2 API, corresponding to SDK level 33.
135
136 palette_status_t PaletteReportLockContention(JNIEnv* env ATTRIBUTE_UNUSED,
137 int32_t wait_ms ATTRIBUTE_UNUSED,
138 const char* filename ATTRIBUTE_UNUSED,
139 int32_t line_number ATTRIBUTE_UNUSED,
140 const char* method_name ATTRIBUTE_UNUSED,
141 const char* owner_filename ATTRIBUTE_UNUSED,
142 int32_t owner_line_number ATTRIBUTE_UNUSED,
143 const char* owner_method_name ATTRIBUTE_UNUSED,
144 const char* proc_name ATTRIBUTE_UNUSED,
145 const char* thread_name ATTRIBUTE_UNUSED) {
146 return PALETTE_STATUS_OK;
147 }
148
149 // Methods in version 3 API, corresponding to SDK level 34.
150
151 palette_status_t PaletteSetTaskProfiles(int32_t tid ATTRIBUTE_UNUSED,
152 const char* const profiles[] ATTRIBUTE_UNUSED,
153 size_t profiles_len ATTRIBUTE_UNUSED) {
154 return PALETTE_STATUS_OK;
155 }