Skip to content
Snippets Groups Projects
Commit 7a8bc3ff authored by CNSS_WLAN Service's avatar CNSS_WLAN Service Committed by Gerrit - the friendly Code Review server
Browse files

Merge "fm: wait for enable event to complete" into fm.lnx.2.1-dev

parents 2b9ceb84 6c3e689d
No related branches found
No related tags found
No related merge requests found
......@@ -224,6 +224,7 @@ public class FMRadioService extends Service
private static Object mNotchFilterLock = new Object();
private boolean mFmA2dpDisabled;
private boolean mEventReceived = false;
public FMRadioService() {
}
......@@ -2124,6 +2125,27 @@ public class FMRadioService extends Service
misAnalogPathEnabled = analogMode;
return true;
}
private boolean waitForEvent() {
boolean status = false;
synchronized (mEventWaitLock) {
Log.d(LOGTAG, "waiting for event");
try {
if (mEventReceived == false)
mEventWaitLock.wait(RADIO_TIMEOUT);
if (mEventReceived == true)
status = true;
} catch (IllegalMonitorStateException e) {
Log.e(LOGTAG, "Exception caught while waiting for event");
e.printStackTrace();
} catch (InterruptedException ex) {
Log.e(LOGTAG, "Exception caught while waiting for event");
ex.printStackTrace();
}
}
return status;
}
/*
* Turn ON FM: Powers up FM hardware, and initializes the FM module
* .
......@@ -2165,7 +2187,12 @@ public class FMRadioService extends Service
Log.d(LOGTAG, "fmOn: RdsStd :"+ config.getRdsStd());
Log.d(LOGTAG, "fmOn: LowerLimit :"+ config.getLowerLimit());
Log.d(LOGTAG, "fmOn: UpperLimit :"+ config.getUpperLimit());
mEventReceived = false;
bStatus = mReceiver.enable(FmSharedPreferences.getFMConfiguration(), this);
if (mReceiver.isCherokeeChip()) {
bStatus = waitForEvent();
}
if (isSpeakerEnabled()) {
setAudioPath(false);
} else {
......@@ -2325,21 +2352,6 @@ public class FMRadioService extends Service
if (mReceiver != null)
{
bStatus = mReceiver.disable(this);
if (bStatus &&
(mReceiver.getFMState() == mReceiver.subPwrLevel_FMTurning_Off)) {
synchronized (mEventWaitLock) {
Log.d(LOGTAG, "waiting for disable event");
try {
mEventWaitLock.wait(RADIO_TIMEOUT);
} catch (IllegalMonitorStateException e) {
Log.e(LOGTAG, "Exception caught while waiting for event");
e.printStackTrace();
} catch (InterruptedException ex) {
Log.e(LOGTAG, "Exception caught while waiting for event");
ex.printStackTrace();
}
}
}
mReceiver = null;
}
fmOperationsOff();
......@@ -2362,21 +2374,11 @@ public class FMRadioService extends Service
// This will disable the FM radio device
if (mReceiver != null)
{
mEventReceived = false;
bStatus = mReceiver.disable(this);
if (bStatus &&
(mReceiver.getFMState() == mReceiver.subPwrLevel_FMTurning_Off)) {
synchronized (mEventWaitLock) {
Log.d(LOGTAG, "waiting for disable event");
try {
mEventWaitLock.wait(RADIO_TIMEOUT);
} catch (IllegalMonitorStateException e) {
Log.e(LOGTAG, "Exception caught while waiting for event");
e.printStackTrace();
} catch (InterruptedException ex) {
Log.e(LOGTAG, "Exception caught while waiting for event");
ex.printStackTrace();
}
}
bStatus = waitForEvent();
}
mReceiver = null;
}
......@@ -3125,14 +3127,23 @@ public class FMRadioService extends Service
public void FmRxEvEnableReceiver() {
Log.d(LOGTAG, "FmRxEvEnableReceiver");
mReceiver.setRawRdsGrpMask();
if (mReceiver != null && mReceiver.isCherokeeChip()) {
synchronized(mEventWaitLock) {
mEventReceived = true;
mEventWaitLock.notify();
}
}
}
public void FmRxEvDisableReceiver()
{
Log.d(LOGTAG, "FmRxEvDisableReceiver");
mFMOn = false;
FmSharedPreferences.clearTags();
synchronized (mEventWaitLock) {
mEventWaitLock.notify();
if (mReceiver != null && mReceiver.isCherokeeChip()) {
synchronized (mEventWaitLock) {
mEventReceived = true;
mEventWaitLock.notify();
}
}
}
public void FmRxEvRadioReset()
......
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