Permission on IntentService with Eclair 2.1
I'm writing two app on Android that开发者_高级运维 uses the permission mechanism to enforces restrictions on caller.
They works perfectly on Froyo 2.2 or greater, but not on Eclair 2.1.
The first app (the caller) have in the Manifest <uses-permission ... />
and the second (that is called) define a new permission with <permission .... />
.
Someone have the same trouble with Eclair 2.1?
I'm using for testing on 2.1 only emulator (2.1-update1 and 2.1update1 with google api).
This is error from logcat:
W/ActivityManager( 52): Permission Denial: Accessing service ComponentInfo{xy.android.myapp.pkg2/xy.android.myapp.pkg2.Service} from pid=52, uid=1000 requires xy.android.myapp.ACCESS_SERVICE
W/System.err( 499): java.lang.SecurityException: Not allowed to start service Intent { act=xy.android.myapp.pkg2.REMOTE_LIST cmp=xy.android.myapp.pkg2/.Service (has extras) } without permission xy.android.myapp.ACCESS_SERVICE
W/System.err( 499): at android.app.ApplicationContext.startService(ApplicationContext.java:765)
W/System.err( 499): at android.content.ContextWrapper.startService(ContextWrapper.java:326)
W/System.err( 499): at xy.android.myapp.pkg1.MainActivity$6.run(MainActivity.java:711)
W/System.err( 499): at java.lang.Thread.run(Thread.java:1096)
When I install the apk, unlike on Froyo, there isn't log about the new permission.
The Manifest of apps are:
Pkg1 (the caller)
<uses-permission android:name="xy.android.myapp.ACCESS_SERVICE" />
Pkg2
<permission android:name="xy.android.myapp.ACCESS_SERVICE"
android:label="@string/label"
android:description="@string/desc"
android:protectionLevel="signature" />
And in the service definition:
<service ... android:permission="xy.android.myapp.ACCESS_SERVICE" ... />
I've tested with protectionLevel value: normal, signature and dangerous. Thanks.
I've just stumbled upon this myself. The app that declares the permission needs to be installed before the one that uses it or it will throw an exception even though the right permission shows up on Settings.
精彩评论