如何确定为什么我的Andr​​oid应用程序需要一定的权限? [英] How do I determine why my Android app requires certain permissions?

查看:107
本文介绍了如何确定为什么我的Andr​​oid应用程序需要一定的权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

比方说,我已经占领了一个Android应用程序开发,我的老板问我,为什么我们的应用程序需要显示给谁买Android Market上的应用程序的用户某些权限。

有没有我可以用它来确定哪些code触发每个权限的任何工具或技巧,这样我就可以弄清楚为什么我们的应用功能需要的权限?我特别感兴趣的是这些权限:


  • 电话呼叫 - 读取手机状态和身份


  • 系统工具 - 检索运行的应用程序 - 允许应用程序检索有关当前和最近运行的任务的信息,可能允许恶意应用程序发现有关其他应用的私密信息


该应用程序是一个GPS跟踪应用程序,这不是显而易见的,为什么可能需要此权限。

这也将有助于了解了为什么可能需要这个权限任何提示,即使你不能告诉我如何直接分析code找出来。


解决方案

下面是我怎么会跟踪这些了。<​​/ P>

第1步 - 找到你的Andr​​oidManifest.xml中声明的清单权限

里面基本上一切&LT;使用许可权/&GT; 标签例如:

 &LT;使用许可权的android:NAME =android.permission.READ_PHONE_STATE/&GT;

第2步 - 搜索developer.android.com对于使用这些权限类

让我们READ_PHONE_STATE的情况下,我们的目标是找出哪些软件包需要此权限。在开发门户网站READ_PHONE_STATE一个简单的搜索开始我们的搜索,我们正在寻找班在这里,前5名的搜索结果我看到了以下类:


  • TelephonyManager

  • PhoneStateListener

点击上了班,并得到他们的包名:


  • android.telephony.TelephonyManager

  • android.telephony.PhoneStateListener

第3步查找您的项目导入这些包中的类

一个简单的grep会做,或在Eclipse中按Ctrl-H,文件搜索 - >包含文字

第四步注释掉进口,看看有什么突破

这些的可能的候选人,为什么需要许可。通过查看开发门户网站,以验证权限确实是由该法要求确认有问题的方法。

最后,你应该能够告诉你的老板,READ_PHONE_STATE因为我们调用函数XYZ这让我们UVW是必需的。

Let's say I have taken over development of an Android app, and my boss asks me why our app requires certain permissions to be displayed to users who buy the app on the Android Market.

Are there any tools or tricks I can use to determine what code triggers each permission, so I can figure out why our app functionally needs those permissions? In particular, I am interested in these permissions:

  • Phone Calls - Read phone status and identity

  • System Tools - Retrieve running applications - Allows app to retrieve information about currently and recently running tasks, May allow malicious apps to discover private information about other apps.

The app is a GPS tracking app, and it's not obvious why this permission might be needed.

It would also be helpful to get any tips on why this permission might be needed, even if you can't tell me how to directly analyze the code to find out.

解决方案

Here is how I would track these down.

Step 1 - Find the manifest permissions declared in your AndroidManifest.xml

Basically everything inside the <uses-permission /> tags e.g.:

<uses-permission android:name="android.permission.READ_PHONE_STATE"/>

Step 2 - Search developer.android.com for classes that use these permissions

Let's take the case of READ_PHONE_STATE, the goal is to find which packages require this permission. A simple search on the dev portal for "READ_PHONE_STATE" starts our search, we are looking for classes here, in the top 5 search results I see the following classes:

  • TelephonyManager
  • PhoneStateListener

Click on the classes and get their package names:

  • android.telephony.TelephonyManager
  • android.telephony.PhoneStateListener

Step 3 Find classes in your project that import these packages

A simple grep will do, or a Ctrl-H in eclipse, File Search -> Containing text

Step 4 Comment out the import and see what breaks

These are likely candidates for why the permission is required. Confirm the methods in question by looking at the dev portal to validate that the permission is indeed required by that method.

Finally you should be able to tell your boss, READ_PHONE_STATE is required because we call function XYZ which gives us UVW.

这篇关于如何确定为什么我的Andr​​oid应用程序需要一定的权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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