Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Cordova Plugin Media need the READ_PHONE_STATE permission?

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.

like image 969
tehmaestro Avatar asked Oct 23 '16 07:10

tehmaestro


1 Answers

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

like image 182
tehmaestro Avatar answered Oct 05 '22 20:10

tehmaestro