Android permissions: Phone Calls: read phone state and identity

前端 未结 2 675
礼貌的吻别
礼貌的吻别 2020-11-27 11:32

My android app has nothing to do with phone calls, but I\'m seeing that when I install a debug build on my test device it requires \"Phone Calls: read phone state and identi

相关标签:
2条回答
  • 2020-11-27 12:13

    Android 1.6 changelog: http://developer.android.com/sdk/android-1.6.html#api

    WRITE_EXTERNAL_STORAGE: Allows an application to write to external storage. Applications using API Level 3 and lower will be implicitly granted this permission (and this will be visible to the user); Applications using API Level 4 or higher must explicitly request this permission.

    But that is only one of them. For some reason the official change log is missing the info about READ_PHONE_STATE. The full story is cleared up here: http://blogs.zdnet.com/Burnette/?p=1369&page=3

    New permissions. 1.6 programs must explicitly request the WRITE_EXTERNAL_STORAGE permission to be able to modify the contents of the SD card, and they must explicitly request the READ_PHONE_STATE permission to be able to be able to retrieve phone state info. Apps targeting earlier versions will always request these permissions implicitly.

    So as you can see, there is no way to publish an app targeted at 1.5 or earlier without requesting those permissions when installed on phones running 1.6 or higher.

    0 讨论(0)
  • 2020-11-27 12:23

    (Answering my own question in case anyone else runs into this problem and searches for it.)

    Digging around in PackageParser.java in the android source, I found out that the system will automatically assign

    android.permission.WRITE_EXTERNAL_STORAGE and 
    android.permission.READ_PHONE_STATE
    

    to any app that declares a targetSdk version of less than 4 (donut). There must be a compatibility reason for this, maybe apps targeting older versions could assume they had these permissions without declaring them explicitly. So, if you don't want these permissions added to your app implicitly, add a section like the following in AndroidManifest.xml

    <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="4" />
    

    That is all.

    Have fun, -Mike

    0 讨论(0)
提交回复
热议问题