Obey rule instance limit.

Do not show a rule type in the 'Add rule' dialog if the number of
current instances of that rule equals the max number of instances 
allowed by that rule type.

Bug: 25563007
Change-Id: I18f2598c6d92aec93c27755bb6b04c460ee294d0
This commit is contained in:
Julia Reynolds
2016-01-15 10:11:16 -05:00
parent 8e7c979bad
commit 0cca0f5c02
4 changed files with 32 additions and 9 deletions

View File

@@ -67,7 +67,7 @@ public abstract class ZenRuleSelectionDialog {
bindType(defaultNewEvent());
bindType(defaultNewSchedule());
mServiceListing.addCallback(mServiceListingCallback);
mServiceListing.reload();
mServiceListing.reloadApprovedServices();
}
mDialog = new AlertDialog.Builder(context)
.setTitle(R.string.zen_mode_choose_rule_type)
@@ -166,7 +166,9 @@ public abstract class ZenRuleSelectionDialog {
for (int i = 0; i < services.size(); i++) {
final ZenRuleInfo ri = ZenModeAutomationSettings.getRuleInfo(mPm, services.get(i));
if (ri != null && ri.configurationActivity != null
&& mNm.isNotificationPolicyAccessGrantedForPackage(ri.packageName)) {
&& mNm.isNotificationPolicyAccessGrantedForPackage(ri.packageName)
&& (ri.ruleInstanceLimit <= 0 || ri.ruleInstanceLimit
>= (mNm.getRuleInstanceCount(services.get(i).getComponentName()) + 1))) {
externalRuleTypes.add(ri);
}
}