Merge "FM-APP2: Save Speaker on/off state"
diff --git a/fmapp2/res/layout/fmstats.xml b/fmapp2/res/layout/fmstats.xml
index d9306d5..2501a51 100644
--- a/fmapp2/res/layout/fmstats.xml
+++ b/fmapp2/res/layout/fmstats.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!--
- * Copyright (c) 2011, 2012, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2011-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:
@@ -88,6 +88,21 @@
                android:textSize="15sp"
                android:visibility="gone"/>
 
+           <Button
+               android:id="@+id/SearchMpxDcc"
+               android:layout_width="wrap_content"
+               android:layout_height="wrap_content"
+               android:text="@string/search_algo_mpx"
+               android:visibility="gone"/>
+
+           <Button
+               android:id="@+id/SearchSinrInt"
+               android:layout_width="wrap_content"
+               android:layout_height="wrap_content"
+               android:text="@string/search_algo_sinrint"
+               android:layout_below="@id/SearchMpxDcc"
+               android:visibility="gone"/>
+
        </RelativeLayout>
 
        <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
diff --git a/fmapp2/res/values/arrays.xml b/fmapp2/res/values/arrays.xml
index cb673c8..d7904be 100644
--- a/fmapp2/res/values/arrays.xml
+++ b/fmapp2/res/values/arrays.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!--
- * Copyright (c) 2009, 2011, 2012 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2009, 2011-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:
@@ -328,7 +328,7 @@
       <item> Get Station Parameters Repeat 20 times</item>
       <item> Get Search  station parameters</item>
       <item> Get FM Band sweep parameters</item>
-      <item> Configure FM Search Parameters</item>
+      <item> Configure Performance Parameters</item>
   </string-array>
 
   <string-array name="cfg_rf1">
@@ -342,12 +342,29 @@
       <item> Set SINR Threshold</item>
       <item> Set IntfDetoutLow Threshold</item>
       <item> Set IntfDetoutHigh Threshold</item>
+      <item> Set SinrFirstStage</item>
+      <item> Set RmssiFirstStage</item>
+      <item> Set CF0Th12</item>
+      <item> Set SearchAlgo Type</item>
+      <item> Get SINR Samples Count</item>
+      <item> Get SINR Threshold</item>
+      <item> Get SinrFirstStage</item>
+      <item> Get RmssiFirstStage</item>
+      <item> Get CF0Th12</item>
+      <item> Get Search Algo Type</item>
+      <item> Set AfJmpRmssi Threshold</item>
+      <item> Set GoodChRmssi Threshold</item>
+      <item> Set AfJmpRmssi Samples count</item>
+      <item> Get AfJmpRmssi Threshold</item>
+      <item> Get GoodChRmssi Threshold</item>
+      <item> Get AfJmpRmssi Samples count</item>
       <item> RF Statistics</item>
+      <item> Set RXREPEAT Count</item>
   </string-array>
 
   <string-array name="stats_options">
       <item> Select the option</item>
-      <item> Configure FM Search parameters</item>
+      <item> Configure Performance parameters</item>
       <item> RF Statistics</item>
   </string-array>
 
diff --git a/fmapp2/res/values/strings.xml b/fmapp2/res/values/strings.xml
index 0c46991..12c9778 100644
--- a/fmapp2/res/values/strings.xml
+++ b/fmapp2/res/values/strings.xml
@@ -229,7 +229,22 @@
     <string name="station_list_delete_station_prompt">Are you sure to delete <xliff:g id="name">%s</xliff:g> .</string>
     <string name="station_name_empty">Station name is empty, please input again.</string>
     <string name="station_name_exist">There is already a station named \"<xliff:g id="name">%s</xliff:g>\". Please input a different name.</string>
-
+    <string name="enter_SinrFirstStage">Enter Sinr First Stage</string>
+    <string name="set_SinrFirstStage">Config Sinr First Stage</string>
+    <string name="enter_RmssiFirstStage">Enter Rmssi First Stage</string>
+    <string name="set_RmssiFirstStage">Config Rmssi First Stage</string>
+    <string name="enter_CF0Th12">Enter CF0 Threshold</string>
+    <string name="set_CF0Th12">Config CF0 Threshold</string>
+    <string name="search_algo_mpx">MPX_DCC Algo</string>
+    <string name="search_algo_sinrint">SINR_INTF Algo</string>
+    <string name="enter_AfJmpRmssiTh">Enter Af Jump Rmssi Threshold</string>
+    <string name="set_AfJmpRmssiTh">Config Af Jump Rmssi Threshold</string>
+    <string name="enter_GdChRmssiTh">Enter Good Channel Rmssi Threshold</string>
+    <string name="set_GdChRmssiTh">Config Good Channel Rmssi Threshold</string>
+    <string name="enter_AfJmpRmssiSmplsCnt">Enter Af Jump Rmssi Samples count</string>
+    <string name="set_AfJmpRmssiSmplsCnt">Config Af Jump Rmssi Samples count</string>
     <string name="rt_plus_tags">Tags</string>
+    <string name="enter_RxRePeatCount">Enter RxRePeat count</string>
+    <string name="set_RxRePeatCount">Config RxRePeat count</string>
 
 </resources>
