Fix NPE when trying to refreshes dnd condition.

Bug: 31685838
Test: manual, will add automated test in master.

The NPE happens when try to refresh dnd condition before the condition
object is created.

Change-Id: Idbd6898472e1ad21a2bbb3be5f0b9c24c03b5c80
This commit is contained in:
Fan Zhang
2016-09-22 15:10:40 -07:00
parent 4199a0d3bd
commit 98487f4d65

View File

@@ -139,8 +139,11 @@ public class DndCondition extends Condition {
public void onReceive(Context context, Intent intent) {
if (NotificationManager.ACTION_INTERRUPTION_FILTER_CHANGED_INTERNAL
.equals(intent.getAction())) {
ConditionManager.get(context).getCondition(DndCondition.class)
.refreshState();
final Condition condition =
ConditionManager.get(context).getCondition(DndCondition.class);
if (condition != null) {
condition.refreshState();
}
}
}
}