Background: I had a rooted Nexus 4 with Android 4.4.4 that was working well. Then I got the notification to update to Android 5. To this end, I flashed the stock recovery for Android 4.4.4 from Google and started the upgrade (but I did not unroot the phone, maybe this was a mistake). The upgrade process itself went smoothly. After the upgrade, I re-flashed TWRP 2.8.2 and re-rooted with SuperSU 2.36, and made a backup.
Then, I realised that some data (photos, E-Books, …) were missing. Well, not actually missing, but located under a spurious "0" directory (/storage/emulated/0/0). Additionally, when I attempted to access my E-Book-Folder directly with FBReader, it told me there were insufficient permissions to access the directory.
First, I tried the "Fix Permissions" button in TWRP, but that put me in a boot loop. After restoring the backup, I used the TWRP file manager to move all data from the spurious "0" directory to where they belong and deleted the now empty "0" directory. Rebooting once again brought up the "Optimizing apps" screen, but only for 7 apps. Now I can access my E-Books again, but still no (old) photos in the Google photos app. Photographs taken after the backup show up fine. With the file manager or the terminal, I can access all photos just fine once I call
setenforce 0. The permissions shown by
ls -Z /storage/emulated/0/DCIM/Camera look alike on all photos, both visible and invisible in the photos app:
-rw-rw---- root sdcard_r u:object_r:fuse:s0. So my guess is that there is some additional SELinux permission I have to set on the older image files so the photo app can access them. Therefore my question is: what permission concepts are at work here, and what commands are necessary to assign files/directories to a certain app? Thanks.
Update: I just found out I can take new pictures only with setenforce 0, so there has to be some major SELinux breakage somewhere.