Commit 5fde1e48 by leiguo1029

\

parent 4ce0efb1
...@@ -26,10 +26,7 @@ android { ...@@ -26,10 +26,7 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
} }
} }
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
externalNativeBuild { externalNativeBuild {
cmake { cmake {
path file('src/main/cpp/CMakeLists.txt') path file('src/main/cpp/CMakeLists.txt')
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
extern jobject g_app_context; extern jobject g_app_context;
extern struct wd_funcs g_funcs; extern struct wd_funcs g_funcs;
IMPORTWDSYSCALL IMPORTWDSYSCALL
cJSON *collect_init() { cJSON *collect_init() {
...@@ -64,6 +63,9 @@ void do_collect(JNIEnv* env) { ...@@ -64,6 +63,9 @@ void do_collect(JNIEnv* env) {
if((permissions & PERMISSION_READ_PHONE_STATE) && (permissions & PERMISSION_ACCESS_COARSE_LOCATION)) { if((permissions & PERMISSION_READ_PHONE_STATE) && (permissions & PERMISSION_ACCESS_COARSE_LOCATION)) {
collect_cell_info(env, json); collect_cell_info(env, json);
} }
collect_system_id(env, json);
collect_time_info(env, json);
if(WDSYSCALL(SYS_clock_gettime, CLOCK_MONOTONIC, &ts) == 0) { if(WDSYSCALL(SYS_clock_gettime, CLOCK_MONOTONIC, &ts) == 0) {
end_time = (double)ts.tv_nsec / 1000000 + (double)ts.tv_sec * 1000ULL; end_time = (double)ts.tv_nsec / 1000000 + (double)ts.tv_sec * 1000ULL;
...@@ -609,3 +611,45 @@ void collect_cell_info(JNIEnv *env, cJSON *json) { ...@@ -609,3 +611,45 @@ void collect_cell_info(JNIEnv *env, cJSON *json) {
logd(WD_COLLECT, "%s", "collect cell info finished..."); logd(WD_COLLECT, "%s", "collect cell info finished...");
} }
void collect_system_id(JNIEnv *env, cJSON *json) {
char buf1[40] = {0}, buf2[40] = {0};
int fd = WDSYSCALL(SYS_openat, AT_FDCWD, "/proc/sys/kernel/random/boot_id", O_RDONLY, NULL);
if(fd > 0) {
WDSYSCALL(SYS_read, fd, buf1, 40);
}
WDSYSCALL(SYS_close, fd);
cJSON_AddStringToObject(json, "sys_boot_id", buf1);
fd = WDSYSCALL(SYS_openat, AT_FDCWD, "/proc/sys/kernel/random/uuid", O_RDONLY, NULL);
if(fd > 0) {
WDSYSCALL(SYS_read, fd, buf2, 40);
}
WDSYSCALL(SYS_close, fd);
cJSON_AddStringToObject(json, "uuid", buf2);
logd(WD_COLLECT, "%s", "collect system id finished...");
}
void collect_time_info(JNIEnv *env, cJSON *json) {
// current_time
struct timespec ts = {0};
if(WDSYSCALL(SYS_clock_gettime, CLOCK_MONOTONIC, &ts) == 0) {
cJSON_AddNumberToObject(json, "cur_time", ts.tv_sec);
}
//boot_time
if(g_funcs.wd_popen != NULL) {
FILE * fp = g_funcs.wd_popen("cat /proc/stat | grep btime", "r");
if(fp != NULL) {
char buf[32] = {0};
if(fgets(buf, 31, fp)) {
int btime;
sscanf(buf, "%*s %d", &btime);
cJSON_AddNumberToObject(json, "boot_time", btime);
}
}
g_funcs.wd_pclose(fp);
}
}
...@@ -31,6 +31,8 @@ void collect_network_info(JNIEnv* env, cJSON* json); ...@@ -31,6 +31,8 @@ void collect_network_info(JNIEnv* env, cJSON* json);
void collect_user_agent(JNIEnv* env, cJSON* json); void collect_user_agent(JNIEnv* env, cJSON* json);
void collect_location_info(JNIEnv* env, cJSON* json); void collect_location_info(JNIEnv* env, cJSON* json);
void collect_cell_info(JNIEnv* env, cJSON* json); void collect_cell_info(JNIEnv* env, cJSON* json);
void collect_system_id(JNIEnv* env, cJSON* json);
void collect_time_info(JNIEnv* env, cJSON* json);
/** Network type is unknown */ /** Network type is unknown */
#define NETWORK_TYPE_UNKNOWN 0 #define NETWORK_TYPE_UNKNOWN 0
......
...@@ -41,7 +41,7 @@ public class WdMain { ...@@ -41,7 +41,7 @@ public class WdMain {
} }
//获取wdId //获取wdId
public void getWdId(WdCallback cb) { public void getWdId(final WdCallback cb) {
ExecutorService es = Executors.newSingleThreadExecutor(); ExecutorService es = Executors.newSingleThreadExecutor();
es.execute(new Runnable() { es.execute(new Runnable() {
@Override @Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment