summaryrefslogtreecommitdiffstats
path: root/fmapp2/src
diff options
context:
space:
mode:
authorDanesh M <daneshm90@gmail.com>2015-08-19 15:43:48 -0700
committerMatt Wagantall <mwagantall@cyngn.com>2016-02-19 14:07:46 -0800
commita3161fd824e8360e0ba9d383b75710f8bb6c7ff4 (patch)
tree373a5ea5431253fb8410bcd66e8b881efc9536e7 /fmapp2/src
parent41493306dba00e1ba5ae0e5a0589e9927e3f55c2 (diff)
downloadandroid_hardware_qcom_fm-a3161fd824e8360e0ba9d383b75710f8bb6c7ff4.tar.gz
android_hardware_qcom_fm-a3161fd824e8360e0ba9d383b75710f8bb6c7ff4.tar.bz2
android_hardware_qcom_fm-a3161fd824e8360e0ba9d383b75710f8bb6c7ff4.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
Diffstat (limited to 'fmapp2/src')
-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 d26a0cd..acccc9e 100644
--- a/fmapp2/src/com/caf/fmradio/FMRadio.java
+++ b/fmapp2/src/com/caf/fmradio/FMRadio.java
@@ -248,9 +248,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;
@@ -522,7 +519,7 @@ public class FMRadio extends Activity
}
try {
if (!mService.isSearchInProgress()) {
- resetSearch();
+ mServiceCallbacks.onSearchComplete();
}
}catch (RemoteException e) {
e.printStackTrace();
@@ -1741,9 +1738,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;
@@ -2116,13 +2110,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);
@@ -3149,11 +3149,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);
@@ -3180,7 +3175,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 d8c0fea..d19af3a 100644
--- a/fmapp2/src/com/caf/fmradio/FMRadioService.java
+++ b/fmapp2/src/com/caf/fmradio/FMRadioService.java
@@ -147,6 +147,7 @@ public class FMRadioService extends Service
private boolean mA2dpDisconnected = false;
private boolean mA2dpConnected = 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
@@ -1981,6 +1982,9 @@ public class FMRadioService extends Service
{
return(mService.get().isSearchInProgress());
}
+ public List<Integer> getScannedFrequencies() {
+ return(mService.get().getScannedFrequencies());
+ }
}
private final IBinder mBinder = new ServiceStub(this);
@@ -2213,6 +2217,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;
@@ -2486,6 +2494,8 @@ public class FMRadioService extends Service
*/
public boolean scan(int pty)
{
+ // Clear previously scanned frequencies
+ mScannedFrequencies.clear();
boolean bCommandSent=false;
if (mReceiver != null)
{
@@ -2983,7 +2993,6 @@ public class FMRadioService extends Service
{
Log.d(LOGTAG, "FmRxEvSetSignalThreshold");
}
-
public void FmRxEvRadioTuneStatus(int frequency)
{
Log.d(LOGTAG, "FmRxEvRadioTuneStatus: Tuned Frequency: " +frequency);
@@ -2996,6 +3005,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 0b26459..48c2039 100644
--- a/fmapp2/src/com/caf/fmradio/IFMRadioService.aidl
+++ b/fmapp2/src/com/caf/fmradio/IFMRadioService.aidl
@@ -76,5 +76,6 @@ interface IFMRadioService
boolean isRtPlusSupported();
boolean isA2DPConnected();
boolean isSearchInProgress();
+ List getScannedFrequencies();
}