KitKat SD permissions issue
A quick recap. When I was making my hack run on KK,
crm701 mentioned needing to use the KK SDfix to make the hack work. Since it worked, I didn't bother looking further. Then a while ago,
RelZeshi and
orion2323 mentioned problems with some of their apps after applying the hack. Basically, apps that had been installed before the hack worked, but new apps installed after the hack didn't always work. I guess not enough people have reported this problem, so I finally took a look at this problem only recently. Sorry about not dealing with this sooner.
So here's the technical lowdown as I understand it. Android emulates a virtual SD card from a portion of "internal" storage (using /data/media, which the hack puts on the external SD). Since KK, apps can no longer have free access to all of the (real or emulated) SD like before. This restriction shouldn't affect most typical apps, but with the hack applied, something prevents those apps from accessing the files on the SD. It turns out that the service responsible for managing the permissions and rights to the SD, "sdcard", reads a list containing the access rights from /data/system/packages.list to determine which apps can access the SD. In a way, this problem is similar to the sensor issue. If "sdcard" ("sensord" in the sensor issue) accesses /data/system/packages.list (/data/misc/sensor/* for sensors) before the external partition is mounted at /data, the file it reads would be the one in the internal /data, which would obviously not contain info about apps installed after the hack.
When I tested on the Carbon rom (no KK SDfix or other hacks), sometimes an app would exhibit this problem after booting into the rom. I could reboot without doing anything else, and then sometimes the problem would go away. Like the sensor issue, it seems to be a race condition. So in theory, once "sdcard" is forced to restart after the external partition is mounted, it should read the correct packages.list and grant access accordingly. In other words, KK SDfix should no longer be necessary unless you actually want to let certain apps access the whole SD.
I'm posting three files. One for the sdcard workaround (for KK, not needed for JB) only. One for the sensord workaround only. And one for both. Each changes the same script, so choose one. Flashing one after another means to replace, not to add to the old one. The sensord one is almost the same as the one previously posted at #476. The only difference is in this version, I added a 1-second delay between stopping and starting sensord to give the sensors some time to reinitialize. The uninstaller in #476 (for the hack plus the workaround) should still be applicable.
If anyone needs this workaround, please let me know if it works. Thanks.