1. ansh462's Avatar
    Android application in java having permission issues when accessing sysfs entry.

    try{
    FileOutputStream fos = new FileOutputStream("/sys/class/shift_reg/shift_reg/value");
    byte mybyte = 1;
    fos.write(mybyte);
    fos.close();
    } catch ( Exception e) {
    Log.d(TAG, "Failed in writing to Shift Register"); <------- I am always getting this exception.
    }
    1) Have tried putting 'setenforce 0'. Does't work. Even though enforce level is permissive.

    2) Do I have to access using JNI way: ( android-app -> jni -> driver )

    3) I have set file permission as 0777 for the sysfs node file.

    Dmesg Error message:

    [ 417.176302] type=1400 audit(418.589:63): avc: denied { write } for pid=3164 comm="com.android.cam" name="value" dev="sysfs" ino=9749 scontext=u:r:untrusted_app:s0 tcontext=u:object_r:sysfs:s0 tclass=file permissive=1
    ps -Z

    u:r:untrusted_app:s0 u0_a67 4360 333
    com.android.cam
    04-03-2017 11:04 AM
  2. BayK's Avatar
    This file is exposed by the kernel, it is not a physical file in the file system.
    For you need to check you kernel doc to verify if it is writable.

    Did you try to write to /sys/class/shift_reg/shift_reg/value from Adb? Does it work?
    04-13-2017 04:22 PM

Similar Threads

  1. Replies: 1
    Last Post: 04-26-2017, 07:24 AM
  2. Replies: 6
    Last Post: 04-07-2017, 12:59 PM
  3. Phone showing wrong date on screen
    By AC Question in forum Ask a Question
    Replies: 1
    Last Post: 04-03-2017, 03:27 PM
  4. *Temporary Fix for Galaxy S7 Verizon Nougat Headphones Issue*
    By deanmysliwiec in forum Legacy Android & Other OS's
    Replies: 1
    Last Post: 04-03-2017, 03:23 PM
  5. How do I delete from external storage
    By AC Question in forum Ask a Question
    Replies: 1
    Last Post: 04-03-2017, 03:19 PM
LINK TO POST COPIED TO CLIPBOARD