Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
29b47ad5ac |
@@ -20,7 +20,6 @@ src = [
|
|||||||
'src/stream.c',
|
'src/stream.c',
|
||||||
'src/tiny_xpm.c',
|
'src/tiny_xpm.c',
|
||||||
'src/video_buffer.c',
|
'src/video_buffer.c',
|
||||||
'src/util/log.c',
|
|
||||||
'src/util/net.c',
|
'src/util/net.c',
|
||||||
'src/util/process.c',
|
'src/util/process.c',
|
||||||
'src/util/str_util.c',
|
'src/util/str_util.c',
|
||||||
|
|||||||
+1
-1
@@ -193,7 +193,7 @@ It requires to lock the video orientation (see --lock-video-orientation).
|
|||||||
|
|
||||||
.TP
|
.TP
|
||||||
.BI "\-V, \-\-verbosity " value
|
.BI "\-V, \-\-verbosity " value
|
||||||
Set the log level ("verbose", "debug", "info", "warn" or "error").
|
Set the log level ("debug", "info", "warn" or "error").
|
||||||
|
|
||||||
Default is "info" for release builds, "debug" for debug builds.
|
Default is "info" for release builds, "debug" for debug builds.
|
||||||
|
|
||||||
|
|||||||
+1
-6
@@ -184,7 +184,7 @@ scrcpy_print_usage(const char *arg0) {
|
|||||||
"\n"
|
"\n"
|
||||||
#endif
|
#endif
|
||||||
" -V, --verbosity value\n"
|
" -V, --verbosity value\n"
|
||||||
" Set the log level (verbose, debug, info, warn or error).\n"
|
" Set the log level (debug, info, warn or error).\n"
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
" Default is debug.\n"
|
" Default is debug.\n"
|
||||||
#else
|
#else
|
||||||
@@ -505,11 +505,6 @@ parse_display_id(const char *s, uint32_t *display_id) {
|
|||||||
|
|
||||||
static bool
|
static bool
|
||||||
parse_log_level(const char *s, enum sc_log_level *log_level) {
|
parse_log_level(const char *s, enum sc_log_level *log_level) {
|
||||||
if (!strcmp(s, "verbose")) {
|
|
||||||
*log_level = SC_LOG_LEVEL_VERBOSE;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!strcmp(s, "debug")) {
|
if (!strcmp(s, "debug")) {
|
||||||
*log_level = SC_LOG_LEVEL_DEBUG;
|
*log_level = SC_LOG_LEVEL_DEBUG;
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#include "control_msg.h"
|
#include "control_msg.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <inttypes.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@@ -9,52 +8,6 @@
|
|||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
#include "util/str_util.h"
|
#include "util/str_util.h"
|
||||||
|
|
||||||
/**
|
|
||||||
* Map an enum value to a string based on an array, without crashing on an
|
|
||||||
* out-of-bounds index.
|
|
||||||
*/
|
|
||||||
#define ENUM_TO_LABEL(labels, value) \
|
|
||||||
((size_t) (value) < ARRAY_LEN(labels) ? labels[value] : "???")
|
|
||||||
|
|
||||||
#define KEYEVENT_ACTION_LABEL(value) \
|
|
||||||
ENUM_TO_LABEL(android_keyevent_action_labels, value)
|
|
||||||
|
|
||||||
#define MOTIONEVENT_ACTION_LABEL(value) \
|
|
||||||
ENUM_TO_LABEL(android_motionevent_action_labels, value)
|
|
||||||
|
|
||||||
#define SCREEN_POWER_MODE_LABEL(value) \
|
|
||||||
ENUM_TO_LABEL(screen_power_mode_labels, value)
|
|
||||||
|
|
||||||
static const char *const android_keyevent_action_labels[] = {
|
|
||||||
"down",
|
|
||||||
"up",
|
|
||||||
"multi",
|
|
||||||
};
|
|
||||||
|
|
||||||
static const char *const android_motionevent_action_labels[] = {
|
|
||||||
"down",
|
|
||||||
"up",
|
|
||||||
"move",
|
|
||||||
"cancel",
|
|
||||||
"outside",
|
|
||||||
"ponter-down",
|
|
||||||
"pointer-up",
|
|
||||||
"hover-move",
|
|
||||||
"scroll",
|
|
||||||
"hover-enter"
|
|
||||||
"hover-exit",
|
|
||||||
"btn-press",
|
|
||||||
"btn-release",
|
|
||||||
};
|
|
||||||
|
|
||||||
static const char *const screen_power_mode_labels[] = {
|
|
||||||
"off",
|
|
||||||
"doze",
|
|
||||||
"normal",
|
|
||||||
"doze-suspend",
|
|
||||||
"suspend",
|
|
||||||
};
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
write_position(uint8_t *buf, const struct position *position) {
|
write_position(uint8_t *buf, const struct position *position) {
|
||||||
buffer_write32be(&buf[0], position->point.x);
|
buffer_write32be(&buf[0], position->point.x);
|
||||||
@@ -140,94 +93,6 @@ control_msg_serialize(const struct control_msg *msg, unsigned char *buf) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
control_msg_log(const struct control_msg *msg) {
|
|
||||||
#define LOG_CMSG(fmt, ...) LOGV("input: " fmt, ## __VA_ARGS__)
|
|
||||||
switch (msg->type) {
|
|
||||||
case CONTROL_MSG_TYPE_INJECT_KEYCODE:
|
|
||||||
LOG_CMSG("key %-4s code=%d repeat=%" PRIu32 " meta=%06lx",
|
|
||||||
KEYEVENT_ACTION_LABEL(msg->inject_keycode.action),
|
|
||||||
(int) msg->inject_keycode.keycode,
|
|
||||||
msg->inject_keycode.repeat,
|
|
||||||
(long) msg->inject_keycode.metastate);
|
|
||||||
break;
|
|
||||||
case CONTROL_MSG_TYPE_INJECT_TEXT:
|
|
||||||
LOG_CMSG("text \"%s\"", msg->inject_text.text);
|
|
||||||
break;
|
|
||||||
case CONTROL_MSG_TYPE_INJECT_TOUCH_EVENT: {
|
|
||||||
int action = msg->inject_touch_event.action
|
|
||||||
& AMOTION_EVENT_ACTION_MASK;
|
|
||||||
uint64_t id = msg->inject_touch_event.pointer_id;
|
|
||||||
if (id == POINTER_ID_MOUSE || id == POINTER_ID_VIRTUAL_FINGER) {
|
|
||||||
// string pointer id
|
|
||||||
LOG_CMSG("touch [id=%s] %-4s position=%" PRIi32 ",%" PRIi32
|
|
||||||
" pressure=%g buttons=%06lx",
|
|
||||||
id == POINTER_ID_MOUSE ? "mouse" : "vfinger",
|
|
||||||
MOTIONEVENT_ACTION_LABEL(action),
|
|
||||||
msg->inject_touch_event.position.point.x,
|
|
||||||
msg->inject_touch_event.position.point.y,
|
|
||||||
msg->inject_touch_event.pressure,
|
|
||||||
(long) msg->inject_touch_event.buttons);
|
|
||||||
} else {
|
|
||||||
// numeric pointer id
|
|
||||||
#ifndef __WIN32
|
|
||||||
# define PRIu64_ PRIu64
|
|
||||||
#else
|
|
||||||
# define PRIu64_ "I64u" // Windows...
|
|
||||||
#endif
|
|
||||||
LOG_CMSG("touch [id=%" PRIu64_ "] %-4s position=%" PRIi32 ",%"
|
|
||||||
PRIi32 " pressure=%g buttons=%06lx",
|
|
||||||
id,
|
|
||||||
MOTIONEVENT_ACTION_LABEL(action),
|
|
||||||
msg->inject_touch_event.position.point.x,
|
|
||||||
msg->inject_touch_event.position.point.y,
|
|
||||||
msg->inject_touch_event.pressure,
|
|
||||||
(long) msg->inject_touch_event.buttons);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CONTROL_MSG_TYPE_INJECT_SCROLL_EVENT:
|
|
||||||
LOG_CMSG("scroll position=%" PRIi32 ",%" PRIi32 " hscroll=%" PRIi32
|
|
||||||
" vscroll=%" PRIi32,
|
|
||||||
msg->inject_scroll_event.position.point.x,
|
|
||||||
msg->inject_scroll_event.position.point.y,
|
|
||||||
msg->inject_scroll_event.hscroll,
|
|
||||||
msg->inject_scroll_event.vscroll);
|
|
||||||
break;
|
|
||||||
case CONTROL_MSG_TYPE_BACK_OR_SCREEN_ON:
|
|
||||||
LOG_CMSG("back-or-screen-on %s",
|
|
||||||
KEYEVENT_ACTION_LABEL(msg->inject_keycode.action));
|
|
||||||
break;
|
|
||||||
case CONTROL_MSG_TYPE_SET_CLIPBOARD:
|
|
||||||
LOG_CMSG("clipboard %s \"%s\"",
|
|
||||||
msg->set_clipboard.paste ? "paste" : "copy",
|
|
||||||
msg->set_clipboard.text);
|
|
||||||
break;
|
|
||||||
case CONTROL_MSG_TYPE_SET_SCREEN_POWER_MODE:
|
|
||||||
LOG_CMSG("power mode %s",
|
|
||||||
SCREEN_POWER_MODE_LABEL(msg->set_screen_power_mode.mode));
|
|
||||||
break;
|
|
||||||
case CONTROL_MSG_TYPE_EXPAND_NOTIFICATION_PANEL:
|
|
||||||
LOG_CMSG("expand notification panel");
|
|
||||||
break;
|
|
||||||
case CONTROL_MSG_TYPE_EXPAND_SETTINGS_PANEL:
|
|
||||||
LOG_CMSG("expand settings panel");
|
|
||||||
break;
|
|
||||||
case CONTROL_MSG_TYPE_COLLAPSE_PANELS:
|
|
||||||
LOG_CMSG("collapse panels");
|
|
||||||
break;
|
|
||||||
case CONTROL_MSG_TYPE_GET_CLIPBOARD:
|
|
||||||
LOG_CMSG("get clipboard");
|
|
||||||
break;
|
|
||||||
case CONTROL_MSG_TYPE_ROTATE_DEVICE:
|
|
||||||
LOG_CMSG("rotate device");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
LOG_CMSG("unknown type: %u", (unsigned) msg->type);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
control_msg_destroy(struct control_msg *msg) {
|
control_msg_destroy(struct control_msg *msg) {
|
||||||
switch (msg->type) {
|
switch (msg->type) {
|
||||||
|
|||||||
@@ -17,8 +17,8 @@
|
|||||||
// type: 1 byte; paste flag: 1 byte; length: 4 bytes
|
// type: 1 byte; paste flag: 1 byte; length: 4 bytes
|
||||||
#define CONTROL_MSG_CLIPBOARD_TEXT_MAX_LENGTH (CONTROL_MSG_MAX_SIZE - 6)
|
#define CONTROL_MSG_CLIPBOARD_TEXT_MAX_LENGTH (CONTROL_MSG_MAX_SIZE - 6)
|
||||||
|
|
||||||
#define POINTER_ID_MOUSE UINT64_C(-1)
|
#define POINTER_ID_MOUSE UINT64_C(-1);
|
||||||
#define POINTER_ID_VIRTUAL_FINGER UINT64_C(-2)
|
#define POINTER_ID_VIRTUAL_FINGER UINT64_C(-2);
|
||||||
|
|
||||||
enum control_msg_type {
|
enum control_msg_type {
|
||||||
CONTROL_MSG_TYPE_INJECT_KEYCODE,
|
CONTROL_MSG_TYPE_INJECT_KEYCODE,
|
||||||
@@ -84,9 +84,6 @@ struct control_msg {
|
|||||||
size_t
|
size_t
|
||||||
control_msg_serialize(const struct control_msg *msg, unsigned char *buf);
|
control_msg_serialize(const struct control_msg *msg, unsigned char *buf);
|
||||||
|
|
||||||
void
|
|
||||||
control_msg_log(const struct control_msg *msg);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
control_msg_destroy(struct control_msg *msg);
|
control_msg_destroy(struct control_msg *msg);
|
||||||
|
|
||||||
|
|||||||
@@ -48,10 +48,6 @@ controller_destroy(struct controller *controller) {
|
|||||||
bool
|
bool
|
||||||
controller_push_msg(struct controller *controller,
|
controller_push_msg(struct controller *controller,
|
||||||
const struct control_msg *msg) {
|
const struct control_msg *msg) {
|
||||||
if (sc_get_log_level() <= SC_LOG_LEVEL_VERBOSE) {
|
|
||||||
control_msg_log(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
sc_mutex_lock(&controller->mutex);
|
sc_mutex_lock(&controller->mutex);
|
||||||
bool was_empty = cbuf_is_empty(&controller->queue);
|
bool was_empty = cbuf_is_empty(&controller->queue);
|
||||||
bool res = cbuf_push(&controller->queue, *msg);
|
bool res = cbuf_push(&controller->queue, *msg);
|
||||||
|
|||||||
@@ -595,12 +595,8 @@ convert_mouse_motion(const SDL_MouseMotionEvent *from, struct screen *screen,
|
|||||||
static void
|
static void
|
||||||
input_manager_process_mouse_motion(struct input_manager *im,
|
input_manager_process_mouse_motion(struct input_manager *im,
|
||||||
const SDL_MouseMotionEvent *event) {
|
const SDL_MouseMotionEvent *event) {
|
||||||
uint32_t mask = SDL_BUTTON_LMASK;
|
if (!event->state) {
|
||||||
if (im->forward_all_clicks) {
|
// do not send motion events when no button is pressed
|
||||||
mask |= SDL_BUTTON_MMASK | SDL_BUTTON_RMASK;
|
|
||||||
}
|
|
||||||
if (!(event->state & mask)) {
|
|
||||||
// do not send motion events when no click is pressed
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (event->which == SDL_TOUCH_MOUSEID) {
|
if (event->which == SDL_TOUCH_MOUSEID) {
|
||||||
|
|||||||
+20
-1
@@ -38,6 +38,24 @@ print_version(void) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static SDL_LogPriority
|
||||||
|
convert_log_level_to_sdl(enum sc_log_level level) {
|
||||||
|
switch (level) {
|
||||||
|
case SC_LOG_LEVEL_DEBUG:
|
||||||
|
return SDL_LOG_PRIORITY_DEBUG;
|
||||||
|
case SC_LOG_LEVEL_INFO:
|
||||||
|
return SDL_LOG_PRIORITY_INFO;
|
||||||
|
case SC_LOG_LEVEL_WARN:
|
||||||
|
return SDL_LOG_PRIORITY_WARN;
|
||||||
|
case SC_LOG_LEVEL_ERROR:
|
||||||
|
return SDL_LOG_PRIORITY_ERROR;
|
||||||
|
default:
|
||||||
|
assert(!"unexpected log level");
|
||||||
|
return SDL_LOG_PRIORITY_INFO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[]) {
|
main(int argc, char *argv[]) {
|
||||||
#ifdef __WINDOWS__
|
#ifdef __WINDOWS__
|
||||||
@@ -61,7 +79,8 @@ main(int argc, char *argv[]) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
sc_set_log_level(args.opts.log_level);
|
SDL_LogPriority sdl_log = convert_log_level_to_sdl(args.opts.log_level);
|
||||||
|
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, sdl_log);
|
||||||
|
|
||||||
if (args.help) {
|
if (args.help) {
|
||||||
scrcpy_print_usage(argv[0]);
|
scrcpy_print_usage(argv[0]);
|
||||||
|
|||||||
+4
-5
@@ -216,15 +216,14 @@ av_log_callback(void *avcl, int level, const char *fmt, va_list vl) {
|
|||||||
if (priority == 0) {
|
if (priority == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
char *local_fmt = malloc(strlen(fmt) + 10);
|
||||||
size_t fmt_len = strlen(fmt);
|
|
||||||
char *local_fmt = malloc(fmt_len + 10);
|
|
||||||
if (!local_fmt) {
|
if (!local_fmt) {
|
||||||
LOGC("Could not allocate string");
|
LOGC("Could not allocate string");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
memcpy(local_fmt, "[FFmpeg] ", 9); // do not write the final '\0'
|
// strcpy is safe here, the destination is large enough
|
||||||
memcpy(local_fmt + 9, fmt, fmt_len + 1); // include '\0'
|
strcpy(local_fmt, "[FFmpeg] ");
|
||||||
|
strcpy(local_fmt + 9, fmt);
|
||||||
SDL_LogMessageV(SDL_LOG_CATEGORY_VIDEO, priority, local_fmt, vl);
|
SDL_LogMessageV(SDL_LOG_CATEGORY_VIDEO, priority, local_fmt, vl);
|
||||||
free(local_fmt);
|
free(local_fmt);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
enum sc_log_level {
|
enum sc_log_level {
|
||||||
SC_LOG_LEVEL_VERBOSE,
|
|
||||||
SC_LOG_LEVEL_DEBUG,
|
SC_LOG_LEVEL_DEBUG,
|
||||||
SC_LOG_LEVEL_INFO,
|
SC_LOG_LEVEL_INFO,
|
||||||
SC_LOG_LEVEL_WARN,
|
SC_LOG_LEVEL_WARN,
|
||||||
|
|||||||
@@ -235,8 +235,6 @@ enable_tunnel_any_port(struct server *server, struct sc_port_range port_range,
|
|||||||
static const char *
|
static const char *
|
||||||
log_level_to_server_string(enum sc_log_level level) {
|
log_level_to_server_string(enum sc_log_level level) {
|
||||||
switch (level) {
|
switch (level) {
|
||||||
case SC_LOG_LEVEL_VERBOSE:
|
|
||||||
return "verbose";
|
|
||||||
case SC_LOG_LEVEL_DEBUG:
|
case SC_LOG_LEVEL_DEBUG:
|
||||||
return "debug";
|
return "debug";
|
||||||
case SC_LOG_LEVEL_INFO:
|
case SC_LOG_LEVEL_INFO:
|
||||||
|
|||||||
@@ -1,53 +0,0 @@
|
|||||||
#include "log.h"
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
static SDL_LogPriority
|
|
||||||
log_level_sc_to_sdl(enum sc_log_level level) {
|
|
||||||
switch (level) {
|
|
||||||
case SC_LOG_LEVEL_VERBOSE:
|
|
||||||
return SDL_LOG_PRIORITY_VERBOSE;
|
|
||||||
case SC_LOG_LEVEL_DEBUG:
|
|
||||||
return SDL_LOG_PRIORITY_DEBUG;
|
|
||||||
case SC_LOG_LEVEL_INFO:
|
|
||||||
return SDL_LOG_PRIORITY_INFO;
|
|
||||||
case SC_LOG_LEVEL_WARN:
|
|
||||||
return SDL_LOG_PRIORITY_WARN;
|
|
||||||
case SC_LOG_LEVEL_ERROR:
|
|
||||||
return SDL_LOG_PRIORITY_ERROR;
|
|
||||||
default:
|
|
||||||
assert(!"unexpected log level");
|
|
||||||
return SDL_LOG_PRIORITY_INFO;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static enum sc_log_level
|
|
||||||
log_level_sdl_to_sc(SDL_LogPriority priority) {
|
|
||||||
switch (priority) {
|
|
||||||
case SDL_LOG_PRIORITY_VERBOSE:
|
|
||||||
return SC_LOG_LEVEL_VERBOSE;
|
|
||||||
case SDL_LOG_PRIORITY_DEBUG:
|
|
||||||
return SC_LOG_LEVEL_DEBUG;
|
|
||||||
case SDL_LOG_PRIORITY_INFO:
|
|
||||||
return SC_LOG_LEVEL_INFO;
|
|
||||||
case SDL_LOG_PRIORITY_WARN:
|
|
||||||
return SC_LOG_LEVEL_WARN;
|
|
||||||
case SDL_LOG_PRIORITY_ERROR:
|
|
||||||
return SC_LOG_LEVEL_ERROR;
|
|
||||||
default:
|
|
||||||
assert(!"unexpected log level");
|
|
||||||
return SC_LOG_LEVEL_INFO;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
sc_set_log_level(enum sc_log_level level) {
|
|
||||||
SDL_LogPriority sdl_log = log_level_sc_to_sdl(level);
|
|
||||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, sdl_log);
|
|
||||||
}
|
|
||||||
|
|
||||||
enum sc_log_level
|
|
||||||
sc_get_log_level(void) {
|
|
||||||
SDL_LogPriority sdl_log = SDL_LogGetPriority(SDL_LOG_CATEGORY_APPLICATION);
|
|
||||||
return log_level_sdl_to_sc(sdl_log);
|
|
||||||
}
|
|
||||||
+2
-12
@@ -1,12 +1,8 @@
|
|||||||
#ifndef SC_LOG_H
|
#ifndef LOG_H
|
||||||
#define SC_LOG_H
|
#define LOG_H
|
||||||
|
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
#include <SDL2/SDL_log.h>
|
#include <SDL2/SDL_log.h>
|
||||||
|
|
||||||
#include "scrcpy.h"
|
|
||||||
|
|
||||||
#define LOGV(...) SDL_LogVerbose(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__)
|
#define LOGV(...) SDL_LogVerbose(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__)
|
||||||
#define LOGD(...) SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__)
|
#define LOGD(...) SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__)
|
||||||
#define LOGI(...) SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__)
|
#define LOGI(...) SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__)
|
||||||
@@ -14,10 +10,4 @@
|
|||||||
#define LOGE(...) SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__)
|
#define LOGE(...) SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__)
|
||||||
#define LOGC(...) SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__)
|
#define LOGC(...) SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, __VA_ARGS__)
|
||||||
|
|
||||||
void
|
|
||||||
sc_set_log_level(enum sc_log_level level);
|
|
||||||
|
|
||||||
enum sc_log_level
|
|
||||||
sc_get_log_level(void);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ public final class Ln {
|
|||||||
private static final String PREFIX = "[server] ";
|
private static final String PREFIX = "[server] ";
|
||||||
|
|
||||||
enum Level {
|
enum Level {
|
||||||
VERBOSE, DEBUG, INFO, WARN, ERROR
|
DEBUG, INFO, WARN, ERROR
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Level threshold = Level.INFO;
|
private static Level threshold = Level.INFO;
|
||||||
@@ -36,13 +36,6 @@ public final class Ln {
|
|||||||
return level.ordinal() >= threshold.ordinal();
|
return level.ordinal() >= threshold.ordinal();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void v(String message) {
|
|
||||||
if (isEnabled(Level.VERBOSE)) {
|
|
||||||
Log.v(TAG, message);
|
|
||||||
System.out.println(PREFIX + "VERBOSE: " + message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void d(String message) {
|
public static void d(String message) {
|
||||||
if (isEnabled(Level.DEBUG)) {
|
if (isEnabled(Level.DEBUG)) {
|
||||||
Log.d(TAG, message);
|
Log.d(TAG, message);
|
||||||
|
|||||||
@@ -47,13 +47,12 @@ public class ContentProvider implements Closeable {
|
|||||||
this.token = token;
|
this.token = token;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("PrivateApi")
|
|
||||||
private Method getCallMethod() throws NoSuchMethodException {
|
private Method getCallMethod() throws NoSuchMethodException {
|
||||||
if (callMethod == null) {
|
if (callMethod == null) {
|
||||||
try {
|
try {
|
||||||
|
@SuppressLint("PrivateApi")
|
||||||
Class<?> attributionSourceClass = Class.forName("android.content.AttributionSource");
|
Class<?> attributionSourceClass = Class.forName("android.content.AttributionSource");
|
||||||
callMethod = provider.getClass().getMethod("call", attributionSourceClass, String.class, String.class, String.class, Bundle.class);
|
callMethod = provider.getClass().getMethod("call", attributionSourceClass, String.class, String.class, String.class, Bundle.class);
|
||||||
callMethodVersion = 0;
|
|
||||||
} catch (NoSuchMethodException | ClassNotFoundException e0) {
|
} catch (NoSuchMethodException | ClassNotFoundException e0) {
|
||||||
// old versions
|
// old versions
|
||||||
try {
|
try {
|
||||||
@@ -74,7 +73,6 @@ public class ContentProvider implements Closeable {
|
|||||||
return callMethod;
|
return callMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("PrivateApi")
|
|
||||||
private Object getAttributionSource()
|
private Object getAttributionSource()
|
||||||
throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
|
throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
|
||||||
if (attributionSource == null) {
|
if (attributionSource == null) {
|
||||||
@@ -104,8 +102,7 @@ public class ContentProvider implements Closeable {
|
|||||||
default:
|
default:
|
||||||
args = new Object[]{ServiceManager.PACKAGE_NAME, callMethod, arg, extras};
|
args = new Object[]{ServiceManager.PACKAGE_NAME, callMethod, arg, extras};
|
||||||
break;
|
break;
|
||||||
}
|
} return (Bundle) method.invoke(provider, args);
|
||||||
return (Bundle) method.invoke(provider, args);
|
|
||||||
} catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException | ClassNotFoundException | InstantiationException e) {
|
} catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException | ClassNotFoundException | InstantiationException e) {
|
||||||
Ln.e("Could not invoke method", e);
|
Ln.e("Could not invoke method", e);
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user