summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2018-07-09 22:28:55 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2018-07-09 22:28:55 +0000
commit5c35d97b9cf96840ffbbc7d7215882eb8ec1c20f (patch)
tree0971536675164d666ea18f527d7697ca4767ee65
parent4aeef16335c04b8d5a80069508f75a3362cff5f4 (diff)
parent800ca4ac0c8405bdfd73a88d3398085a25d6770b (diff)
Merge "Add boolean to check never occurring zen schedule rule validity"
-rw-r--r--core/java/android/service/notification/ZenModeConfig.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/core/java/android/service/notification/ZenModeConfig.java b/core/java/android/service/notification/ZenModeConfig.java
index 5546e803342b..df88e642a970 100644
--- a/core/java/android/service/notification/ZenModeConfig.java
+++ b/core/java/android/service/notification/ZenModeConfig.java
@@ -1007,6 +1007,24 @@ public class ZenModeConfig implements Parcelable {
return true;
}
+ /**
+ * Returns whether the conditionId is a valid ScheduleCondition.
+ * If allowNever is true, this will return true even if the ScheduleCondition never occurs.
+ */
+ public static boolean isValidScheduleConditionId(Uri conditionId, boolean allowNever) {
+ ScheduleInfo info;
+ try {
+ info = tryParseScheduleConditionId(conditionId);
+ } catch (NullPointerException | ArrayIndexOutOfBoundsException e) {
+ return false;
+ }
+
+ if (info == null || (!allowNever && (info.days == null || info.days.length == 0))) {
+ return false;
+ }
+ return true;
+ }
+
public static ScheduleInfo tryParseScheduleConditionId(Uri conditionId) {
final boolean isSchedule = conditionId != null
&& conditionId.getScheme().equals(Condition.SCHEME)