Since Android 6.0 listening to the PhoneStateListener.LISTEN_DATA_CONNECTION_STATE changes seems to no longer require READ_PHONE_STATE permission

前端 未结 2 689
梦毁少年i
梦毁少年i 2021-02-08 18:37

I\'m applying Android 6.0 runtime permissions into an app which listens to carrier data connection state changes. I first tried to just remove the READ_PHONE_STATE from the mani

2条回答
  •  孤独总比滥情好
    2021-02-08 19:26

    Is there any way to confirm this?

    Yes, this commit removes the request of READ_PHONE_STATE when register the event type LISTEN_CALL_STATE, LISTEN_DATA_ACTIVITY and LISTEN_DATA_CONNECTION_STATE:

    Do not enforce PHONE_STATE_PERMISSION to register listener PHONE_STATE_PERMISSION should not be required to register to the following event types:
    - PhoneStateListener.LISTEN_CALL_STATE
    - PhoneStateListener.LISTEN_DATA_ACTIVITY
    - PhoneStateListener.LISTEN_DATA_CONNECTION_STATE
    
    In case of LISTEN_CALL_STATE, an empty string should be passed instead of incomingNumber, when caller has no PHONE_STATE_PERMISSION.
    
    Bug: 21588537 Change-Id: I5b6d0308924f7e4cd13a983b8e0c9b3a5bbb119b
    

    The documentation on developer.android.com was updated and correctly shows that the permission are not required.

    If your code doesn't need the permission READ_PHONE_STATE for other reason apart from LISTEN_DATA_CONNECTION_STATE you can change your AndroidManifest.xml adding maxSdkVersion to the uses-permission:

    
    

提交回复
热议问题