[INFO] java.lang.SecurityException: Given calling package android does not match caller's uid
See original GitHub issueI don’t know it’s a real issue of RemotePreferences, I report for info to other users. With Xposed and similar projects, it is not possible to have the Context of hooked application, thank to @MPeti1 and the info in issue #3 there was a good alternative for old versions of Android.
Context systemContext = (Context) XposedHelpers.callMethod( XposedHelpers.callStaticMethod( XposedHelpers.findClass("android.app.ActivityThread", loadPackageParam.classLoader), "currentActivityThread"), "getSystemContext" );
With this row we can get the context of package “android” and is good for create the object RemotePreferences. With Android 8 and 8.1, the context “android” can query the Provider without exception. I’m testing an old module which use RemotePreferences on Android 10 (LineageOS 17.1) and LSPosed, but everytime my module from handleLoadPackage try to query the provider I got this exception:
java.lang.SecurityException: Given calling package android does not match caller's uid 10161
at android.os.Parcel.createException(Parcel.java:2071)
at android.os.Parcel.readException(Parcel.java:2039)
at android.os.Parcel.readException(Parcel.java:1987)
at android.app.IActivityManager$Stub$Proxy.getContentProvider(IActivityManager.java:5056)
at android.app.ActivityThread.acquireProvider(ActivityThread.java:6561)
at android.app.ContextImpl$ApplicationContentResolver.acquireUnstableProvider(ContextImpl.java:2725)
at android.content.ContentResolver.acquireUnstableProvider(ContentResolver.java:2117)
at android.content.ContentResolver.query(ContentResolver.java:928)
at android.content.ContentResolver.query(ContentResolver.java:880)
at android.content.ContentResolver.query(ContentResolver.java:836)
at com.crossbowffs.remotepreferences.RemotePreferences.query(RemotePreferences.java:214)
at com.crossbowffs.remotepreferences.RemotePreferences.querySingle(RemotePreferences.java:263)
at com.crossbowffs.remotepreferences.RemotePreferences.getBoolean(RemotePreferences.java:135)
I tried to set strictmode to true without success, I tried the solution in issue #12 setExecutable(true, false) and setReadable(true, false) without success. Android check the name of package in context (“android”) and the uid of caller (my hooked application) and with mismatch throw an exception.
So I think this project is useless with *Posed and new Android if this check can’t be disabled.
From Readme: "This library was developed to simplify Xposed module preference access. " In the past sure, now not more.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (2 by maintainers)
Thank to all which reply me. I found a solution. newApplication is invoked before a new Activity is created and should invoked also when there is no activity but only a service.
@apsun would be great
@MPeti1 I tried to analyze, but it wasn’t easy for me
Is the app you are hooking (and the class) having context as a parameter somewhere? If so, you can hook it to get context.
See https://github.com/apsun/NekoSMS/blob/82205ebed9cd57fd59a59457d2a65b10a5e17751/app/src/main/java/com/crossbowffs/nekosms/xposed/SmsHandlerHook.java#L182