Open bluesky139 opened 7 years ago
Weird enough that my module still works without any changes, at least in handleLoadPackage(), But maybe you want to look at https://github.com/GravityBox/GravityBox/commit/d825b7be445c18de9a90eb8f77c1c5eb2b74deb8?
I already checked GravityBox, they put it in /data/user_de/
, but I tried with failure.
I don't know if it's a problem related to my ROM. My device is Nexus 5, flashed latest RR ROM, it's based on CM ROM.
I can read it on Genymotion simulator.
I also think it's weird, maybe I have to try another ROM? I don't know how to investigate more.
It's been reported by some of my users that there are strange issues with Device Protected Storage on Lineage and possibly other derivatives like RR. I don't have additional details as I didn't do any tests on custom ROMs myself. @bluesky139 Also note that if you use settings activity together with its SharedPreferences you have to tell preference manager to use Protected Storage. getPreferenceManager().setStorageDeviceProtected()
Thanks @C3C0 I have used setStorageDeviceProtected()
, then preferences will be stored in /data/user_de/
.
And, plus your report, my guess is all Lineage users have this problem.
OK, I think I figured out something, but I don't know why.
I noticed this folder /data/user_de/0/[package name]
is 700
permission, if I changed it to 711
, then I can read preferences in handleLoadPackage()
.
Why need "execute" permission on this folder?
Execute permission on a folder is needed for others to be able to descend into it and access files and subfolders.
Even though, it still can't be accessed in initZygote()
, but at least I can use it in handleLoadPackage()
.
More weird thing happened, I'm using File.canRead()
to check preferences readability, it returns false, but if I use XSharedPreferences
to get value by key, it returns right value.
File file = new File(Prefs.PATH); Logger.d("file exists " + file.exists() + ", read " + file.canRead()); // false XSharedPreferences xprefs = new XSharedPreferences(file); Logger.d("read pref " + xprefs.getBoolean("xxx", false)); // true
I don't know your special case. As C3C0 said, you need to set up correct permission on the package folder and also the preference.xml. Then you should be unblocked. The typical setting for the package folder is 711 and for the preference file is 664.
I write a file based SharedPreferences library, it work for me: FileSharedPreferences
I've updated to Android 7.1.2 with Xposed v88 recently, I want to hook system method, yes, package name is
android
, but I need to read preferences.I tried to put preferences in
/data/data/[package name]/shared_prefs/xxx.xml
or/data/user_de/0/[package name]/shared_prefs/xxx.xml
, and modify permission to664
(checked it still be 664 after reboot), it can't be read ininitZygote()
orhandleLoadPackage()
.I can't use content provider (something like RemotePreferences) to provide preferences, because system it not boot up yet.
Or find a way to put it in
/data/system
?