get rid of READ_PHONE_STATE permission

This permission was only used to autoresume after a call - a feature i always disliked anyway
This commit is contained in:
Adrian Ulrich 2014-04-12 22:10:00 +02:00
parent c7ae9b97b7
commit 98cd32189c
4 changed files with 1 additions and 74 deletions

View File

@ -28,7 +28,6 @@ THE SOFTWARE.
android:installLocation="auto">
<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="16" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<!-- This is needed for isWiredHeadsetOn() to work in some cases. (bug?) -->
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />

View File

@ -32,7 +32,6 @@ import android.media.AudioManager;
import android.net.Uri;
import android.os.Build;
import android.os.SystemClock;
import android.telephony.TelephonyManager;
import android.view.KeyEvent;
/**
@ -51,11 +50,6 @@ public class MediaButtonReceiver extends BroadcastReceiver {
* uninitialized.
*/
private static int sUseControls = -1;
/**
* Whether the phone is currently in a call. 1 for yes, 0 for no, -1 for
* uninitialized.
*/
private static int sInCall = -1;
/**
* Time of the last play/pause click. Used to detect double-clicks.
*/
@ -125,30 +119,6 @@ public class MediaButtonReceiver extends BroadcastReceiver {
return sUseControls == 1;
}
/**
* Return whether the phone is currently in a call.
*
* @param context A context to use.
*/
private static boolean isInCall(Context context)
{
if (sInCall == -1) {
TelephonyManager manager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
sInCall = (byte)(manager.getCallState() == TelephonyManager.CALL_STATE_IDLE ? 0 : 1);
}
return sInCall == 1;
}
/**
* Set the cached value for whether the phone is in a call.
*
* @param value True if in a call, false otherwise.
*/
public static void setInCall(boolean value)
{
sInCall = value ? 1 : 0;
}
/**
* Process a media button key press.
*
@ -159,7 +129,7 @@ public class MediaButtonReceiver extends BroadcastReceiver {
*/
public static boolean processKey(Context context, KeyEvent event)
{
if (event == null || isInCall(context) || !useHeadsetControls(context))
if (event == null || !useHeadsetControls(context))
return false;
int action = event.getAction();

View File

@ -133,7 +133,6 @@ public abstract class PlaybackActivity extends Activity
{
super.onResume();
MediaButtonReceiver.registerMediaButton(this);
MediaButtonReceiver.setInCall(false);
if (PlaybackService.hasInstance()) {
PlaybackService service = PlaybackService.get(this);
service.userActionTriggered();

View File

@ -57,8 +57,6 @@ import android.os.Process;
import android.os.SystemClock;
import android.preference.PreferenceManager;
import android.provider.MediaStore;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.widget.RemoteViews;
import android.widget.Toast;
@ -328,7 +326,6 @@ public final class PlaybackService extends Service
*/
private long mPendingSeekSong;
public Receiver mReceiver;
public InCallListener mCallListener;
private String mErrorMessage;
/**
* Current fade-out progress. 1.0f if we are not fading out
@ -430,14 +427,6 @@ public final class PlaybackService extends Service
PowerManager powerManager = (PowerManager)getSystemService(POWER_SERVICE);
mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "VanillaMusicLock");
try {
mCallListener = new InCallListener();
TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
telephonyManager.listen(mCallListener, PhoneStateListener.LISTEN_CALL_STATE);
} catch (SecurityException e) {
// don't have READ_PHONE_STATE
}
mReceiver = new Receiver();
IntentFilter filter = new IntentFilter();
filter.addAction(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
@ -1288,36 +1277,6 @@ public final class PlaybackService extends Service
}
}
private class InCallListener extends PhoneStateListener {
@Override
public void onCallStateChanged(int state, String incomingNumber)
{
switch (state) {
case TelephonyManager.CALL_STATE_RINGING:
case TelephonyManager.CALL_STATE_OFFHOOK: {
MediaButtonReceiver.setInCall(true);
if (!mPlayingBeforeCall) {
synchronized (mStateLock) {
if (mPlayingBeforeCall = (mState & FLAG_PLAYING) != 0)
unsetFlag(FLAG_PLAYING);
}
}
break;
}
case TelephonyManager.CALL_STATE_IDLE: {
MediaButtonReceiver.setInCall(false);
if (mPlayingBeforeCall) {
setFlag(FLAG_PLAYING);
mPlayingBeforeCall = false;
}
break;
}
}
}
}
public void onMediaChange()
{
if (MediaUtils.isSongAvailable(getContentResolver())) {