Commit 4ce0efb1 by Fear1ess

4/6

parent d4c7b1b9
......@@ -37,7 +37,6 @@ android {
path file('src/main/cpp/CMakeLists.txt')
}
}
ndkVersion '22.0.7026061'
}
dependencies {
......
......@@ -32,6 +32,7 @@ import android.os.Bundle;
import android.provider.Settings;
import android.provider.Telephony;
import android.telephony.CellInfo;
import android.telephony.CellLocation;
import android.telephony.NeighboringCellInfo;
import android.telephony.TelephonyManager;
import android.util.DisplayMetrics;
......@@ -115,6 +116,7 @@ public class MainActivity extends AppCompatActivity {
TelephonyManager tm = (TelephonyManager) getApplicationContext().getSystemService(Service.TELEPHONY_SERVICE);
List<CellInfo> cellInfos = tm.getAllCellInfo();
CellLocation cl = tm.getCellLocation();
......
......@@ -35,7 +35,6 @@ android {
path file('src/main/cpp/CMakeLists.txt')
}
}
ndkVersion '22.0.7026061'
}
dependencies {
......
......@@ -18,6 +18,7 @@
#include "openssl/md5.h"
#include <arpa/inet.h>
#include <sys/syscall.h>
#include <linux/prctl.h>
#define WD_COLLECT "wd_collect"
......@@ -60,7 +61,9 @@ void do_collect(JNIEnv* env) {
if((permissions & PERMISSION_ACCESS_FINE_LOCATION) && (permissions & PERMISSION_ACCESS_COARSE_LOCATION)) {
collect_location_info(env, json);
}
if((permissions & PERMISSION_READ_PHONE_STATE) && (permissions & PERMISSION_ACCESS_COARSE_LOCATION)) {
collect_cell_info(env, json);
}
if(WDSYSCALL(SYS_clock_gettime, CLOCK_MONOTONIC, &ts) == 0) {
end_time = (double)ts.tv_nsec / 1000000 + (double)ts.tv_sec * 1000ULL;
......@@ -146,7 +149,7 @@ int collect_permissions(JNIEnv* env, cJSON* json) {
for(int i = 0; i < sizeof(permissions)/sizeof(const char*); ++i) {
jstring str = (*env)->NewStringUTF(env, permissions[i]);
if(wdCallIntMethod(env, g_app_context, "checkSelfPermission", "(Ljava/lang/String;)I", str) == 0) {
value |= (2 << i);
value |= (1 << i);
}
(*env)->DeleteLocalRef(env, str);
}
......@@ -581,5 +584,28 @@ void collect_location_info(JNIEnv *env, cJSON *json) {
void collect_cell_info(JNIEnv *env, cJSON *json) {
//cell info need ACCESSS_COARSE_LOCATION permission
cJSON* item = cJSON_CreateObject();
jstring phone_jstr = (*env)->NewStringUTF(env, "phone");
jobject tm = wdCallObjectMethod(env, g_app_context, "getSystemService",
"(Ljava/lang/String;)Ljava/lang/Object;", phone_jstr);
jobject cl = wdCallObjectMethod(env, tm, "getCellLocation", "()Landroid/telephony/CellLocation;");
if(cl == NULL) goto return_label;
jclass gsm_cls = (*env)->FindClass(env, "android/telephony/gsm/GsmCellLocation");
if((*env)->IsInstanceOf(env, cl, gsm_cls) == JNI_TRUE) {
jint cid = wdCallIntMethod(env, cl, "getCid", "()I");
jint lac = wdCallIntMethod(env, cl, "getLac", "()I");
jint psc = wdCallIntMethod(env, cl, "getPsc", "()I");
cJSON_AddNumberToObject(item, "cid", cid);
cJSON_AddNumberToObject(item, "lac", lac);
cJSON_AddNumberToObject(item, "psc", psc);
}
(*env)->DeleteLocalRef(env, gsm_cls);
return_label:
(*env)->DeleteLocalRef(env, cl);
(*env)->DeleteLocalRef(env, tm);
(*env)->DeleteLocalRef(env, phone_jstr);
cJSON_AddItemToObject(json, "cell", item);
logd(WD_COLLECT, "%s", "collect cell info finished...");
}
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