-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy path99_patch_core
328 lines (298 loc) · 11.3 KB
/
99_patch_core
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
diff --git a/adb/adb_utils.cpp b/adb/adb_utils.cpp
index b236fb3..6f86583 100644
--- a/adb/adb_utils.cpp
+++ b/adb/adb_utils.cpp
@@ -242,6 +242,15 @@ std::string adb_get_homedir_path() {
}
return home_str;
#else
+#if defined(ADB_HOST)
+ if (const char* const home = getenv("HOMEDIR")) {
+ return home;
+ }
+
+ if (const char* const data = getenv("ANDROID_DATA")) {
+ return data;
+ }
+#endif /* ADB_HOST */
if (const char* const home = getenv("HOME")) {
return home;
}
@@ -308,8 +317,13 @@ std::string GetLogFilePath() {
return temp_path_utf8 + log_name;
#else
+#if defined(ADB_HOST)
+ const char* tmp_dir = getenv("HOMEDIR");
+ if (tmp_dir == nullptr) tmp_dir = "/data/local/tmp";
+#else
const char* tmp_dir = getenv("TMPDIR");
if (tmp_dir == nullptr) tmp_dir = "/tmp";
+#endif
return android::base::StringPrintf("%s/adb.%u.log", tmp_dir, getuid());
#endif
}
diff --git a/adb/client/usb_linux.cpp b/adb/client/usb_linux.cpp
index a7df0ed..1d8bd50 100644
--- a/adb/client/usb_linux.cpp
+++ b/adb/client/usb_linux.cpp
@@ -18,6 +18,7 @@
#include "sysdeps.h"
+#include <sys/sysmacros.h>
#include <ctype.h>
#include <dirent.h>
#include <errno.h>
diff --git a/adb/diagnose_usb.cpp b/adb/diagnose_usb.cpp
index 9f721bf..90b9f29 100644
--- a/adb/diagnose_usb.cpp
+++ b/adb/diagnose_usb.cpp
@@ -33,7 +33,7 @@ static const char kPermissionsHelpUrl[] = "http://developer.android.com/tools/de
// Returns a message describing any potential problems we find with udev, or an empty string if we
// can't find plugdev information (i.e. udev is not installed).
static std::string GetUdevProblem() {
-#if defined(__linux__)
+#if defined(__linux__) && !defined(ADB_HOST)
errno = 0;
group* plugdev_group = getgrnam("plugdev");
diff --git a/adb/sockets.cpp b/adb/sockets.cpp
index c53fbb4..807b7aa 100644
--- a/adb/sockets.cpp
+++ b/adb/sockets.cpp
@@ -610,7 +610,7 @@ char* skip_host_serial(char* service) {
for (const std::string& prefix : prefixes) {
if (!strncmp(service, prefix.c_str(), prefix.length())) {
- return strchr(service + prefix.length(), ':');
+ return strchr((char *)(service + prefix.length()), ':');
}
}
diff --git a/base/logging.cpp b/base/logging.cpp
index 6357b4b..5c859a2 100644
--- a/base/logging.cpp
+++ b/base/logging.cpp
@@ -46,7 +46,11 @@
// Headers for LogMessage::LogLine.
#ifdef __ANDROID__
#include <log/log.h>
+#if defined(ANDROID_HOST_BUILD)
+extern "C" void android_set_abort_message(const char *msg);
+#else
#include <android/set_abort_message.h>
+#endif
#else
#include <sys/types.h>
#include <unistd.h>
@@ -124,7 +128,7 @@ static std::mutex& LoggingLock() {
}
static LogFunction& Logger() {
-#ifdef __ANDROID__
+#if defined(__ANDROID__) && !defined(ANDROID_HOST_BUILD)
static auto& logger = *new LogFunction(LogdLogger());
#else
static auto& logger = *new LogFunction(StderrLogger);
@@ -217,7 +221,7 @@ void DefaultAborter(const char* abort_message) {
}
-#ifdef __ANDROID__
+#if defined(__ANDROID__) && !defined(ANDROID_HOST_BUILD)
LogdLogger::LogdLogger(LogId default_log_id) : default_log_id_(default_log_id) {
}
diff --git a/fastboot/protocol.cpp b/fastboot/protocol.cpp
index dcdf8f0..37aab61 100644
--- a/fastboot/protocol.cpp
+++ b/fastboot/protocol.cpp
@@ -27,7 +27,7 @@
*/
#define round_down(a, b) \
- ({ typeof(a) _a = (a); typeof(b) _b = (b); _a - (_a % _b); })
+ ({ __typeof__(a) _a = (a); __typeof__(b) _b = (b); _a - (_a % _b); })
#include <fcntl.h>
#include <stdio.h>
diff --git a/fastboot/socket.h b/fastboot/socket.h
index 7eaa0ab..080f549 100644
--- a/fastboot/socket.h
+++ b/fastboot/socket.h
@@ -41,7 +41,6 @@
#include <android-base/macros.h>
#include <cutils/sockets.h>
-#include <gtest/gtest_prod.h>
// Socket interface to be implemented for each platform.
class Socket {
@@ -120,9 +119,6 @@ class Socket {
socket_send_buffers_function_ = &socket_send_buffers;
private:
- FRIEND_TEST(SocketTest, TestTcpSendBuffers);
- FRIEND_TEST(SocketTest, TestUdpSendBuffers);
-
DISALLOW_COPY_AND_ASSIGN(Socket);
};
diff --git a/libcutils/canned_fs_config.c b/libcutils/canned_fs_config.c
index 819a846..993e2be 100644
--- a/libcutils/canned_fs_config.c
+++ b/libcutils/canned_fs_config.c
@@ -114,7 +114,11 @@ void canned_fs_config(const char* path, int dir, const char* target_out_path,
unsigned c_uid, c_gid, c_mode;
uint64_t c_capabilities;
+#if defined(ANDROID_HOST_BUILD)
+ printf("%d %s\n", dir, target_out_path);
+#else
fs_config(path, dir, target_out_path, &c_uid, &c_gid, &c_mode, &c_capabilities);
+#endif /* ANDROID_HOST_BUILD */
if (c_uid != *uid) printf("%s uid %d %d\n", path, *uid, c_uid);
if (c_gid != *gid) printf("%s gid %d %d\n", path, *gid, c_gid);
diff --git a/libcutils/properties.cpp b/libcutils/properties.cpp
index d2645e6..b94949d 100644
--- a/libcutils/properties.cpp
+++ b/libcutils/properties.cpp
@@ -129,6 +129,7 @@ struct callback_data {
void* cookie;
};
+#if __ANDROID_API__ >= 26
static void trampoline(void* raw_data, const char* name, const char* value, unsigned /*serial*/) {
callback_data* data = reinterpret_cast<callback_data*>(raw_data);
data->callback(name, value, data->cookie);
@@ -137,6 +138,16 @@ static void trampoline(void* raw_data, const char* name, const char* value, unsi
static void property_list_callback(const prop_info* pi, void* data) {
__system_property_read_callback(pi, trampoline, data);
}
+#else
+static void property_list_callback(const prop_info* pi, void* data) {
+ char name[PROP_NAME_MAX];
+ char value[PROP_VALUE_MAX];
+ callback_data *cb_data = reinterpret_cast<callback_data*>(data);
+
+ __system_property_read(pi, name, value);
+ cb_data->callback(name, value, cb_data->cookie);
+}
+#endif
int property_list(void (*fn)(const char* name, const char* value, void* cookie), void* cookie) {
callback_data data = { fn, cookie };
diff --git a/liblog/event_tag_map.cpp b/liblog/event_tag_map.cpp
index 83064fd..79340cb 100644
--- a/liblog/event_tag_map.cpp
+++ b/liblog/event_tag_map.cpp
@@ -578,6 +578,11 @@ LIBLOG_ABI_PUBLIC const char* android_lookupEventTag(const EventTagMap* map,
return tagStr;
}
+#if defined(ANDROID_HOST_BUILD)
+int __android_log_is_loggable_len(int prio, const char* tag, size_t len,
+ int default_prio);
+#endif /* ANDROID_HOST_BUILD */
+
// Look up tagname, generate one if necessary, and return a tag
LIBLOG_ABI_PUBLIC int android_lookupEventTagNum(EventTagMap* map,
const char* tagname,
diff --git a/liblog/include/log/log_event_list.h b/liblog/include/log/log_event_list.h
index bb1ce34..dfd4599 100644
--- a/liblog/include/log/log_event_list.h
+++ b/liblog/include/log/log_event_list.h
@@ -42,6 +42,11 @@ extern "C" {
#endif
#endif
+#ifdef ANDROID_HOST_BUILD
+#undef __ANDROID_USE_LIBLOG_EVENT_INTERFACE
+#define __ANDROID_USE_LIBLOG_EVENT_INTERFACE 1
+#endif /* ANDROID_HOST_BUILD */
+
#if __ANDROID_USE_LIBLOG_EVENT_INTERFACE
/* For manipulating lists of events. */
diff --git a/liblog/include/log/log_properties.h b/liblog/include/log/log_properties.h
index 7d398a6..0554834 100644
--- a/liblog/include/log/log_properties.h
+++ b/liblog/include/log/log_properties.h
@@ -24,6 +24,11 @@ extern "C" {
#endif
#endif
+#ifdef ANDROID_HOST_BUILD
+#undef __ANDROID_USE_LIBLOG_IS_DEBUGGABLE_INTERFACE
+#define __ANDROID_USE_LIBLOG_IS_DEBUGGABLE_INTERFACE 1
+#endif /* ANDROID_HOST_BUILD */
+
#if __ANDROID_USE_LIBLOG_IS_DEBUGGABLE_INTERFACE
int __android_log_is_debuggable();
#endif
diff --git a/liblog/include/log/log_read.h b/liblog/include/log/log_read.h
index d118563..c3f5d2e 100644
--- a/liblog/include/log/log_read.h
+++ b/liblog/include/log/log_read.h
@@ -251,6 +251,10 @@ int android_logger_set_prune_list(struct logger_list* logger_list, char* buf,
#define ANDROID_LOG_PSTORE 0x80000000
#endif
+#ifdef ANDROID_HOST_BUILD
+#define ANDROID_LOG_PSTORE 0x80000000
+#endif /* ANDROID_HOST_BUILD */
+
struct logger_list* android_logger_list_alloc(int mode, unsigned int tail,
pid_t pid);
struct logger_list* android_logger_list_alloc_time(int mode, log_time start,
diff --git a/liblog/logger_write.c b/liblog/logger_write.c
index 84feb20..a6e8349 100644
--- a/liblog/logger_write.c
+++ b/liblog/logger_write.c
@@ -21,8 +21,12 @@
#include <sys/time.h>
#ifdef __BIONIC__
+#if defined(FAKE_LOG_DEVICE)
+extern void android_set_abort_message(const char *msg);
+#else
#include <android/set_abort_message.h>
#endif
+#endif
#include <log/event_tag_map.h>
#include <log/log_transport.h>
@@ -254,7 +258,7 @@ static int __write_to_log_daemon(log_id_t log_id, struct iovec* vec, size_t nr)
return -EINVAL;
}
-#if defined(__ANDROID__)
+#if defined(__ANDROID__) && !defined(ANDROID_HOST_BUILD)
clock_gettime(android_log_clockid(), &ts);
if (log_id == LOG_ID_SECURITY) {
diff --git a/liblog/logprint.c b/liblog/logprint.c
index b62f8b4..8895af7 100644
--- a/liblog/logprint.c
+++ b/liblog/logprint.c
@@ -218,7 +218,7 @@ LIBLOG_ABI_PUBLIC AndroidLogFormat* android_log_format_new() {
p_ret->year_output = false;
p_ret->zone_output = false;
p_ret->epoch_output = false;
-#ifdef __ANDROID__
+#if defined(__ANDROID__) && !defined(ANDROID_HOST_BUILD)
p_ret->monotonic_output = android_log_clockid() == CLOCK_MONOTONIC;
#else
p_ret->monotonic_output = false;
@@ -1583,7 +1583,7 @@ LIBLOG_ABI_PUBLIC char* android_log_formatLogLine(AndroidLogFormat* p_format,
*/
now = entry->tv_sec;
nsec = entry->tv_nsec;
-#if __ANDROID__
+#if defined(__ANDROID__) && !defined(ANDROID_HOST_BUILD)
if (p_format->monotonic_output) {
/* prevent convertMonotonic from being called if logd is monotonic */
if (android_log_clockid() != CLOCK_MONOTONIC) {
diff --git a/libziparchive/zip_archive.cc b/libziparchive/zip_archive.cc
index 4559b32..64fad0f 100644
--- a/libziparchive/zip_archive.cc
+++ b/libziparchive/zip_archive.cc
@@ -210,7 +210,7 @@ static int32_t MapCentralDirectory0(const char* debug_file_name, ZipArchive* arc
if (static_cast<off64_t>(eocd->cd_start_offset) + eocd->cd_size > eocd_offset) {
ALOGW("Zip: bad offsets (dir %" PRIu32 ", size %" PRIu32 ", eocd %" PRId64 ")",
eocd->cd_start_offset, eocd->cd_size, static_cast<int64_t>(eocd_offset));
-#if defined(__ANDROID__)
+#if defined(__ANDROID__) && !defined(ANDROID_HOST_BUILD)
if (eocd->cd_start_offset + eocd->cd_size <= eocd_offset) {
android_errorWriteLog(0x534e4554, "31251826");
}
@@ -327,7 +327,7 @@ static int32_t ParseZipArchive(ZipArchive* archive) {
for (uint16_t i = 0; i < num_entries; i++) {
if (ptr > cd_end - sizeof(CentralDirectoryRecord)) {
ALOGW("Zip: ran off the end (at %" PRIu16 ")", i);
-#if defined(__ANDROID__)
+#if defined(__ANDROID__) && !defined(ANDROID_HOST_BUILD)
android_errorWriteLog(0x534e4554, "36392138");
#endif
return -1;
@@ -389,7 +389,7 @@ static int32_t ParseZipArchive(ZipArchive* archive) {
if (lfh_start_bytes != LocalFileHeader::kSignature) {
ALOGW("Zip: Entry at offset zero has invalid LFH signature %" PRIx32, lfh_start_bytes);
-#if defined(__ANDROID__)
+#if defined(__ANDROID__) && !defined(ANDROID_HOST_BUILD)
android_errorWriteLog(0x534e4554, "64211847");
#endif
return -1;