From 583b3dfcab2b6b9a75e7e2c821605a083811d8fa Mon Sep 17 00:00:00 2001 From: Yuri Lin Date: Thu, 7 Dec 2023 16:46:15 -0500 Subject: [PATCH] Settings changes for changing default for zen policy. This change sets a rule's ZenPolicy to the device default right before entering the customization screen, rather than setting it to a copy of the global DND policy. Further, because all policies are now fully specified, when the MODES_API flag is on, skip the radio button screen for selecting between a default and a custom setting and jump straight to the page for setting custom settings. Bug: 312739308 Test: manual -- entered settings for rules created before and after V, modified settings, verified they took Change-Id: I1e3a777b60a8fcf06732879f823b033826a52a43 --- .../zen/ZenModeRuleSettingsBase.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/com/android/settings/notification/zen/ZenModeRuleSettingsBase.java b/src/com/android/settings/notification/zen/ZenModeRuleSettingsBase.java index cda5b1adfc7..ff217b50dba 100644 --- a/src/com/android/settings/notification/zen/ZenModeRuleSettingsBase.java +++ b/src/com/android/settings/notification/zen/ZenModeRuleSettingsBase.java @@ -19,7 +19,9 @@ package com.android.settings.notification.zen; import static android.app.NotificationManager.EXTRA_AUTOMATIC_RULE_ID; import android.app.AutomaticZenRule; +import android.app.Flags; import android.app.NotificationManager; +import android.app.settings.SettingsEnums; import android.content.Context; import android.content.Intent; import android.net.Uri; @@ -100,10 +102,21 @@ public abstract class ZenModeRuleSettingsBase extends ZenModeSettingsBase { public boolean onPreferenceClick(Preference preference) { Bundle bundle = new Bundle(); bundle.putString(ZenCustomRuleSettings.RULE_ID, mId); + + // When modes_api flag is on, we skip the radio button screen distinguishing + // between "default" and "custom" and take users directly to the custom + // settings screen. + String destination = ZenCustomRuleSettings.class.getName(); + int sourceMetricsCategory = 0; + if (Flags.modesApi()) { + // From ZenRuleCustomPolicyPreferenceController#launchCustomSettings + destination = ZenCustomRuleConfigSettings.class.getName(); + sourceMetricsCategory = SettingsEnums.ZEN_CUSTOM_RULE_SOUND_SETTINGS; + } new SubSettingLauncher(mContext) - .setDestination(ZenCustomRuleSettings.class.getName()) + .setDestination(destination) .setArguments(bundle) - .setSourceMetricsCategory(0) // TODO + .setSourceMetricsCategory(sourceMetricsCategory) .launch(); return true; }