调用@hide系统隐藏类
通过反射
public static String getProperty(String key, String defaultValue) {
String value = defaultValue;
try {
Class<?> c = Class.forName("android.os.SystemProperties");
Method get = c.getMethod("get", String.class, String.class);
value = (String)(get.invoke(c, key, "unknown" ));
} catch (Exception e) {
e.printStackTrace();
}finally {
return value;
}
}
public static void setProperty(String key, String value) {
try {
Class<?> c = Class.forName("android.os.SystemProperties");
Method set = c.getMethod("set", String.class, String.class);
set.invoke(c, key, value );
} catch (Exception e) {
e.printStackTrace();
}
}
添加系统framework.jar 目录:out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes.jar
框架层系统源码中添加监听
/**{@hide}*/
private VolumeListener listener;
/**{@hide}*/
public void setListener(VolumeListener listener){
this.listener = listener;
}
/**{@hide}*/
public interface VolumeListener{
void updateVolume(int type,int index);
}
|