From 8d881500af82520682fb5eacd1303462b9bf89cb Mon Sep 17 00:00:00 2001
From: Rupesh Tatiya <rtatiya@codeaurora.org>
Date: Tue, 12 Jan 2016 18:37:31 +0530
Subject: [PATCH] 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
---
.../src/com/caf/fmradio/FMRadioService.java | 27 +++++++++++--------
1 file changed, 16 insertions(+), 11 deletions(-)
diff --git a/fmapp2/src/com/caf/fmradio/FMRadioService.java b/fmapp2/src/com/caf/fmradio/FMRadioService.java
index 65e42bb..b610187 100644
--- a/fmapp2/src/com/caf/fmradio/FMRadioService.java
+++ b/fmapp2/src/com/caf/fmradio/FMRadioService.java
@@ -216,6 +216,8 @@ public class FMRadioService extends Service
private static final int FM_OFF_FROM_APPLICATION = 1;
private static final int FM_OFF_FROM_ANTENNA = 2;
+ private static Object mNotchFilterLock = new Object();
+
public FMRadioService() {
}
@@ -1434,14 +1436,13 @@ public class FMRadioService extends Service
}
} 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;
+ }
}
}
}
@@ -1471,9 +1472,13 @@ public class FMRadioService extends Service
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:
--
GitLab