summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanesh M <daneshm90@gmail.com>2015-08-19 15:43:48 -0700
committerDanesh M <daneshm90@gmail.com>2015-08-19 16:21:56 -0700
commit32b71fc0c0fc940893ecfd353176c56019ee6fdf (patch)
tree5b2144bcc3e0068d279df396329ab9fbcdb29048
parent3bcae23a75fb62ea40750606e8a3fb1d8d325a40 (diff)
downloadandroid_hardware_qcom_fm-32b71fc0c0fc940893ecfd353176c56019ee6fdf.tar.gz
android_hardware_qcom_fm-32b71fc0c0fc940893ecfd353176c56019ee6fdf.tar.bz2
android_hardware_qcom_fm-32b71fc0c0fc940893ecfd353176c56019ee6fdf.zip
FMRadio : Keep track of scanned frequencies in service
By keeping track of scanned frequencies in the service, this allows us to fetch it when the activity is resumed and not rely on having active callbacks. Change-Id: Idea9cab3e5fd2a789333c3f126416e0102613aa8
-rw-r--r--fmapp2/src/com/caf/fmradio/FMRadio.java33
-rw-r--r--fmapp2/src/com/caf/fmradio/FMRadioService.java14
-rw-r--r--fmapp2/src/com/caf/fmradio/IFMRadioService.aidl1
3 files changed, 31 insertions, 17 deletions
diff --git a/fmapp2/src/com/caf/fmradio/FMRadio.java b/fmapp2/src/com/caf/fmradio/FMRadio.java
index 2de2b95..e91d538 100644
--- a/fmapp2/src/com/caf/fmradio/FMRadio.java
+++ b/fmapp2/src/com/caf/fmradio/FMRadio.java
@@ -247,9 +247,6 @@ public class FMRadio extends Activity
private ScrollerText mRadioTextScroller = null;
private ScrollerText mERadioTextScroller = null;
- /* Scanning frequencies */
- ArrayList<Integer> mScannedFrequencies;
-
private PresetStation mTunedStation = new PresetStation("", 102100);
private PresetStation mPresetButtonStation = null;
@@ -520,7 +517,7 @@ public class FMRadio extends Activity
}
try {
if (!mService.isSearchInProgress()) {
- resetSearch();
+ mServiceCallbacks.onSearchComplete();
}
}catch (RemoteException e) {
e.printStackTrace();
@@ -1735,9 +1732,6 @@ public class FMRadio extends Activity
SharedPreferences.Editor editor = sp.edit();
editor.clear();
editor.commit();
- if (mScannedFrequencies != null) {
- mScannedFrequencies.clear();
- }
}
public boolean fmConfigure() {
boolean bStatus = true;
@@ -2072,13 +2066,19 @@ public class FMRadio extends Activity
}
private void saveStations() {
- if (mScannedFrequencies != null && mScannedFrequencies.size() > 0) {
- Collections.sort(mScannedFrequencies);
+ List<Integer> scannedFrequencies = null;
+ try {
+ scannedFrequencies = mService.getScannedFrequencies();
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ if (scannedFrequencies != null && scannedFrequencies.size() > 0) {
+ Collections.sort(scannedFrequencies);
SharedPreferences sp = getSharedPreferences(SCAN_STATION_PREFS_NAME, 0);
SharedPreferences.Editor editor = sp.edit();
int index = 0;
- for (Integer freq : mScannedFrequencies) {
+ for (Integer freq : scannedFrequencies) {
index++;
editor.putString(STATION_NAME + index, index + "");
editor.putInt(STATION_FREQUENCY + index, freq);
@@ -3086,11 +3086,6 @@ public class FMRadio extends Activity
Log.d(LOGTAG, "mServiceCallbacks.onTuneStatusChanged: ");
if (mIsScaning) {
Log.d(LOGTAG, "isScanning....................");
- if (mScannedFrequencies == null) {
- mScannedFrequencies = new ArrayList<Integer>();
- }
-
- mScannedFrequencies.add(FmSharedPreferences.getTunedFrequency());
}
cleanupTimeoutHandler();
mHandler.post(mUpdateStationInfo);
@@ -3117,7 +3112,13 @@ public class FMRadio extends Activity
public void onSearchComplete() {
Log.d(LOGTAG, "mServiceCallbacks.onSearchComplete :");
if (mIsScaning) {
- if (mScannedFrequencies != null && mScannedFrequencies.size() > 0) {
+ List<Integer> scannedFrequencies = null;
+ try {
+ scannedFrequencies = mService.getScannedFrequencies();
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ if (scannedFrequencies != null && !scannedFrequencies.isEmpty()) {
mShowStationList = true;
} else {
mHandler.post(new Runnable() {
diff --git a/fmapp2/src/com/caf/fmradio/FMRadioService.java b/fmapp2/src/com/caf/fmradio/FMRadioService.java
index c90ffd5..4669b06 100644
--- a/fmapp2/src/com/caf/fmradio/FMRadioService.java
+++ b/fmapp2/src/com/caf/fmradio/FMRadioService.java
@@ -134,6 +134,7 @@ public class FMRadioService extends Service
private boolean misAnalogPathEnabled = false;
private boolean mA2dpDisconnected = false;
//PhoneStateListener instances corresponding to each
+ private ArrayList<Integer> mScannedFrequencies = new ArrayList<Integer>();
private FmRxRdsData mFMRxRDSData=null;
// interval after which we stop the service when idle
@@ -1745,6 +1746,9 @@ public class FMRadioService extends Service
public boolean isSearchInProgress() {
return(mService.get().isSearchInProgress());
}
+ public List<Integer> getScannedFrequencies() {
+ return(mService.get().getScannedFrequencies());
+ }
}
private final IBinder mBinder = new ServiceStub(this);
@@ -1979,6 +1983,10 @@ public class FMRadioService extends Service
return(bStatus);
}
+ public List<Integer> getScannedFrequencies() {
+ return mScannedFrequencies;
+ }
+
public boolean isSearchInProgress() {
int state = mReceiver.getFMState();
return state == qcom.fmradio.FmTransceiver.FMState_Srch_InProg;
@@ -2281,6 +2289,8 @@ public class FMRadioService extends Service
*/
public boolean scan(int pty)
{
+ // Clear previously scanned frequencies
+ mScannedFrequencies.clear();
boolean bCommandSent=false;
if (mReceiver != null)
{
@@ -2772,7 +2782,6 @@ public class FMRadioService extends Service
{
Log.d(LOGTAG, "FmRxEvSetSignalThreshold");
}
-
public void FmRxEvRadioTuneStatus(int frequency)
{
Log.d(LOGTAG, "FmRxEvRadioTuneStatus: Tuned Frequency: " +frequency);
@@ -2785,6 +2794,9 @@ public class FMRadioService extends Service
if(mReceiver != null) {
clearStationInfo();
}
+ if (isSearchInProgress()) {
+ mScannedFrequencies.add(frequency);
+ }
if(mCallbacks != null)
{
mCallbacks.onTuneStatusChanged();
diff --git a/fmapp2/src/com/caf/fmradio/IFMRadioService.aidl b/fmapp2/src/com/caf/fmradio/IFMRadioService.aidl
index 3ff3bc6..bd32102 100644
--- a/fmapp2/src/com/caf/fmradio/IFMRadioService.aidl
+++ b/fmapp2/src/com/caf/fmradio/IFMRadioService.aidl
@@ -74,5 +74,6 @@ interface IFMRadioService
boolean isSleepTimerActive();
boolean isSSRInProgress();
boolean isSearchInProgress();
+ List getScannedFrequencies();
}