Why does Cordova Plugin Media need the READ_PHONE_STATE permission?
Asked Answered
R

1

7

So, why is cordova-plugin-media adding the READ_PHONE_STATE permission?

I found a commit in Chromium https://chromiumcodereview.appspot.com/12480009/ that might be related. It seems the MediiaPlayerListener.java dropped the need for READ_PHONE_STATE permission.

Can we do the same thing with the cordova plugin? Thanks.

Rejoice answered 23/10, 2016 at 7:29 Comment(0)
R
5

I found the answer. It seems cordova plugin media is listening for state changes such as ringing or idle to mute the audio. These events are sent by the cordova-android platform itself by listening to the PhoneStateListener (https://developer.android.com/reference/android/telephony/PhoneStateListener.html) events.

Apparently, up until Android API 22, the READ_PHONE_STATE permission was required for this. For API 23, the permission is not required anymore.

Here's an answer on stackoverflow pointing to the commit in Android that changed this. Since Android 6.0 listening to the PhoneStateListener.LISTEN_DATA_CONNECTION_STATE changes seems to no longer require READ_PHONE_STATE permission

Rejoice answered 23/10, 2016 at 9:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.