AndroidManifest.xml 隐含与显式权限( uses-feature 与 uses-permission ) [英] AndroidManifest.xml implied vs explicit permissions ( uses-feature vs uses-permission )

查看:19
本文介绍了AndroidManifest.xml 隐含与显式权限( uses-feature 与 uses-permission )的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用中有一些权限,例如

I have some permissions in my app such as

<uses-permission android:name="android.permission.CONTROL_LOCATION_UPDATES" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />

我怀疑它们实际上没有必要.

and I am under the suspicion that they aren't actually necessary.

根据Android文档,它们都暗示

According to the Android documents, they all imply that

<uses-feature
    android:name="android.hardware.location"/>

是正确的并且是必需的.

is true and required.

因此,例如,如果我取出了其中三个命令中的两个,我所有与 A-GPS 相关的调用仍将完全以相同的方式工作吗?

so, for instance, if I took out two out of three of those commands, all of my A-GPS related calls will still work the exact same way?

除了人们重复 android 文档之外,似乎没有太多关于此的文献.

There doesn't really seem to be much literature about this, except for people repeating the android documents.

最终,我认为对这么多代码元素暗示 android:required = true 会限制我可以访问的设备数量.

Ultimately, I think that implying that android:required = true for so many elements of the code is limiting the amount of devices I can access.

 <uses-feature
    android:name="android.hardware.location" android:required="false"/>

将向更多设备开放应用程序,我可以在应用程序中使用条件逻辑来允许执行某些功能.

will open up to the app to many more devices, and I can use conditionally logic within the app to allow some features to execute.

但我的主要问题是 android.hardware.location 涵盖了很多 <uses-permission/> 功能.没有 android.hardware.location.ACCESS_MOCK_LOCATIONandroid.hardware.location.CONTROL_LOCATION_UPDATES ,只有 android.hardware.location

But my main problem is that android.hardware.location covers SO many of the <uses-permission/> features. There is no android.hardware.location.ACCESS_MOCK_LOCATION or android.hardware.location.CONTROL_LOCATION_UPDATES , only android.hardware.location

这里有几个假设,但 android 开发人员文档并没有详细说明,只是表明那些单独的 uses-permissions 暗示需要一个单独的 uses-feature.当它不一定是必需的,我只是想确保我的 android sdk 调用有权运行

a couple assumptions here, but the android developer documents really don't elaborate, except reveal that those separate uses-permissions imply that one single uses-feature is required. when it necessarily is not intended to be required and I just want to make sure my android sdk calls have permission to run

问题:

1) 如果我取出其中三个 uses-permissions 中的两个,那么我所有与 A-GPS 相关的调用是否仍会像我拥有所有这些个人一样以完全相同的方式工作权限设置?

1) if I took out two out of three of those uses-permissions, would all of my A-GPS related calls will still work the exact same way as if I had all of those individual permissions set?

2) android.hardware.location 是否更具体?我见过 android.hardware.location.NETWORK 但我在哪里可以看到所有的可能性?

2) does android.hardware.location get more specific? I have seen android.hardware.location.NETWORK but where can I see what all of the possibilities are?

推荐答案

因此,例如,如果我取出了其中三个命令中的两个,我所有与 A-GPS 相关的调用仍将以完全相同的方式工作吗?

so, for instance, if I took out two out of three of those commands, all of my A-GPS related calls will still work the exact same way?

嗯,这三个权限中的两个应该不是必需的.ACCESS_MOCK_LOCATION 与 GPS 无关,而是与您自己的模拟位置提供商有关.引用 Cyril Mottier:

Well, two out of those three permissions should not be necessary. ACCESS_MOCK_LOCATION has nothing to do with GPS, but with your own mock location provider. To quote Cyril Mottier:

请大家在发布应用之前从清单中删除 ACCESS_MOCK_LOCATION 权限.忘记会让你成为业余爱好者.

Please guys, remove the ACCESS_MOCK_LOCATION permission from your manifest prior publishing your app. Forgetting makes you an amateur.

而普通的 SDK 应用程序不能保存 CONTROL_LOCATION_UPDATES -- 这仅适用于使用固件签名密钥签名或安装在固件本身中的应用程序.

And normal SDK apps cannot hold CONTROL_LOCATION_UPDATES -- that is only available to apps signed with the firmware's signing key or installed in the firmware itself.

因此,一个普通的 SDK 应用程序可以删除这两个用于生产,并可以删除 CONTROL_LOCATION_UPDATES 用于开发.如果您没有在您的应用程序中使用模拟位置提供程序,您也可以在开发中删除 ACCESS_MOCK_LOCATION.很可能,您一开始就不应该将这两个权限添加到您的应用中.

Hence, a normal SDK app can remove both of those for production, and can remove CONTROL_LOCATION_UPDATES for development. If you are not using mock location providers in your app, you can remove ACCESS_MOCK_LOCATION in development too. Most likely, you should have never added those two permissions to your app in the first place.

不过,这些都与 <uses-feature> 无关.

None of this has anything to do with <uses-feature> though.

我可以在应用程序中使用条件逻辑来允许执行某些功能.

I can use conditionally logic within the app to allow some features to execute.

当然.在处理 LocationManager.

但我的主要问题是 android.hardware.location 涵盖了很多功能.

But my main problem is that android.hardware.location covers SO many of the features.

动词cover"在这里对我来说毫无意义,或者在某种程度上,你的方向颠倒了. 元素可能暗示 元素,但不能反过来.

The verb "cover" makes no sense here to me, or to the extent it does, you have the direction reversed. <uses-permission> elements may imply <uses-feature> elements, but not the reverse.

如果我取消了其中三个使用权限中的两个,我的所有 A-GPS 相关调用是否仍会像我设置了所有这些单独的权限一样工作?

if I took out two out of three of those uses-permissions, would all of my A-GPS related calls will still work the exact same way as if I had all of those individual permissions set?

见上文.

我见过android.hardware.location.NETWORK

I have seen android.hardware.location.NETWORK

您可能已经看过 android.hardware.location.network.

我见过android.hardware.location.NETWORK

I have seen android.hardware.location.NETWORK

<uses-feature> 的文档中:http://developer.android.com/guide/topics/manifest/uses-feature-element.html

这篇关于AndroidManifest.xml 隐含与显式权限( uses-feature 与 uses-permission )的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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