From 98487f4d65697d1f674341cb6b93a84e75c495a7 Mon Sep 17 00:00:00 2001 From: Fan Zhang Date: Thu, 22 Sep 2016 15:10:40 -0700 Subject: [PATCH] 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 --- .../settings/dashboard/conditional/DndCondition.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/com/android/settings/dashboard/conditional/DndCondition.java b/src/com/android/settings/dashboard/conditional/DndCondition.java index dcab2796f87..49d67c270d3 100644 --- a/src/com/android/settings/dashboard/conditional/DndCondition.java +++ b/src/com/android/settings/dashboard/conditional/DndCondition.java @@ -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(); + } } } }