Loading core/java/android/app/AutomaticZenRule.java +17 −0 Original line number Diff line number Diff line Loading @@ -396,6 +396,23 @@ public final class AutomaticZenRule implements Parcelable { mDeviceEffects = deviceEffects; } /** * Sets the component name of the * {@link android.service.notification.ConditionProviderService} that manages this rule * (but note that {@link android.service.notification.ConditionProviderService} is * deprecated in favor of using {@link NotificationManager#setAutomaticZenRuleState} to * notify the system about the state of your rule). * * <p>This is exclusive with {@link #setConfigurationActivity}; rules where a configuration * activity is set will not use the component set here to determine whether the rule * should be active. * * @hide */ public void setOwner(@Nullable ComponentName owner) { this.owner = owner; } /** * Sets the configuration activity - an activity that handles * {@link NotificationManager#ACTION_AUTOMATIC_ZEN_RULE} that shows the user more information Loading core/java/android/service/notification/ZenModeConfig.java +28 −1 Original line number Diff line number Diff line Loading @@ -2373,7 +2373,7 @@ public class ZenModeConfig implements Parcelable { public int userId = UserHandle.USER_NULL; // USER_NULL = unspecified - use current user public String calName; // CalendarContract.Calendars.DISPLAY_NAME, or null for any public Long calendarId; // Calendars._ID, or null if restored from < Q calendar @Nullable public Long calendarId; // Calendars._ID, or null if restored from < Q calendar public int reply; @Override Loading Loading @@ -2405,6 +2405,33 @@ public class ZenModeConfig implements Parcelable { } } // ==== Built-in system condition: custom manual ==== public static final String CUSTOM_MANUAL_PATH = "custom_manual"; private static final Uri CUSTOM_MANUAL_CONDITION_ID = new Uri.Builder().scheme(Condition.SCHEME) .authority(SYSTEM_AUTHORITY) .appendPath(CUSTOM_MANUAL_PATH) .build(); /** Returns the condition id used for manual (not automatically triggered) custom rules. */ public static Uri toCustomManualConditionId() { return CUSTOM_MANUAL_CONDITION_ID; } /** * Returns whether the supplied {@link Uri} corresponds to the condition id used for manual (not * automatically triggered) custom rules. */ public static boolean isValidCustomManualConditionId(Uri conditionId) { return CUSTOM_MANUAL_CONDITION_ID.equals(conditionId); } /** Returns the {@link ComponentName} of the custom manual condition provider. */ public static ComponentName getCustomManualConditionProvider() { return new ComponentName(SYSTEM_AUTHORITY, "CustomManualConditionProvider"); } // ==== End built-in system conditions ==== private static int[] tryParseHourAndMinute(String value) { Loading core/res/res/values/config.xml +1 −0 Original line number Diff line number Diff line Loading @@ -3917,6 +3917,7 @@ <item>countdown</item> <item>schedule</item> <item>event</item> <item>custom_manual</item> </string-array> <!-- Priority repeat caller threshold, in minutes --> Loading services/core/java/com/android/server/notification/CustomManualConditionProvider.java 0 → 100644 +61 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.notification; import android.net.Uri; import android.service.notification.ZenModeConfig; import java.io.PrintWriter; /** * Condition provider used for custom manual rules (i.e. user-created rules without an automatic * trigger). */ public class CustomManualConditionProvider extends SystemConditionProviderService { private static final String SIMPLE_NAME = CustomManualConditionProvider.class.getSimpleName(); @Override public boolean isValidConditionId(Uri id) { return ZenModeConfig.isValidCustomManualConditionId(id); } @Override public void onBootComplete() { // Nothing to do. } @Override public void onConnected() { // No need to keep subscriptions because we won't ever call notifyConditions } @Override public void onSubscribe(Uri conditionId) { // No need to keep subscriptions because we won't ever call notifyConditions } @Override public void onUnsubscribe(Uri conditionId) { // No need to keep subscriptions because we won't ever call notifyConditions } @Override public void dump(PrintWriter pw, NotificationManagerService.DumpFilter filter) { pw.print(" "); pw.print(SIMPLE_NAME); pw.println(": ENABLED"); } } services/core/java/com/android/server/notification/ZenModeConditions.java +3 −0 Original line number Diff line number Diff line Loading @@ -58,6 +58,9 @@ public class ZenModeConditions implements ConditionProviders.Callback { if (mConditionProviders.isSystemProviderEnabled(ZenModeConfig.EVENT_PATH)) { mConditionProviders.addSystemProvider(new EventConditionProvider()); } if (mConditionProviders.isSystemProviderEnabled(ZenModeConfig.CUSTOM_MANUAL_PATH)) { mConditionProviders.addSystemProvider(new CustomManualConditionProvider()); } mConditionProviders.setCallback(this); } Loading Loading
core/java/android/app/AutomaticZenRule.java +17 −0 Original line number Diff line number Diff line Loading @@ -396,6 +396,23 @@ public final class AutomaticZenRule implements Parcelable { mDeviceEffects = deviceEffects; } /** * Sets the component name of the * {@link android.service.notification.ConditionProviderService} that manages this rule * (but note that {@link android.service.notification.ConditionProviderService} is * deprecated in favor of using {@link NotificationManager#setAutomaticZenRuleState} to * notify the system about the state of your rule). * * <p>This is exclusive with {@link #setConfigurationActivity}; rules where a configuration * activity is set will not use the component set here to determine whether the rule * should be active. * * @hide */ public void setOwner(@Nullable ComponentName owner) { this.owner = owner; } /** * Sets the configuration activity - an activity that handles * {@link NotificationManager#ACTION_AUTOMATIC_ZEN_RULE} that shows the user more information Loading
core/java/android/service/notification/ZenModeConfig.java +28 −1 Original line number Diff line number Diff line Loading @@ -2373,7 +2373,7 @@ public class ZenModeConfig implements Parcelable { public int userId = UserHandle.USER_NULL; // USER_NULL = unspecified - use current user public String calName; // CalendarContract.Calendars.DISPLAY_NAME, or null for any public Long calendarId; // Calendars._ID, or null if restored from < Q calendar @Nullable public Long calendarId; // Calendars._ID, or null if restored from < Q calendar public int reply; @Override Loading Loading @@ -2405,6 +2405,33 @@ public class ZenModeConfig implements Parcelable { } } // ==== Built-in system condition: custom manual ==== public static final String CUSTOM_MANUAL_PATH = "custom_manual"; private static final Uri CUSTOM_MANUAL_CONDITION_ID = new Uri.Builder().scheme(Condition.SCHEME) .authority(SYSTEM_AUTHORITY) .appendPath(CUSTOM_MANUAL_PATH) .build(); /** Returns the condition id used for manual (not automatically triggered) custom rules. */ public static Uri toCustomManualConditionId() { return CUSTOM_MANUAL_CONDITION_ID; } /** * Returns whether the supplied {@link Uri} corresponds to the condition id used for manual (not * automatically triggered) custom rules. */ public static boolean isValidCustomManualConditionId(Uri conditionId) { return CUSTOM_MANUAL_CONDITION_ID.equals(conditionId); } /** Returns the {@link ComponentName} of the custom manual condition provider. */ public static ComponentName getCustomManualConditionProvider() { return new ComponentName(SYSTEM_AUTHORITY, "CustomManualConditionProvider"); } // ==== End built-in system conditions ==== private static int[] tryParseHourAndMinute(String value) { Loading
core/res/res/values/config.xml +1 −0 Original line number Diff line number Diff line Loading @@ -3917,6 +3917,7 @@ <item>countdown</item> <item>schedule</item> <item>event</item> <item>custom_manual</item> </string-array> <!-- Priority repeat caller threshold, in minutes --> Loading
services/core/java/com/android/server/notification/CustomManualConditionProvider.java 0 → 100644 +61 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.notification; import android.net.Uri; import android.service.notification.ZenModeConfig; import java.io.PrintWriter; /** * Condition provider used for custom manual rules (i.e. user-created rules without an automatic * trigger). */ public class CustomManualConditionProvider extends SystemConditionProviderService { private static final String SIMPLE_NAME = CustomManualConditionProvider.class.getSimpleName(); @Override public boolean isValidConditionId(Uri id) { return ZenModeConfig.isValidCustomManualConditionId(id); } @Override public void onBootComplete() { // Nothing to do. } @Override public void onConnected() { // No need to keep subscriptions because we won't ever call notifyConditions } @Override public void onSubscribe(Uri conditionId) { // No need to keep subscriptions because we won't ever call notifyConditions } @Override public void onUnsubscribe(Uri conditionId) { // No need to keep subscriptions because we won't ever call notifyConditions } @Override public void dump(PrintWriter pw, NotificationManagerService.DumpFilter filter) { pw.print(" "); pw.print(SIMPLE_NAME); pw.println(": ENABLED"); } }
services/core/java/com/android/server/notification/ZenModeConditions.java +3 −0 Original line number Diff line number Diff line Loading @@ -58,6 +58,9 @@ public class ZenModeConditions implements ConditionProviders.Callback { if (mConditionProviders.isSystemProviderEnabled(ZenModeConfig.EVENT_PATH)) { mConditionProviders.addSystemProvider(new EventConditionProvider()); } if (mConditionProviders.isSystemProviderEnabled(ZenModeConfig.CUSTOM_MANUAL_PATH)) { mConditionProviders.addSystemProvider(new CustomManualConditionProvider()); } mConditionProviders.setCallback(this); } Loading