During automated tests for my product, I push files to the apps private directory and chmod
the file so that the app can access it. On APIs < Marshmallow, this was fine and the apps never had an issue accessing files.
Now, on some files, I get the following logs when trying to open it:
W/System.err(7669): Caused by:
java.io.FileNotFoundException: /data/user/0/foo/foo.txt: open failed: EACCES (Permission denied) 09-28 18:20:56.724:
W/System.err(7669): at libcore.io.IoBridge.open(IoBridge.java:452) 09-28 18:20:56.724:
W/System.err(7669): at java.io.FileInputStream.<init>(FileInputStream.java:76) 09-28 18:20:56.724:
W/System.err(7669): at android.app.ContextImpl.openFileInput(ContextImpl.java:384) 09-28 18:20:56.724:
W/System.err(7669): at android.content.ContextWrapper.openFileInput(ContextWrapper.java:177) 09-28 18:20:56.724:
W/System.err(7669): Caused by: android.system.ErrnoException: open failed: EACCES (Permission denied) 09-28 18:20:56.724:
W/System.err(7669): at libcore.io.Posix.open(Native Method) 09-28 18:20:56.724:
W/System.err(7669): at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186) 09-28 18:20:56.724:
W/System.err(7669): at libcore.io.IoBridge.open(IoBridge.java:438) 09-28 18:20:56.716:
W/pool-5-thread-1(8279): type=1400 audit(0.0:57): avc: denied { search } for name="files" dev="mtdblock1" ino=7314 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:app_data_file:s0 tclass=dir permissive=0
How can I fix?