am f5d3f960: am 2a6f1d4a: Merge "ZenModeHelper: fix cross deadlock with AudioService" into mnc-dr-dev
* commit 'f5d3f96001b42ff902022ebf4d97f9ab5e1f26f8': ZenModeHelper: fix cross deadlock with AudioService
This commit is contained in:
@@ -104,7 +104,7 @@ public class ZenModeConditions implements ConditionProviders.Callback {
|
||||
public void onServiceAdded(ComponentName component) {
|
||||
if (DEBUG) Log.d(TAG, "onServiceAdded " + component);
|
||||
if (isAutomaticActive(component)) {
|
||||
mHelper.setConfig(mHelper.getConfig(), "zmc.onServiceAdded");
|
||||
mHelper.setConfigAsync(mHelper.getConfig(), "zmc.onServiceAdded");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ public class ZenModeConditions implements ConditionProviders.Callback {
|
||||
updated |= updateSnoozing(automaticRule);
|
||||
}
|
||||
if (updated) {
|
||||
mHelper.setConfig(config, "conditionChanged");
|
||||
mHelper.setConfigAsync(config, "conditionChanged");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -315,6 +315,10 @@ public class ZenModeHelper {
|
||||
return setConfig(config, reason, true /*setRingerMode*/);
|
||||
}
|
||||
|
||||
public void setConfigAsync(ZenModeConfig config, String reason) {
|
||||
mHandler.postSetConfig(config, reason);
|
||||
}
|
||||
|
||||
private boolean setConfig(ZenModeConfig config, String reason, boolean setRingerMode) {
|
||||
if (config == null || !config.isValid()) {
|
||||
Log.w(TAG, "Invalid config in setConfig; " + config);
|
||||
@@ -742,6 +746,17 @@ 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 final class ConfigMessageData {
|
||||
public final ZenModeConfig config;
|
||||
public final String reason;
|
||||
|
||||
ConfigMessageData(ZenModeConfig config, String reason) {
|
||||
this.config = config;
|
||||
this.reason = reason;
|
||||
}
|
||||
}
|
||||
|
||||
private static final long METRICS_PERIOD_MS = 6 * 60 * 60 * 1000;
|
||||
|
||||
@@ -759,6 +774,10 @@ 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)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
@@ -768,6 +787,10 @@ public class ZenModeHelper {
|
||||
case MSG_METRICS:
|
||||
mMetrics.emit();
|
||||
break;
|
||||
case MSG_SET_CONFIG:
|
||||
ConfigMessageData configData = (ConfigMessageData)msg.obj;
|
||||
setConfig(configData.config, configData.reason);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user