Merge "ConditionManager: don't crash when trying to add unexpected condition" am: 46f7199cb1
am: 6270dce2cd
am: 7151be926d
Change-Id: I16805427f0d053c6d1c5975275f00cb0ed1c9cbb
This commit is contained in:
@@ -96,8 +96,12 @@ public class ConditionManager implements LifecycleObserver, OnResume, OnPause {
|
|||||||
Condition condition = createCondition(Class.forName(clz));
|
Condition condition = createCondition(Class.forName(clz));
|
||||||
PersistableBundle bundle = PersistableBundle.restoreFromXml(parser);
|
PersistableBundle bundle = PersistableBundle.restoreFromXml(parser);
|
||||||
if (DEBUG) Log.d(TAG, "Reading " + clz + " -- " + bundle);
|
if (DEBUG) Log.d(TAG, "Reading " + clz + " -- " + bundle);
|
||||||
condition.restoreState(bundle);
|
if (condition != null) {
|
||||||
conditions.add(condition);
|
condition.restoreState(bundle);
|
||||||
|
conditions.add(condition);
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, "failed to add condition: " + clz);
|
||||||
|
}
|
||||||
while (parser.getDepth() > depth) {
|
while (parser.getDepth() > depth) {
|
||||||
parser.next();
|
parser.next();
|
||||||
}
|
}
|
||||||
@@ -155,7 +159,10 @@ public class ConditionManager implements LifecycleObserver, OnResume, OnPause {
|
|||||||
private void addIfMissing(Class<? extends Condition> clz, ArrayList<Condition> conditions) {
|
private void addIfMissing(Class<? extends Condition> clz, ArrayList<Condition> conditions) {
|
||||||
if (getCondition(clz, conditions) == null) {
|
if (getCondition(clz, conditions) == null) {
|
||||||
if (DEBUG) Log.d(TAG, "Adding missing " + clz.getName());
|
if (DEBUG) Log.d(TAG, "Adding missing " + clz.getName());
|
||||||
conditions.add(createCondition(clz));
|
Condition condition = createCondition(clz);
|
||||||
|
if (condition != null) {
|
||||||
|
conditions.add(condition);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,7 +184,8 @@ public class ConditionManager implements LifecycleObserver, OnResume, OnPause {
|
|||||||
} else if (NightDisplayCondition.class == clz) {
|
} else if (NightDisplayCondition.class == clz) {
|
||||||
return new NightDisplayCondition(this);
|
return new NightDisplayCondition(this);
|
||||||
}
|
}
|
||||||
throw new RuntimeException("Unexpected Condition " + clz);
|
Log.e(TAG, "unknown condition class: " + clz.getSimpleName());
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Context getContext() {
|
Context getContext() {
|
||||||
|
Reference in New Issue
Block a user