summaryrefslogtreecommitdiffstats
path: root/fmapp
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2013-07-23 13:09:22 -0700
committerGerrit - the friendly Code Review server <code-review@localhost>2013-07-23 13:09:22 -0700
commitb6e25e2179d777664baa39b854f19437acba03e7 (patch)
treeebb06dde68ea77071f773f32cded44ffbea77f8e /fmapp
parentf6e06b911452c2c59a900ff69cff670fb8f1759d (diff)
parent154037c8bc09283b834634b244db33c803ef1d1a (diff)
downloadandroid_hardware_qcom_fm-b6e25e2179d777664baa39b854f19437acba03e7.tar.gz
android_hardware_qcom_fm-b6e25e2179d777664baa39b854f19437acba03e7.tar.bz2
android_hardware_qcom_fm-b6e25e2179d777664baa39b854f19437acba03e7.zip
Merge "FM: Added support for configurable FM band sweep"
Diffstat (limited to 'fmapp')
-rw-r--r--fmapp/res/layout/band_sweep_setting.xml90
-rw-r--r--fmapp/res/layout/fmstats.xml11
-rw-r--r--fmapp/res/values/arrays.xml20
-rw-r--r--fmapp/res/values/strings.xml13
-rw-r--r--fmapp/src/com/codeaurora/fmradio/FMStats.java1094
-rw-r--r--fmapp/src/com/codeaurora/fmradio/FmSharedPreferences.java53
-rw-r--r--fmapp/src/com/codeaurora/fmradio/Settings.java666
7 files changed, 1219 insertions, 728 deletions
diff --git a/fmapp/res/layout/band_sweep_setting.xml b/fmapp/res/layout/band_sweep_setting.xml
new file mode 100644
index 0000000..777332c
--- /dev/null
+++ b/fmapp/res/layout/band_sweep_setting.xml
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (c) 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:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of The Linux Foundation nor
+ * the names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+-->
+
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:scrollbars="vertical"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content">
+
+ <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_gravity="center_horizontal"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent">
+
+ <TextView
+ android:id="@+id/lbl_band_sweep_spinner"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:textSize="15sp"
+ android:text="@string/band_sweep_choose"/>
+
+ <Spinner
+ android:id="@+id/band_sweep_spinner"
+ android:layout_width="fill_parent"
+ android:layout_height="75dp"
+ android:layout_below="@id/lbl_band_sweep_spinner"
+ android:prompt="@string/band_method_prompt"
+ android:textSize="25sp"/>
+
+ <TextView
+ android:id="@+id/LabelStartdelay"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:textSize="15sp"
+ android:layout_below="@id/band_sweep_spinner"
+ android:text="@string/enter_start_delay_time"/>
+
+ <EditText
+ android:id="@+id/txtboxDelayTime"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:textSize="15sp"
+ android:inputType="number"
+ android:layout_toRightOf="@id/LabelStartdelay"/>
+
+ <TextView
+ android:id="@+id/LabelDwellTime"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:textSize="15sp"
+ android:layout_below="@id/LabelStartdelay"
+ android:text="@string/enter_dwell_time"/>
+
+ <EditText
+ android:id="@+id/txtboxDwellTime"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:textSize="15sp"
+ android:inputType="number"
+ android:layout_toRightOf="@id/LabelDwellTime"/>
+
+ </LinearLayout>
+
+</ScrollView>
diff --git a/fmapp/res/layout/fmstats.xml b/fmapp/res/layout/fmstats.xml
index 2501a51..1cf8023 100644
--- a/fmapp/res/layout/fmstats.xml
+++ b/fmapp/res/layout/fmstats.xml
@@ -50,9 +50,18 @@
<Button
android:id= "@+id/Runbutton"
- android:text="@string/test_run"
+ android:text="@string/band_sweep_setting"
android:layout_width="wrap_content"
android:layout_height="100dp"
+ android:textSize="25dp"
+ android:visibility="gone"/>
+
+ <TextView
+ android:id= "@+id/BandSweepSetting"
+ android:text="@string/band_sweep_setting"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_toRightOf="@id/Runbutton"
android:textSize="25sp"
android:visibility="gone"/>
diff --git a/fmapp/res/values/arrays.xml b/fmapp/res/values/arrays.xml
index d7904be..c453c6a 100644
--- a/fmapp/res/values/arrays.xml
+++ b/fmapp/res/values/arrays.xml
@@ -243,6 +243,7 @@
<item>Turkey</item>
<item>United Kingdom </item>
<item>United States</item>
+ <item>User Defined Band</item>
</string-array>
<string-array name="regional_band_values">
@@ -282,6 +283,7 @@
<item>33</item>
<item>34</item>
<item>35</item>
+ <item>36</item>
</string-array>
<string-array name="regional_band_summary">
@@ -321,6 +323,7 @@
<item>Turkey (87.5MHz To 108.0MHz In 100 Khz Steps)</item>
<item>United Kingdom (87.5MHz To 108.0MHz In 100 Khz Steps)</item>
<item>United States (88.1MHz To 107.9MHz In 200 Khz Steps)</item>
+ <item>User Defined Band</item>
</string-array>
<string-array name="rf_cfg">
@@ -368,4 +371,21 @@
<item> RF Statistics</item>
</string-array>
+ <string-array name="channel_spacing_val">
+ <item>2</item>
+ <item>1</item>
+ <item>0</item>
+ </string-array>
+
+ <string-array name="channel_spacing_entries">
+ <item>50 Khz</item>
+ <item>100 Khz</item>
+ <item>200 Khz</item>
+ </string-array>
+
+ <string-array name="band_sweep_methods">
+ <item>Manual</item>
+ <item>From File</item>
+ </string-array>
+
</resources>
diff --git a/fmapp/res/values/strings.xml b/fmapp/res/values/strings.xml
index f293047..995ae04 100644
--- a/fmapp/res/values/strings.xml
+++ b/fmapp/res/values/strings.xml
@@ -263,4 +263,17 @@
<string name="set_RxRePeatCount">Config RxRePeat count</string>
<string name="save_record_file">FM Recorded file saved to "<xliff:g id="record_file">%1$s</xliff:g>"</string>
+ <string name="usr_def_band_min">Lower Freq Limit(In Mhz)</string>
+ <string name="usr_def_band_max">Higher Freq Limit(In Mhz)</string>
+ <string name="sel_chanl_spacing">Select Channel Spacing</string>
+ <string name="chanl_spacing">Channel Spacing</string>
+
+ <string name="band_method_prompt">Select Method</string>
+ <string name="enter_start_delay_time">Start Delay Time</string>
+ <string name="enter_dwell_time">Dwell Time</string>
+ <string name="band_sweep_setting">Sweep Setting</string>
+ <string name="band_sweep_setting_set">Set</string>
+ <string name="band_sweep_setting_cancel">Cancel</string>
+ <string name="band_sweep_choose">Choose Band Sweep Method</string>
+
</resources>
diff --git a/fmapp/src/com/codeaurora/fmradio/FMStats.java b/fmapp/src/com/codeaurora/fmradio/FMStats.java
index 00cd56f..147afc1 100644
--- a/fmapp/src/com/codeaurora/fmradio/FMStats.java
+++ b/fmapp/src/com/codeaurora/fmradio/FMStats.java
@@ -55,6 +55,10 @@ import android.widget.TextView;
import android.widget.AdapterView.OnItemSelectedListener;
import qcom.fmradio.FmReceiver;
import android.os.SystemProperties;
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.view.LayoutInflater;
+import android.content.DialogInterface;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
@@ -62,7 +66,8 @@ import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.HashMap;
import android.os.SystemProperties;
-
+import java.io.BufferedReader;
+import java.io.FileReader;
public class FMStats extends Activity {
@@ -77,12 +82,13 @@ public class FMStats extends Activity {
private FmReceiver mReceiver;
+ TextView bandSweepSettingButton;
+
/*Data structure for band*/
private class Band {
-
- public int lFreq;
- public int hFreq;
- public int Spacing;
+ public int lFreq;
+ public int hFreq;
+ public int Spacing;
}
/* Data structure for Result*/
private class Result {
@@ -141,47 +147,51 @@ public class FMStats extends Activity {
public String getSINR() {
return mSINR;
}
-
};
/*constant column header*/
Result mColumnHeader = new Result();
boolean mTestRunning = false;
- FmRfItemSelectedListener mSpinFmRfListener = new FmRfItemSelectedListener();
- RfCfgItemSelectedListener mSpinRfCfgListener = new RfCfgItemSelectedListener();
+ FmRfItemSelectedListener mSpinFmRfListener =
+ new FmRfItemSelectedListener();
+ RfCfgItemSelectedListener mSpinRfCfgListener =
+ new RfCfgItemSelectedListener();
CfgRfItemSelectedListener1 mSpinCfgRfListener1 = null;
CfgRfItemSelectedListener2 mSpinCfgRfListener2 = null;
-
+ BandSweepMthdsSelectedListener mSweepMthdsListener =
+ new BandSweepMthdsSelectedListener();
int mTestSelected = 0;
boolean mIsSearching = false;
private static String LOGTAG = "FMStats";
private static IFMRadioService mService = null;
- private Thread mMultiUpdateThread =null;
- private static final int STATUS_UPDATE =1;
- private static final int STATUS_DONE =2;
- private static final int STOP_ROW_ID =200;
+ private Thread mMultiUpdateThread = null;
+ private static final int STATUS_UPDATE = 1;
+ private static final int STATUS_DONE = 2;
+ private static final int STOP_ROW_ID = 200;
private static final int NEW_ROW_ID = 300;
private int mStopIds = STOP_ROW_ID;
private int mNewRowIds = NEW_ROW_ID;
private static final int SCAN_DWELL_PERIOD = 1;
- private static final int CUR_FREQ_TEST =0;
+ private static final int CUR_FREQ_TEST = 0;
private static final int CUR_MULTI_TEST = 1;
private static final int SEARCH_TEST =2;
- private static final int SWEEP_TEST =3;
- private Band mBand =null;
+ private static final int SWEEP_TEST = 3;
+ private Band mBand = null;
private Band mSync = null;
int Lo = 1, Auto = 0;
- private FileOutputStream mFileCursor =null;
+ private FileOutputStream mFileCursor = null;
private String mCurrentFileName = null;
Spinner spinOptionFmRf;
+ Spinner spinOptionBandSweepMthds;
ArrayAdapter<CharSequence> adaptCfgRf;
ArrayAdapter<CharSequence> adaptRfCfg;
ArrayAdapter<CharSequence> adaptFmRf;
+ ArrayAdapter<CharSequence> bandSweepMthds;
private static boolean mIsTransportSMD = false;
@@ -204,27 +214,42 @@ public class FMStats extends Activity {
private static final int MIN_AF_JMP_RMSSI_SAMPLES = 0;
private static final int MAX_AF_JMP_RMSSI_SAMPLES = 255;
+ private static final int DIALOG_BAND_SWEEP_SETTING = 1;
+
+ private int prevDwellTime = 2; //2secs
+ private int prevDelayTime = 0;//0secs
+ private int prevSweepMthd = 0; //Manual (using band min, max)
+
+ private int curSweepMthd = 0;
+
+ private final String FREQ_LIST_FILE_NAME = "/freq_list_comma_separated.txt";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.fmstats);
- spinOptionFmRf = (Spinner) findViewById(R.id.spinner);
- adaptFmRf = ArrayAdapter.createFromResource(
- this, R.array.stats_options, android.R.layout.simple_spinner_item);
- adaptFmRf.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+ spinOptionFmRf = (Spinner)findViewById(R.id.spinner);
+ adaptFmRf = ArrayAdapter.createFromResource
+ (this, R.array.stats_options
+ , android.R.layout.simple_spinner_item);
+ adaptFmRf.setDropDownViewResource
+ (android.R.layout.simple_spinner_dropdown_item);
if (spinOptionFmRf != null) {
spinOptionFmRf.setAdapter(adaptFmRf);
spinOptionFmRf.setOnItemSelectedListener(mSpinFmRfListener);
}
+ bandSweepMthds = ArrayAdapter.createFromResource
+ (this, R.array.band_sweep_methods,
+ android.R.layout.simple_spinner_item);
+
checkTransportLayer();
if (!isTransportLayerSMD()) {
mSpinCfgRfListener1 = new CfgRfItemSelectedListener1();
adaptCfgRf = ArrayAdapter.createFromResource(
this, R.array.cfg_rf1,
android.R.layout.simple_spinner_item);
- } else {
+ }else {
mSpinCfgRfListener2 = new CfgRfItemSelectedListener2();
adaptCfgRf = ArrayAdapter.createFromResource(
this, R.array.cfg_rf2,
@@ -238,194 +263,205 @@ public class FMStats extends Activity {
if(mReceiver == null)
mReceiver = new FmReceiver();
- long curTime = System.currentTimeMillis();
- mCurrentFileName = "FMStats_".concat(Long.toString(curTime).concat(".txt"));
- Log.e(LOGTAG,"Filename is "+mCurrentFileName);
+ long curTime = System.currentTimeMillis();
+ mCurrentFileName = "FMStats_".concat(
+ Long.toString(curTime).concat(".txt")
+ );
+ Log.e(LOGTAG,"Filename is " + mCurrentFileName);
try {
- mFileCursor = openFileOutput(mCurrentFileName, Context.MODE_PRIVATE);
+ mFileCursor = openFileOutput(
+ mCurrentFileName,
+ Context.MODE_PRIVATE);
if(null != mFileCursor) {
Log.e(LOGTAG, "location of the file is"+getFilesDir());
}
- } catch (IOException e) {
- e.printStackTrace();
+ }catch (IOException e) {
+ e.printStackTrace();
Log.e(LOGTAG,"Couldn't create the file to writeLog");
mCurrentFileName = null;
}
- if (false == bindToService(this, osc))
- {
- Log.d(LOGTAG, "onCreate: Failed to Start Service");
- }
- else
- {
- Log.d(LOGTAG, "onCreate: Start Service completed successfully");
+ if (false == bindToService(this, osc)) {
+ Log.d(LOGTAG, "onCreate: Failed to Start Service");
+ }else {
+ Log.d(LOGTAG, "onCreate: Start Service completed successfully");
}
- /*Initialize the column header with
- constant values*/
- mColumnHeader.setFreq("Freq");
- mColumnHeader.setRSSI("RMSSI");
- mColumnHeader.setIoC("IoC");
+ /*Initialize the column header with
+ constant values*/
+ mColumnHeader.setFreq("Freq");
+ mColumnHeader.setRSSI("RMSSI");
+ mColumnHeader.setIoC("IoC");
mColumnHeader.setSINR("SINR");
- mColumnHeader.setMpxDcc("Offset");
- mColumnHeader.setIntDet("IntDet");
+ mColumnHeader.setMpxDcc("Offset");
+ mColumnHeader.setIntDet("IntDet");
+
+ bandSweepSettingButton = (TextView)findViewById(R.id.BandSweepSetting);
+ if(bandSweepSettingButton != null) {
+ bandSweepSettingButton.setOnClickListener(mClicktBandSweepSettingListener);
+ }
}
public void onDestroy() {
- if (null != mFileCursor ) {
- try {
- mFileCursor.close();
- } catch (IOException e) {
-
+ if(null != mFileCursor ) {
+ try {
+ mFileCursor.close();
+ }catch (IOException e) {
e.printStackTrace();
}
}
- /*Stop the thread by interrupting it*/
- if (mMultiUpdateThread != null) {
- mMultiUpdateThread.interrupt();
- mMultiUpdateThread = null;
- }
- /*Stop the search/scan if there is an ongoing*/
- if (SEARCH_TEST == mTestSelected)
- {
+ /*Stop the thread by interrupting it*/
+ if(mMultiUpdateThread != null) {
+ mMultiUpdateThread.interrupt();
+ mMultiUpdateThread = null;
+ }
+ /*Stop the search/scan if there is an ongoing*/
+ if(SEARCH_TEST == mTestSelected) {
Log.d(LOGTAG, "Stop Search\n");
try {
- mService.cancelSearch();
- } catch (RemoteException e) {
- e.printStackTrace();
- }
+ mService.cancelSearch();
+ }catch (RemoteException e) {
+ e.printStackTrace();
+ }
}
unbindFromService(this);
Log.d(LOGTAG, "onDestroy: unbindFromService completed");
mReceiver = null;
mService = null;
+ removeDialog(DIALOG_BAND_SWEEP_SETTING);
super.onDestroy();
}
private View.OnClickListener mOnRunListener = new View.OnClickListener() {
- public void onClick(View v) {
- if(false == mTestRunning)
- {
+ public void onClick(View v) {
+ if(false == mTestRunning) {
clearPreviousTestResults();
mTestRunning = true;
+ if(mTestSelected == SWEEP_TEST) {
+ disableBandSweepSetting();
+ }
runCurrentTest();
- }
- else
- {
+ }else {
mTestRunning = false;
/*Set it back to ready to Run*/
SetButtonState(true);
/*Stop the thread by interrupting it*/
- if (mMultiUpdateThread != null) {
- mMultiUpdateThread.interrupt();
- mMultiUpdateThread = null;
- }
+ if(mMultiUpdateThread != null) {
+ mMultiUpdateThread.interrupt();
+ mMultiUpdateThread = null;
+ }
- if(SEARCH_TEST == mTestSelected )
- {
+ if(SEARCH_TEST == mTestSelected) {
try {
mService.cancelSearch();
- } catch (RemoteException e) {
+ }catch (RemoteException e) {
e.printStackTrace();
}
}
- }
+ if(mTestSelected == SWEEP_TEST) {
+ enableBandSweepSetting();
+ }
+ }
}
};
- private void clearPreviousTestResults()
- {
- TableLayout tl = (TableLayout) findViewById(R.id.maintable);
+ private void clearPreviousTestResults() {
+ TableLayout tl = (TableLayout)findViewById(R.id.maintable);
if (tl != null) {
- tl.removeAllViewsInLayout();
+ tl.removeAllViewsInLayout();
}
mNewRowIds = NEW_ROW_ID;
- }
-
+ }
- private void SetButtonState(boolean state)
- {
- // Get the TableRow
- Button RunButton = (Button)findViewById(R.id.Runbutton);
- ProgressBar pbar = (ProgressBar) findViewById(R.id.progressbar);
- /*Update the state of the button based on
+ private void SetButtonState(boolean state) {
+ // Get the TableRow
+ Button RunButton = (Button)findViewById(R.id.Runbutton);
+ ProgressBar pbar = (ProgressBar)findViewById(R.id.progressbar);
+ /*Update the state of the button based on
state*/
- if( state )
- {
- if (RunButton != null) {
- RunButton.setText(R.string.test_run);
- }
- if (pbar != null) {
- pbar.setVisibility(View.INVISIBLE);
- }
- }
- else
- {
- if (RunButton != null) {
- RunButton.setText("Stop Test");
- }
- if (pbar != null) {
- pbar.setVisibility(View.VISIBLE);
- }
- }
+ if(state) {
+ if(RunButton != null) {
+ RunButton.setText(R.string.test_run);
+ }
+ if(pbar != null) {
+ pbar.setVisibility(View.INVISIBLE);
+ }
+ if(mTestSelected == SWEEP_TEST) {
+ enableBandSweepSetting();
+ }
+ }else {
+ if(RunButton != null) {
+ RunButton.setText("Stop Test");
+ }
+ if(pbar != null) {
+ pbar.setVisibility(View.VISIBLE);
+ }
+ }
}
private void chooseFMRFoption(){
- String[] szTestInformation = getResources().getStringArray(
+ String[] szTestInformation = getResources().getStringArray(
R.array.stats_options);
- final StringBuilder szbTestHeader = new StringBuilder();
- szbTestHeader.append("running test:").append(szTestInformation[mTestSelected]);
- String szTestHeader = new String(szbTestHeader);
- switch(mTestSelected){
- case 1:
- RunButton = (Button)findViewById(R.id.Runbutton);
- if (RunButton != null) {
- RunButton.setVisibility(View.INVISIBLE);
- }
- pbar = (ProgressBar) findViewById(R.id.progressbar);
- if (pbar != null) {
- pbar.setVisibility(View.INVISIBLE);
- }
- adaptCfgRf.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
- spinOptionFmRf.setAdapter(adaptCfgRf);
- if(isTransportLayerSMD())
- spinOptionFmRf.setOnItemSelectedListener(mSpinCfgRfListener2);
- else
- spinOptionFmRf.setOnItemSelectedListener(mSpinCfgRfListener1);
- break;
- case 2:
- txtbox1 = (EditText) findViewById(R.id.txtbox1);
- tv1 = (TextView) findViewById(R.id.label);
- if (txtbox1 != null) {
- txtbox1.setVisibility(View.INVISIBLE);
- }
- if (tv1 != null) {
- tv1.setVisibility(View.INVISIBLE);
- }
- Button SetButton = (Button)findViewById(R.id.Setbutton);
- if (SetButton != null) {
- SetButton.setVisibility(View.INVISIBLE);
- }
- adaptRfCfg.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
- spinOptionFmRf.setAdapter(adaptRfCfg);
- spinOptionFmRf.setOnItemSelectedListener(mSpinRfCfgListener);
- break;
+ final StringBuilder szbTestHeader = new StringBuilder();
+ szbTestHeader.append("running test:").append
+ (szTestInformation[mTestSelected]);
+ String szTestHeader = new String(szbTestHeader);
+ switch(mTestSelected)
+ {
+ case 1:
+ RunButton = (Button)findViewById(R.id.Runbutton);
+ if(RunButton != null) {
+ RunButton.setVisibility(View.INVISIBLE);
+ }
+ pbar = (ProgressBar) findViewById(R.id.progressbar);
+ if(pbar != null) {
+ pbar.setVisibility(View.INVISIBLE);
+ }
+ adaptCfgRf.setDropDownViewResource
+ (android.R.layout.simple_spinner_dropdown_item);
+ spinOptionFmRf.setAdapter(adaptCfgRf);
+ if(isTransportLayerSMD())
+ spinOptionFmRf.setOnItemSelectedListener
+ (mSpinCfgRfListener2);
+ else
+ spinOptionFmRf.setOnItemSelectedListener
+ (mSpinCfgRfListener1);
+ break;
+ case 2:
+ txtbox1 = (EditText)findViewById(R.id.txtbox1);
+ tv1 = (TextView)findViewById(R.id.label);
+ if(txtbox1 != null) {
+ txtbox1.setVisibility(View.INVISIBLE);
+ }
+ if(tv1 != null) {
+ tv1.setVisibility(View.INVISIBLE);
+ }
+ Button SetButton = (Button)findViewById(R.id.Setbutton);
+ if(SetButton != null) {
+ SetButton.setVisibility(View.INVISIBLE);
+ }
+ adaptRfCfg.setDropDownViewResource
+ (android.R.layout.simple_spinner_dropdown_item);
+ spinOptionFmRf.setAdapter(adaptRfCfg);
+ spinOptionFmRf.setOnItemSelectedListener(mSpinRfCfgListener);
+ break;
}
}
- private View.OnClickListener mOnSetRmssitListener = new View.OnClickListener() {
+ private View.OnClickListener mOnSetRmssitListener =
+ new View.OnClickListener() {
public void onClick(View v) {
String a;
- a = txtbox1.getText().toString();
+ a = txtbox1.getText().toString();
try {
int rdel = Integer.parseInt(a);
Log.d(LOGTAG, "Value of RMSSI DELTA is : " + rdel);
mReceiver.setRmssiDel(rdel);
- } catch (NumberFormatException e) {
+ }catch (NumberFormatException e) {
Log.e(LOGTAG, "Value entered is not in correct format: " + a);
txtbox1.setText("");
- } catch (NullPointerException e) {
+ }catch (NullPointerException e) {
e.printStackTrace();
}
}
@@ -433,129 +469,138 @@ public class FMStats extends Activity {
private View.OnClickListener mOnSetRxRePeatCount = new View.OnClickListener() {
public void onClick(View v) {
- String a;
- a = txtbox1.getText().toString();
- try {
- int count = Integer.parseInt(a);
- Log.d(LOGTAG, "Value entered for mOnSetRxRePeatCount: " + count);
- if ((count < 0) || (count > 255))
- return;
- if (mService != null) {
- try {
- mService.setRxRepeatCount(count);
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- }
- } catch (NumberFormatException e) {
- Log.e(LOGTAG, "Value entered is not in correct format : " + a);
- txtbox1.setText("");
- }
+ String a;
+ a = txtbox1.getText().toString();
+ try {
+ int count = Integer.parseInt(a);
+ Log.d(LOGTAG, "Value entered for mOnSetRxRePeatCount: " + count);
+ if((count < 0) ||
+ (count > 255))
+ return;
+ if(mService != null) {
+ try {
+ mService.setRxRepeatCount(count);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
+ } catch (NumberFormatException e) {
+ Log.e(LOGTAG, "Value entered is not in correct format : " + a);
+ txtbox1.setText("");
+ }
}
};
- private View.OnClickListener mOnSetSigThListener = new View.OnClickListener() {
+ private View.OnClickListener mOnSetSigThListener =
+ new View.OnClickListener() {
public void onClick(View v) {
String a;
- a = txtbox1.getText().toString();
+ a = txtbox1.getText().toString();
try {
int rdel = Integer.parseInt(a);
Log.d(LOGTAG, "Value of Signal Th. is : " + rdel);
mReceiver.setSignalThreshold(rdel);
- } catch (NumberFormatException e) {
+ }catch (NumberFormatException e) {
Log.e(LOGTAG, "Value entered is not in correct format: " + a);
txtbox1.setText("");
- } catch (NullPointerException e) {
+ }catch (NullPointerException e) {
e.printStackTrace();
}
}
};
- private View.OnClickListener mOnSetSinrSmplCntListener = new View.OnClickListener() {
+ private View.OnClickListener mOnSetSinrSmplCntListener =
+ new View.OnClickListener() {
public void onClick(View v) {
String a;
- a = txtbox1.getText().toString();
+ a = txtbox1.getText().toString();
try {
int rdel = Integer.parseInt(a);
Log.d(LOGTAG, "Value of Sinr Samples count is : " + rdel);
if(mService != null) {
try {
mService.setSinrSamplesCnt(rdel);
- } catch (RemoteException e) {
+ }catch (RemoteException e) {
e.printStackTrace();
}
}
- } catch (NumberFormatException e) {
+ }catch (NumberFormatException e) {
Log.e(LOGTAG, "Value entered is not in correct format: " + a);
txtbox1.setText("");
}
}
};
- private View.OnClickListener mOnSetSinrThListener = new View.OnClickListener() {
+
+ private View.OnClickListener mOnSetSinrThListener =
+ new View.OnClickListener() {
public void onClick(View v) {
String a;
- a = txtbox1.getText().toString();
+ a = txtbox1.getText().toString();
try {
int rdel = Integer.parseInt(a);
Log.d(LOGTAG, "Value of Sinr Th is : " + rdel);
if(mService != null) {
try {
mService.setSinrTh(rdel);
- } catch (RemoteException e) {
+ }catch (RemoteException e) {
e.printStackTrace();
}
}
- } catch (NumberFormatException e) {
+ }catch (NumberFormatException e) {
Log.e(LOGTAG, "Value entered is not in correct format: " + a);
txtbox1.setText("");
}
}
};
- private View.OnClickListener mOnSetIntfLowThListener = new View.OnClickListener() {
+
+ private View.OnClickListener mOnSetIntfLowThListener =
+ new View.OnClickListener() {
public void onClick(View v) {
String a;
- a = txtbox1.getText().toString();
+ a = txtbox1.getText().toString();
try {
int rdel = Integer.parseInt(a);
Log.d(LOGTAG, "Value of Intf Det Low Th is : " + rdel);
if(mService != null) {
try {
mService.setIntfDetLowTh(rdel);
- } catch (RemoteException e) {
+ }catch (RemoteException e) {
e.printStackTrace();
}
}
- } catch (NumberFormatException e) {
+ }catch (NumberFormatException e) {
Log.e(LOGTAG, "Value entered is not in correct format: " + a);
txtbox1.setText("");
}
}
};
- private View.OnClickListener mOnSetIntfHighThListener = new View.OnClickListener() {
+ private View.OnClickListener mOnSetIntfHighThListener =
+ new View.OnClickListener() {
public void onClick(View v) {
String a;
- a = txtbox1.getText().toString();
+ a = txtbox1.getText().toString();
try {
int rdel = Integer.parseInt(a);
Log.d(LOGTAG, "Value of Intf Det Low Th is : " + rdel);
if(mService != null) {
try {
mService.setIntfDetHighTh(rdel);
- } catch (RemoteException e) {
+ }catch (RemoteException e) {
e.printStackTrace();
}
}
- } catch (NumberFormatException e) {
+ }catch (NumberFormatException e) {
Log.e(LOGTAG, "Value entered is not in correct format : " + a);
txtbox1.setText("");
}
}
};
- private View.OnClickListener mOnSetSinrFirstStageListener = new View.OnClickListener() {
+ private View.OnClickListener mOnSetSinrFirstStageListener =
+ new View.OnClickListener() {
public void onClick(View v) {
String a;
- a = txtbox1.getText().toString();
+ a = txtbox1.getText().toString();
try {
int sinr = Integer.parseInt(a);
Log.d(LOGTAG, "Value entered for SINR FIRST STAGE is : " + sinr);
@@ -565,20 +610,22 @@ public class FMStats extends Activity {
if(mService != null) {
try {
mService.setSinrFirstStage(sinr);
- } catch (RemoteException e) {
+ }catch (RemoteException e) {
e.printStackTrace();
}
}
- } catch (NumberFormatException e) {
+ }catch (NumberFormatException e) {
Log.e(LOGTAG, "Value entered is not in correct format : " + a);
txtbox1.setText("");
}
}
};
- private View.OnClickListener mOnSetRmssiFirstStageListener = new View.OnClickListener() {
+
+ private View.OnClickListener mOnSetRmssiFirstStageListener =
+ new View.OnClickListener() {
public void onClick(View v) {
String a;
- a = txtbox1.getText().toString();
+ a = txtbox1.getText().toString();
try {
int rmssi = Integer.parseInt(a);
Log.d(LOGTAG, "Value entered for RMSSI FIRST STAGE is: " + rmssi);
@@ -588,21 +635,22 @@ public class FMStats extends Activity {
if(mService != null) {
try {
mService.setRmssiFirstStage(rmssi);
- } catch (RemoteException e) {
+ }catch (RemoteException e) {
e.printStackTrace();
}
}
- } catch (NumberFormatException e) {
+ }catch (NumberFormatException e) {
Log.e(LOGTAG, "Value entered is not in correct format : " + a);
txtbox1.setText("");
}
}
};
- private View.OnClickListener mOnSetCFOMeanThListener = new View.OnClickListener() {
+ private View.OnClickListener mOnSetCFOMeanThListener =
+ new View.OnClickListener() {
public void onClick(View v) {
String a;
- a = txtbox1.getText().toString();
+ a = txtbox1.getText().toString();
try {
int cf0 = Integer.parseInt(a);
Log.d(LOGTAG, "Value entered for CF0TH12 is: " + cf0);
@@ -612,46 +660,50 @@ public class FMStats extends Activity {
if(mService != null) {
try {
mService.setCFOMeanTh(cf0);
- } catch (RemoteException e) {
+ }catch (RemoteException e) {
e.printStackTrace();
}
}
- } catch (NumberFormatException e) {
+ }catch (NumberFormatException e) {
Log.e(LOGTAG, "Value entered is not in correct format : " + a);
txtbox1.setText("");
}
}
};
- private View.OnClickListener mOnSetSearchMPXDCCListener = new View.OnClickListener() {
+ private View.OnClickListener mOnSetSearchMPXDCCListener =
+ new View.OnClickListener() {
public void onClick(View v) {
- Log.d(LOGTAG, "Value entered for search is: MPX DCC");
- if(mService != null) {
- try {
- mService.setSearchAlgoType(MPX_DCC);
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- }
+ Log.d(LOGTAG, "Value entered for search is: MPX DCC");
+ if(mService != null) {
+ try {
+ mService.setSearchAlgoType(MPX_DCC);
+ }catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
}
};
- private View.OnClickListener mOnSetSearchSinrIntfListener = new View.OnClickListener() {
+
+ private View.OnClickListener mOnSetSearchSinrIntfListener =
+ new View.OnClickListener() {
public void onClick(View v) {
- Log.d(LOGTAG, "Value entered for search is: SINR INTF");
- if(mService != null) {
- try {
- mService.setSearchAlgoType(SINR_INTF);
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- }
+ Log.d(LOGTAG, "Value entered for search is: SINR INTF");
+ if(mService != null) {
+ try {
+ mService.setSearchAlgoType(SINR_INTF);
+ }catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ }
}
};
- private View.OnClickListener mOnSetAfJmpRmssiThListener = new View.OnClickListener() {
+ private View.OnClickListener mOnSetAfJmpRmssiThListener =
+ new View.OnClickListener() {
public void onClick(View v) {
String a;
- a = txtbox1.getText().toString();
+ a = txtbox1.getText().toString();
try {
int th = Integer.parseInt(a);
Log.d(LOGTAG, "Value entered for AfJmpRmssiTh is: " + th);
@@ -661,21 +713,22 @@ public class FMStats extends Activity {
if(mService != null) {
try {
mService.setAfJmpRmssiTh(th);
- } catch (RemoteException e) {
+ }catch (RemoteException e) {
e.printStackTrace();
}
}
- } catch (NumberFormatException e) {
+ }catch (NumberFormatException e) {
Log.e(LOGTAG, "Value entered is not in correct format : " + a);
txtbox1.setText("");
}
}
};
- private View.OnClickListener mOnSetGdChRmssiThListener = new View.OnClickListener() {
+ private View.OnClickListener mOnSetGdChRmssiThListener =
+ new View.OnClickListener() {
public void onClick(View v) {
String a;
- a = txtbox1.getText().toString();
+ a = txtbox1.getText().toString();
try {
int th = Integer.parseInt(a);
Log.d(LOGTAG, "Value entered for Good channel Rmssi Th is: " + th);
@@ -685,21 +738,22 @@ public class FMStats extends Activity {
if(mService != null) {
try {
mService.setGoodChRmssiTh(th);
- } catch (RemoteException e) {
+ }catch (RemoteException e) {
e.printStackTrace();
}
}
- } catch (NumberFormatException e) {
+ }catch (NumberFormatException e) {
Log.e(LOGTAG, "Value entered is not in correct format : " + a);
txtbox1.setText("");
}
}
};
- private View.OnClickListener mOnSetAfJmpRmssiSmplsCntListener = new View.OnClickListener() {
+ private View.OnClickListener mOnSetAfJmpRmssiSmplsCntListener =
+ new View.OnClickListener() {
public void onClick(View v) {
String a;
- a = txtbox1.getText().toString();
+ a = txtbox1.getText().toString();
try {
int cnt = Integer.parseInt(a);
Log.d(LOGTAG, "Value entered for AfJmpRmssiSamples is: " + cnt);
@@ -709,11 +763,11 @@ public class FMStats extends Activity {
if(mService != null) {
try {
mService.setAfJmpRmssiSamplesCnt(cnt);
- } catch (RemoteException e) {
+ }catch (RemoteException e) {
e.printStackTrace();
}
}
- } catch (NumberFormatException e) {
+ }catch (NumberFormatException e) {
Log.e(LOGTAG, "Value entered is not in correct format : " + a);
txtbox1.setText("");
}
@@ -721,61 +775,64 @@ public class FMStats extends Activity {
};
public class CfgRfItemSelectedListener1 implements OnItemSelectedListener {
- public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
+ public void onItemSelected(
+ AdapterView<?> parent, View view, int pos, long id) {
Log.d("Table","onItemSelected is hit with " + pos);
- txtbox1 = (EditText) findViewById(R.id.txtbox1);
- tv1 = (TextView) findViewById(R.id.label);
+ txtbox1 = (EditText)findViewById(R.id.txtbox1);
+ tv1 = (TextView)findViewById(R.id.label);
Button SetButton = (Button)findViewById(R.id.Setbutton);
tLayout.setVisibility(View.INVISIBLE);
switch(pos)
{
- case 0:
- if (txtbox1 != null) {
+ case 0:
+ if (txtbox1 != null) {
txtbox1.setText(R.string.type_rd);
txtbox1.setVisibility(View.VISIBLE);
- }
- if (tv1 != null) {
+ }
+ if (tv1 != null) {
tv1.setText(R.string.enter_rssi);
tv1.setVisibility(View.VISIBLE);
- }
- if (SetButton != null) {
+ }
+ if (SetButton != null) {
SetButton.setText(R.string.set_rmmsi_delta);
SetButton.setVisibility(View.VISIBLE);
SetButton.setOnClickListener(mOnSetRmssitListener);
- }
- break;
- case 1:
- if (txtbox1 != null) {
+ }
+ break;
+ case 1:
+ if (txtbox1 != null) {
txtbox1.setText(R.string.type_rd);
txtbox1.setVisibility(View.VISIBLE);
- }
- if (tv1 != null) {
+ }
+ if (tv1 != null) {
tv1.setText(R.string.enter_sigth);
tv1.setVisibility(View.VISIBLE);
- }
- if (SetButton != null) {
+ }
+ if (SetButton != null) {
SetButton.setText(R.string.set_sigth);
SetButton.setVisibility(View.VISIBLE);
SetButton.setOnClickListener(mOnSetSigThListener);
- }
- break;
- case 2:
- tLayout.removeAllViewsInLayout();
- mNewRowIds = NEW_ROW_ID;
- tLayout.setVisibility(View.VISIBLE);
- if (txtbox1 != null) {
+ }
+ break;
+ case 2:
+ tLayout.removeAllViewsInLayout();
+ mNewRowIds = NEW_ROW_ID;
+ tLayout.setVisibility(View.VISIBLE);
+ if (txtbox1 != null) {
txtbox1.setVisibility(View.INVISIBLE);
- }
- if (tv1 != null) {
+ }
+ if (tv1 != null) {
tv1.setVisibility(View.INVISIBLE);
- }
- if (SetButton != null) {
+ }
+ if (SetButton != null) {
SetButton.setVisibility(View.INVISIBLE);
- }
- adaptRfCfg.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
- spinOptionFmRf.setAdapter(adaptRfCfg);
- spinOptionFmRf.setOnItemSelectedListener(mSpinRfCfgListener);
- break;
+ }
+ adaptRfCfg.setDropDownViewResource(
+ android.R.layout.simple_spinner_dropdown_item);
+ spinOptionFmRf.setAdapter(adaptRfCfg);
+ spinOptionFmRf.setOnItemSelectedListener(
+ mSpinRfCfgListener);
+ break;
}
}
@@ -785,7 +842,8 @@ public class FMStats extends Activity {
}
public class CfgRfItemSelectedListener2 implements OnItemSelectedListener {
- public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
+ public void onItemSelected(AdapterView<?> parent,
+ View view, int pos, long id) {
Log.d("Table","onItemSelected is hit with " + pos);
int ret = Integer.MAX_VALUE;
txtbox1 = (EditText) findViewById(R.id.txtbox1);
@@ -1305,7 +1363,8 @@ public class FMStats extends Activity {
if(button2 != null) {
button2.setVisibility(View.INVISIBLE);
}
- adaptRfCfg.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+ adaptRfCfg.setDropDownViewResource(
+ android.R.layout.simple_spinner_dropdown_item);
spinOptionFmRf.setAdapter(adaptRfCfg);
spinOptionFmRf.setOnItemSelectedListener(mSpinRfCfgListener);
break;
@@ -1332,7 +1391,8 @@ public class FMStats extends Activity {
}
public class RfCfgItemSelectedListener implements OnItemSelectedListener {
- public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
+ public void onItemSelected(AdapterView<?> parent,
+ View view, int pos, long id) {
Log.d("Table","onItemSelected is hit with "+pos);
tLayout.setVisibility(View.INVISIBLE);
if (mTestRunning)
@@ -1353,6 +1413,11 @@ public class FMStats extends Activity {
RunButton.setVisibility(View.VISIBLE);
RunButton.setOnClickListener(mOnRunListener);
}
+ if(mTestSelected == SWEEP_TEST) {
+ enableBandSweepSetting();
+ }else {
+ disableBandSweepSetting();
+ }
break;
case 4:
RunButton = (Button)findViewById(R.id.Runbutton);
@@ -1363,12 +1428,14 @@ public class FMStats extends Activity {
if (pbar != null) {
pbar.setVisibility(View.INVISIBLE);
}
- adaptCfgRf.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+ adaptCfgRf.setDropDownViewResource(
+ android.R.layout.simple_spinner_dropdown_item);
spinOptionFmRf.setAdapter(adaptCfgRf);
if(isTransportLayerSMD())
spinOptionFmRf.setOnItemSelectedListener(mSpinCfgRfListener2);
else
spinOptionFmRf.setOnItemSelectedListener(mSpinCfgRfListener1);
+ disableBandSweepSetting();
break;
}
}
@@ -1383,9 +1450,7 @@ public class FMStats extends Activity {
mTestSelected = pos;
tLayout.setVisibility(View.INVISIBLE);
chooseFMRFoption();
-
}
-
public void onNothingSelected(AdapterView<?> parent) {
// Do Nothing
}
@@ -1478,8 +1543,7 @@ public class FMStats extends Activity {
}
}
-
- private void runCurrentTest(){
+ private void runCurrentTest() {
Log.d(LOGTAG, "The test being run is" +mTestSelected);
//get test summary
@@ -1489,118 +1553,107 @@ public class FMStats extends Activity {
szbTestHeader.append("running test:").append(szTestInformation[mTestSelected]);
szbTestHeader.append("\r\n");
String szTestHeader = new String(szbTestHeader);
- if(null != mFileCursor )
- {
- try {
+ if(null != mFileCursor ) {
+ try {
mFileCursor.write(szTestHeader.getBytes());
- } catch (IOException ioe) {
+ } catch (IOException ioe) {
ioe.printStackTrace();
- }
+ }
}
- switch(mTestSelected){
- case CUR_FREQ_TEST:
- Log.d(LOGTAG,"Current Freq test is going to run");
- int freq = FmSharedPreferences.getTunedFrequency();
- Result res = GetFMStatsForFreq(freq);
- createResult(mColumnHeader);
- if(res != null)
- createResult(res);
- mTestRunning = false;
- break;
- case CUR_MULTI_TEST:
- /*Set it to ready to Stop*/
- SetButtonState(false);
- createResult(mColumnHeader);
-
- if (mMultiUpdateThread == null)
- {
- mMultiUpdateThread = new Thread(null, getMultipleResults,
- "MultiResultsThread");
- }
- /* Launch dummy thread to simulate the transfer progress */
- Log.d(LOGTAG, "Thread State: " + mMultiUpdateThread.getState());
- if (mMultiUpdateThread.getState() == Thread.State.TERMINATED)
- {
- mMultiUpdateThread = new Thread(null, getMultipleResults,
- "MultiResultsThread");
- }
- /* If the thread state is "new" then the thread has not yet started */
- if (mMultiUpdateThread.getState() == Thread.State.NEW)
- {
- mMultiUpdateThread.start();
- }
- // returns and UI in different thread.
- break;
- case SEARCH_TEST:
- try {
- Log.d(LOGTAG, "start scanning\n");
- if(isTransportLayerSMD()) {
- Log.d(LOGTAG,"Scanning with 0 scan time");
- if (mReceiver != null)
- mIsSearching = mReceiver.searchStations(FmReceiver.FM_RX_SRCH_MODE_SCAN,
- SCAN_DWELL_PERIOD, FmReceiver.FM_RX_SEARCHDIR_UP);
- } else {
- mIsSearching = mService.scan(0);
- }
- } catch (RemoteException e) {
-
- e.printStackTrace();
- }
+ switch(mTestSelected)
+ {
+ case CUR_FREQ_TEST:
+ Log.d(LOGTAG,"Current Freq test is going to run");
+ int freq = FmSharedPreferences.getTunedFrequency();
+ Result res = GetFMStatsForFreq(freq);
+ createResult(mColumnHeader);
+ if(res != null)
+ createResult(res);
+ mTestRunning = false;
+ break;
+ case CUR_MULTI_TEST:
+ /*Set it to ready to Stop*/
+ SetButtonState(false);
+ createResult(mColumnHeader);
+
+ if(mMultiUpdateThread == null) {
+ mMultiUpdateThread = new Thread(null, getMultipleResults,
+ "MultiResultsThread");
+ }
+ /* Launch dummy thread to simulate the transfer progress */
+ Log.d(LOGTAG, "Thread State: " + mMultiUpdateThread.getState());
+ if(mMultiUpdateThread.getState() == Thread.State.TERMINATED) {
+ mMultiUpdateThread = new Thread(null, getMultipleResults,
+ "MultiResultsThread");
+ }
+ /* If the thread state is "new" then the thread has not yet started */
+ if(mMultiUpdateThread.getState() == Thread.State.NEW) {
+ mMultiUpdateThread.start();
+ }
+ // returns and UI in different thread.
+ break;
+ case SEARCH_TEST:
+ try {
+ Log.d(LOGTAG, "start scanning\n");
+ if(isTransportLayerSMD()) {
+ Log.d(LOGTAG,"Scanning with 0 scan time");
+ if (mReceiver != null)
+ mIsSearching = mReceiver.searchStations(FmReceiver.FM_RX_SRCH_MODE_SCAN,
+ SCAN_DWELL_PERIOD, FmReceiver.FM_RX_SEARCHDIR_UP);
+ }else {
+ mIsSearching = mService.scan(0);
+ }
+ }catch (RemoteException e) {
+ e.printStackTrace();
+ }
- if(mIsSearching)
- {
- /*Set it to Ready to Stop*/
- SetButtonState(false);
- createResult(mColumnHeader);
- Log.d(LOGTAG, "Created the results and cancel UI\n");
- }
- else
- {
- mTestRunning = false;
- }
- break;
- case SWEEP_TEST:
- int Spacing = FmSharedPreferences.getChSpacing();
- int lowerFreq = FmSharedPreferences.getLowerLimit();
- int higherFreq = FmSharedPreferences.getUpperLimit();
- try {
- Log.d(LOGTAG, "Going to set low side injection\n");
- mService.setHiLoInj(Lo);
- } catch (RemoteException e) {
-
- e.printStackTrace();
- }
- /* Set it to Ready to stop*/
- SetButtonState(false);
- createResult(mColumnHeader);
- getFMStatsInBand(lowerFreq,higherFreq,Spacing);
- break;
+ if(mIsSearching) {
+ /*Set it to Ready to Stop*/
+ SetButtonState(false);
+ createResult(mColumnHeader);
+ Log.d(LOGTAG, "Created the results and cancel UI\n");
+ }else {
+ mTestRunning = false;
+ }
+ break;
+ case SWEEP_TEST:
+ int Spacing = FmSharedPreferences.getChSpacing();
+ int lowerFreq = FmSharedPreferences.getLowerLimit();
+ int higherFreq = FmSharedPreferences.getUpperLimit();
+ try {
+ Log.d(LOGTAG, "Going to set low side injection\n");
+ mService.setHiLoInj(Lo);
+ }catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ /* Set it to Ready to stop*/
+ SetButtonState(false);
+ createResult(mColumnHeader);
+ getFMStatsInBand(lowerFreq, higherFreq, Spacing);
+ break;
}
}
/* Thread processing */
private Runnable getMultipleResults = new Runnable() {
public void run() {
- /*Collect the data for the current frequency
- 20 times*/
- int freq = FmSharedPreferences.getTunedFrequency();
+ /*Collect the data for the current frequency
+ 20 times*/
+ int freq = FmSharedPreferences.getTunedFrequency();
- for (int i = 0; i < 20; i++)
- {
- try
- {
- Thread.sleep(500);
- Message updateUI = new Message();
- updateUI.what = STATUS_UPDATE;
- updateUI.obj = (Object)GetFMStatsForFreq(freq);
- if (updateUI.obj == null)
- break;
- mUIUpdateHandlerHandler.sendMessage(updateUI);
- } catch (InterruptedException e)
- {
- /*break the loop*/
+ for(int i = 0; i < 20; i++) {
+ try {
+ Thread.sleep(500);
+ Message updateUI = new Message();
+ updateUI.what = STATUS_UPDATE;
+ updateUI.obj = (Object)GetFMStatsForFreq(freq);
+ if(updateUI.obj == null)
break;
- }
+ mUIUpdateHandlerHandler.sendMessage(updateUI);
+ }catch (InterruptedException e) {
+ /*break the loop*/
+ break;
+ }
}
mTestRunning = false;
Message updateStop = new Message();
@@ -1609,92 +1662,167 @@ public class FMStats extends Activity {
}
};
- private void getFMStatsInBand(int lFreq, int hFreq, int Spacing)
- {
- if( null == mBand) {
- mBand = new Band();
- }
- mBand.lFreq = lFreq;
- mBand.hFreq = hFreq;
- if(Spacing == 0)
- {
- mBand.Spacing = 200; // 200KHz
- }
- else if( Spacing == 1)
- {
- mBand.Spacing = 100; // 100KHz
- }
- else
- {
- mBand.Spacing = 50;
- }
+ private void getFMStatsInBand(int lFreq, int hFreq, int Spacing) {
+ if(null == mBand) {
+ mBand = new Band();
+ }
+ mBand.lFreq = lFreq;
+ mBand.hFreq = hFreq;
+ if(Spacing == 0) {
+ mBand.Spacing = 200; // 200KHz
+ }else if(Spacing == 1) {
+ mBand.Spacing = 100; // 100KHz
+ }else {
+ mBand.Spacing = 50;
+ }
- if (mMultiUpdateThread == null)
- {
- mMultiUpdateThread = new Thread(null, getSweepResults,
- "MultiResultsThread");
- }
- /* Launch he dummy thread to simulate the transfer progress */
- Log.d(LOGTAG, "Thread State: " + mMultiUpdateThread.getState());
- if (mMultiUpdateThread.getState() == Thread.State.TERMINATED)
- {
- mMultiUpdateThread = new Thread(null, getSweepResults,
+ if(mMultiUpdateThread == null) {
+ if(prevSweepMthd == 0) {
+ mMultiUpdateThread = new Thread(null, getManualSweepResults,
+ "MultiResultsThread");
+ }else {
+ mMultiUpdateThread = new Thread(null, getFileSweepResults,
+ "MultiResultsThread");
+ }
+ }
+ /* Launch he dummy thread to simulate the transfer progress */
+ Log.d(LOGTAG, "Thread State: " + mMultiUpdateThread.getState());
+ if((mMultiUpdateThread.getState() == Thread.State.TERMINATED)) {
+ if(prevSweepMthd == 0) {
+ mMultiUpdateThread = new Thread(null, getManualSweepResults,
"MultiResultsThread");
- }
- /* If the thread state is "new" then the thread has not yet started */
- if (mMultiUpdateThread.getState() == Thread.State.NEW)
- {
- mMultiUpdateThread.start();
- }
+ }else {
+ mMultiUpdateThread = new Thread(null, getFileSweepResults,
+ "MultiResultsThread");
+ }
+ }
+ /* If the thread state is "new" then the thread has not yet started */
+ if(mMultiUpdateThread.getState() == Thread.State.NEW) {
+ mMultiUpdateThread.start();
+ }
}
/* Thread processing */
- private Runnable getSweepResults = new Runnable() {
+ private Runnable getManualSweepResults = new Runnable() {
public void run() {
- for (int i = mBand.lFreq; (i <= mBand.hFreq) && (mService != null);
- i += mBand.Spacing)
- {
- try {
- if (!mService.tune(i)) {
- Log.e(LOGTAG, "tune failed");
- break;
- }
- mSync = new Band();
- synchronized(mSync) {
- mSync.wait(); //wait till notified
- }
- mSync = null;
- Message updateUI = new Message();
- updateUI.what = STATUS_UPDATE;
- updateUI.obj = (Object)GetFMStatsForFreq(i);
- if (updateUI.obj == null) {
- break;
- } else {
- mUIUpdateHandlerHandler.sendMessage(updateUI);
- Log.d(LOGTAG,"highFerq is "+mBand.hFreq);
- }
+ try {
+ Thread.sleep(prevDelayTime * 1000);
+ }catch(InterruptedException e) {
+ }
+ for (int i = mBand.lFreq; (i <= mBand.hFreq) &&
+ (mService != null); i += mBand.Spacing) {
+ if(!tuneAndUpdateSweepResult(i)) {
+ break;
}
- catch (RemoteException e) {
- Log.e(LOGTAG, "SweepResults:Tune failed\n");
+ try {
+ Thread.sleep(prevDwellTime * 1000);
+ }catch (InterruptedException e) {
+ /*Stop the thrad*/
+ break;
}
+ }
+ sendStatusDoneMsg();
+ }
+ };
- catch (InterruptedException e) {
- /*Stop the thrad*/
- break;
- }
+ private void sendStatusDoneMsg() {
+ mTestRunning = false;
+ Message updateStop = new Message();
+ updateStop.what = STATUS_DONE;
+ try {
+ Log.d(LOGTAG, "Going to set auto hi-lo injection\n");
+ mService.setHiLoInj(Auto);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ }
+ if(mUIUpdateHandlerHandler != null) {
+ Log.d(LOGTAG, "Sending message to stop test");
+ mUIUpdateHandlerHandler.sendMessage(updateStop);
+ }
+ }
+
+ private Runnable getFileSweepResults = new Runnable() {
+ public void run() {
+ boolean status = true;
+ try {
+ BufferedReader reader = new BufferedReader
+ (new FileReader(getFilesDir()
+ + FREQ_LIST_FILE_NAME));
+ String curLine = null;
+ try {
+ Thread.sleep(prevDelayTime * 1000);
+ }catch(InterruptedException e) {
+ }
+ while((reader != null) && (curLine = reader.readLine()) != null) {
+ String[] freq_list = curLine.split(",");
+ for(int i = 0; (freq_list != null ) &&
+ (i < freq_list.length); i++) {
+ int freq =
+ (int)(Double.parseDouble(freq_list[i]) * 1000);
+ if(validFreq(freq)) {
+ if(!tuneAndUpdateSweepResult(freq)) {
+ status = false;
+ break;
+ }else {
+ try {
+ Thread.sleep(prevDwellTime * 1000);
+ }catch (InterruptedException e) {
+ /*Stop the thrad*/
+ status = false;
+ break;
+ }
+ }
+ }
+ }
+ if(!status) {
+ break;
+ }
+ }
+ reader.close();
+ }catch(IOException e) {
+ e.printStackTrace();
+ }
+ sendStatusDoneMsg();
+ }
+ };
+
+ private boolean validFreq(int freq) {
+ if((freq >= mBand.lFreq) &&
+ (((freq - mBand.lFreq) / mBand.Spacing) >= 0)) {
+ return true;
+ }else {
+ return false;
+ }
+ }
+
+ private boolean tuneAndUpdateSweepResult(int freq) {
+ try {
+ if(!mService.tune(freq)) {
+ Log.e(LOGTAG, "tune failed");
+ return false;
}
- mTestRunning = false;
- Message updateStop = new Message();
- updateStop.what = STATUS_DONE;
- try {
- Log.d(LOGTAG, "Going to set auto hi-lo injection\n");
- mService.setHiLoInj(Auto);
- } catch (RemoteException e) {
- e.printStackTrace();
+ mSync = new Band();
+ synchronized(mSync) {
+ mSync.wait(); //wait till notified
}
- mUIUpdateHandlerHandler.sendMessage(updateStop);
+ mSync = null;
+ Message updateUI = new Message();
+ updateUI.what = STATUS_UPDATE;
+ updateUI.obj = (Object)GetFMStatsForFreq(freq);
+ if(updateUI.obj == null) {
+ return false;
+ }else {
+ mUIUpdateHandlerHandler.sendMessage(updateUI);
+ Log.d(LOGTAG,"highFerq is " + mBand.hFreq);
+ }
+ }catch (RemoteException e) {
+ Log.e(LOGTAG, "SweepResults:Tune failed\n");
+ return false;
+ }catch (InterruptedException e) {
+ return false;
}
- };
+ return true;
+ }
private Result GetFMStatsForFreq(int freq)
{
@@ -2010,4 +2138,90 @@ public class FMStats extends Activity {
mTestRunning = false;
}
}
+
+ @Override
+ protected Dialog onCreateDialog(int id) {
+ AlertDialog.Builder dlgBuilder = new AlertDialog.Builder(this);
+ switch(id)
+ {
+ case DIALOG_BAND_SWEEP_SETTING:
+ return createBandSweepDialog(id, dlgBuilder);
+ }
+ return null;
+ }
+
+ private Dialog createBandSweepDialog(int id, AlertDialog.Builder dlgBuilder) {
+ LayoutInflater inflater = LayoutInflater.from(this);
+ final View listview = inflater.inflate(R.layout.band_sweep_setting, null);
+ spinOptionBandSweepMthds = (Spinner)listview.findViewById(R.id.band_sweep_spinner);
+ final EditText delayBox = (EditText)listview.findViewById(R.id.txtboxDelayTime);
+ final EditText dwellBox = (EditText)listview.findViewById(R.id.txtboxDwellTime);
+
+ if(delayBox != null) {
+ delayBox.setText("" + prevDelayTime);
+ }
+ if(dwellBox != null) {
+ dwellBox.setText("" + prevDwellTime);
+ }
+ if(spinOptionBandSweepMthds != null) {
+ spinOptionBandSweepMthds.setAdapter(bandSweepMthds);
+ spinOptionBandSweepMthds.setOnItemSelectedListener(mSweepMthdsListener);
+ spinOptionBandSweepMthds.setSelection(prevSweepMthd);
+ }else {
+ Log.e(LOGTAG, "could not find spinner for methods\n");
+ }
+ dlgBuilder.setView(listview)
+ .setPositiveButton(R.string.band_sweep_setting_set, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ prevSweepMthd = curSweepMthd;
+ if(delayBox != null) {
+ String s = delayBox.getText().toString();
+ prevDelayTime = Integer.parseInt(s);
+ }
+ if(dwellBox != null) {
+ String s = dwellBox.getText().toString();
+ prevDwellTime = Integer.parseInt(s);
+ }
+ removeDialog(DIALOG_BAND_SWEEP_SETTING);
+ }
+ })
+ .setNegativeButton(R.string.band_sweep_setting_cancel, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ removeDialog(DIALOG_BAND_SWEEP_SETTING);
+ }
+ });
+ return dlgBuilder.create();
+ }
+
+ private View.OnClickListener mClicktBandSweepSettingListener = new View.OnClickListener() {
+ public void onClick(View v) {
+ showDialog(DIALOG_BAND_SWEEP_SETTING);
+ }
+ };
+
+ private void enableBandSweepSetting() {
+ if(bandSweepSettingButton != null) {
+ bandSweepSettingButton.setEnabled(true);
+ bandSweepSettingButton.setVisibility(View.VISIBLE);
+ }
+ }
+
+ private void disableBandSweepSetting() {
+ if(bandSweepSettingButton != null) {
+ bandSweepSettingButton.setEnabled(false);
+ bandSweepSettingButton.setVisibility(View.INVISIBLE);
+ }
+ }
+
+ public class BandSweepMthdsSelectedListener implements OnItemSelectedListener {
+ public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
+ Log.d("Band Sweep Methods","onItemSelected is hit with " + pos);
+ curSweepMthd = pos;
+ }
+
+ public void onNothingSelected(AdapterView<?> parent) {
+ // Do Nothing
+ }
+ }
+
}
diff --git a/fmapp/src/com/codeaurora/fmradio/FmSharedPreferences.java b/fmapp/src/com/codeaurora/fmradio/FmSharedPreferences.java
index 0e5484c..ac4ac2c 100644
--- a/fmapp/src/com/codeaurora/fmradio/FmSharedPreferences.java
+++ b/fmapp/src/com/codeaurora/fmradio/FmSharedPreferences.java
@@ -78,6 +78,7 @@ public class FmSharedPreferences
public static final int REGIONAL_BAND_TURKEY = 33;
public static final int REGIONAL_BAND_UNITEDKINGDOM = 34;
public static final int REGIONAL_BAND_UNITED_STATES = 35;
+ public static final int REGIONAL_BAND_USER_DEFINED = 36;
public static final int RECORD_DUR_INDEX_0_VAL = 5;
public static final int RECORD_DUR_INDEX_1_VAL = 15;
@@ -98,9 +99,9 @@ public class FmSharedPreferences
private static final String FMCONFIG_COUNTRY = "fmconfig_country";
//private static final String FMCONFIG_BAND = "fmconfig_band";
- //private static final String FMCONFIG_MIN = "fmconfig_min";
- //private static final String FMCONFIG_MAX = "fmconfig_max";
- //private static final String FMCONFIG_STEP = "fmconfig_step";
+ private static final String FMCONFIG_MIN = "fmconfig_min";
+ private static final String FMCONFIG_MAX = "fmconfig_max";
+ private static final String FMCONFIG_STEP = "fmconfig_step";
//private static final String FMCONFIG_EMPH = "fmconfig_emphasis";
//private static final String FMCONFIG_RDSSTD = "fmconfig_rdsstd";
/* Storage key String */
@@ -152,9 +153,12 @@ public class FmSharedPreferences
private static int mListIndex;
private Context mContext;
private static int mTunedFrequency = 98100;
+ private static int mBandMinFreq = 76000;
+ private static int mBandMaxFreq = 108000;
+ private static int mChanSpacing = 0;
private static int mFrequencyBand_Stepsize = 200;
- private static int mCountry=0;
+ private static int mCountry = 0;
/* true = Stereo and false = "force Mono" even if Station is transmitting a
* Stereo signal
*/
@@ -444,7 +448,11 @@ public class FmSharedPreferences
mTunedFrequency = sp.getInt(PREF_LAST_TUNED_FREQUENCY, DEFAULT_NO_FREQUENCY);
mRecordDuration = sp.getInt(LAST_RECORD_DURATION, RECORD_DUR_INDEX_0_VAL);
mAFAutoSwitch = sp.getBoolean(LAST_AF_JUMP_VALUE, true);
-
+ if(sp.getInt(FMCONFIG_COUNTRY, 0) == REGIONAL_BAND_USER_DEFINED) {
+ mBandMinFreq = sp.getInt(FMCONFIG_MIN, mBandMinFreq);
+ mBandMaxFreq = sp.getInt(FMCONFIG_MAX, mBandMaxFreq);
+ mChanSpacing = sp.getInt(FMCONFIG_STEP, mChanSpacing);
+ }
int num_lists = sp.getInt(LIST_NUM, 1);
if (mListOfPlists.size() == 0) {
@@ -544,6 +552,11 @@ public class FmSharedPreferences
/* Save Configuration */
ed.putInt(FMCONFIG_COUNTRY, mCountry);
+ if(mCountry == REGIONAL_BAND_USER_DEFINED) {
+ ed.putInt(FMCONFIG_MIN, mBandMinFreq);
+ ed.putInt(FMCONFIG_MAX, mBandMaxFreq);
+ ed.putInt(FMCONFIG_STEP, mChanSpacing);
+ }
ed.putInt(LAST_RECORD_DURATION, mRecordDuration);
ed.putBoolean(LAST_AF_JUMP_VALUE, mAFAutoSwitch);
ed.commit();
@@ -686,8 +699,8 @@ public class FmSharedPreferences
public static void setChSpacing(int spacing)
{
- if( (spacing>=FmReceiver.FM_CHSPACE_200_KHZ)
- && (spacing<=FmReceiver.FM_CHSPACE_50_KHZ))
+ if( (spacing >= FmReceiver.FM_CHSPACE_200_KHZ)
+ && (spacing <= FmReceiver.FM_CHSPACE_50_KHZ))
{
mFrequencyBand_Stepsize = 200;
switch (spacing)
@@ -703,6 +716,7 @@ public class FmSharedPreferences
break;
}
}
+ mChanSpacing = spacing;
mFMConfiguration.setChSpacing(spacing);
}
}
@@ -761,12 +775,18 @@ public class FmSharedPreferences
return mFMConfiguration.getLowerLimit();
}
- public static void setLowerLimit(int lowLimit){
+ public static void setLowerLimit(int lowLimit) {
mFMConfiguration.setLowerLimit(lowLimit);
+ if(mCountry == REGIONAL_BAND_USER_DEFINED) {
+ mBandMinFreq = lowLimit;
+ }
}
public static void setUpperLimit(int upLimit){
mFMConfiguration.setUpperLimit(upLimit);
+ if(mCountry == REGIONAL_BAND_USER_DEFINED) {
+ mBandMaxFreq = upLimit;
+ }
}
public static void setCountry(int nCountryCode){
@@ -1052,6 +1072,23 @@ public class FmSharedPreferences
mFrequencyBand_Stepsize = 200;
break;
}
+ case REGIONAL_BAND_USER_DEFINED:
+ {
+ mFMConfiguration.setRadioBand(FmReceiver.FM_USER_DEFINED_BAND);
+ mFMConfiguration.setChSpacing(mChanSpacing);
+ mFMConfiguration.setEmphasis(FmReceiver.FM_DE_EMP75);
+ mFMConfiguration.setRdsStd(FmReceiver.FM_RDS_STD_RDS);
+ mFMConfiguration.setLowerLimit(mBandMinFreq);
+ mFMConfiguration.setUpperLimit(mBandMaxFreq);
+ if(mChanSpacing == 0) {
+ mFrequencyBand_Stepsize = 200;
+ }else if(mChanSpacing == 1) {
+ mFrequencyBand_Stepsize = 100;
+ }else {
+ mFrequencyBand_Stepsize = 50;
+ }
+ break;
+ }
default:
{
Log.d(LOGTAG, "Invalid: countryCode: "+nCountryCode);
diff --git a/fmapp/src/com/codeaurora/fmradio/Settings.java b/fmapp/src/com/codeaurora/fmradio/Settings.java
index b721a15..d5222c9 100644
--- a/fmapp/src/com/codeaurora/fmradio/Settings.java
+++ b/fmapp/src/com/codeaurora/fmradio/Settings.java
@@ -42,6 +42,9 @@ import android.preference.CheckBoxPreference;
import android.preference.PreferenceCategory;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
+import android.preference.EditTextPreference;
+import android.text.InputType;
+import android.widget.Toast;
import android.util.Log;
@@ -56,333 +59,438 @@ public class Settings extends PreferenceActivity implements
public static final String AUTO_AF = "af_checkbox_preference";
public static final String RESTORE_FACTORY_DEFAULT = "revert_to_fac";
public static final int RESTORE_FACTORY_DEFAULT_INT = 1;
+ public static final String USER_DEFINED_BAND_MIN_KEY = "user_defined_band_min";
+ public static final String USER_DEFINED_BAND_MAX_KEY = "user_defined_band_max";
+ public static final String CHAN_SPACING_KEY = "chanl_spacing";
public static final String RESTORE_FACTORY_DEFAULT_ACTION = "com.codeaurora.fmradio.settings.revert_to_defaults";
private static final String LOGTAG = FMRadio.LOGTAG;
+ private static final String USR_BAND_MSG = "Enter Freq from range 76.0 - 108.0";
private ListPreference mBandPreference;
private ListPreference mAudioPreference;
private ListPreference mRecordDurPreference;
private CheckBoxPreference mAfPref;
+ private EditTextPreference mUserBandMinPref;
+ private EditTextPreference mUserBandMaxPref;
+ private ListPreference mChannelSpacingPref;
private Preference mRestoreDefaultPreference;
private FmSharedPreferences mPrefs = null;
private boolean mRxMode = false;
+ private int min_freq;
+ private int max_freq;
+ private int chan_spacing;
+ private String[] summaryBandItems;
+ private String[] chSpacingItems;
+ private String[] summaryAudioModeItems;
+ private String[] summaryRecordItems;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- Intent intent = getIntent();
- if (intent != null) {
- mRxMode = intent.getBooleanExtra(RX_MODE, false);
- }
- mPrefs = new FmSharedPreferences(this);
- if (mPrefs != null) {
- setPreferenceScreen(createPreferenceHierarchy());
- }
+ super.onCreate(savedInstanceState);
+ Intent intent = getIntent();
+ if (intent != null) {
+ mRxMode = intent.getBooleanExtra(RX_MODE, false);
+ }
+ mPrefs = new FmSharedPreferences(this);
+ if (mPrefs != null) {
+ setPreferenceScreen(createPreferenceHierarchy());
+ }
}
-
private PreferenceScreen createPreferenceHierarchy() {
- int index = 0;
- if (mPrefs == null) {
- return null;
- }
+ int index = 0;
+ if (mPrefs == null) {
+ return null;
+ }
// Root
- PreferenceScreen root = getPreferenceManager().createPreferenceScreen(
+ PreferenceScreen root = getPreferenceManager().createPreferenceScreen(
this);
- // Band/Country
- String[] summaryBandItems = getResources().getStringArray(
+ summaryBandItems = getResources().getStringArray(
R.array.regional_band_summary);
- mBandPreference = new ListPreference(this);
- mBandPreference.setEntries(R.array.regional_band_entries);
- mBandPreference.setEntryValues(R.array.regional_band_values);
- mBandPreference.setDialogTitle(R.string.sel_band_menu);
- mBandPreference.setKey(REGIONAL_BAND_KEY);
- mBandPreference.setTitle(R.string.regional_band);
- index = FmSharedPreferences.getCountry();
- Log.d(LOGTAG, "createPreferenceHierarchy: Country: " + index);
- // Get the preference and list the value.
- if ((index < 0) || (index >= summaryBandItems.length)) {
- index = 0;
- }
- Log.d(LOGTAG, "createPreferenceHierarchy: CountrySummary: "
- + summaryBandItems[index]);
- mBandPreference.setSummary(summaryBandItems[index]);
- mBandPreference.setValueIndex(index);
- root.addPreference(mBandPreference);
-
- if (mRxMode) {
- // Audio Output (Stereo or Mono)
- String[] summaryAudioModeItems = getResources().getStringArray(
+ chSpacingItems = getResources().getStringArray(
+ R.array.channel_spacing_entries);
+ mBandPreference = new ListPreference(this);
+ mBandPreference.setEntries(R.array.regional_band_entries);
+ mBandPreference.setEntryValues(R.array.regional_band_values);
+ mBandPreference.setDialogTitle(R.string.sel_band_menu);
+ mBandPreference.setKey(REGIONAL_BAND_KEY);
+ mBandPreference.setTitle(R.string.regional_band);
+ index = FmSharedPreferences.getCountry();
+ Log.d(LOGTAG, "createPreferenceHierarchy: Country: " + index);
+ // Get the preference and list the value.
+ if ((index < 0) || (index >= summaryBandItems.length)) {
+ index = 0;
+ }
+ mBandPreference.setValueIndex(index);
+ root.addPreference(mBandPreference);
+
+ mChannelSpacingPref = new ListPreference(this);
+ mChannelSpacingPref.setEntries(R.array.channel_spacing_entries);
+ mChannelSpacingPref.setEntryValues(R.array.channel_spacing_val);
+ mChannelSpacingPref.setDialogTitle(R.string.sel_chanl_spacing);
+ mChannelSpacingPref.setTitle(R.string.chanl_spacing);
+ mChannelSpacingPref.setKey(CHAN_SPACING_KEY);
+
+ mUserBandMinPref = new EditTextPreference(this);
+ mUserBandMinPref.setKey(USER_DEFINED_BAND_MIN_KEY);
+ mUserBandMinPref.setTitle(R.string.usr_def_band_min);
+ mUserBandMinPref.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER |
+ InputType.TYPE_NUMBER_FLAG_DECIMAL);
+ mUserBandMinPref.setDialogTitle(R.string.usr_def_band_min);
+
+ mUserBandMaxPref = new EditTextPreference(this);
+ mUserBandMaxPref.setKey(USER_DEFINED_BAND_MAX_KEY);
+ mUserBandMaxPref.setTitle(R.string.usr_def_band_max);
+ mUserBandMaxPref.setDialogTitle(R.string.usr_def_band_max);
+ mUserBandMaxPref.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER |
+ InputType.TYPE_NUMBER_FLAG_DECIMAL);
+
+ setBandSummary(index);
+
+ root.addPreference(mChannelSpacingPref);
+ root.addPreference(mUserBandMinPref);
+ root.addPreference(mUserBandMaxPref);
+
+ if (mRxMode) {
+ // Audio Output (Stereo or Mono)
+ summaryAudioModeItems = getResources().getStringArray(
R.array.ster_mon_entries);
- mAudioPreference = new ListPreference(this);
- mAudioPreference.setEntries(R.array.ster_mon_entries);
- mAudioPreference.setEntryValues(R.array.ster_mon_values);
- mAudioPreference.setDialogTitle(R.string.sel_audio_output);
- mAudioPreference.setKey(AUDIO_OUTPUT_KEY);
- mAudioPreference.setTitle(R.string.aud_output_mode);
- boolean audiomode = FmSharedPreferences.getAudioOutputMode();
- if (audiomode) {
- index = 0;
- } else {
- index = 1;
- }
- Log.d(LOGTAG, "createPreferenceHierarchy: audiomode: " + audiomode);
- mAudioPreference.setSummary(summaryAudioModeItems[index]);
- mAudioPreference.setValueIndex(index);
- root.addPreference(mAudioPreference);
-
- // AF Auto Enable (Checkbox)
- mAfPref = new CheckBoxPreference(this);
- mAfPref.setKey(AUTO_AF);
- mAfPref.setTitle(R.string.auto_select_af);
- mAfPref.setSummaryOn(R.string.auto_select_af_enabled);
- mAfPref.setSummaryOff(R.string.auto_select_af_disabled);
- boolean bAFAutoSwitch = FmSharedPreferences.getAutoAFSwitch();
- Log.d(LOGTAG, "createPreferenceHierarchy: bAFAutoSwitch: "
- + bAFAutoSwitch);
- mAfPref.setChecked(bAFAutoSwitch);
- root.addPreference(mAfPref);
-
-
- if(FMRadio.RECORDING_ENABLE)
- {
- String[] summaryRecordItems = getResources().getStringArray(
- R.array.record_durations_entries);
- int nRecordDuration = 0;
- mRecordDurPreference = new ListPreference(this);
- mRecordDurPreference.setEntries(R.array.record_durations_entries);
- mRecordDurPreference.setEntryValues(R.array.record_duration_values);
- mRecordDurPreference.setDialogTitle(R.string.sel_rec_dur);
- mRecordDurPreference.setKey(RECORD_DURATION_KEY);
- mRecordDurPreference.setTitle(R.string.record_dur);
- nRecordDuration = FmSharedPreferences.getRecordDuration();
- Log
- .d(LOGTAG, "createPreferenceHierarchy: recordDuration: "
+ mAudioPreference = new ListPreference(this);
+ mAudioPreference.setEntries(R.array.ster_mon_entries);
+ mAudioPreference.setEntryValues(R.array.ster_mon_values);
+ mAudioPreference.setDialogTitle(R.string.sel_audio_output);
+ mAudioPreference.setKey(AUDIO_OUTPUT_KEY);
+ mAudioPreference.setTitle(R.string.aud_output_mode);
+ boolean audiomode = FmSharedPreferences.getAudioOutputMode();
+ if (audiomode) {
+ index = 0;
+ } else {
+ index = 1;
+ }
+ Log.d(LOGTAG, "createPreferenceHierarchy: audiomode: " + audiomode);
+ mAudioPreference.setSummary(summaryAudioModeItems[index]);
+ mAudioPreference.setValueIndex(index);
+ root.addPreference(mAudioPreference);
+
+ // AF Auto Enable (Checkbox)
+ mAfPref = new CheckBoxPreference(this);
+ mAfPref.setKey(AUTO_AF);
+ mAfPref.setTitle(R.string.auto_select_af);
+ mAfPref.setSummaryOn(R.string.auto_select_af_enabled);
+ mAfPref.setSummaryOff(R.string.auto_select_af_disabled);
+ boolean bAFAutoSwitch = FmSharedPreferences.getAutoAFSwitch();
+ Log.d(LOGTAG, "createPreferenceHierarchy: bAFAutoSwitch: "
+ + bAFAutoSwitch);
+ mAfPref.setChecked(bAFAutoSwitch);
+ root.addPreference(mAfPref);
+
+
+ if(FMRadio.RECORDING_ENABLE) {
+ summaryRecordItems = getResources().getStringArray(
+ R.array.record_durations_entries);
+ int nRecordDuration = 0;
+ mRecordDurPreference = new ListPreference(this);
+ mRecordDurPreference.setEntries(R.array.record_durations_entries);
+ mRecordDurPreference.setEntryValues(R.array.record_duration_values);
+ mRecordDurPreference.setDialogTitle(R.string.sel_rec_dur);
+ mRecordDurPreference.setKey(RECORD_DURATION_KEY);
+ mRecordDurPreference.setTitle(R.string.record_dur);
+ nRecordDuration = FmSharedPreferences.getRecordDuration();
+ Log.d(LOGTAG, "createPreferenceHierarchy: recordDuration: "
+ nRecordDuration);
- switch( nRecordDuration ) {
- case FmSharedPreferences.RECORD_DUR_INDEX_0_VAL:
- index =0;
- break;
- case FmSharedPreferences.RECORD_DUR_INDEX_1_VAL:
- index =1;
- break;
- case FmSharedPreferences.RECORD_DUR_INDEX_2_VAL:
- index =2;
- break;
- case FmSharedPreferences.RECORD_DUR_INDEX_3_VAL:
- index =3;
- break;
- }
- // Get the preference and list the value.
- if ((index < 0) || (index >= summaryRecordItems.length)) {
- index = 0;
- }
- Log.d(LOGTAG, "createPreferenceHierarchy: recordDurationSummary: "
- + summaryRecordItems[index]);
- mRecordDurPreference.setSummary(summaryRecordItems[index]);
- mRecordDurPreference.setValueIndex(index);
- root.addPreference(mRecordDurPreference);
- }
- }
-
- // Add a new category
- PreferenceCategory prefCat = new PreferenceCategory(this);
- root.addPreference(prefCat);
-
- mRestoreDefaultPreference = new Preference(this);
- mRestoreDefaultPreference
+ switch( nRecordDuration ) {
+ case FmSharedPreferences.RECORD_DUR_INDEX_0_VAL:
+ index = 0;
+ break;
+ case FmSharedPreferences.RECORD_DUR_INDEX_1_VAL:
+ index = 1;
+ break;
+ case FmSharedPreferences.RECORD_DUR_INDEX_2_VAL:
+ index = 2;
+ break;
+ case FmSharedPreferences.RECORD_DUR_INDEX_3_VAL:
+ index = 3;
+ break;
+ }
+ // Get the preference and list the value.
+ if ((index < 0) || (index >= summaryRecordItems.length)) {
+ index = 0;
+ }
+ Log.d(LOGTAG, "createPreferenceHierarchy: recordDurationSummary: "
+ + summaryRecordItems[index]);
+ mRecordDurPreference.setSummary(summaryRecordItems[index]);
+ mRecordDurPreference.setValueIndex(index);
+ root.addPreference(mRecordDurPreference);
+ }
+ }
+
+ // Add a new category
+ PreferenceCategory prefCat = new PreferenceCategory(this);
+ root.addPreference(prefCat);
+
+ mRestoreDefaultPreference = new Preference(this);
+ mRestoreDefaultPreference
.setTitle(R.string.settings_revert_defaults_title);
- mRestoreDefaultPreference.setKey(RESTORE_FACTORY_DEFAULT);
- mRestoreDefaultPreference
+ mRestoreDefaultPreference.setKey(RESTORE_FACTORY_DEFAULT);
+ mRestoreDefaultPreference
.setSummary(R.string.settings_revert_defaults_summary);
- mRestoreDefaultPreference.setOnPreferenceClickListener(this);
- root.addPreference(mRestoreDefaultPreference);
- return root;
+ mRestoreDefaultPreference.setOnPreferenceClickListener(this);
+ root.addPreference(mRestoreDefaultPreference);
+ return root;
}
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
String key) {
- int mTunedFreq = 0;
- boolean bStatus = false;
- if (key.equals(REGIONAL_BAND_KEY)) {
- int curListIndex = FmSharedPreferences.getCurrentListIndex();
- PresetList curList = FmSharedPreferences.getStationList(curListIndex);
- String[] summaryBandItems = getResources().getStringArray(
- R.array.regional_band_summary);
- String valueStr = sharedPreferences.getString(key, "");
- int index = 0;
- if (valueStr != null) {
- index = mBandPreference.findIndexOfValue(valueStr);
- }
- if ((index < 0) || (index >= summaryBandItems.length)) {
- index = 0;
- mBandPreference.setValueIndex(0);
- }
- Log.d(LOGTAG, "onSharedPreferenceChanged: Country Change: "
- + index);
- mBandPreference.setSummary(summaryBandItems[index]);
- FmSharedPreferences.setCountry(index);
- bStatus = FMRadio.fmConfigure();
- FMTransmitterActivity.fmConfigure();
- if (curList != null) {
- curList.clear();
- }
- } else {
- if (mRxMode) {
- if (key.equals(AUTO_AF)) {
- boolean bAFAutoSwitch = mAfPref.isChecked();
- Log.d(LOGTAG, "onSharedPreferenceChanged: Auto AF Enable: "
- + bAFAutoSwitch);
- FmSharedPreferences.setAutoAFSwitch(bAFAutoSwitch);
- FMRadio.fmAutoAFSwitch();
- mPrefs.Save();
- } else if (key.equals(RECORD_DURATION_KEY)) {
- if(FMRadio.RECORDING_ENABLE)
- {
- String[] recordItems = getResources().getStringArray(
- R.array.record_durations_entries);
- String valueStr = mRecordDurPreference.getValue();
- int index = 0;
- if (valueStr != null) {
- index = mRecordDurPreference.findIndexOfValue(valueStr);
- }
- if ((index < 0) || (index >= recordItems.length)) {
- index = 0;
- mRecordDurPreference.setValueIndex(index);
- }
- Log.d(LOGTAG, "onSharedPreferenceChanged: recorddur: "
- + recordItems[index]);
- mRecordDurPreference.setSummary(recordItems[index]);
- FmSharedPreferences.setRecordDuration(index);
+ int mTunedFreq = 0;
+ boolean bStatus = false;
+ if (key.equals(REGIONAL_BAND_KEY)) {
+ int curListIndex = FmSharedPreferences.getCurrentListIndex();
+ PresetList curList = FmSharedPreferences.getStationList(curListIndex);
+ String valueStr = sharedPreferences.getString(key, "");
+ int index = 0;
+ if (valueStr != null) {
+ index = mBandPreference.findIndexOfValue(valueStr);
}
- } else if (key.equals(AUDIO_OUTPUT_KEY)) {
- String[] bandItems = getResources().getStringArray(
- R.array.ster_mon_entries);
- String valueStr = mAudioPreference.getValue();
- int index = 0;
- if (valueStr != null) {
- index = mAudioPreference.findIndexOfValue(valueStr);
- }
- if (index != 1) {
- if (index != 0) {
- index = 0;
- /* It shud be 0(Stereo) or 1(Mono) */
- mAudioPreference.setValueIndex(index);
- }
- }
- Log.d(LOGTAG, "onSharedPreferenceChanged: audiomode: "
- + bandItems[index]);
- mAudioPreference.setSummary(bandItems[index]);
- if (index == 0) {
- // Stereo
- FmSharedPreferences.setAudioOutputMode(true);
- } else {
- // Mono
- FmSharedPreferences.setAudioOutputMode(false);
- }
- FMRadio.fmAudioOutputMode();
- }
- }
- }
- if (mPrefs != null)
- {
- if(bStatus)
- mPrefs.Save();
- else {
- mTunedFreq = FmSharedPreferences.getTunedFrequency();
- if (mTunedFreq > FmSharedPreferences.getUpperLimit() || mTunedFreq < FmSharedPreferences.getLowerLimit()) {
- FmSharedPreferences.setTunedFrequency(FmSharedPreferences.getLowerLimit());
- }
- mPrefs.Save();
- }
- }
+ if ((index < 0) || (index >= summaryBandItems.length)) {
+ index = 0;
+ mBandPreference.setValueIndex(0);
+ }else if((index + 1) == summaryBandItems.length) {
+ mChannelSpacingPref.setEnabled(true);
+ }else {
+ mChannelSpacingPref.setEnabled(false);
+ }
+ Log.d(LOGTAG, "onSharedPreferenceChanged: Country Change: "
+ + index);
+ FmSharedPreferences.setCountry(index);
+ setBandSummary(index);
+ bStatus = FMRadio.fmConfigure();
+ FMTransmitterActivity.fmConfigure();
+ if (curList != null) {
+ curList.clear();
+ }
+ }else if(key.equals(CHAN_SPACING_KEY)) {
+ int curListIndex = FmSharedPreferences.getCurrentListIndex();
+ PresetList curList = FmSharedPreferences.getStationList(curListIndex);
+ String valStr = mChannelSpacingPref.getValue();
+ int index = 0;
+ if(valStr != null) {
+ index = mChannelSpacingPref.findIndexOfValue(valStr);
+ }
+ if ((index < 0) || (index >= summaryRecordItems.length)) {
+ index = 0;
+ mChannelSpacingPref.setValueIndex(0);
+ }
+ mChannelSpacingPref.setSummary(chSpacingItems[index]);
+ FmSharedPreferences.setChSpacing(2 - index);
+ FMRadio.fmConfigure();
+ FMTransmitterActivity.fmConfigure();
+ if(curList != null) {
+ curList.clear();
+ }
+ }else if(key.equals(USER_DEFINED_BAND_MIN_KEY)) {
+ String valStr = mUserBandMinPref.getText();
+ double freq = Double.parseDouble(valStr) * 1000;
+ max_freq = FmSharedPreferences.getUpperLimit();
+ min_freq = FmSharedPreferences.getLowerLimit();
+ if((freq > 0) && (freq < max_freq) && (freq >= 76000)) {
+ FmSharedPreferences.setLowerLimit((int)freq);
+ FMRadio.fmConfigure();
+ FMTransmitterActivity.fmConfigure();
+ setBandSummary(summaryBandItems.length - 1);
+ }else {
+ displayToast(USR_BAND_MSG);
+ }
+ }else if(key.equals(USER_DEFINED_BAND_MAX_KEY)) {
+ String valStr = mUserBandMaxPref.getText();
+ double freq = Double.parseDouble(valStr) * 1000;
+ min_freq = FmSharedPreferences.getLowerLimit();
+ max_freq = FmSharedPreferences.getUpperLimit();
+ if((freq > 0) && (freq > min_freq) && (freq <= 108000)) {
+ FmSharedPreferences.setUpperLimit((int)freq);
+ FMRadio.fmConfigure();
+ FMTransmitterActivity.fmConfigure();
+ setBandSummary(summaryBandItems.length - 1);
+ }else {
+ displayToast(USR_BAND_MSG);
+ }
+ }else {
+ if (mRxMode) {
+ if (key.equals(AUTO_AF)) {
+ boolean bAFAutoSwitch = mAfPref.isChecked();
+ Log.d(LOGTAG, "onSharedPreferenceChanged: Auto AF Enable: "
+ + bAFAutoSwitch);
+ FmSharedPreferences.setAutoAFSwitch(bAFAutoSwitch);
+ FMRadio.fmAutoAFSwitch();
+ mPrefs.Save();
+ } else if (key.equals(RECORD_DURATION_KEY)) {
+ if(FMRadio.RECORDING_ENABLE) {
+ String valueStr = mRecordDurPreference.getValue();
+ int index = 0;
+ if (valueStr != null) {
+ index = mRecordDurPreference.findIndexOfValue(valueStr);
+ }
+ if ((index < 0) || (index >= summaryRecordItems.length)) {
+ index = 0;
+ mRecordDurPreference.setValueIndex(index);
+ }
+ Log.d(LOGTAG, "onSharedPreferenceChanged: recorddur: "
+ + summaryRecordItems[index]);
+ mRecordDurPreference.setSummary(summaryRecordItems[index]);
+ FmSharedPreferences.setRecordDuration(index);
+ }
+ } else if (key.equals(AUDIO_OUTPUT_KEY)) {
+ String valueStr = mAudioPreference.getValue();
+ int index = 0;
+ if (valueStr != null) {
+ index = mAudioPreference.findIndexOfValue(valueStr);
+ }
+ if (index != 1) {
+ if (index != 0) {
+ index = 0;
+ /* It shud be 0(Stereo) or 1(Mono) */
+ mAudioPreference.setValueIndex(index);
+ }
+ }
+ Log.d(LOGTAG, "onSharedPreferenceChanged: audiomode: "
+ + summaryAudioModeItems[index]);
+ mAudioPreference.setSummary(summaryAudioModeItems[index]);
+ if (index == 0) {
+ // Stereo
+ FmSharedPreferences.setAudioOutputMode(true);
+ } else {
+ // Mono
+ FmSharedPreferences.setAudioOutputMode(false);
+ }
+ FMRadio.fmAudioOutputMode();
+ }
+ }
+ }
+ if (mPrefs != null) {
+ if(bStatus) {
+ mPrefs.Save();
+ }else {
+ mTunedFreq = FmSharedPreferences.getTunedFrequency();
+ if ((mTunedFreq > FmSharedPreferences.getUpperLimit())
+ || mTunedFreq < FmSharedPreferences.getLowerLimit()) {
+
+ FmSharedPreferences.setTunedFrequency(FmSharedPreferences.getLowerLimit());
+ }
+ mPrefs.Save();
+ }
+ }
}
public boolean onPreferenceClick(Preference preference) {
- boolean handled = false;
- if (preference == mRestoreDefaultPreference) {
- showDialog(RESTORE_FACTORY_DEFAULT_INT);
- }
- return handled;
+ boolean handled = false;
+ if (preference == mRestoreDefaultPreference) {
+ showDialog(RESTORE_FACTORY_DEFAULT_INT);
+ }
+ return handled;
}
@Override
protected Dialog onCreateDialog(int id) {
- switch (id) {
- case RESTORE_FACTORY_DEFAULT_INT:
- return new AlertDialog.Builder(this).setIcon(
- R.drawable.alert_dialog_icon).setTitle(
- R.string.settings_revert_confirm_title).setMessage(
- R.string.settings_revert_confirm_msg).setPositiveButton(
- R.string.alert_dialog_ok,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog,
- int whichButton) {
- Intent data = new Intent(
- RESTORE_FACTORY_DEFAULT_ACTION);
- setResult(RESULT_OK, data);
- restoreSettingsDefault();
- finish();
- }
-
- }).setNegativeButton(R.string.alert_dialog_cancel,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog,
- int whichButton) {
- }
- }).create();
- default:
- break;
- }
- return null;
+ switch (id) {
+ case RESTORE_FACTORY_DEFAULT_INT:
+ return new AlertDialog.Builder(this).setIcon(
+ R.drawable.alert_dialog_icon).setTitle(
+ R.string.settings_revert_confirm_title).setMessage(
+ R.string.settings_revert_confirm_msg).setPositiveButton(
+ R.string.alert_dialog_ok,
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog,
+ int whichButton) {
+ Intent data = new Intent(
+ RESTORE_FACTORY_DEFAULT_ACTION);
+ setResult(RESULT_OK, data);
+ restoreSettingsDefault();
+ finish();
+ }
+
+ }).setNegativeButton(R.string.alert_dialog_cancel,
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog,
+ int whichButton) {
+ }
+ }).create();
+ default:
+ break;
+ }
+ return null;
}
private void restoreSettingsDefault() {
- if (mPrefs != null) {
- mBandPreference.setValueIndex(0);
- if (mRxMode) {
- mAudioPreference.setValueIndex(0);
- if(FMRadio.RECORDING_ENABLE)
- {
- mRecordDurPreference.setValueIndex(0);
- }
- mAfPref.setChecked(false);
- FmSharedPreferences.SetDefaults();
- }
- else
- {
- FmSharedPreferences.setCountry(FmSharedPreferences.REGIONAL_BAND_NORTH_AMERICA);
- }
- mPrefs.Save();
- }
+ if (mPrefs != null) {
+ mBandPreference.setValueIndex(0);
+ if (mRxMode) {
+ mAudioPreference.setValueIndex(0);
+ if(FMRadio.RECORDING_ENABLE) {
+ mRecordDurPreference.setValueIndex(0);
+ }
+ mAfPref.setChecked(false);
+ FmSharedPreferences.SetDefaults();
+ } else {
+ FmSharedPreferences.setCountry(FmSharedPreferences.REGIONAL_BAND_NORTH_AMERICA);
+ }
+ mPrefs.Save();
+ }
}
@Override
protected void onResume() {
- super.onResume();
- PreferenceScreen preferenceScreen = getPreferenceScreen();
- SharedPreferences sharedPreferences = null;
- if (preferenceScreen != null) {
- sharedPreferences = preferenceScreen.getSharedPreferences();
- }
- if (sharedPreferences != null) {
- sharedPreferences.registerOnSharedPreferenceChangeListener(this);
- }
+ super.onResume();
+ PreferenceScreen preferenceScreen = getPreferenceScreen();
+ SharedPreferences sharedPreferences = null;
+ if (preferenceScreen != null) {
+ sharedPreferences = preferenceScreen.getSharedPreferences();
+ }
+ if (sharedPreferences != null) {
+ sharedPreferences.registerOnSharedPreferenceChangeListener(this);
+ }
}
@Override
protected void onPause() {
- super.onPause();
- PreferenceScreen preferenceScreen = getPreferenceScreen();
- SharedPreferences sharedPreferences = null;
- if (preferenceScreen != null) {
- sharedPreferences = preferenceScreen.getSharedPreferences();
- }
- if (sharedPreferences != null) {
- sharedPreferences.unregisterOnSharedPreferenceChangeListener(this);
- }
+ super.onPause();
+ PreferenceScreen preferenceScreen = getPreferenceScreen();
+ SharedPreferences sharedPreferences = null;
+ if (preferenceScreen != null) {
+ sharedPreferences = preferenceScreen.getSharedPreferences();
+ }
+ if (sharedPreferences != null) {
+ sharedPreferences.unregisterOnSharedPreferenceChangeListener(this);
+ }
+ }
+ private void setBandSummary(int index) {
+ if((index + 1) == summaryBandItems.length) {
+ min_freq = FmSharedPreferences.getLowerLimit();
+ max_freq = FmSharedPreferences.getUpperLimit();
+ chan_spacing = FmSharedPreferences.getChSpacing();
+ if(chan_spacing < 0) {
+ chan_spacing = 0;
+ }
+ mBandPreference.setSummary(summaryBandItems[index] + "( "
+ + (min_freq / 1000.0) +"Mhz To " + (max_freq / 1000.0) +
+ "Mhz)");
+ mChannelSpacingPref.setValueIndex(2 - chan_spacing);
+ mChannelSpacingPref.setSummary(chSpacingItems[2 - chan_spacing]);
+ mChannelSpacingPref.setEnabled(true);
+ mUserBandMinPref.setEnabled(true);
+ mUserBandMaxPref.setEnabled(true);
+ mUserBandMinPref.setSummary((min_freq / 1000.0) + "Mhz");
+ mUserBandMaxPref.setSummary((max_freq / 1000.0) + "Mhz");
+ }else {
+ mBandPreference.setSummary(summaryBandItems[index]);
+ mChannelSpacingPref.setEnabled(false);
+ mUserBandMinPref.setEnabled(false);
+ mUserBandMaxPref.setEnabled(false);
+ }
}
+ private void displayToast(String msg) {
+ Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG).show();
+ }
}