Android权限:电话:读取手机状态和身份 [英] Android permissions: Phone Calls: read phone state and identity

查看:4672
本文介绍了Android权限:电话:读取手机状态和身份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Andr​​oid应用程序无关,与电话,但我看到,当我我的测试设备上安装调试版本它需要电话:读取手机状态和身份的权限。 (我没有提到这一点的Andr​​oidManifest.xml )。

My android app has nothing to do with phone calls, but I'm seeing that when I install a debug build on my test device it requires "Phone Calls: read phone state and identity" permissions. (I make no mention of this in AndroidManifest.xml).

我想有可能的最小权限,并想知道是否有人知道如何摆脱呢?我评论了,我是记录从 Build.MODEL Build.VERSION一些东西的一部分。* 等。我也谈到了我在那里检测横向/纵向认为这可能是手机状态的一部分。但无论是那些似乎消除要求的权限。

I'd like to have the minimum possible permissions, and wondered if anyone knew how to get rid of this? I commented out the part where I was logging some stuff from Build.MODEL, Build.VERSION.*, etc. I also commented out the part where I was detecting the landscape/portrait orientation thinking that that might be the "phone state". But neither of those seemed to remove that permission required.

我发现这个错误报告:<一href="http://$c$c.google.com/p/android/issues/detail?id=4101">http://$c$c.google.com/p/android/issues/detail?id=4101但它标志着工作-AS-打算与有关权限是正确的市场,但没有其他的说明。这是其他人的经验吗? (我讨厌不得不发布到市场只是为了测试这一点。)否则,没有人知道是否有一个API,我能避免调用,这将使它所以我的应用程序并不需要这个权限?

I found this bug report: http://code.google.com/p/android/issues/detail?id=4101 but it's marked working-as-intended with a note about permissions being correct from the market but not otherwise. Is this other people's experience? (I'd hate to have to publish to the market just to test that out.) Otherwise, does anyone know if there's an API I can avoid calling that will make it so my app doesn't need this permission?

谢谢!

推荐答案

(回答我的问题,以防别人运行到这个问题,并搜索了。)

(Answering my own question in case anyone else runs into this problem and searches for it.)

在Android源周围挖在PackageParser.java,我发现,该系统会自动分配

Digging around in PackageParser.java in the android source, I found out that the system will automatically assign

android.permission.WRITE_EXTERNAL_STORAGE and 
android.permission.READ_PHONE_STATE

任何应用程序,声明了targetSdk版本小于4(甜甜圈)。必须有一个兼容性的原因,也许是应用程序针对旧版本可以假设他们有没有明确声明他们这些权限。所以,如果你不想添加到您的应用程序这些权限含蓄,添加部分像在AndroidManifest.xml中以下

to any app that declares a targetSdk version of less than 4 (donut). There must be a compatibility reason for this, maybe apps targeting older versions could assume they had these permissions without declaring them explicitly. So, if you don't want these permissions added to your app implicitly, add a section like the following in AndroidManifest.xml

<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="4" />

这就是一切。

That is all.

玩得开心,-Mike

Have fun, -Mike

这篇关于Android权限:电话:读取手机状态和身份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