Commit deefe57d by Fear1ess

4/23

parent 20242691
...@@ -26,6 +26,7 @@ import android.location.Location; ...@@ -26,6 +26,7 @@ import android.location.Location;
import android.location.LocationListener; import android.location.LocationListener;
import android.location.LocationManager; import android.location.LocationManager;
import android.net.ConnectivityManager; import android.net.ConnectivityManager;
import android.net.LinkProperties;
import android.net.Network; import android.net.Network;
import android.net.NetworkCapabilities; import android.net.NetworkCapabilities;
import android.net.NetworkInfo; import android.net.NetworkInfo;
...@@ -51,6 +52,7 @@ import com.reyun.wandun.WdMain; ...@@ -51,6 +52,7 @@ import com.reyun.wandun.WdMain;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;
import java.net.InetAddress;
import java.net.NetworkInterface; import java.net.NetworkInterface;
import java.net.SocketException; import java.net.SocketException;
import java.security.cert.Certificate; import java.security.cert.Certificate;
...@@ -107,14 +109,6 @@ public class MainActivity extends AppCompatActivity { ...@@ -107,14 +109,6 @@ public class MainActivity extends AppCompatActivity {
e.printStackTrace(); e.printStackTrace();
} }
CameraManager camera = (CameraManager) getSystemService(Service.CAMERA_SERVICE);
try {
String[] list = camera.getCameraIdList();
CameraCharacteristics cc = camera.getCameraCharacteristics("0");
Log.d("haha", "onCreate: ");
} catch (CameraAccessException e) {
e.printStackTrace();
}
} }
@Override @Override
...@@ -144,5 +138,27 @@ public class MainActivity extends AppCompatActivity { ...@@ -144,5 +138,27 @@ public class MainActivity extends AppCompatActivity {
}); });
} }
} }
public String getDns() {
String result = "";
ConnectivityManager cm = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetworkInfo = cm.getActiveNetworkInfo();
for (Network network : cm.getAllNetworks()) {
NetworkInfo networkInfo = cm.getNetworkInfo(network);
if (networkInfo.getType() == activeNetworkInfo.getType()) {
LinkProperties lp = cm.getLinkProperties(network);
for (InetAddress addr : lp.getDnsServers()) {
// Get DNS IP address here:
result += addr.getHostAddress() + ",";
}
}
}
if(result.contains(",")){
result=result.substring(0, result.length() - 1);
}
result="[" + result + "]";
return result;
}
} }
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <jni.h> #include <jni.h>
void addJniStringToJson(JNIEnv* env, cJSON* json, const char* key, jobject jstr); void addJniStringToJson(JNIEnv* env, cJSON* json, const char* key, jobject jstr);
void addJniStringToArray(JNIEnv* env, cJSON* json, jobject jstr);
void getJniStringSha256(JNIEnv* env, jobject jstr, char* sha256); void getJniStringSha256(JNIEnv* env, jobject jstr, char* sha256);
void bytes2Hex(const unsigned char* source, char* dest, int sourceLen, int mac_format); void bytes2Hex(const unsigned char* source, char* dest, int sourceLen, int mac_format);
void hex2Bytes(const char* source, unsigned char* dest, int sourceLen); void hex2Bytes(const char* source, unsigned char* dest, int sourceLen);
......
...@@ -12,11 +12,13 @@ ...@@ -12,11 +12,13 @@
#ifdef __arm__ #ifdef __arm__
#define WDSYSCALL(cmd, args...) wd_syscall_arm(WDNUM(cmd), ##args) #define WDSYSCALL(cmd, args...) wd_syscall_arm(WDNUM(cmd), ##args)
#define WD_SYS_mmap SYS_mmap2 #define WD_SYS_mmap SYS_mmap2
#define WD_SYS_fstatat SYS_fstatat64
#endif #endif
#ifdef __aarch64__ #ifdef __aarch64__
#define WDSYSCALL(cmd, args...) wd_syscall_aarch64(WDNUM(cmd), ##args) #define WDSYSCALL(cmd, args...) wd_syscall_aarch64(WDNUM(cmd), ##args)
#define WD_SYS_mmap SYS_mmap #define WD_SYS_mmap SYS_mmap
#define WD_SYS_fstatat SYS_newfstatat
#endif #endif
#ifdef x86 #ifdef x86
......
...@@ -76,13 +76,19 @@ void hex2Bytes(const char* source, unsigned char* dest, int sourceLen) ...@@ -76,13 +76,19 @@ void hex2Bytes(const char* source, unsigned char* dest, int sourceLen)
return; return;
} }
void addJniStringToArray(JNIEnv* env, cJSON* json, jobject jstr) {
addJniStringToJson(env, json, NULL, jstr);
}
void addJniStringToJson(JNIEnv *env, cJSON *json, const char *key, jobject jstr) { void addJniStringToJson(JNIEnv *env, cJSON *json, const char *key, jobject jstr) {
if(jstr == NULL) { if(jstr == NULL) {
cJSON_AddStringToObject(json, key, ""); if(key) cJSON_AddStringToObject(json, key, "");
else cJSON_AddItemToArray(json, cJSON_CreateString(""));
}else{ }else{
jboolean bl = 0; jboolean bl = 0;
const char* value= (*env)->GetStringUTFChars(env, jstr, &bl); const char* value= (*env)->GetStringUTFChars(env, jstr, &bl);
cJSON_AddStringToObject(json, key, value); if(key) cJSON_AddStringToObject(json, key, value);
else cJSON_AddItemToArray(json, cJSON_CreateString(value));
(*env)->ReleaseStringUTFChars(env, jstr, value); (*env)->ReleaseStringUTFChars(env, jstr, value);
} }
} }
......
...@@ -251,6 +251,10 @@ jvalue wdCallStaticMethod(JNIEnv* env, const char* clsName, const char* methodNa ...@@ -251,6 +251,10 @@ jvalue wdCallStaticMethod(JNIEnv* env, const char* clsName, const char* methodNa
jvalue wdCallMethod(JNIEnv* env, jobject obj, const char* methodName, const char* methodSig, va_list args) { jvalue wdCallMethod(JNIEnv* env, jobject obj, const char* methodName, const char* methodSig, va_list args) {
jclass cls = (*env)->GetObjectClass(env, obj); jclass cls = (*env)->GetObjectClass(env, obj);
jmethodID methodId = (*env)->GetMethodID(env, cls, methodName, methodSig); jmethodID methodId = (*env)->GetMethodID(env, cls, methodName, methodSig);
if(methodId == NULL) {
logd(WD_JNI, "not find method %s%s", methodName, methodSig);
goto return_label;
}
jvalue value = {0}; jvalue value = {0};
switch(wdGetMethodRetType(methodSig)) { switch(wdGetMethodRetType(methodSig)) {
case 'V': case 'V':
...@@ -287,6 +291,7 @@ jvalue wdCallMethod(JNIEnv* env, jobject obj, const char* methodName, const char ...@@ -287,6 +291,7 @@ jvalue wdCallMethod(JNIEnv* env, jobject obj, const char* methodName, const char
default: break; default: break;
} }
wdCheckException(env); wdCheckException(env);
return_label:
(*env)->DeleteLocalRef(env, cls); (*env)->DeleteLocalRef(env, cls);
return value; return value;
} }
......
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