How do I determine why my Android app requires certain permissions?

前端 未结 4 1569
执念已碎
执念已碎 2021-01-05 01:25

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 Andr

4条回答
  •  醉话见心
    2021-01-05 01:39

    Here is how I would track these down.

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

    Basically everything inside the tags e.g.:

    
    

    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.

提交回复
热议问题