Closed StevenStanleyBayes closed 9 years ago
Obviously, Xposed error log file states clearly the problem is with a read only implementation BUT the file is world writeable and should be possible to write into.
XSharedPreferences is intended to be a read-only implementation. I decided not to implement write access because of the various kinds of issues that could occur. For example, a file created by your module inside a callback in app X would be owned by that app X (or by root in initZygote), and not by your module's app. So you might have issues writing into that file later from your own module. Also, the standard implementation doesn't check whether the file has been changed, because under normal circumstances, that can't happen. So it would still operate on old values and would possibly overwrite your modified file. And then there's SELinux, which might prevent (write) access to the file even if it's world-writeable.
You can look at this solution: http://forum.xda-developers.com/showpost.php?p=57348038&postcount=4
The old issue with how to read a shared preferences file from an Xposed module has been solved as described in https://github.com/rovo89/XposedBridge/issues/56.
Thank you for your solution with the new XposedBridge v 73. I still use v 54 which is stable and is OK for KitKat.
I have provided you with the needed code and I will provide you with the new one here where the names have been arranged to provide more clarity.
As mentioned, getPreferenceManager().setSharedPreferencesMode(MODE_WORLD_READABLE) is not always available only in the cases outlined in the provided link.
Here is the new problem :
I have created a shared preferences file as MODE_WORLD_WRITEABLE. The code is exactly the same as in https://github.com/rovo89/XposedBridge/issues/56 just the word READABLE is replaced by the word WRITEABLE.
Here is the code from the Xposed module :
static XSharedPreferences prefs; static XSharedPreferences.Editor thePrefsEditor;
@Override public void initZygote(StartupParam startupParam) throws Throwable {
// Tried here : prefsEditor = prefs.edit();
// In the hooked method : prefsEditor = prefs.edit(); prefsEditor.putBoolean("SomeNewKey", true); prefsEditor.commit();
Here is what the Xposed error log shows :
java.lang.UnsupportedOperationException: read-only implementation at de.robv.android.xposed.XSharedPreferences.edit(XSharedPreferences.java:222)
Here are some notes :
The file FileName is a shared preferences file which is MODE_WORLD_WRITEABLE and has elevated permissions with setWritable(true, false).
Obviously, Xposed error log file states clearly the problem is with a read only implementation BUT the file is world writeable and should be possible to write into.
HOW CAN I WRITE INTO A FILE FROM THE XPOSED MODULE?