在哪里可以找到有关android特定权限的更多信息 [英] Where can I find more info about android specific permissions

查看:93
本文介绍了在哪里可以找到有关android特定权限的更多信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从minSdkVersion ="19"升级旧的Android应用程序,因此我需要处理所有权限.

I need to upgrade old android aplication from minSdkVersion="19" , so I need to handle all the permissions.

在清单中,它需要一些危险的权限.例如:

In the manifest, it requires some dangerous permissions. e.g.:

<uses-permission android:name="android.permission.BLUETOOTH" /> <!-- normal -->
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <!-- normal -->
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <!-- normal -->

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <!-- dangerous -->
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" /> <!-- ??? -->
<uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- normal -->
<uses-permission android:name="android.permission.INTERNET" /> <!-- normal -->
<uses-permission android:name="android.permission.VIBRATE" /> <!-- normal -->
<uses-permission android:name="android.permission.CAMERA" /> <!-- dangerous -->

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <!-- dangerous -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <!-- dangerous -->

<android:uses-permission android:name="android.permission.READ_PHONE_STATE" /> <!-- dangerous -->
<android:uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"  android:maxSdkVersion="18" /> <!-- dangerous -->

  1. 如何在代码中找到需要这些危险权限的地方?是否有取决于每个权限的功能列表?

  1. How can I find in code where these dangerous permissions are needed? Is there a list of functions that depends on each permission?

关于 MOUNT_UNMOUNT_FILESYSTEMS -在哪里可以找到它是危险的还是正常的?

Regarding MOUNT_UNMOUNT_FILESYSTEMS - where can I find if it is dangerous or normal?

推荐答案

在回答具体问题之前,我要说一下,如果普通用户将使用您的应用程序(即从Google Play或其他商店下载该应用程序),那么许多权限可能会吓跑用户.从这个问题看来,您好像继承了别人的代码,甚至不需要其中的某些权限.

Before answering the specific questions, let me say that if your app is to be used by normal users (i.e. download it from Google play or other stores) listing so many permissions will probably scare users away. From the question it sounds like you inherit someone else's code, and some of those permissions are not even needed.

这里要注意的另一重要事项是第三方应用程序(例如,您从Google Play商店下载的应用程序)与电话制造商的应用程序(购买时安装在手机上的大多数应用程序)之间的区别.

Another important thing to notice here is the difference between 3rd party apps (for example, apps you download from Google's play store) and phone-manufacturer apps (most of the apps installed on your phone when you buy it).

制造商应用可以使用第三方不能使用的权限.

Manufacturer apps can use permissions that 3rd parties can't.

对您的问题:

  1. 我不记得所有具有所需权限的功能的完整列表.也许其他人可以在这里启发我们两个人:)面向Android M及更高版本的代码应使用 ContextCompat.checkSelfPermission(Context,String)之类的函数包装所有危险"行为,并检查是否已授予权限,以避免运行时 SecurityException s.但是在旧代码中发现危险"行为几乎是不可能的,主要是因为Android OS与开发人员的协议是您只需要在清单中请求这些权限,并且我将确保不会抛出运行时安全异常".恐怕这里需要手动搜索.

  1. I don't recall a complete list for functionalities with needed permission for each. Maybe someone else can enlighten both of us here :) Code targeting Android M and above SHOULD wrap any "dangerous" behaviour with a check that permission is granted, using functions like ContextCompat.checkSelfPermission(Context, String) in order to avoid runtime SecurityExceptions. But finding "dangerous" behaviors in old code is almost impossible, mainly because Android OS's agreement with the developers was "you just request those permissions in the manifest and I will make sure no runtime security exceptions will be thrown". A manual search is in need here, I'm afraid.

这是来自Android官方文档的所有可用权限的完整列表-

Here is a complete list of all available permissions, from Android official documentation -

https://developer.android.com/reference/android/Manifest.permission

请注意,第三方应用程序会忽略MOUNT_UNMOUNT_FILESYSTEM权限,因此(除非您为Samsung或Xiaomi工作),您可以从清单中安全删除此权限.

Notice that MOUNT_UNMOUNT_FILESYSTEM permission is ignored for 3rd party apps, so (unless you work for e.g. Samsung or Xiaomi) you can safely delete this permission from your manifest.

  1. 还请注意,如果您请求FINE_LOCATION权限,则无需同时请求COARSE_LOCATION权限.

这篇关于在哪里可以找到有关android特定权限的更多信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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