【问题标题】:android open("/dev/input/event1", O_RDWR); with permission denied?android open("/dev/input/event1", O_RDWR);经许可被拒绝?
【发布时间】: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 权限,但我对“权限被拒绝”感到困惑。

【问题讨论】:

    标签: android linux input root


    【解决方案1】:

    我添加代码

    apkRoot="chmod 777 /dev/input/event1";
    RootCommand(apkRoot);"
    

    而且效果很好。

    【讨论】:

      猜你喜欢
      • 2013-02-07
      • 1970-01-01
      • 1970-01-01
      • 2016-09-15
      • 1970-01-01
      • 1970-01-01
      • 2016-07-15
      • 1970-01-01
      • 2020-09-18
      相关资源
      最近更新 更多