From 6706ef97c131bababd34a55244623ef8504c6070 Mon Sep 17 00:00:00 2001 From: Rupesh Tatiya Date: Tue, 12 Jan 2016 18:37:31 +0530 Subject: 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 --- fmapp2/src/com/caf/fmradio/FMRadioService.java | 27 +++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'fmapp2') diff --git a/fmapp2/src/com/caf/fmradio/FMRadioService.java b/fmapp2/src/com/caf/fmradio/FMRadioService.java index ef7ea4d..cf4c0d4 100644 --- a/fmapp2/src/com/caf/fmradio/FMRadioService.java +++ b/fmapp2/src/com/caf/fmradio/FMRadioService.java @@ -223,6 +223,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() { } @@ -1484,14 +1486,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; + } } } } @@ -1521,9 +1522,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: -- cgit v1.2.3