Commit 9e932f82 by Fear1ess

4/8

parent 5fde1e48
...@@ -14,6 +14,7 @@ import android.content.IntentFilter; ...@@ -14,6 +14,7 @@ import android.content.IntentFilter;
import android.content.pm.ApplicationInfo; import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo; import android.content.pm.PackageInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.pm.Signature; import android.content.pm.Signature;
import android.hardware.Camera; import android.hardware.Camera;
import android.hardware.Sensor; import android.hardware.Sensor;
...@@ -73,6 +74,12 @@ public class MainActivity extends AppCompatActivity { ...@@ -73,6 +74,12 @@ public class MainActivity extends AppCompatActivity {
String bssid = wi.getBSSID(); String bssid = wi.getBSSID();
int ip = wi.getIpAddress(); int ip = wi.getIpAddress();
PackageManager pm =getPackageManager();
Intent intent = new Intent("android.intent.action.MAIN");
intent.addCategory("android.intent.category.HOME");
ResolveInfo ri = pm.resolveActivity(intent, 0);
String ss = ri.activityInfo.packageName;
// Example of a call to a native method // Example of a call to a native method
...@@ -83,43 +90,6 @@ public class MainActivity extends AppCompatActivity { ...@@ -83,43 +90,6 @@ public class MainActivity extends AppCompatActivity {
@Override @Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
if(requestCode == 100) { if(requestCode == 100) {
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
return;
}
Location bestLocation = null;
LocationManager lm = (LocationManager) getApplicationContext().getSystemService(Service.LOCATION_SERVICE);
Log.d("testdemo-1", "ha ha ha...");
List<String> list = lm.getAllProviders();
for (String provider : list) {
Location l = lm.getLastKnownLocation(provider);
if (l == null) {
continue;
}
if (bestLocation == null || l.getAccuracy() < bestLocation.getAccuracy()) {
// Found best last known location: %s", l);
Log.d("testdemo-1", "provider: " + provider);
bestLocation = l;
}
}
if(bestLocation != null) {
double lat = bestLocation.getLatitude();
double lon = bestLocation.getLongitude();
Log.d("testdemo-1", lat + ", " + lon);
}
TelephonyManager tm = (TelephonyManager) getApplicationContext().getSystemService(Service.TELEPHONY_SERVICE);
List<CellInfo> cellInfos = tm.getAllCellInfo();
CellLocation cl = tm.getCellLocation();
//初始化sdk环境 //初始化sdk环境
WdMain wm = WdMain.getInstance(); WdMain wm = WdMain.getInstance();
wm.init(getApplicationContext(), "test-a341fsfr3123ddadfs"); wm.init(getApplicationContext(), "test-a341fsfr3123ddadfs");
......
...@@ -613,19 +613,19 @@ void collect_cell_info(JNIEnv *env, cJSON *json) { ...@@ -613,19 +613,19 @@ void collect_cell_info(JNIEnv *env, cJSON *json) {
void collect_system_id(JNIEnv *env, cJSON *json) { void collect_system_id(JNIEnv *env, cJSON *json) {
char buf1[40] = {0}, buf2[40] = {0}; char buf1[40] = {0}, buf2[40] = {0};
int fd = WDSYSCALL(SYS_openat, AT_FDCWD, "/proc/sys/kernel/random/boot_id", O_RDONLY, NULL); FILE* fp = fopen("/proc/sys/kernel/random/boot_id", "r");
if(fd > 0) { if(fp) {
WDSYSCALL(SYS_read, fd, buf1, 40); fscanf(fp, "%s", buf1);
} }
WDSYSCALL(SYS_close, fd); fclose(fp);
cJSON_AddStringToObject(json, "sys_boot_id", buf1); cJSON_AddStringToObject(json, "sys_boot_id", buf1);
fd = WDSYSCALL(SYS_openat, AT_FDCWD, "/proc/sys/kernel/random/uuid", O_RDONLY, NULL); fp = fopen("/proc/sys/kernel/random/uuid", "r");
if(fd > 0) { if(fp) {
WDSYSCALL(SYS_read, fd, buf2, 40); fscanf(fp, "%s", buf2);
} }
WDSYSCALL(SYS_close, fd); fclose(fp);
cJSON_AddStringToObject(json, "uuid", buf2); cJSON_AddStringToObject(json, "sys_uuid", buf2);
logd(WD_COLLECT, "%s", "collect system id finished..."); logd(WD_COLLECT, "%s", "collect system id finished...");
} }
...@@ -633,23 +633,12 @@ void collect_system_id(JNIEnv *env, cJSON *json) { ...@@ -633,23 +633,12 @@ void collect_system_id(JNIEnv *env, cJSON *json) {
void collect_time_info(JNIEnv *env, cJSON *json) { void collect_time_info(JNIEnv *env, cJSON *json) {
// current_time // current_time
struct timespec ts = {0}; struct timespec ts = {0};
if(WDSYSCALL(SYS_clock_gettime, CLOCK_MONOTONIC, &ts) == 0) { if(WDSYSCALL(SYS_clock_gettime, CLOCK_REALTIME, &ts) == 0) {
cJSON_AddNumberToObject(json, "cur_time", ts.tv_sec); cJSON_AddNumberToObject(json, "cur_time", ts.tv_sec);
} }
//boot_time if(WDSYSCALL(SYS_clock_gettime, CLOCK_BOOTTIME, &ts) == 0) {
if(g_funcs.wd_popen != NULL) { cJSON_AddNumberToObject(json, "start_boot_time", ts.tv_sec);
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);
}
} }
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