blob: b148f685b3f746d544d75aab010a0f7bffb16bd8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
package se.leap.bitmaskclient.base.utils;
import android.content.Context;
import java.lang.reflect.Method;
public class SystemPropertiesHelper {
/**
* Checks if SystemProperties contains a given key using reflection
* @return true if reflection was successful and the key was found
*/
public static boolean contains(String key, Context context) {
String result = null;
try {
ClassLoader cl = context.getClassLoader();
@SuppressWarnings("rawtypes")
Class SystemProperties = cl.loadClass("android.os.SystemProperties");
@SuppressWarnings("rawtypes")
Class[] paramTypes= new Class[1];
paramTypes[0]= String.class;
Method get = SystemProperties.getMethod("get", paramTypes);
Object[] params= new Object[1];
params[0]= key;
result = (String) get.invoke(SystemProperties, params);
} catch (Exception e) {
e.printStackTrace();
}
return result != null;
}
}
|