diff --git a/fmapp2/src/com/caf/fmradio/FMRadioService.java b/fmapp2/src/com/caf/fmradio/FMRadioService.java
index 3f1f6d8..df52734 100644
--- a/fmapp2/src/com/caf/fmradio/FMRadioService.java
+++ b/fmapp2/src/com/caf/fmradio/FMRadioService.java
@@ -1399,6 +1399,74 @@
       {
           return (mService.get().setIntfDetHighTh(intfHighTh));
       }
+      public int getSearchAlgoType()
+      {
+          return (mService.get().getSearchAlgoType());
+      }
+      public boolean setSearchAlgoType(int searchType)
+      {
+          return (mService.get().setSearchAlgoType(searchType));
+      }
+      public int getSinrFirstStage()
+      {
+          return (mService.get().getSinrFirstStage());
+      }
+      public boolean setSinrFirstStage(int sinr)
+      {
+          return (mService.get().setSinrFirstStage(sinr));
+      }
+      public int getRmssiFirstStage()
+      {
+          return (mService.get().getRmssiFirstStage());
+      }
+      public boolean setRmssiFirstStage(int rmssi)
+      {
+          return (mService.get().setRmssiFirstStage(rmssi));
+      }
+      public int getCFOMeanTh()
+      {
+          return (mService.get().getCFOMeanTh());
+      }
+      public boolean setCFOMeanTh(int th)
+      {
+          return (mService.get().setCFOMeanTh(th));
+      }
+      public int getSinrSamplesCnt()
+      {
+          return (mService.get().getSinrSamplesCnt());
+      }
+      public int getSinrTh()
+      {
+          return (mService.get().getSinrTh());
+      }
+      public int getAfJmpRmssiTh()
+      {
+          return (mService.get().getAfJmpRmssiTh());
+      }
+      public boolean setAfJmpRmssiTh(int afJmpRmssiTh)
+      {
+          return (mService.get().setAfJmpRmssiTh(afJmpRmssiTh));
+      }
+      public int getGoodChRmssiTh()
+      {
+          return (mService.get().getGoodChRmssiTh());
+      }
+      public boolean setGoodChRmssiTh(int gdChRmssiTh)
+      {
+          return (mService.get().setGoodChRmssiTh(gdChRmssiTh));
+      }
+      public int getAfJmpRmssiSamplesCnt()
+      {
+          return (mService.get().getAfJmpRmssiSamplesCnt());
+      }
+      public boolean setAfJmpRmssiSamplesCnt(int afJmpRmssiSmplsCnt)
+      {
+          return (mService.get().setAfJmpRmssiSamplesCnt(afJmpRmssiSmplsCnt));
+      }
+      public boolean setRxRepeatCount(int count)
+      {
+           return (mService.get().setRxRepeatCount(count));
+      }
    }
    private final IBinder mBinder = new ServiceStub(this);
 
@@ -2712,7 +2780,103 @@
       else
          return false;
    }
+   public int getSearchAlgoType() {
+       if(mReceiver != null)
+          return mReceiver.getSearchAlgoType();
+       else
+          return -1;
+   }
+   public boolean setSearchAlgoType(int searchType) {
+        if(mReceiver != null)
+           return mReceiver.setSearchAlgoType(searchType);
+        else
+           return false;
+   }
+   public int getSinrFirstStage() {
+        if(mReceiver != null)
+           return mReceiver.getSinrFirstStage();
+        else
+           return Integer.MAX_VALUE;
+   }
+   public boolean setSinrFirstStage(int sinr) {
+        if(mReceiver != null)
+           return mReceiver.setSinrFirstStage(sinr);
+        else
+           return false;
+   }
+   public int getRmssiFirstStage() {
+        if(mReceiver != null)
+           return mReceiver.getRmssiFirstStage();
+        else
+           return Integer.MAX_VALUE;
+   }
+   public boolean setRmssiFirstStage(int rmssi) {
+         if(mReceiver != null)
+            return mReceiver.setRmssiFirstStage(rmssi);
+         else
+            return false;
+   }
+   public int getCFOMeanTh() {
+          if(mReceiver != null)
+             return mReceiver.getCFOMeanTh();
+          else
+             return Integer.MAX_VALUE;
+   }
+   public boolean setCFOMeanTh(int th) {
+          if(mReceiver != null)
+             return mReceiver.setCFOMeanTh(th);
+          else
+             return false;
+   }
+   public int getSinrSamplesCnt() {
+          if(mReceiver != null)
+             return mReceiver.getSINRsamples();
+          else
+             return Integer.MAX_VALUE;
+   }
+   public int getSinrTh() {
+          if(mReceiver != null)
+             return mReceiver.getSINRThreshold();
+          else
+             return Integer.MAX_VALUE;
+   }
 
