/**
* 查询系统prop属性值
* @param context 上下文对象
* @param key 属性名称
* @param def 默认值
* @return prop属性值
* @throws IllegalArgumentException
*/
public static String selectSystemPropName(Context context, String key,
String def) throws IllegalArgumentException {
String ret = def;
try {
ClassLoader cl = context.getClassLoader();
@SuppressWarnings("rawtypes")
Class SystemProperties = cl
.loadClass("android.os.SystemProperties");
@SuppressWarnings("rawtypes")
Class[] paramTypes = new Class[2];
paramTypes[0] = String.class;
paramTypes[1] = String.class;
@SuppressWarnings("unchecked")
Method get = SystemProperties.getMethod("get", paramTypes);
Object[] params = new Object[2];
params[0] = new String(key);
params[1] = new String(def);
ret = (String) get.invoke(SystemProperties, params);
} catch (IllegalArgumentException iAE) {
throw iAE;
} catch (Exception e) {
ret = def;
}
return ret.toLowerCase();
}