Example crashes when trying to access remote preference
a1b2c opened this issue · 1 comments
Scope request works perfect but crash when trying to edit RemotePreference or openFileOutputStream. I just added
val pref : SharedPreferences? = service.getRemotePreferences(packageName)
pref?.edit()?.putBoolean("temp", true)?.apply()
to onServiceBind method of callback like this
override fun onServiceBind(service: XposedService) {
mService = service
binding.binder.text = "Binder acquired"
binding.api.text = "API " + service.apiVersion
binding.framework.text = "Framework " + service.frameworkName
binding.frameworkVersion.text = "Framework version " + service.frameworkVersion
binding.frameworkVersionCode.text = "Framework version code " + service.frameworkVersionCode
binding.scope.text = "Scope: " + service.scope
service.requestScope("com.android.settings", mCallback)
val pref : SharedPreferences? = service.getRemotePreferences(packageName)
pref?.edit()?.putBoolean("temp", true)?.apply()
}
here is exception
FATAL EXCEPTION: main
Process: io.github.libxposed.example, PID: 6414
java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.Iterator java.util.ArrayList.iterator()' on a null object reference
at android.os.Parcel.createExceptionOrNull(Parcel.java:2379)
at android.os.Parcel.createException(Parcel.java:2357)
at android.os.Parcel.readException(Parcel.java:2340)
at android.os.Parcel.readException(Parcel.java:2282)
at io.github.libxposed.service.IXposedService$Stub$Proxy.updateRemotePreferences(IXposedService.java:448)
at io.github.libxposed.service.RemotePreferences$Editor.doUpdate(RemotePreferences.java:207)
at io.github.libxposed.service.RemotePreferences$Editor.lambda$apply$1$io-github-libxposed-service-RemotePreferences$Editor(RemotePreferences.java:233)
at io.github.libxposed.service.RemotePreferences$Editor$$ExternalSyntheticLambda2.run(Unknown Source:2)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:233)
at android.app.ActivityThread.main(ActivityThread.java:8010)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:631)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:978)
+1