+   boolean setAfJmpRmssiTh(int afJmpRmssiTh) {
+          if(mReceiver != null)
+             return mReceiver.setAFJumpRmssiTh(afJmpRmssiTh);
+          else
+             return false;
+   }
+   boolean setGoodChRmssiTh(int gdChRmssiTh) {
+          if(mReceiver != null)
+             return mReceiver.setGdChRmssiTh(gdChRmssiTh);
+          else
+             return false;
+   }
+   boolean setAfJmpRmssiSamplesCnt(int afJmpRmssiSmplsCnt) {
+          if(mReceiver != null)
+             return mReceiver.setAFJumpRmssiSamples(afJmpRmssiSmplsCnt);
+          else
+             return false;
+   }
+   int getAfJmpRmssiTh() {
+          if(mReceiver != null)
+             return mReceiver.getAFJumpRmssiTh();
+          else
+             return Integer.MIN_VALUE;
+   }
+   int getGoodChRmssiTh() {
+          if(mReceiver != null)
+             return mReceiver.getGdChRmssiTh();
+          else
+             return Integer.MAX_VALUE;
+   }
+   int getAfJmpRmssiSamplesCnt() {
+          if(mReceiver != null)
+             return mReceiver.getAFJumpRmssiSamples();
+          else
+             return Integer.MIN_VALUE;
+   }
    private void setAlarmSleepExpired (long duration) {
        Intent i = new Intent(SLEEP_EXPIRED_ACTION);
        AlarmManager am = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
@@ -2756,6 +2920,13 @@
        cancelAlarmRecordTimeout();
        cancelAlarmDealyedServiceStop();
    }
+   public boolean setRxRepeatCount(int count) {
+      if(mReceiver != null)
+         return mReceiver.setPSRxRepeatCount(count);
+      else
+         return false;
+   }
+
    //handling the sleep and record stop when FM App not in focus
    private void delayedStop(long duration, int nType) {
        int whatId = (nType == STOP_SERVICE) ? STOPSERVICE_ONSLEEP: STOPRECORD_ONTIMEOUT;
diff --git a/fmapp2/src/com/caf/fmradio/FMStats.java b/fmapp2/src/com/caf/fmradio/FMStats.java
index feb6aab..4014b8e 100644
--- a/fmapp2/src/com/caf/fmradio/FMStats.java
+++ b/fmapp2/src/com/caf/fmradio/FMStats.java
@@ -45,6 +45,7 @@
 import android.widget.AdapterView;
 import android.widget.ArrayAdapter;
 import android.widget.Button;
+import android.widget.RadioButton;
 import android.widget.EditText;
 import android.widget.ProgressBar;
 import android.widget.Spinner;
@@ -66,6 +67,8 @@
 public class FMStats extends Activity  {
 
     EditText txtbox1;
+    Button button1;
+    Button button2;
     TextView tv1;
     Button SetButton;
     Button RunButton;
@@ -182,6 +185,25 @@
 
     private static boolean mIsTransportSMD = false;
 
+    private static final int MPX_DCC = 0;
+    private static final int SINR_INTF = 1;
+    private static final int MIN_SINR_FIRST_STAGE = -128;
+    private static final int MAX_SINR_FIRST_STAGE = 127;
+    private static final int MIN_RMSSI_FIRST_STAGE = -128;
+    private static final int MAX_RMSSI_FIRST_STAGE = 127;
+    private static final int MIN_CF0TH12 = -2147483648;
+    private static final int MAX_CF0TH12 = 2147483647;
+    private static final int MIN_SINR_TH = -128;
+    private static final int MAX_SINR_TH = 127;
+    private static final int MIN_SINR_SAMPLES = 0;
+    private static final int MAX_SINR_SAMPLES = 255;
+    private static final int MIN_AF_JMP_RMSSI_TH = 0;
+    private static final int MAX_AF_JMP_RMSSI_TH = 65535;
+    private static final int MIN_GD_CH_RMSSI_TH = -128;
+    private static final int MAX_GD_CH_RMSSI_TH = 127;
+    private static final int MIN_AF_JMP_RMSSI_SAMPLES = 0;
+    private static final int MAX_AF_JMP_RMSSI_SAMPLES = 255;
+
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -409,6 +431,30 @@
        }
     };
 
+    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("");
+            }
+        }
+    };
+
     private View.OnClickListener mOnSetSigThListener = new View.OnClickListener() {
        public void onClick(View v) {
           String a;
@@ -507,6 +553,174 @@
        }
     };
 
