Stop posting config asynchronously.
am: 3ebe72b26a
Change-Id: If0ebacf0a128d56c70178a03c1c2532d984c796e
This commit is contained in:
@@ -99,7 +99,7 @@ public class ZenModeConditions implements ConditionProviders.Callback {
|
|||||||
@Override
|
@Override
|
||||||
public void onServiceAdded(ComponentName component) {
|
public void onServiceAdded(ComponentName component) {
|
||||||
if (DEBUG) Log.d(TAG, "onServiceAdded " + component);
|
if (DEBUG) Log.d(TAG, "onServiceAdded " + component);
|
||||||
mHelper.setConfigAsync(mHelper.getConfig(), "zmc.onServiceAdded");
|
mHelper.setConfig(mHelper.getConfig(), "zmc.onServiceAdded");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -113,7 +113,7 @@ public class ZenModeConditions implements ConditionProviders.Callback {
|
|||||||
updated |= updateSnoozing(automaticRule);
|
updated |= updateSnoozing(automaticRule);
|
||||||
}
|
}
|
||||||
if (updated) {
|
if (updated) {
|
||||||
mHelper.setConfigAsync(config, "conditionChanged");
|
mHelper.setConfig(config, "conditionChanged");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -620,8 +620,10 @@ public class ZenModeHelper {
|
|||||||
return setConfigLocked(config, reason, true /*setRingerMode*/);
|
return setConfigLocked(config, reason, true /*setRingerMode*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setConfigAsync(ZenModeConfig config, String reason) {
|
public void setConfig(ZenModeConfig config, String reason) {
|
||||||
mHandler.postSetConfig(config, reason);
|
synchronized (mConfig) {
|
||||||
|
setConfigLocked(config, reason);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean setConfigLocked(ZenModeConfig config, String reason, boolean setRingerMode) {
|
private boolean setConfigLocked(ZenModeConfig config, String reason, boolean setRingerMode) {
|
||||||
@@ -1084,7 +1086,6 @@ public class ZenModeHelper {
|
|||||||
private final class H extends Handler {
|
private final class H extends Handler {
|
||||||
private static final int MSG_DISPATCH = 1;
|
private static final int MSG_DISPATCH = 1;
|
||||||
private static final int MSG_METRICS = 2;
|
private static final int MSG_METRICS = 2;
|
||||||
private static final int MSG_SET_CONFIG = 3;
|
|
||||||
private static final int MSG_APPLY_CONFIG = 4;
|
private static final int MSG_APPLY_CONFIG = 4;
|
||||||
|
|
||||||
private final class ConfigMessageData {
|
private final class ConfigMessageData {
|
||||||
@@ -1092,12 +1093,6 @@ public class ZenModeHelper {
|
|||||||
public final String reason;
|
public final String reason;
|
||||||
public final boolean setRingerMode;
|
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) {
|
ConfigMessageData(ZenModeConfig config, String reason, boolean setRingerMode) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.reason = reason;
|
this.reason = reason;
|
||||||
@@ -1121,10 +1116,6 @@ public class ZenModeHelper {
|
|||||||
sendEmptyMessageDelayed(MSG_METRICS, METRICS_PERIOD_MS);
|
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) {
|
private void postApplyConfig(ZenModeConfig config, String reason, boolean setRingerMode) {
|
||||||
sendMessage(obtainMessage(MSG_APPLY_CONFIG,
|
sendMessage(obtainMessage(MSG_APPLY_CONFIG,
|
||||||
new ConfigMessageData(config, reason, setRingerMode)));
|
new ConfigMessageData(config, reason, setRingerMode)));
|
||||||
@@ -1139,12 +1130,6 @@ public class ZenModeHelper {
|
|||||||
case MSG_METRICS:
|
case MSG_METRICS:
|
||||||
mMetrics.emit();
|
mMetrics.emit();
|
||||||
break;
|
break;
|
||||||
case MSG_SET_CONFIG:
|
|
||||||
ConfigMessageData configData = (ConfigMessageData) msg.obj;
|
|
||||||
synchronized (mConfig) {
|
|
||||||
setConfigLocked(configData.config, configData.reason);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MSG_APPLY_CONFIG:
|
case MSG_APPLY_CONFIG:
|
||||||
ConfigMessageData applyConfigData = (ConfigMessageData) msg.obj;
|
ConfigMessageData applyConfigData = (ConfigMessageData) msg.obj;
|
||||||
applyConfig(applyConfigData.config, applyConfigData.reason,
|
applyConfig(applyConfigData.config, applyConfigData.reason,
|
||||||
|
|||||||
Reference in New Issue
Block a user