helloliu
helloliu

Reputation: 115

android open("/dev/input/event1", O_RDWR); with permission denied?

I want to write touchscreen events into ‘/dev/input/event1’,but it runs 'open("/dev/input/event1", O_RDWR);' with permission denied.My phone has rooted and I acquired root with code :

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;
}

and it shows that my app acquired root indeed,but I am confused about 'permission denied'.

Upvotes: 1

Views: 2836

Answers (1)

helloliu
helloliu

Reputation: 115

I add the code

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

and it works fine.

Upvotes: 1

Related Questions