SecurityException: Denial of Permission: Opening Provider

I have the following problem. We created the Game Center application, which provides the basis for creating ad hoc wifi games and manages the records / meetings of such games.

Access to databases for records is carried out using the provider:

<provider android:name="com.identifier.gamecenterapp.contentprovider.MyGamesContentProvider" android:authorities="com.identifier.gamecenterapp.contentprovider" > </provider> 

our demo game (as a link for future game developers) contains the following permissions:

 <uses-permission android:name="com.identifier.gamecenterapp.contentprovider.READ_DATABASE"/> <uses-permission android:name="com.identifier.gamecenterapp.contentprovider.WRITE_DATABASE"/> 

Now - whenever we try to access the provider with the game, we get the following error:

 09-17 12:15:52.221: E/AndroidRuntime(4551): FATAL EXCEPTION: main 09-17 12:15:52.221: E/AndroidRuntime(4551): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.identifier.gamecenter.gctictactoe/com.identifier.gamecenter.game.MainActivity}: java.lang.SecurityException: Permission Denial: opening provider com.identifier.gamecenterapp.contentprovider.MyGamesContentProvider from ProcessRecord{42622078 4551:com.identifier.gamecenter.gctictactoe/u0a10108} (pid=4551, uid=10108) that is not exported from uid 10072 09-17 12:15:52.221: E/AndroidRuntime(4551): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211) 09-17 12:15:52.221: E/AndroidRuntime(4551): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261) 09-17 12:15:52.221: E/AndroidRuntime(4551): at android.app.ActivityThread.access$600(ActivityThread.java:141) 09-17 12:15:52.221: E/AndroidRuntime(4551): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256) 09-17 12:15:52.221: E/AndroidRuntime(4551): at android.os.Handler.dispatchMessage(Handler.java:99) 09-17 12:15:52.221: E/AndroidRuntime(4551): at android.os.Looper.loop(Looper.java:137) 09-17 12:15:52.221: E/AndroidRuntime(4551): at android.app.ActivityThread.main(ActivityThread.java:5103) 09-17 12:15:52.221: E/AndroidRuntime(4551): at java.lang.reflect.Method.invokeNative(Native Method) 09-17 12:15:52.221: E/AndroidRuntime(4551): at java.lang.reflect.Method.invoke(Method.java:525) 09-17 12:15:52.221: E/AndroidRuntime(4551): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) 09-17 12:15:52.221: E/AndroidRuntime(4551): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 09-17 12:15:52.221: E/AndroidRuntime(4551): at dalvik.system.NativeStart.main(Native Method) 09-17 12:15:52.221: E/AndroidRuntime(4551): Caused by: java.lang.SecurityException: Permission Denial: opening provider c.identifier.gamecenterapp.contentprovider.MyGamesContentProvider from ProcessRecord{42622078 4551:com.identifier.gamecenter.gctictactoe/u0a10108} (pid=4551, uid=10108) that is not exported from uid 10072 09-17 12:15:52.221: E/AndroidRuntime(4551): at android.os.Parcel.readException(Parcel.java:1431) 09-17 12:15:52.221: E/AndroidRuntime(4551): at android.os.Parcel.readException(Parcel.java:1385) 09-17 12:15:52.221: E/AndroidRuntime(4551): at android.app.ActivityManagerProxy.getContentProvider(ActivityManagerNative.java:2611) 09-17 12:15:52.221: E/AndroidRuntime(4551): at android.app.ActivityThread.acquireProvider(ActivityThread.java:4515) 09-17 12:15:52.221: E/AndroidRuntime(4551): at android.app.ContextImpl$ApplicationContentResolver.acquireUnstableProvider(ContextImpl.java:2036) 09-17 12:15:52.221: E/AndroidRuntime(4551): at android.content.ContentResolver.acquireUnstableProvider(ContentResolver.java:1149) 09-17 12:15:52.221: E/AndroidRuntime(4551): at android.content.ContentResolver.query(ContentResolver.java:398) 09-17 12:15:52.221: E/AndroidRuntime(4551): at android.content.ContentResolver.query(ContentResolver.java:357) 09-17 12:15:52.221: E/AndroidRuntime(4551): at ch.ethz.csg.wlanopp.gapi.GameCenterController.getIdByGameTitle(GameCenterController.java:602) 09-17 12:15:52.221: E/AndroidRuntime(4551): at ch.ethz.csg.wlanopp.gapi.GameCenterController.isRegistered(GameCenterController.java:343) 09-17 12:15:52.221: E/AndroidRuntime(4551): at ch.ethz.csg.wlanopp.gapi.GameCenterController.addGame(GameCenterController.java:352) 09-17 12:15:52.221: E/AndroidRuntime(4551): at ch.ethz.csg.gamecenter.gctictactoe.MainActivity.onCreate(MainActivity.java:130) 09-17 12:15:52.221: E/AndroidRuntime(4551): at android.app.Activity.performCreate(Activity.java:5133) 09-17 12:15:52.221: E/AndroidRuntime(4551): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 09-17 12:15:52.221: E/AndroidRuntime(4551): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175) 09-17 12:15:52.221: E/AndroidRuntime(4551): ... 11 more 09-17 12:20:52.487: I/Process(4551): Sending signal. PID: 4551 SIG: 9 

It is strange that this worked for quite some time. The error is only on Android 4.3, previous versions (for example, tested 4.1) did not have this problem.

Thank you for your understanding of how this can be resolved.

+8
android android-contentprovider permissions android-4.3-jelly-bean
source share
1 answer

Below Android 4.3, your provider’s “exported” default value is set to true. Android 4.3 is set to false.

 <provider android:name="com.identifier.gamecenterapp.contentprovider.MyGamesContentProvider" android:authorities="com.identifier.gamecenterapp.contentprovider" android:exported="true"> </provider> 

And he will work.

+34
source share

All Articles