Skip to content

Commit b1ad676

Browse files
Yuri LinAndroid Build Coastguard Worker
authored andcommitted
Revert "Check rule package name in ZenModeHelper.addAutomaticRule"
This reverts commit b6d0441. Reason for revert: broke DND schedules in multi-user mode b/257477671 Change-Id: Idf32ab7ebd132ee460504976ba31252fd4da47fa (cherry picked from commit 9223d27) Merged-In: Idf32ab7ebd132ee460504976ba31252fd4da47fa
1 parent 52a404f commit b1ad676

2 files changed

Lines changed: 6 additions & 31 deletions

File tree

services/core/java/com/android/server/notification/ZenModeHelper.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ public AutomaticZenRule getAutomaticZenRule(String id) {
326326

327327
public String addAutomaticZenRule(String pkg, AutomaticZenRule automaticZenRule,
328328
String reason) {
329-
if (!ZenModeConfig.SYSTEM_AUTHORITY.equals(pkg)) {
329+
if (!isSystemRule(automaticZenRule)) {
330330
PackageItemInfo component = getServiceInfo(automaticZenRule.getOwner());
331331
if (component == null) {
332332
component = getActivityInfo(automaticZenRule.getConfigurationActivity());
@@ -582,6 +582,11 @@ protected void updateDefaultZenRules() {
582582
}
583583
}
584584

585+
private boolean isSystemRule(AutomaticZenRule rule) {
586+
return rule.getOwner() != null
587+
&& ZenModeConfig.SYSTEM_AUTHORITY.equals(rule.getOwner().getPackageName());
588+
}
589+
585590
private ServiceInfo getServiceInfo(ComponentName owner) {
586591
Intent queryIntent = new Intent();
587592
queryIntent.setComponent(owner);

services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1671,36 +1671,6 @@ public void testAddAutomaticZenRule_beyondSystemLimit_differentComponents() {
16711671
}
16721672
}
16731673

1674-
@Test
1675-
public void testAddAutomaticZenRule_claimedSystemOwner() {
1676-
// Make sure anything that claims to have a "system" owner but not actually part of the
1677-
// system package still gets limited on number of rules
1678-
for (int i = 0; i < RULE_LIMIT_PER_PACKAGE; i++) {
1679-
ScheduleInfo si = new ScheduleInfo();
1680-
si.startHour = i;
1681-
AutomaticZenRule zenRule = new AutomaticZenRule("name" + i,
1682-
new ComponentName("android", "ScheduleConditionProvider" + i),
1683-
null, // configuration activity
1684-
ZenModeConfig.toScheduleConditionId(si),
1685-
new ZenPolicy.Builder().build(),
1686-
NotificationManager.INTERRUPTION_FILTER_PRIORITY, true);
1687-
String id = mZenModeHelperSpy.addAutomaticZenRule("pkgname", zenRule, "test");
1688-
assertNotNull(id);
1689-
}
1690-
try {
1691-
AutomaticZenRule zenRule = new AutomaticZenRule("name",
1692-
new ComponentName("android", "ScheduleConditionProviderFinal"),
1693-
null, // configuration activity
1694-
ZenModeConfig.toScheduleConditionId(new ScheduleInfo()),
1695-
new ZenPolicy.Builder().build(),
1696-
NotificationManager.INTERRUPTION_FILTER_PRIORITY, true);
1697-
String id = mZenModeHelperSpy.addAutomaticZenRule("pkgname", zenRule, "test");
1698-
fail("allowed too many rules to be created");
1699-
} catch (IllegalArgumentException e) {
1700-
// yay
1701-
}
1702-
}
1703-
17041674
@Test
17051675
public void testAddAutomaticZenRule_CA() {
17061676
AutomaticZenRule zenRule = new AutomaticZenRule("name",

0 commit comments

Comments
 (0)