Androd.bp
cc_binary {
name: "xxx",
srcs: ["xxx.c"],
cflags: ["-Werror"],
shared_libs: [
"libbase",
"libcutils",
"liblog",
],
}
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <ctype.h>
#include <poll.h>
#include <sys/ioctl.h>
#include <linux/ioctl.h>
#include <android/log.h>
#define DEBUG
#define ANDROID_PLATFORM
#define LOG_TAG "XXX"
#ifdef DEBUG
#ifdef ANDROID_PLATFORM
#define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__))
#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__))
#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__))
#else
#define LOGD(fmt, ...) printf(fmt"\n", ##__VA_ARGS__)
#define LOGI(fmt, ...) printf(fmt"\n", ##__VA_ARGS__)
#define LOGW(fmt, ...) printf(fmt"\n", ##__VA_ARGS__)
#define LOGE(fmt, ...) printf(fmt"\n", ##__VA_ARGS__)
#endif
#else
#define LOGD(...)
#define LOGI(...)
#define LOGW(...)
#define LOGE(...)
#endif
int main(int argc, char **argv)
{
LOGD("just logcat test!");
return 0;
}
下面主要考虑user 版本
type xxx_logcat, domain;
type xxx_logcat_exec, exec_type, file_type, vendor_file_type;
init_daemon_domain(xxx_logcat)
not_full_treble(`allow xxx_logcat shell_exec:file rx_file_perms;')
full_treble_only(`allow xxx_logcat vendor_shell_exec:file rx_file_perms;')
网友评论