+    private View.OnClickListener mOnSetSinrFirstStageListener = new View.OnClickListener() {
+       public void onClick(View v) {
+          String a;
+          a =  txtbox1.getText().toString();
+          try {
+              int sinr = Integer.parseInt(a);
+              Log.d(LOGTAG, "Value entered for SINR FIRST STAGE is : " + sinr);
+              if((sinr < MIN_SINR_FIRST_STAGE) ||
+                     (sinr > MAX_SINR_FIRST_STAGE))
+                  return;
+              if(mService != null) {
+                 try {
+                     mService.setSinrFirstStage(sinr);
+                 } catch (RemoteException e) {
+                     e.printStackTrace();
+                 }
+              }
+          } catch (NumberFormatException e) {
+              Log.e(LOGTAG, "Value entered is not in correct format : " + a);
+              txtbox1.setText("");
+          }
+       }
+    };
+    private View.OnClickListener mOnSetRmssiFirstStageListener = new View.OnClickListener() {
+       public void onClick(View v) {
+          String a;
+          a =  txtbox1.getText().toString();
+          try {
+              int rmssi = Integer.parseInt(a);
+              Log.d(LOGTAG, "Value entered for RMSSI FIRST STAGE is: " + rmssi);
+              if((rmssi < MIN_RMSSI_FIRST_STAGE) ||
+                     (rmssi > MAX_RMSSI_FIRST_STAGE))
+                  return;
+              if(mService != null) {
+                 try {
+                     mService.setRmssiFirstStage(rmssi);
+                 } catch (RemoteException e) {
+                     e.printStackTrace();
+                 }
+              }
+          } catch (NumberFormatException e) {
+              Log.e(LOGTAG, "Value entered is not in correct format : " + a);
+              txtbox1.setText("");
+          }
+       }
+    };
+
+    private View.OnClickListener mOnSetCFOMeanThListener = new View.OnClickListener() {
+       public void onClick(View v) {
+          String a;
+          a =  txtbox1.getText().toString();
+          try {
+              int cf0 = Integer.parseInt(a);
+              Log.d(LOGTAG, "Value entered for CF0TH12 is: " + cf0);
+              if((cf0 < MIN_CF0TH12) ||
+                     (cf0 > MAX_CF0TH12))
+                  return;
+              if(mService != null) {
+                 try {
+                     mService.setCFOMeanTh(cf0);
+                 } catch (RemoteException e) {
+                     e.printStackTrace();
+                 }
+              }
+          } catch (NumberFormatException e) {
+              Log.e(LOGTAG, "Value entered is not in correct format : " + a);
+              txtbox1.setText("");
+          }
+       }
+    };
+
+    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();
+                 }
+              }
+       }
+    };
+    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();
+                 }
+              }
+       }
+    };
+
+    private View.OnClickListener mOnSetAfJmpRmssiThListener = new View.OnClickListener() {
+       public void onClick(View v) {
+          String a;
+          a =  txtbox1.getText().toString();
+          try {
+              int th = Integer.parseInt(a);
+              Log.d(LOGTAG, "Value entered for AfJmpRmssiTh is: " + th);
+              if((th < MIN_AF_JMP_RMSSI_TH) ||
+                     (th > MAX_AF_JMP_RMSSI_TH))
+                  return;
+              if(mService != null) {
+                 try {
+                     mService.setAfJmpRmssiTh(th);
+                 } catch (RemoteException e) {
+                     e.printStackTrace();
+                 }
+              }
+          } catch (NumberFormatException e) {
+              Log.e(LOGTAG, "Value entered is not in correct format : " + a);
+              txtbox1.setText("");
+          }
+       }
+    };
+
+    private View.OnClickListener mOnSetGdChRmssiThListener = new View.OnClickListener() {
+       public void onClick(View v) {
+          String a;
+          a =  txtbox1.getText().toString();
+          try {
+              int th = Integer.parseInt(a);
+              Log.d(LOGTAG, "Value entered for Good channel Rmssi Th is: " + th);
+              if((th < MIN_GD_CH_RMSSI_TH) ||
+                     (th > MAX_GD_CH_RMSSI_TH))
+                  return;
+              if(mService != null) {
+                 try {
+                     mService.setGoodChRmssiTh(th);
+                 } catch (RemoteException e) {
+                     e.printStackTrace();
+                 }
+              }
+          } catch (NumberFormatException e) {
+              Log.e(LOGTAG, "Value entered is not in correct format : " + a);
+              txtbox1.setText("");
+          }
+       }
+    };
+
+    private View.OnClickListener mOnSetAfJmpRmssiSmplsCntListener = new View.OnClickListener() {
+       public void onClick(View v) {
+          String a;
+          a =  txtbox1.getText().toString();
+          try {
+              int cnt = Integer.parseInt(a);
+              Log.d(LOGTAG, "Value entered for AfJmpRmssiSamples is: " + cnt);
+              if((cnt < MIN_AF_JMP_RMSSI_SAMPLES) ||
+                     (cnt > MAX_AF_JMP_RMSSI_SAMPLES))
+                  return;
+              if(mService != null) {
+                 try {
+                     mService.setAfJmpRmssiSamplesCnt(cnt);
+                 } catch (RemoteException e) {
+                     e.printStackTrace();
+                 }
+              }
+          } catch (NumberFormatException e) {
+              Log.e(LOGTAG, "Value entered is not in correct format : " + a);
+              txtbox1.setText("");
+          }
+       }
+    };
+
     public class CfgRfItemSelectedListener1 implements OnItemSelectedListener {
         public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
             Log.d("Table","onItemSelected is hit with " + pos);
@@ -574,8 +788,11 @@
     public class CfgRfItemSelectedListener2 implements OnItemSelectedListener {
         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);
             tv1 = (TextView) findViewById(R.id.label);
+            button1 = (Button)findViewById(R.id.SearchMpxDcc);
+            button2 = (Button)findViewById(R.id.SearchSinrInt);
             Button SetButton = (Button)findViewById(R.id.Setbutton);
             tLayout.setVisibility(View.INVISIBLE);
             switch(pos)
@@ -589,6 +806,12 @@
                        tv1.setText(R.string.enter_SinrSmplsCnt);
                        tv1.setVisibility(View.VISIBLE);
                     }
