【发布时间】:2023-04-05 17:44:02
【问题描述】:
我想将触摸屏事件写入'/dev/input/event1',但它运行'open("/dev/input/event1", O_RDWR);'权限被拒绝。我的手机已经root了,我用代码获得了root:
String apkRoot="chmod 777 "+getPackageCodePath();
RootCommand(apkRoot);
public static boolean RootCommand(String command)
{
Process process = null;
DataOutputStream os = null;
try
{
process = Runtime.getRuntime().exec("su");
os = new DataOutputStream(process.getOutputStream());
os.writeBytes(command + "\n");
os.writeBytes("exit\n");
os.flush();
process.waitFor();
} catch (Exception e)
{
Log.d("*** DEBUG ***", "ROOT REE" + e.getMessage());
return false;
} finally
{
try
{
if (os != null)
{
os.close();
}
process.destroy();
} catch (Exception e)
{
}
}
Log.d("*** DEBUG ***", "Root SUC ");
return true;
}
这表明我的应用确实获得了 root 权限,但我对“权限被拒绝”感到困惑。
【问题讨论】: