Why can't my Android app (has root privilege) access /dev/input?
<p>My app aims the rooted Android devices, it has the root privilege and needs accessing the directory <code>/dev/input</code>, but why does it throw <code>opendir failed, Permission denied</code> even <code>/dev/input</code> has already been <code>chmod</code> to <code>777</code>?</p>

<p>I use the code below to get the root privilege:</p>

<pre><code>Process root = Runtime.getRuntime().exec("su");
</code></pre>

<p>And use the code below to change the permissions of <code>/dev/input</code>:</p>

<pre><code>Shell.runCommand("chmod 777 /dev/input");
</code></pre>

<p>Both the two steps above are successful, but why can't it be accessed by my app still? From the searching, someone says the runtime permissions of an app is nothing to do with the permissions of the file in file system. What's the permissions system of Android runtime? How can I make the app be able to access <code>/dev/input</code>?</p>

<p><strong>Addition:</strong></p>

<p>My test environment is Android 5.1.1, main part of the code is:</p>

<pre><code>jint Java_com_foo_funnyapp_Native_scanInputDevicesJNI(JNIEnv* env, jclass clazz)
{
    const char *dirname = "/dev/input";

    DIR *dir;
    dir = opendir(dirname); // opendir failed, Permission denied
    if(dir == NULL)
        return -1;

    ......

    return 0;
}
</code></pre>

<p>SELinux error from <code>/prog/kmsg</code></p>

<pre><code>&lt;36&gt;[19700411_05:32:43.957165]@0 type=1400 audit(8631163.939:1105): avc: denied { write } for pid=15706 comm="app_process64_o" name="system@framework@boot.art" dev="mmcblk0p43" ino=442379 scontext=u:r:shell:s0 tcontext=u:object_r:dalvikcache_data_file:s0 tclass=file permissive=0
&lt;11&gt;[19700411_05:32:44.118202]@0 init: untracked pid 15674 exited with status 0
&lt;11&gt;[19700411_05:32:44.202288]@0 init: untracked pid 15704 exited with status 224
&lt;36&gt;[19700411_05:32:44.225334]@0 type=1400 audit(8631164.209:1106): avc: denied { read } for pid=15734 comm="Thread-111" name="input" dev="tmpfs" ino=12525 scontext=u:r:untrusted_app:s0 tcontext=u:object_r:input_device:s0 tclass=dir permissive=0
&lt;36&gt;[19700411_05:32:44.332135]@0 type=1400 audit(8631164.319:1107): avc: denied { write } for pid=15742 comm="app_process64_o" name="system@framework@boot.art" dev="mmcblk0p43" ino=442379 scontext=u:r:shell:s0 tcontext=u:object_r:dalvikcache_data_file:s0 tclass=file permissive=0
</code></pre>