From 3ebe72b26a400ceb0bc6de0ffe94df6e1345add0 Mon Sep 17 00:00:00 2001 From: Julia Reynolds Date: Thu, 15 Sep 2016 11:07:50 -0400 Subject: Stop posting config asynchronously. All of the instances of calling into other services with locks held should be resolved, so this isn't needed anymore. Test: have 2 rules end or start at the same time; ensure the resulting state is correct. Fixes: 28459870 Bug: 31980467 Change-Id: I3f12f1d3b8460361dab6fa9468f0ede55ca8dd5e (cherry picked from commit 89aeab0e714ea8449c20816e6d2acea04c9348ca) --- .../server/notification/ZenModeConditions.java | 4 ++-- .../android/server/notification/ZenModeHelper.java | 23 ++++------------------ 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/services/core/java/com/android/server/notification/ZenModeConditions.java b/services/core/java/com/android/server/notification/ZenModeConditions.java index 1c12a961ad04..40b0be2991f6 100644 --- a/services/core/java/com/android/server/notification/ZenModeConditions.java +++ b/services/core/java/com/android/server/notification/ZenModeConditions.java @@ -99,7 +99,7 @@ public class ZenModeConditions implements ConditionProviders.Callback { @Override public void onServiceAdded(ComponentName component) { if (DEBUG) Log.d(TAG, "onServiceAdded " + component); - mHelper.setConfigAsync(mHelper.getConfig(), "zmc.onServiceAdded"); + mHelper.setConfig(mHelper.getConfig(), "zmc.onServiceAdded"); } @Override @@ -113,7 +113,7 @@ public class ZenModeConditions implements ConditionProviders.Callback { updated |= updateSnoozing(automaticRule); } if (updated) { - mHelper.setConfigAsync(config, "conditionChanged"); + mHelper.setConfig(config, "conditionChanged"); } } diff --git a/services/core/java/com/android/server/notification/ZenModeHelper.java b/services/core/java/com/android/server/notification/ZenModeHelper.java index afd42ea67c0f..15549d234ab7 100644 --- a/services/core/java/com/android/server/notification/ZenModeHelper.java +++ b/services/core/java/com/android/server/notification/ZenModeHelper.java @@ -620,8 +620,10 @@ public class ZenModeHelper { return setConfigLocked(config, reason, true /*setRingerMode*/); } - public void setConfigAsync(ZenModeConfig config, String reason) { - mHandler.postSetConfig(config, reason); + public void setConfig(ZenModeConfig config, String reason) { + synchronized (mConfig) { + setConfigLocked(config, reason); + } } private boolean setConfigLocked(ZenModeConfig config, String reason, boolean setRingerMode) { @@ -1084,7 +1086,6 @@ public class ZenModeHelper { private final class H extends Handler { private static final int MSG_DISPATCH = 1; private static final int MSG_METRICS = 2; - private static final int MSG_SET_CONFIG = 3; private static final int MSG_APPLY_CONFIG = 4; private final class ConfigMessageData { @@ -1092,12 +1093,6 @@ public class ZenModeHelper { public final String reason; public final boolean setRingerMode; - ConfigMessageData(ZenModeConfig config, String reason) { - this.config = config; - this.reason = reason; - this.setRingerMode = false; - } - ConfigMessageData(ZenModeConfig config, String reason, boolean setRingerMode) { this.config = config; this.reason = reason; @@ -1121,10 +1116,6 @@ public class ZenModeHelper { sendEmptyMessageDelayed(MSG_METRICS, METRICS_PERIOD_MS); } - private void postSetConfig(ZenModeConfig config, String reason) { - sendMessage(obtainMessage(MSG_SET_CONFIG, new ConfigMessageData(config, reason))); - } - private void postApplyConfig(ZenModeConfig config, String reason, boolean setRingerMode) { sendMessage(obtainMessage(MSG_APPLY_CONFIG, new ConfigMessageData(config, reason, setRingerMode))); @@ -1139,12 +1130,6 @@ public class ZenModeHelper { case MSG_METRICS: mMetrics.emit(); break; - case MSG_SET_CONFIG: - ConfigMessageData configData = (ConfigMessageData) msg.obj; - synchronized (mConfig) { - setConfigLocked(configData.config, configData.reason); - } - break; case MSG_APPLY_CONFIG: ConfigMessageData applyConfigData = (ConfigMessageData) msg.obj; applyConfig(applyConfigData.config, applyConfigData.reason, -- cgit v1.2.3-59-g8ed1b