Commit 6cc5b333 authored by Sébastien Toque's avatar Sébastien Toque

AudioService: always stay alive + always block headset button events from the OS

it prevent accidental calls on double click
parent ddd3062c
......@@ -108,9 +108,9 @@ public class AudioService extends Service {
}
@Override
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
public int onStartCommand(Intent intent, int flags, int startId) {
updateWidget(this);
return super.onStartCommand(intent, flags, startId);
}
@Override
......@@ -164,10 +164,14 @@ public class AudioService extends Service {
else if (action.equalsIgnoreCase(Intent.ACTION_MEDIA_BUTTON)) {
KeyEvent event = (KeyEvent) intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
TelephonyManager telManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
if (mCurrentMedia == null || event == null ||
telManager.getCallState() != TelephonyManager.CALL_STATE_IDLE)
if (event == null || telManager.getCallState() != TelephonyManager.CALL_STATE_IDLE)
return;
if (mCurrentMedia == null) {
abortBroadcast();
return;
}
switch (event.getKeyCode())
{
/*
......@@ -193,8 +197,6 @@ public class AudioService extends Service {
// double click
} else if (time - mHeadsetUpTime <= 500) {
next();
// block the double click event to prevent android from dialing last number
abortBroadcast();
}
// one click
else {
......@@ -223,6 +225,7 @@ public class AudioService extends Service {
previous();
break;
}
abortBroadcast();
}
/*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment