AndroidManifest.xml中暗示VS明确权限(使用特征VS用途,权限) [英] AndroidManifest.xml implied vs explicit permissions ( uses-feature vs uses-permission )

查看:221
本文介绍了AndroidManifest.xml中暗示VS明确权限(使用特征VS用途,权限)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序的一些权限,如

 <使用-权限的Andr​​oid:名称=android.permission.CONTROL_LOCATION_UPDATES/>
<使用-权限的Andr​​oid:名称=android.permission.ACCESS_FINE_LOCATION/>
<使用-权限的Andr​​oid:名称=android.permission.ACCESS_MOCK_LOCATION/>
 

和我的怀疑下,他们实际上并没有必要。

根据Android的文件,它们都表示了

 <使用特征
    机器人:名称=android.hardware.location/>
 

是真实的,必须的。

所以,举例来说,如果我拿出三分之二的命令,我所有的A-GPS的相关的调用仍然可以工作在确切的一样吗?

目前并没有真正似乎是对这么多的文学,除了人们重复了Android的文件。

最后,我认为,这意味着Android的:所需=如此的code这么多的元素是限制设备,我可以访问量

 <使用特征
    机器人:名称=android.hardware.location机器人:要求=FALSE/>
 

将开放给应用程序,以更多的设备,我可以使用有条件逻辑的应用程序中,让一些功能来执行。

但我的主要问题是, android.hardware.location 涵盖这么多的&LT的方法;使用-许可/> 功能。没有 android.hardware.location.ACCESS_MOCK_LOCATION android.hardware.location.CONTROL_LOCATION_UPDATES ,只有 android.hardware.location

下面几个假设,但Android开发者文档真的不细说了,只是表明这些独立的使用-权限意味着一个单一的采用特征是必需的。当它一定不是为了需要,我只是想确保我的Andr​​oid SDK中调用具有权限来运行

问题:

1),如果我拿出三分之二的的使用-权限,将我所有的A-GPS相关的调用仍然可以工作完全相同的方式,如果我把所有的个人权限设定?

2)不 android.hardware.location 得到更具体的?我已经看到 android.hardware.location.NETWORK ,但我在这里可以看到所有的可能性?

解决方案
  

所以,举例来说,如果我拿出三分之二的命令,我所有的A-GPS的相关要求仍然有效完全相同的方式?

嗯,三分之二的这三个权限不应该是必要的。 ACCESS_MOCK_LOCATION 无关了GPS,但用自己的模拟位置信息提供者。引用西里尔Mottier

  

请人,请从你的清单之前发布您的应用程序ACCESS_MOCK_LOCATION权限。遗忘使你的业余爱好者。

和常规的SDK应用程序不能持有 CONTROL_LOCATION_UPDATES - 这仅与固件的签名密钥签名或安装固件本身的应用

因此​​,一个正常的SDK应用程序可以删除这两个的生产,并可以删除 CONTROL_LOCATION_UPDATES 的发展。如果你不使用模拟位置提供你的应用程序,你可以删除发展 ACCESS_MOCK_LOCATION 太。最有可能的,你应该从来没有加入这两个权限你的应用程序中的第一位。

这都不是什么关系<使用特征> 虽然

  

我可以使用有条件逻辑的应用程序中,让一些功能来执行。

当然可以。您可以使用 hasSystemFeature() PackageManager 来看看,如果你有 android.hardware.location ,之前困扰处理 LocationManager

  

但我的主要问题是android.hardware.location涵盖这么多的功能。

动词盖是没有意义的我这里来,或者它的范围内,你有方向逆转。 <使用-许可> 元素可能意味着<使用特征> 元素,而不是相反

  

如果我拿出三分之二的这些用途,权限的,将我所有的A-GPS的相关要求仍然有效完全相同的方式,如果我有所有这些不同权限设置?

见上面。

  

我看到android.hardware.location.NETWORK

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

  

我看到android.hardware.location.NETWORK

在对&LT文件;使用特征> http://developer.android.com/guide/topics/manifest/uses-feature-element.html

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.

According to the Android documents, they all imply that

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

is true and required.

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?

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

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.

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

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

questions:

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) 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?

解决方案

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?

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:

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

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.

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.

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.

Absolutely. You can use hasSystemFeature() on PackageManager to see if you have android.hardware.location, before bothering dealing with LocationManager.

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

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.

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?

See above.

I have seen android.hardware.location.NETWORK

You may have seen android.hardware.location.network.

I have seen android.hardware.location.NETWORK

In the documentation for <uses-feature>: http://developer.android.com/guide/topics/manifest/uses-feature-element.html

这篇关于AndroidManifest.xml中暗示VS明确权限(使用特征VS用途,权限)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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