+                    if(button1 != null) {
+                       button1.setVisibility(View.INVISIBLE);
+                    }
+                    if(button2 != null) {
+                       button2.setVisibility(View.INVISIBLE);
+                    }
                     if (SetButton != null) {
                        SetButton.setText(R.string.set_SinrSmplsCnt);
                        SetButton.setVisibility(View.VISIBLE);
@@ -604,6 +827,12 @@
                        tv1.setText(R.string.enter_SinrTh);
                        tv1.setVisibility(View.VISIBLE);
                     }
+                    if(button1 != null) {
+                       button1.setVisibility(View.INVISIBLE);
+                    }
+                    if(button2 != null) {
+                       button2.setVisibility(View.INVISIBLE);
+                    }
                     if (SetButton != null) {
                        SetButton.setText(R.string.set_SinrTh);
                        SetButton.setVisibility(View.VISIBLE);
@@ -619,6 +848,12 @@
                        tv1.setText(R.string.enter_IntfLowTh);
                        tv1.setVisibility(View.VISIBLE);
                     }
+                    if(button1 != null) {
+                       button1.setVisibility(View.INVISIBLE);
+                    }
+                    if(button2 != null) {
+                       button2.setVisibility(View.INVISIBLE);
+                    }
                     if (SetButton != null) {
                        SetButton.setText(R.string.set_IntfLowTh);
                        SetButton.setVisibility(View.VISIBLE);
@@ -634,6 +869,12 @@
                        tv1.setText(R.string.enter_IntfHighTh);
                        tv1.setVisibility(View.VISIBLE);
                     }
+                    if(button1 != null) {
+                       button1.setVisibility(View.INVISIBLE);
+                    }
+                    if(button2 != null) {
+                       button2.setVisibility(View.INVISIBLE);
+                    }
                     if (SetButton != null) {
                        SetButton.setText(R.string.set_IntfHighTh);
                        SetButton.setVisibility(View.VISIBLE);
@@ -641,6 +882,412 @@
                     }
                     break;
                 case 4:
