android 使用系统级别权限

java.lang.SecurityException: Neither user 10027 nor current process has android.permission.MODIFY_PHONE_STATE

 1、root手机,奇兔刷机助手

2、将app拷贝至/system/priv-app目录下

3、重启手机

附:

/**
* 应用程序运行命令获取 Root权限,设备必须已破解(获得ROOT权限)
*
* @return 应用程序是/否获取Root权限
*/
public static boolean upgradeRootPermission(String pkgCodePath) {
Process process = null;
DataOutputStream os = null;
try {
String cmd = "chmod 777 " + pkgCodePath;
process = Runtime.getRuntime().exec("su"); //切换到root帐号
os = new DataOutputStream(process.getOutputStream());
os.writeBytes(cmd + " ");
os.writeBytes("exit ");
os.flush();
process.waitFor();
} catch (Exception e) {
return false;
} finally {
try {
if (os != null) {
os.close();
}
process.destroy();
} catch (Exception e) {
}
}
return true;
}
原文地址:https://www.cnblogs.com/agilezhu/p/6015403.html