Merge "Protect against a lack of metadata." into nyc-dev

This commit is contained in:
Julia Reynolds
2016-03-01 18:56:15 +00:00
committed by Android (Google) Code Review

View File

@@ -271,8 +271,11 @@ public class ZenModeHelper {
throw new IllegalArgumentException("Owner is not a condition provider service");
}
final int ruleInstanceLimit = owner.metaData.getInt(
ConditionProviderService.META_DATA_RULE_INSTANCE_LIMIT, -1);
int ruleInstanceLimit = -1;
if (owner.metaData != null) {
ruleInstanceLimit = owner.metaData.getInt(
ConditionProviderService.META_DATA_RULE_INSTANCE_LIMIT, -1);
}
if (ruleInstanceLimit > 0 && ruleInstanceLimit
< (getCurrentInstanceCount(automaticZenRule.getOwner()) + 1)) {
throw new IllegalArgumentException("Rule instance limit exceeded");