+                    if (txtbox1 != null) {
+                       txtbox1.setText(R.string.type_rd);
+                       txtbox1.setVisibility(View.VISIBLE);
+                    }
+                    if (tv1 != null) {
+                       tv1.setText(R.string.enter_SinrFirstStage);
+                       tv1.setVisibility(View.VISIBLE);
+                    }
+                    if(button1 != null) {
+                       button1.setVisibility(View.INVISIBLE);
+                    }
+                    if(button2 != null) {
+                       button2.setVisibility(View.INVISIBLE);
+                    }
+                    if (SetButton != null) {
+                       SetButton.setText(R.string.set_SinrFirstStage);
+                       SetButton.setVisibility(View.VISIBLE);
+                       SetButton.setOnClickListener(mOnSetSinrFirstStageListener);
+                    }
+                    break;
+                case 5:
+                    if (txtbox1 != null) {
+                       txtbox1.setText(R.string.type_rd);
+                       txtbox1.setVisibility(View.VISIBLE);
+                    }
+                    if (tv1 != null) {
+                       tv1.setText(R.string.enter_RmssiFirstStage);
+                       tv1.setVisibility(View.VISIBLE);
+                    }
+                    if(button1 != null) {
+                       button1.setVisibility(View.INVISIBLE);
+                    }
+                    if(button2 != null) {
+                       button2.setVisibility(View.INVISIBLE);
+                    }
+                    if (SetButton != null) {
+                       SetButton.setText(R.string.set_RmssiFirstStage);
+                       SetButton.setVisibility(View.VISIBLE);
+                       SetButton.setOnClickListener(mOnSetRmssiFirstStageListener);
+                    }
+                    break;
+                case 6:
+                    if (txtbox1 != null) {
+                       txtbox1.setText(R.string.type_rd);
+                       txtbox1.setVisibility(View.VISIBLE);
+                    }
+                    if (tv1 != null) {
+                       tv1.setText(R.string.enter_CF0Th12);
+                       tv1.setVisibility(View.VISIBLE);
+                    }
+                    if(button1 != null) {
+                       button1.setVisibility(View.INVISIBLE);
+                    }
+                    if(button2 != null) {
+                       button2.setVisibility(View.INVISIBLE);
+                    }
+                    if (SetButton != null) {
+                       SetButton.setText(R.string.set_CF0Th12);
+                       SetButton.setVisibility(View.VISIBLE);
+                       SetButton.setOnClickListener(mOnSetCFOMeanThListener);
+                    }
+                    break;
+                case 7:
+                    if (txtbox1 != null) {
+                        txtbox1.setVisibility(View.INVISIBLE);
+                    }
+                    if (tv1 != null) {
+                        tv1.setVisibility(View.INVISIBLE);
+                    }
+                    if (SetButton != null) {
+                        SetButton.setVisibility(View.INVISIBLE);
+                    }
+                    if(button1 != null) {
+                       button1.setText(R.string.search_algo_mpx);
+                       button1.setVisibility(View.VISIBLE);
+                       button1.setOnClickListener(mOnSetSearchMPXDCCListener);
+                    }
+                    if(button2 != null) {
+                       button2.setText(R.string.search_algo_sinrint);
+                       button2.setVisibility(View.VISIBLE);
+                       button2.setOnClickListener(mOnSetSearchSinrIntfListener);
+                    }
+                    break;
+                case 8:
+                    if (txtbox1 != null) {
+                        txtbox1.setVisibility(View.INVISIBLE);
+                    }
+                    if (tv1 != null) {
+                        tv1.setText("");
+                        tv1.setVisibility(View.VISIBLE);
+                    }
+                    if(button1 != null) {
+                       button1.setVisibility(View.INVISIBLE);
+                    }
+                    if(button2 != null) {
+                       button2.setVisibility(View.INVISIBLE);
+                    }
+                    if (SetButton != null) {
+                        SetButton.setVisibility(View.INVISIBLE);
+                    }
+                    try {
+                        if(mService != null)
+                           ret = mService.getSinrSamplesCnt();
+                           Log.d(LOGTAG, "Get Sinr Samples Count: " + ret);
+                           if((ret >= MIN_SINR_SAMPLES) &&
+                                  (ret <= MAX_SINR_SAMPLES))
+                              tv1.setText(" " + String.valueOf(ret));
+                    }catch (RemoteException e) {
+                    }
+                    break;
+                case 9:
+                    if (txtbox1 != null) {
+                        txtbox1.setVisibility(View.INVISIBLE);
+                    }
+                    if (tv1 != null) {
+                        tv1.setText("");
+                        tv1.setVisibility(View.VISIBLE);
+                    }
+                    if(button1 != null) {
+                       button1.setVisibility(View.INVISIBLE);
+                    }
+                    if(button2 != null) {
+                       button2.setVisibility(View.INVISIBLE);
+                    }
+                    if (SetButton != null) {
+                        SetButton.setVisibility(View.INVISIBLE);
+                    }
+                    try {
+                        if(mService != null)
+                           ret = mService.getSinrTh();
+                           Log.d(LOGTAG, "Get Sinr Threshold: " + ret);
+                           if((ret >= MIN_SINR_TH) &&
+                                   (ret <= MAX_SINR_TH))
+                              tv1.setText(" " + String.valueOf(ret));
+                    }catch (RemoteException e) {
+
+                    }
+                    break;
+                case 10:
+                    if (txtbox1 != null) {
+                        txtbox1.setVisibility(View.INVISIBLE);
+                    }
+                    if (tv1 != null) {
+                        tv1.setText("");
+                        tv1.setVisibility(View.VISIBLE);
+                    }
+                    if(button1 != null) {
+                       button1.setVisibility(View.INVISIBLE);
+                    }
+                    if(button2 != null) {
+                       button2.setVisibility(View.INVISIBLE);
+                    }
+                    if (SetButton != null) {
+                        SetButton.setVisibility(View.INVISIBLE);
+                    }
+                    try {
+                        if(mService != null) {
+                           ret = mService.getSinrFirstStage();
+                           Log.d(LOGTAG, "Get Sinr First Stage: " + ret);
+                           if (ret >= MIN_SINR_FIRST_STAGE &&
+                                   ret <= MAX_SINR_FIRST_STAGE)
+                               tv1.setText(" " + String.valueOf(ret));
+                        }
+                    }catch (RemoteException e) {
+
+                    }
+                    break;
+                case 11:
+                    if (txtbox1 != null) {
+                        txtbox1.setVisibility(View.INVISIBLE);
+                    }
+                    if (tv1 != null) {
+                        tv1.setText("");
+                        tv1.setVisibility(View.VISIBLE);
+                    }
+                    if(button1 != null) {
+                       button1.setVisibility(View.INVISIBLE);
+                    }
+                    if(button2 != null) {
+                       button2.setVisibility(View.INVISIBLE);
+                    }
+                    if (SetButton != null) {
+                        SetButton.setVisibility(View.INVISIBLE);
+                    }
+                    try {
+                        if(mService != null) {
+                           ret = mService.getRmssiFirstStage();
+                           Log.d(LOGTAG, "Get Rmssi First Stage: " + ret);
+                           if (ret >= MIN_RMSSI_FIRST_STAGE &&
+                                   ret <= MAX_RMSSI_FIRST_STAGE)
+                               tv1.setText(" " + String.valueOf(ret));
+                        }
+                    }catch (RemoteException e) {
+
+                    }
+                    break;
+                case 12:
+                    if (txtbox1 != null) {
+                        txtbox1.setVisibility(View.INVISIBLE);
+                    }
+                    if (tv1 != null) {
+                        tv1.setText("");
+                        tv1.setVisibility(View.VISIBLE);
+                    }
+                    if(button1 != null) {
+                       button1.setVisibility(View.INVISIBLE);
+                    }
+                    if(button2 != null) {
+                       button2.setVisibility(View.INVISIBLE);
+                    }
+                    if (SetButton != null) {
+                        SetButton.setVisibility(View.INVISIBLE);
+                    }
+                    try {
+                        if(mService != null) {
+                           ret = mService.getCFOMeanTh();
+                           Log.d(LOGTAG, "Get CF0 Threshold: " + ret);
+                           if (ret >= MIN_CF0TH12 &&
+                                   ret <= MAX_CF0TH12)
+                               tv1.setText(" " + String.valueOf(ret));
+                        }
+                    }catch (RemoteException e) {
+
+                    }
+                    break;
+                case 13:
+                    if (txtbox1 != null) {
+                        txtbox1.setVisibility(View.INVISIBLE);
+                    }
+                    if (tv1 != null) {
+                        tv1.setText("");
+                        tv1.setVisibility(View.VISIBLE);
+                    }
+                    if(button1 != null) {
+                       button1.setVisibility(View.INVISIBLE);
+                    }
+                    if(button2 != null) {
+                       button2.setVisibility(View.INVISIBLE);
+                    }
+                    if (SetButton != null) {
+                        SetButton.setVisibility(View.INVISIBLE);
+                    }
+                    try {
+                        if(mService != null) {
+                           ret = mService.getSearchAlgoType();
+                           Log.d(LOGTAG, "Search Type: " + ret);
+                           if (ret == MPX_DCC)
+                               tv1.setText(R.string.search_algo_mpx);
+                           else if(ret == SINR_INTF)
+                               tv1.setText(R.string.search_algo_sinrint);
+                        }
+                    }catch (RemoteException e) {
+
+                    }
+                    break;
+                case 14:
+                    if (txtbox1 != null) {
+                       txtbox1.setText(R.string.type_rd);
+                       txtbox1.setVisibility(View.VISIBLE);
+                    }
+                    if (tv1 != null) {
+                       tv1.setText(R.string.enter_AfJmpRmssiTh);
+                       tv1.setVisibility(View.VISIBLE);
+                    }
+                    if(button1 != null) {
+                       button1.setVisibility(View.INVISIBLE);
+                    }
+                    if(button2 != null) {
+                       button2.setVisibility(View.INVISIBLE);
+                    }
+                    if (SetButton != null) {
+                       SetButton.setText(R.string.set_AfJmpRmssiTh);
+                       SetButton.setVisibility(View.VISIBLE);
+                       SetButton.setOnClickListener(mOnSetAfJmpRmssiThListener);
+                    }
+                    break;
+                case 15:
+                    if (txtbox1 != null) {
+                       txtbox1.setText(R.string.type_rd);
+                       txtbox1.setVisibility(View.VISIBLE);
+                    }
+                    if (tv1 != null) {
+                       tv1.setText(R.string.enter_GdChRmssiTh);
+                       tv1.setVisibility(View.VISIBLE);
+                    }
+                    if(button1 != null) {
+                       button1.setVisibility(View.INVISIBLE);
+                    }
+                    if(button2 != null) {
+                       button2.setVisibility(View.INVISIBLE);
+                    }
+                    if (SetButton != null) {
+                       SetButton.setText(R.string.set_GdChRmssiTh);
+                       SetButton.setVisibility(View.VISIBLE);
+                       SetButton.setOnClickListener(mOnSetGdChRmssiThListener);
+                    }
+                    break;
+                case 16:
+                    if (txtbox1 != null) {
+                       txtbox1.setText(R.string.type_rd);
+                       txtbox1.setVisibility(View.VISIBLE);
+                    }
+                    if (tv1 != null) {
+                       tv1.setText(R.string.enter_AfJmpRmssiSmplsCnt);
+                       tv1.setVisibility(View.VISIBLE);
+                    }
+                    if(button1 != null) {
+                       button1.setVisibility(View.INVISIBLE);
+                    }
+                    if(button2 != null) {
+                       button2.setVisibility(View.INVISIBLE);
+                    }
+                    if (SetButton != null) {
+                       SetButton.setText(R.string.set_AfJmpRmssiSmplsCnt);
+                       SetButton.setVisibility(View.VISIBLE);
+                       SetButton.setOnClickListener(mOnSetAfJmpRmssiSmplsCntListener);
+                    }
+                    break;
+                case 17:
+                    if (txtbox1 != null) {
+                        txtbox1.setVisibility(View.INVISIBLE);
+                    }
+                    if (tv1 != null) {
+                        tv1.setText("");
+                        tv1.setVisibility(View.VISIBLE);
+                    }
+                    if(button1 != null) {
+                       button1.setVisibility(View.INVISIBLE);
+                    }
+                    if(button2 != null) {
+                       button2.setVisibility(View.INVISIBLE);
+                    }
+                    if (SetButton != null) {
+                        SetButton.setVisibility(View.INVISIBLE);
+                    }
+                    try {
+                        if(mService != null) {
+                           ret = mService.getAfJmpRmssiTh();
+                           Log.d(LOGTAG, "Get Af Jmp Rmssi Th: " + ret);
+                           if ((ret >= MIN_AF_JMP_RMSSI_TH) &&
+                                  (ret <= MAX_AF_JMP_RMSSI_TH))
+                               tv1.setText(" " + String.valueOf(ret));
+                        }
+                    }catch (RemoteException e) {
+
+                    }
+                    break;
+                case 18:
+                    if (txtbox1 != null) {
+                        txtbox1.setVisibility(View.INVISIBLE);
+                    }
+                    if (tv1 != null) {
+                        tv1.setText("");
+                        tv1.setVisibility(View.VISIBLE);
+                    }
+                    if(button1 != null) {
+                       button1.setVisibility(View.INVISIBLE);
+                    }
+                    if(button2 != null) {
+                       button2.setVisibility(View.INVISIBLE);
+                    }
+                    if (SetButton != null) {
+                        SetButton.setVisibility(View.INVISIBLE);
+                    }
+                    try {
+                        if(mService != null) {
+                           ret = mService.getGoodChRmssiTh();
+                           Log.d(LOGTAG, "Get GoodChRmssi Threshold: " + ret);
+                           if ((ret >= MIN_GD_CH_RMSSI_TH) &&
+                                  (ret <= MAX_GD_CH_RMSSI_TH))
+                               tv1.setText(" " + String.valueOf(ret));
+                        }
+                    }catch (RemoteException e) {
+
+                    }
+                    break;
+                case 19:
+                    if (txtbox1 != null) {
+                        txtbox1.setVisibility(View.INVISIBLE);
+                    }
+                    if (tv1 != null) {
+                        tv1.setText("");
+                        tv1.setVisibility(View.VISIBLE);
+                    }
+                    if(button1 != null) {
+                       button1.setVisibility(View.INVISIBLE);
+                    }
+                    if(button2 != null) {
+                       button2.setVisibility(View.INVISIBLE);
+                    }
+                    if (SetButton != null) {
+                        SetButton.setVisibility(View.INVISIBLE);
+                    }
+                    try {
+                        if(mService != null) {
+                           ret = mService.getAfJmpRmssiSamplesCnt();
+                           Log.d(LOGTAG, "Get AfJmpRmssiSamples count: " + ret);
+                           if ((ret >= MIN_AF_JMP_RMSSI_SAMPLES) &&
+                                  (ret <= MAX_AF_JMP_RMSSI_SAMPLES))
+                               tv1.setText(" " + String.valueOf(ret));
+                        }
+                    }catch (RemoteException e) {
+
+                    }
+                    break;
+                case 20:
                     tLayout.removeAllViewsInLayout();
                     mNewRowIds = NEW_ROW_ID;
                     tLayout.setVisibility(View.VISIBLE);
