简体   繁体   English

带有Eclair 2.1的IntentService的权限

[英]Permission on IntentService with Eclair 2.1

I'm writing two app on Android that uses the permission mechanism to enforces restrictions on caller. 我正在Android上编写两个应用程序,该应用程序使用权限机制对呼叫者实施限制。

They works perfectly on Froyo 2.2 or greater, but not on Eclair 2.1. 它们可以在Froyo 2.2或更高版本上完美运行,但不能在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 .... /> . 第一个应用程序(调用者)在清单<uses-permission ... /> ,第二个应用程序(称为)使用<permission .... />定义新的许可。

Someone have the same trouble with Eclair 2.1? 有人对Eclair 2.1遇到同样的麻烦吗?

I'm using for testing on 2.1 only emulator (2.1-update1 and 2.1update1 with google api). 我正在用于仅2.1模拟器(带有Google api的2.1-update1和2.1update1)进行测试。

This is error from logcat: 这是来自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. 当我安装apk时,与在Froyo上不同,没有关于新权限的日志。

The Manifest of apps are: 应用清单显示:

Pkg1 (the caller) Pkg1(呼叫者)

<uses-permission android:name="xy.android.myapp.ACCESS_SERVICE" />

Pkg2 包2

<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. 我已经测试了protectionLevel值:正常,签名和危险。 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. 声明许可的应用需要在使用该许可的应用之前安装,否则即使设置中显示了正确的许可,该应用也会引发异常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM