프로그래밍/안드로이드

안드로이드 - 컨텐트프로바이더 exported

가카리 2014. 1. 19. 14:48
반응형

I have the following problem. We have created a Game Center Application that provides a framework to create ad hoc wifi games and manages the highscores / encounters of such games.

Database access for highscores is done with a provider:

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

our demo game (as reference 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

The strange thing is, that it worked for quite a while. The error only throws on Android 4.3, previous versions (we tested 4.1 for example) did not have this issue.

Thank you for any insights how this might be resolved.

 

 

Below Android 4.3 the default value of "exported" of your provider is set to true. In Android 4.3 it is set to false.

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

And it will work.

 

출처 : http://stackoverflow.com/questions/18847302/securityexception-permission-denial-opening-provider

반응형