Merge "FM: Fix the issue with sleep timer thread" into private_master
diff --git a/Android.mk b/Android.mk
index 027bddf..cfbd558 100644
--- a/Android.mk
+++ b/Android.mk
@@ -1,13 +1,14 @@
-ifneq ($(TARGET_USES_AOSP),true)
-
-ifeq ($(BOARD_HAVE_QCOM_FM),true)
-ifneq (,$(filter $(QCOM_BOARD_PLATFORMS),$(TARGET_BOARD_PLATFORM)))
 LOCAL_PATH:= $(call my-dir)
 LOCAL_DIR_PATH:= $(call my-dir)
 include $(CLEAR_VARS)
 
 LOCAL_MODULE_TAGS := optional
 
+ifneq ($(TARGET_USES_AOSP),true)
+
+ifeq ($(BOARD_HAVE_QCOM_FM),true)
+ifneq (,$(filter $(QCOM_BOARD_PLATFORMS),$(TARGET_BOARD_PLATFORM)))
+
 LOCAL_SRC_FILES := $(call all-java-files-under, qcom/fmradio)
 LOCAL_JNI_SHARED_LIBRARIES := libqcomfm_jni
 
@@ -16,13 +17,14 @@
 include $(BUILD_JAVA_LIBRARY)
 
 include $(LOCAL_PATH)/jni/Android.mk
-LOCAL_PATH := $(LOCAL_DIR_PATH)
-include $(LOCAL_PATH)/fmapp2/Android.mk
-LOCAL_PATH := $(LOCAL_DIR_PATH)
-include $(LOCAL_PATH)/FMRecord/Android.mk
-LOCAL_PATH := $(LOCAL_DIR_PATH)
-include $(LOCAL_PATH)/libfm_jni/Android.mk
+#LOCAL_PATH := $(LOCAL_DIR_PATH)
+#include $(LOCAL_PATH)/fmapp2/Android.mk
+#LOCAL_PATH := $(LOCAL_DIR_PATH)
+#include $(LOCAL_PATH)/FMRecord/Android.mk
 endif # is-vendor-board-platform
 endif # BOARD_HAVE_QCOM_FM
 
 endif # Not (TARGET_USES_AOSP)
+
+LOCAL_PATH := $(LOCAL_DIR_PATH)
+include $(LOCAL_PATH)/libfm_jni/Android.mk
diff --git a/fmapp2/res/values/strings.xml b/fmapp2/res/values/strings.xml
index 55b2932..8c5ba5c 100644
--- a/fmapp2/res/values/strings.xml
+++ b/fmapp2/res/values/strings.xml
@@ -273,6 +273,6 @@
     <string name="band_sweep_choose">Choose Band Sweep Method</string>
     <string name="set">Set</string>
     <string name="cancel">Cancel</string>
-    <string name="user_defind_band_msg">Enter Freq from range 76.0 - 108.0 and with min 1 channel spacing</string>
+    <string name="user_defind_band_msg">Enter Freq from range 76.0 - 108.0, with min 1 channel spacing and 100KHz space between max, min freq</string>
 
 </resources>
diff --git a/fmapp2/src/com/caf/fmradio/FMRadioService.java b/fmapp2/src/com/caf/fmradio/FMRadioService.java
index f9d9b7f..36db42d 100644
--- a/fmapp2/src/com/caf/fmradio/FMRadioService.java
+++ b/fmapp2/src/com/caf/fmradio/FMRadioService.java
@@ -1217,6 +1217,14 @@
                       }
                    }
               }
+          } else {
+              if (!isFmOn() && (mServiceInUse) && (mCallbacks != null)) {
+                  try {
+                      mCallbacks.onDisabled();
+                  } catch (RemoteException e) {
+                      e.printStackTrace();
+                  }
+              }
           }
        }//idle
    }
diff --git a/fmapp2/src/com/caf/fmradio/Settings.java b/fmapp2/src/com/caf/fmradio/Settings.java
index e6adb21..de19f01 100644
--- a/fmapp2/src/com/caf/fmradio/Settings.java
+++ b/fmapp2/src/com/caf/fmradio/Settings.java
@@ -265,6 +265,7 @@
           int noOfChannels = 0;
           int channelSpacing = 0;
           int preIndex;
+          int band_width;
 
           if (key.equals(REGIONAL_BAND_KEY)) {
               int curListIndex = FmSharedPreferences.getCurrentListIndex();
@@ -339,8 +340,10 @@
                noOfChannels = 0;
                max_freq = FmSharedPreferences.getUpperLimit();
                min_freq = FmSharedPreferences.getLowerLimit();
-               noOfChannels =  (int) (max_freq - freq)/FmSharedPreferences.getFrequencyStepSize();
-               if((freq > 0) && (freq < max_freq) && (freq >= 76000) && (noOfChannels > 0)) {
+               band_width = (int) (max_freq - freq);
+               noOfChannels =  band_width/FmSharedPreferences.getFrequencyStepSize();
+               if((freq > 0) && (freq < max_freq) && (freq >= 76000)
+                  && (noOfChannels > 0) && (band_width >= 100)) {
                   FmSharedPreferences.setLowerLimit((int)freq);
                   sendSettingsChangedIntent(FM_BAND_CHANGED);
                   setBandSummary(summaryBandItems.length - 1);
@@ -365,8 +368,10 @@
                noOfChannels = 0;
                min_freq = FmSharedPreferences.getLowerLimit();
                max_freq = FmSharedPreferences.getUpperLimit();
-               noOfChannels = (int) (freq - min_freq)/FmSharedPreferences.getFrequencyStepSize();
-               if((freq > 0) && (freq > min_freq) && (freq <= 108000) && (noOfChannels > 0)) {
+               band_width = (int) (freq - min_freq);
+               noOfChannels = band_width/FmSharedPreferences.getFrequencyStepSize();
+               if((freq > 0) && (freq > min_freq) && (freq <= 108000)
+                  && (noOfChannels > 0) && (band_width >= 100)) {
                   FmSharedPreferences.setUpperLimit((int)freq);
                   sendSettingsChangedIntent(FM_BAND_CHANGED);
                   setBandSummary(summaryBandItems.length - 1);