fm: Handle seek event properly
FM application layer receives wrong frequency
on seek up/down completion. Inform registered
client about seek completion when tune event is
received after seek complete event.
Change-Id: I1f8ecb1f1a35400e99e67987e86577acf85c08e0
CRs-Fixed: 549726
diff --git a/qcom/fmradio/FmReceiver.java b/qcom/fmradio/FmReceiver.java
index 533814b..b1bdb31 100644
--- a/qcom/fmradio/FmReceiver.java
+++ b/qcom/fmradio/FmReceiver.java
@@ -39,7 +39,7 @@
public class FmReceiver extends FmTransceiver
{
- public static int mSearchState = 0;
+ public static int mSearchState = subSrchLevel_NoSearch;
static final int STD_BUF_SIZE = 256;
static final int GRP_3A = 64;
@@ -630,8 +630,14 @@
break;
case subSrchLevel_SrchComplete:
/* Update the state of the FM device */
+ mSearchState = subSrchLevel_NoSearch;
setFMPowerState(FMState_Rx_Turned_On);
break;
+ case subSrchLevel_SrchAbort:
+ break;
+ default:
+ mSearchState = subSrchLevel_NoSearch;
+ break;
}
}
diff --git a/qcom/fmradio/FmRxEventListner.java b/qcom/fmradio/FmRxEventListner.java
index 376e430..f4613e8 100644
--- a/qcom/fmradio/FmRxEventListner.java
+++ b/qcom/fmradio/FmRxEventListner.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009,2012, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2009,2012-2013, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -104,16 +104,26 @@
case 1:
Log.d(TAG, "Got TUNE_EVENT");
freq = FmReceiverJNI.getFreqNative(fd);
- if (freq > 0)
- cb.FmRxEvRadioTuneStatus(freq);
- else
- Log.e(TAG, "get frequency command failed");
+ state = FmReceiver.getSearchState();
+ switch(state) {
+ case FmTransceiver.subSrchLevel_SeekInPrg :
+ Log.v(TAG, "Current state is " + state);
+ FmReceiver.setSearchState(FmTransceiver.subSrchLevel_SrchComplete);
+ Log.v(TAG, "RxEvtList: CURRENT-STATE : Search ---> NEW-STATE : FMRxOn");
+ cb.FmRxEvSearchComplete(freq);
+ break;
+ default:
+ if (freq > 0)
+ cb.FmRxEvRadioTuneStatus(freq);
+ else
+ Log.e(TAG, "get frequency command failed");
+ break;
+ }
break;
case 2:
Log.d(TAG, "Got SEEK_COMPLETE_EVENT");
state = FmReceiver.getSearchState();
switch(state) {
- case FmTransceiver.subSrchLevel_SeekInPrg :
case FmTransceiver.subSrchLevel_ScanInProg:
Log.v(TAG, "Current state is " + state);
FmReceiver.setSearchState(FmTransceiver.subSrchLevel_SrchComplete);
diff --git a/qcom/fmradio/FmTransceiver.java b/qcom/fmradio/FmTransceiver.java
index 8a02c2d..20f0544 100644
--- a/qcom/fmradio/FmTransceiver.java
+++ b/qcom/fmradio/FmTransceiver.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009-2012, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2009-2013, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -57,6 +57,7 @@
* These are the sub-levels of FM Search operations : seek/scan/auto-preset.
* Used internally for distinguishing between the various search operations.
*/
+ public static final int subSrchLevel_NoSearch = -1;
public static final int subSrchLevel_SeekInPrg = 0;
public static final int subSrchLevel_ScanInProg = 1;
public static final int subSrchLevel_SrchListInProg = 2;