@@ -653,10 +1300,31 @@
                     if (SetButton != null) {
                        SetButton.setVisibility(View.INVISIBLE);
                     }
+                    if(button1 != null) {
+                       button1.setVisibility(View.INVISIBLE);
+                    }
+                    if(button2 != null) {
+                       button2.setVisibility(View.INVISIBLE);
+                    }
                     adaptRfCfg.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                     spinOptionFmRf.setAdapter(adaptRfCfg);
                     spinOptionFmRf.setOnItemSelectedListener(mSpinRfCfgListener);
                     break;
+                case 21:
+                    if (txtbox1 != null) {
+                        txtbox1.setText(R.string.type_rd);
+                        txtbox1.setVisibility(View.VISIBLE);
+                    }
+                    if (tv1 != null) {
+                        tv1.setText(R.string.enter_RxRePeatCount);
+                        tv1.setVisibility(View.VISIBLE);
+                    }
+                    if (SetButton != null) {
+                        SetButton.setText(R.string.set_RxRePeatCount);
+                        SetButton.setVisibility(View.VISIBLE);
+                        SetButton.setOnClickListener(mOnSetRxRePeatCount);
+                    }
+                    break;
             }
         }
         public void onNothingSelected(AdapterView<?> parent) {
diff --git a/fmapp2/src/com/caf/fmradio/IFMRadioService.aidl b/fmapp2/src/com/caf/fmradio/IFMRadioService.aidl
index 8e2fe99..c2dc7fb 100644
--- a/fmapp2/src/com/caf/fmradio/IFMRadioService.aidl
+++ b/fmapp2/src/com/caf/fmradio/IFMRadioService.aidl
@@ -53,5 +53,22 @@
     boolean setIntfDetLowTh(int intfLowTh);
     boolean setIntfDetHighTh(int intfHighTh);
     String getExtenRadioText();
+    int getSinrSamplesCnt();
+    int getSinrTh();
+    int getSearchAlgoType();
+    boolean setSearchAlgoType(int searchType);
+    int getSinrFirstStage();
+    boolean setSinrFirstStage(int sinr);
+    int getRmssiFirstStage();
+    boolean setRmssiFirstStage(int rmssi);
+    int getCFOMeanTh();
+    boolean setCFOMeanTh(int cf0);
+    boolean setAfJmpRmssiTh(int afJmpRmssiTh);
+    boolean setGoodChRmssiTh(int gdChRmssiTh);
+    boolean setAfJmpRmssiSamplesCnt(int afJmpRmssiSmplsCnt);
+    int getAfJmpRmssiTh();
+    int getGoodChRmssiTh();
+    int getAfJmpRmssiSamplesCnt();
+    boolean setRxRepeatCount(int count);
 }