Reset notch filter only if it is set.

Everytime there is data activity, notch filter settings need to be
updated. This request gets queued and executed after a delay of 10
seconds. The update request might take 2 seconds in the worst case.

Data activity might change very rapidly resulting in large number of
RESET_NOTCH_FILTER messages being put queue before the first request
itself is processed. In such scenario, multiple requests are processed
together and they will take time to execute greater than ANR threashold
time.

CRs-Fixed: 958512
Change-Id: I78521f425d7419f3a3d577cc573560d3601b1b1e
diff --git a/fmapp2/src/com/caf/fmradio/FMRadioService.java b/fmapp2/src/com/caf/fmradio/FMRadioService.java
index b9adc42..4e725b7 100644
--- a/fmapp2/src/com/caf/fmradio/FMRadioService.java
+++ b/fmapp2/src/com/caf/fmradio/FMRadioService.java
@@ -209,6 +209,8 @@
    private Object mRecordSinkLock = new Object();
    private boolean mIsFMDeviceLoopbackActive = false;
 
+   private static Object mNotchFilterLock = new Object();
+
    public FMRadioService() {
    }
 
@@ -1489,14 +1491,13 @@
                  }
          } else {
                if (mReceiver != null) {
-                   if( true == mNotchFilterSet )
-                   {
-                       mDelayedStopHandler.removeMessages(RESET_NOTCH_FILTER);
-                   }
-                   else
-                   {
-                       mReceiver.setNotchFilter(true);
-                       mNotchFilterSet = true;
+                   synchronized (mNotchFilterLock) {
+                       if (true == mNotchFilterSet) {
+                           mDelayedStopHandler.removeMessages(RESET_NOTCH_FILTER);
+                       } else {
+                           mReceiver.setNotchFilter(true);
+                           mNotchFilterSet = true;
+                       }
                    }
                }
          }
@@ -1526,9 +1527,13 @@
               stopSelf(mServiceStartId);
               break;
           case RESET_NOTCH_FILTER:
-              if (mReceiver != null) {
-                  mReceiver.setNotchFilter(false);
-                  mNotchFilterSet = false;
+              synchronized (mNotchFilterLock) {
+                  if (false == mNotchFilterSet)
+                      break;
+                  if (mReceiver != null) {
+                      mReceiver.setNotchFilter(false);
+                      mNotchFilterSet = false;
+                  }
               }
               break;
           case STOPSERVICE_ONSLEEP: