Skip to content
Snippets Groups Projects
Commit cd9ddcdb authored by Kamal Negi's avatar Kamal Negi Committed by Gerrit - the friendly Code Review server
Browse files

fm: Resume FM after telephony state become idle

On call disconnection, AUDIOFOCUS_GAIN received before telephony state
intent and telephony state update happens after audio focus gain. Hence
FM turn on won't happen.
Turn on FM if telephony intent received or rety once after
100ms.

Change-Id: I6bdc7f13afd024be8d3428c83f7117277affc45f
parent 7a8bc3ff
No related branches found
No related tags found
No related merge requests found
...@@ -1449,31 +1449,33 @@ public class FMRadioService extends Service ...@@ -1449,31 +1449,33 @@ public class FMRadioService extends Service
resolver.insert(uri, values); resolver.insert(uri, values);
} }
private void resumeAfterCall() { Runnable resumeAfterCall = new Runnable() {
if (getCallState() != TelephonyManager.CALL_STATE_IDLE) public void run() {
return; if (getCallState() != TelephonyManager.CALL_STATE_IDLE)
// start playing again
if (!mResumeAfterCall)
return;
// resume playback only if FM Radio was playing
// when the call was answered
if (isAntennaAvailable() && (!isFmOn()) && mServiceInUse) {
Log.d(LOGTAG, "Resuming after call:");
if(!fmOn()) {
return; return;
}
mResumeAfterCall = false; // start playing again
if (mCallbacks != null) { if (!mResumeAfterCall)
try { return;
mCallbacks.onEnabled();
} catch (RemoteException e) { // resume playback only if FM Radio was playing
e.printStackTrace(); // when the call was answered
if (isAntennaAvailable() && (!isFmOn()) && mServiceInUse) {
Log.d(LOGTAG, "Resuming after call:");
if(!fmOn()) {
return;
}
mResumeAfterCall = false;
if (mCallbacks != null) {
try {
mCallbacks.onEnabled();
} catch (RemoteException e) {
e.printStackTrace();
}
} }
} }
} }
} };
private void fmActionOnCallState( int state ) { private void fmActionOnCallState( int state ) {
//if Call Status is non IDLE we need to Mute FM as well stop recording if //if Call Status is non IDLE we need to Mute FM as well stop recording if
...@@ -1623,7 +1625,11 @@ public class FMRadioService extends Service ...@@ -1623,7 +1625,11 @@ public class FMRadioService extends Service
mStoppedOnFocusLoss = false; mStoppedOnFocusLoss = false;
if (mResumeAfterCall) { if (mResumeAfterCall) {
Log.v(LOGTAG, "resumeAfterCall"); Log.v(LOGTAG, "resumeAfterCall");
resumeAfterCall(); if (getCallState() != TelephonyManager.CALL_STATE_IDLE) {
mHandler.postDelayed(resumeAfterCall, 100);
return;
}
mHandler.post(resumeAfterCall);
break; break;
} }
if(false == mPlaybackInProgress) if(false == mPlaybackInProgress)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment