Inline MODES_API flag

Bug: 310620812
Test: Preexisting
Flag: EXEMPT Inlining flag
Change-Id: I54ad81d87ea4ce85940400b0e8680a1bac0ca342
This commit is contained in:
Matías Hernández
2025-02-11 15:12:06 +01:00
parent d9214f1328
commit 7235474792
29 changed files with 53 additions and 135 deletions

View File

@@ -22,7 +22,6 @@ import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.pm.PackageInfo; import android.content.pm.PackageInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.os.AsyncTask;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
@@ -139,13 +138,8 @@ public class ApprovalPreferenceController extends BasePreferenceController {
public void disable(final ComponentName cn) { public void disable(final ComponentName cn) {
logSpecialPermissionChange(true, cn.getPackageName()); logSpecialPermissionChange(true, cn.getPackageName());
mNm.setNotificationListenerAccessGranted(cn, false); mNm.setNotificationListenerAccessGranted(cn, false);
if (!mNm.isNotificationPolicyAccessGrantedForPackage( if (!mNm.isNotificationPolicyAccessGrantedForPackage(cn.getPackageName())) {
cn.getPackageName())) { mNm.removeAutomaticZenRules(cn.getPackageName(), /* fromUser= */ true);
if (android.app.Flags.modesApi()) {
mNm.removeAutomaticZenRules(cn.getPackageName(), /* fromUser= */ true);
} else {
mNm.removeAutomaticZenRules(cn.getPackageName());
}
} }
} }

View File

@@ -56,7 +56,7 @@ public class FriendlyWarningDialogFragment extends InstrumentedDialogFragment {
NotificationAccessDetails parent = (NotificationAccessDetails) getTargetFragment(); NotificationAccessDetails parent = (NotificationAccessDetails) getTargetFragment();
final String summary = getResources().getString( final String summary = getResources().getString(
Flags.modesApi() && Flags.modesUi() Flags.modesUi()
? R.string.notification_listener_disable_modes_warning_summary ? R.string.notification_listener_disable_modes_warning_summary
: R.string.notification_listener_disable_warning_summary, : R.string.notification_listener_disable_warning_summary,
label); label);

View File

@@ -98,7 +98,7 @@ public class ScaryWarningDialogFragment extends InstrumentedDialogFragment {
((TextView) content.findViewById(R.id.prompt)).setText(prompt); ((TextView) content.findViewById(R.id.prompt)).setText(prompt);
((TextView) content.findViewById(R.id.settings_description)).setText( ((TextView) content.findViewById(R.id.settings_description)).setText(
Flags.modesApi() && Flags.modesUi() Flags.modesUi()
? R.string.nls_feature_modes_settings_summary ? R.string.nls_feature_modes_settings_summary
: R.string.nls_feature_settings_summary); : R.string.nls_feature_settings_summary);

View File

@@ -59,12 +59,12 @@ public class FriendlyWarningDialogFragment extends InstrumentedDialogFragment {
final String label = args.getString(KEY_LABEL); final String label = args.getString(KEY_LABEL);
final String title = getResources().getString( final String title = getResources().getString(
Flags.modesApi() && Flags.modesUi() Flags.modesUi()
? R.string.zen_modes_access_revoke_warning_dialog_title ? R.string.zen_modes_access_revoke_warning_dialog_title
: R.string.zen_access_revoke_warning_dialog_title, : R.string.zen_access_revoke_warning_dialog_title,
label); label);
final String summary = getResources() final String summary = getResources()
.getString(Flags.modesApi() && Flags.modesUi() .getString(Flags.modesUi()
? R.string.zen_modes_access_revoke_warning_dialog_summary ? R.string.zen_modes_access_revoke_warning_dialog_summary
: R.string.zen_access_revoke_warning_dialog_summary); : R.string.zen_access_revoke_warning_dialog_summary);

View File

@@ -57,12 +57,12 @@ public class ScaryWarningDialogFragment extends InstrumentedDialogFragment {
final String label = args.getString(KEY_LABEL); final String label = args.getString(KEY_LABEL);
final String title = getResources().getString( final String title = getResources().getString(
Flags.modesApi() && Flags.modesUi() Flags.modesUi()
? R.string.zen_modes_access_warning_dialog_title ? R.string.zen_modes_access_warning_dialog_title
: R.string.zen_access_warning_dialog_title, : R.string.zen_access_warning_dialog_title,
label); label);
final String summary = getResources() final String summary = getResources()
.getString(Flags.modesApi() && Flags.modesUi() .getString(Flags.modesUi()
? R.string.zen_modes_access_warning_dialog_summary ? R.string.zen_modes_access_warning_dialog_summary
: R.string.zen_access_warning_dialog_summary); : R.string.zen_access_warning_dialog_summary);

View File

@@ -56,7 +56,7 @@ public class ZenAccessController extends BasePreferenceController {
public void displayPreference(PreferenceScreen screen) { public void displayPreference(PreferenceScreen screen) {
Preference preference = screen.findPreference(getPreferenceKey()); Preference preference = screen.findPreference(getPreferenceKey());
if (preference != null) { if (preference != null) {
preference.setTitle(Flags.modesApi() && Flags.modesUi() preference.setTitle(Flags.modesUi()
? R.string.manage_zen_modes_access_title ? R.string.manage_zen_modes_access_title
: R.string.manage_zen_access_title); : R.string.manage_zen_access_title);
} }
@@ -116,11 +116,7 @@ public class ZenAccessController extends BasePreferenceController {
public static void deleteRules(final Context context, final String pkg) { public static void deleteRules(final Context context, final String pkg) {
final NotificationManager mgr = context.getSystemService(NotificationManager.class); final NotificationManager mgr = context.getSystemService(NotificationManager.class);
if (android.app.Flags.modesApi()) { mgr.removeAutomaticZenRules(pkg, /* fromUser= */ true);
mgr.removeAutomaticZenRules(pkg, /* fromUser= */ true);
} else {
mgr.removeAutomaticZenRules(pkg);
}
} }
@VisibleForTesting @VisibleForTesting

View File

@@ -51,7 +51,7 @@ public class ZenAccessDetails extends AppInfoWithHeader implements
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
requireActivity().setTitle(Flags.modesApi() && Flags.modesUi() requireActivity().setTitle(Flags.modesUi()
? R.string.manage_zen_modes_access_title ? R.string.manage_zen_modes_access_title
: R.string.manage_zen_access_title); : R.string.manage_zen_access_title);
} }
@@ -89,7 +89,7 @@ public class ZenAccessDetails extends AppInfoWithHeader implements
preference.setSummary(getString(R.string.zen_access_disabled_package_warning)); preference.setSummary(getString(R.string.zen_access_disabled_package_warning));
return; return;
} }
preference.setTitle(Flags.modesApi() && Flags.modesUi() preference.setTitle(Flags.modesUi()
? R.string.zen_modes_access_detail_switch ? R.string.zen_modes_access_detail_switch
: R.string.zen_access_detail_switch); : R.string.zen_access_detail_switch);
preference.setChecked(ZenAccessController.hasAccess(context, mPackageName)); preference.setChecked(ZenAccessController.hasAccess(context, mPackageName));

View File

@@ -16,7 +16,6 @@
package com.android.settings.homepage.contextualcards.conditional; package com.android.settings.homepage.contextualcards.conditional;
import android.app.Flags;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.app.settings.SettingsEnums; import android.app.settings.SettingsEnums;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
@@ -87,12 +86,8 @@ public class DndConditionCardController implements ConditionalCardController {
@Override @Override
public void onActionClick() { public void onActionClick() {
if (Flags.modesApi()) { mNotificationManager.setZenMode(Settings.Global.ZEN_MODE_OFF, null, TAG,
mNotificationManager.setZenMode(Settings.Global.ZEN_MODE_OFF, null, TAG, /* fromUser= */ true);
/* fromUser= */ true);
} else {
mNotificationManager.setZenMode(Settings.Global.ZEN_MODE_OFF, null, TAG);
}
} }
@Override @Override

View File

@@ -59,7 +59,7 @@ abstract class AbstractZenModeHeaderController extends AbstractZenModePreference
@Override @Override
public boolean isAvailable() { public boolean isAvailable() {
return Flags.modesApi() && Flags.modesUi(); return Flags.modesUi();
} }
protected void setUpHeader(PreferenceScreen screen, int iconSizePx) { protected void setUpHeader(PreferenceScreen screen, int iconSizePx) {

View File

@@ -43,7 +43,7 @@ class ZenSettingsObserver extends ContentObserver {
} }
void register() { void register() {
if (Flags.modesApi() && Flags.modesUi()) { if (Flags.modesUi()) {
mContext.getContentResolver().registerContentObserver(ZEN_MODE_URI, false, this); mContext.getContentResolver().registerContentObserver(ZEN_MODE_URI, false, this);
mContext.getContentResolver().registerContentObserver(ZEN_MODE_CONFIG_ETAG_URI, false, mContext.getContentResolver().registerContentObserver(ZEN_MODE_CONFIG_ETAG_URI, false,
this); this);
@@ -51,7 +51,7 @@ class ZenSettingsObserver extends ContentObserver {
} }
void unregister() { void unregister() {
if (Flags.modesApi() && Flags.modesUi()) { if (Flags.modesUi()) {
mContext.getContentResolver().unregisterContentObserver(this); mContext.getContentResolver().unregisterContentObserver(this);
} }
} }

View File

@@ -167,7 +167,7 @@ abstract public class AbstractZenModeAutomaticRulePreferenceController extends
mMetricsFeatureProvider.action(mContext, mMetricsFeatureProvider.action(mContext,
SettingsEnums.ACTION_ZEN_MODE_RULE_NAME_CHANGE_OK); SettingsEnums.ACTION_ZEN_MODE_RULE_NAME_CHANGE_OK);
AutomaticZenRule rule; AutomaticZenRule rule;
if (Flags.modesApi() && Flags.modesUi()) { if (Flags.modesUi()) {
rule = new AutomaticZenRule.Builder(ruleName, mRuleInfo.defaultConditionId) rule = new AutomaticZenRule.Builder(ruleName, mRuleInfo.defaultConditionId)
.setType(mRuleInfo.type) .setType(mRuleInfo.type)
.setOwner(mRuleInfo.serviceComponent) .setOwner(mRuleInfo.serviceComponent)

View File

@@ -76,7 +76,7 @@ public class ZenAccessSettings extends EmptyTextSettings implements
@Override @Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState); super.onViewCreated(view, savedInstanceState);
setEmptyText(Flags.modesApi() && Flags.modesUi() setEmptyText(Flags.modesUi()
? R.string.zen_modes_access_empty_text ? R.string.zen_modes_access_empty_text
: R.string.zen_access_empty_text); : R.string.zen_access_empty_text);
} }
@@ -89,7 +89,7 @@ public class ZenAccessSettings extends EmptyTextSettings implements
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
requireActivity().setTitle(Flags.modesApi() && Flags.modesUi() requireActivity().setTitle(Flags.modesUi()
? R.string.manage_zen_modes_access_title ? R.string.manage_zen_modes_access_title
: R.string.manage_zen_access_title); : R.string.manage_zen_access_title);
reloadList(); reloadList();
@@ -145,7 +145,7 @@ public class ZenAccessSettings extends EmptyTextSettings implements
pref.setOnPreferenceClickListener(preference -> { pref.setOnPreferenceClickListener(preference -> {
AppInfoBase.startAppInfoFragment( AppInfoBase.startAppInfoFragment(
ZenAccessDetails.class /* fragment */, ZenAccessDetails.class /* fragment */,
getString(Flags.modesApi() && Flags.modesUi() getString(Flags.modesUi()
? R.string.manage_zen_modes_access_title ? R.string.manage_zen_modes_access_title
: R.string.manage_zen_access_title), : R.string.manage_zen_access_title),
pkg, pkg,

View File

@@ -95,32 +95,19 @@ public class ZenModeBackend {
} }
protected boolean updateZenRule(String id, AutomaticZenRule rule) { protected boolean updateZenRule(String id, AutomaticZenRule rule) {
if (android.app.Flags.modesApi()) { return mNotificationManager.updateAutomaticZenRule(id, rule, /* fromUser= */ true);
return mNotificationManager.updateAutomaticZenRule(id, rule, /* fromUser= */ true);
} else {
return NotificationManager.from(mContext).updateAutomaticZenRule(id, rule);
}
} }
protected void setZenMode(int zenMode) { protected void setZenMode(int zenMode) {
if (android.app.Flags.modesApi()) { mNotificationManager.setZenMode(zenMode, null, TAG, /* fromUser= */ true);
mNotificationManager.setZenMode(zenMode, null, TAG, /* fromUser= */ true);
} else {
NotificationManager.from(mContext).setZenMode(zenMode, null, TAG);
}
mZenMode = getZenMode(); mZenMode = getZenMode();
} }
protected void setZenModeForDuration(int minutes) { protected void setZenModeForDuration(int minutes) {
Uri conditionId = ZenModeConfig.toTimeCondition(mContext, minutes, Uri conditionId = ZenModeConfig.toTimeCondition(mContext, minutes,
ActivityManager.getCurrentUser(), true).id; ActivityManager.getCurrentUser(), true).id;
if (android.app.Flags.modesApi()) { mNotificationManager.setZenMode(Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS,
mNotificationManager.setZenMode(Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS, conditionId, TAG, /* fromUser= */ true);
conditionId, TAG, /* fromUser= */ true);
} else {
mNotificationManager.setZenMode(Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS,
conditionId, TAG);
}
mZenMode = getZenMode(); mZenMode = getZenMode();
} }
@@ -190,14 +177,9 @@ public class ZenModeBackend {
int priorityConversationSenders) { int priorityConversationSenders) {
mPolicy = new NotificationManager.Policy(priorityCategories, priorityCallSenders, mPolicy = new NotificationManager.Policy(priorityCategories, priorityCallSenders,
priorityMessageSenders, suppressedVisualEffects, priorityConversationSenders); priorityMessageSenders, suppressedVisualEffects, priorityConversationSenders);
if (android.app.Flags.modesApi()) { mNotificationManager.setNotificationPolicy(mPolicy, /* fromUser= */ true);
mNotificationManager.setNotificationPolicy(mPolicy, /* fromUser= */ true);
} else {
mNotificationManager.setNotificationPolicy(mPolicy);
}
} }
private int getNewSuppressedEffects(boolean suppress, int effectType) { private int getNewSuppressedEffects(boolean suppress, int effectType) {
int effects = mPolicy.suppressedVisualEffects; int effects = mPolicy.suppressedVisualEffects;
@@ -373,11 +355,7 @@ public class ZenModeBackend {
} }
public boolean removeZenRule(String ruleId) { public boolean removeZenRule(String ruleId) {
if (android.app.Flags.modesApi()) { return mNotificationManager.removeAutomaticZenRule(ruleId, /* fromUser= */ true);
return mNotificationManager.removeAutomaticZenRule(ruleId, /* fromUser= */ true);
} else {
return NotificationManager.from(mContext).removeAutomaticZenRule(ruleId);
}
} }
public NotificationManager.Policy getConsolidatedPolicy() { public NotificationManager.Policy getConsolidatedPolicy() {
@@ -386,11 +364,7 @@ public class ZenModeBackend {
protected String addZenRule(AutomaticZenRule rule) { protected String addZenRule(AutomaticZenRule rule) {
try { try {
if (android.app.Flags.modesApi()) { return mNotificationManager.addAutomaticZenRule(rule, /* fromUser= */ true);
return mNotificationManager.addAutomaticZenRule(rule, /* fromUser= */ true);
} else {
return NotificationManager.from(mContext).addAutomaticZenRule(rule);
}
} catch (Exception e) { } catch (Exception e) {
return null; return null;
} }

View File

@@ -104,16 +104,11 @@ public abstract class ZenModeRuleSettingsBase extends ZenModeSettingsBase {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString(ZenCustomRuleSettings.RULE_ID, mId); bundle.putString(ZenCustomRuleSettings.RULE_ID, mId);
// When modes_api flag is on, we skip the radio button screen distinguishing // Skip the radio button screen distinguishing between "default" and
// between "default" and "custom" and take users directly to the custom // "custom" and take users directly to the custom settings screen.
// settings screen. // From ZenRuleCustomPolicyPreferenceController#launchCustomSettings
String destination = ZenCustomRuleSettings.class.getName(); String destination = ZenCustomRuleConfigSettings.class.getName();
int sourceMetricsCategory = 0; int sourceMetricsCategory = SettingsEnums.ZEN_CUSTOM_RULE_SOUND_SETTINGS;
if (Flags.modesApi()) {
// From ZenRuleCustomPolicyPreferenceController#launchCustomSettings
destination = ZenCustomRuleConfigSettings.class.getName();
sourceMetricsCategory = SettingsEnums.ZEN_CUSTOM_RULE_SOUND_SETTINGS;
}
new SubSettingLauncher(mContext) new SubSettingLauncher(mContext)
.setDestination(destination) .setDestination(destination)
.setArguments(bundle) .setArguments(bundle)
@@ -165,7 +160,7 @@ public abstract class ZenModeRuleSettingsBase extends ZenModeSettingsBase {
protected void updateScheduleRule(ZenModeConfig.ScheduleInfo schedule) { protected void updateScheduleRule(ZenModeConfig.ScheduleInfo schedule) {
mRule.setConditionId(ZenModeConfig.toScheduleConditionId(schedule)); mRule.setConditionId(ZenModeConfig.toScheduleConditionId(schedule));
if (Flags.modesApi() && Flags.modesUi()) { if (Flags.modesUi()) {
mRule.setTriggerDescription( mRule.setTriggerDescription(
SystemZenRules.getTriggerDescriptionForScheduleTime(mContext, schedule)); SystemZenRules.getTriggerDescriptionForScheduleTime(mContext, schedule));
} }
@@ -174,7 +169,7 @@ public abstract class ZenModeRuleSettingsBase extends ZenModeSettingsBase {
protected void updateEventRule(ZenModeConfig.EventInfo event) { protected void updateEventRule(ZenModeConfig.EventInfo event) {
mRule.setConditionId(ZenModeConfig.toEventConditionId(event)); mRule.setConditionId(ZenModeConfig.toEventConditionId(event));
if (Flags.modesApi() && Flags.modesUi()) { if (Flags.modesUi()) {
mRule.setTriggerDescription( mRule.setTriggerDescription(
SystemZenRules.getTriggerDescriptionForScheduleEvent(mContext, event)); SystemZenRules.getTriggerDescriptionForScheduleEvent(mContext, event));
} }

View File

@@ -19,7 +19,6 @@ package com.android.settings.notification.zen;
import static android.app.slice.Slice.EXTRA_TOGGLE_STATE; import static android.app.slice.Slice.EXTRA_TOGGLE_STATE;
import android.annotation.ColorInt; import android.annotation.ColorInt;
import android.app.Flags;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.app.settings.SettingsEnums; import android.app.settings.SettingsEnums;
@@ -117,12 +116,8 @@ public class ZenModeSliceBuilder {
} else { } else {
zenMode = Settings.Global.ZEN_MODE_OFF; zenMode = Settings.Global.ZEN_MODE_OFF;
} }
if (Flags.modesApi()) { NotificationManager.from(context).setZenMode(zenMode, /* conditionId= */ null, TAG,
NotificationManager.from(context).setZenMode(zenMode, /* conditionId= */ null, TAG, /* fromUser= */ true);
/* fromUser= */ true);
} else {
NotificationManager.from(context).setZenMode(zenMode, null /* conditionId */, TAG);
}
// Do not notifyChange on Uri. The service takes longer to update the current value than it // Do not notifyChange on Uri. The service takes longer to update the current value than it
// does for the Slice to check the current value again. Let {@link SliceBroadcastRelay} // does for the Slice to check the current value again. Let {@link SliceBroadcastRelay}
// handle it. // handle it.

View File

@@ -19,19 +19,14 @@ package com.android.settings.notification.zen;
import android.app.AutomaticZenRule; import android.app.AutomaticZenRule;
import android.app.settings.SettingsEnums; import android.app.settings.SettingsEnums;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.View; import android.view.View;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceScreen; import androidx.preference.PreferenceScreen;
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.core.SubSettingLauncher;
import com.android.settingslib.core.lifecycle.Lifecycle; import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.widget.ActionButtonsPreference; import com.android.settingslib.widget.ActionButtonsPreference;
@@ -87,7 +82,6 @@ public class ZenRuleButtonsPreferenceController extends AbstractZenModePreferenc
mMetricsFeatureProvider.action(mContext, mMetricsFeatureProvider.action(mContext,
SettingsEnums.ACTION_ZEN_MODE_RULE_NAME_CHANGE_OK); SettingsEnums.ACTION_ZEN_MODE_RULE_NAME_CHANGE_OK);
mRule.setName(ruleName); mRule.setName(ruleName);
mRule.setModified(true);
mBackend.updateZenRule(mId, mRule); mBackend.updateZenRule(mId, mRule);
} }
}); });

View File

@@ -143,8 +143,7 @@ public class ZenRulePreference extends PrimarySwitchPreference {
private String computeRuleSummary(AutomaticZenRule rule) { private String computeRuleSummary(AutomaticZenRule rule) {
if (rule != null) { if (rule != null) {
if (Flags.modesApi() && Flags.modesUi() if (Flags.modesUi() && !TextUtils.isEmpty(rule.getTriggerDescription())) {
&& !TextUtils.isEmpty(rule.getTriggerDescription())) {
return rule.getTriggerDescription(); return rule.getTriggerDescription();
} }

View File

@@ -181,7 +181,7 @@ public class ZenRuleSelectionDialog extends InstrumentedDialogFragment {
rt.title = mContext.getString(R.string.zen_schedule_rule_type_name); rt.title = mContext.getString(R.string.zen_schedule_rule_type_name);
rt.packageName = ZenModeConfig.getEventConditionProvider().getPackageName(); rt.packageName = ZenModeConfig.getEventConditionProvider().getPackageName();
rt.defaultConditionId = ZenModeConfig.toScheduleConditionId(schedule); rt.defaultConditionId = ZenModeConfig.toScheduleConditionId(schedule);
if (Flags.modesApi() && Flags.modesUi()) { if (Flags.modesUi()) {
rt.type = AutomaticZenRule.TYPE_SCHEDULE_TIME; rt.type = AutomaticZenRule.TYPE_SCHEDULE_TIME;
rt.defaultTriggerDescription = SystemZenRules.getTriggerDescriptionForScheduleTime( rt.defaultTriggerDescription = SystemZenRules.getTriggerDescriptionForScheduleTime(
mContext, schedule); mContext, schedule);
@@ -201,7 +201,7 @@ public class ZenRuleSelectionDialog extends InstrumentedDialogFragment {
rt.title = mContext.getString(R.string.zen_event_rule_type_name); rt.title = mContext.getString(R.string.zen_event_rule_type_name);
rt.packageName = ZenModeConfig.getScheduleConditionProvider().getPackageName(); rt.packageName = ZenModeConfig.getScheduleConditionProvider().getPackageName();
rt.defaultConditionId = ZenModeConfig.toEventConditionId(event); rt.defaultConditionId = ZenModeConfig.toEventConditionId(event);
if (Flags.modesApi() && Flags.modesUi()) { if (Flags.modesUi()) {
rt.type = AutomaticZenRule.TYPE_SCHEDULE_CALENDAR; rt.type = AutomaticZenRule.TYPE_SCHEDULE_CALENDAR;
rt.defaultTriggerDescription = SystemZenRules.getTriggerDescriptionForScheduleEvent( rt.defaultTriggerDescription = SystemZenRules.getTriggerDescriptionForScheduleEvent(
mContext, event); mContext, event);

View File

@@ -32,7 +32,7 @@ public class ShortcutsUpdateReceiver extends BroadcastReceiver {
@Override @Override
public void onReceive(@NonNull Context context, @NonNull Intent intent) { public void onReceive(@NonNull Context context, @NonNull Intent intent) {
if (!Flags.modesApi() || !Flags.modesUi()) { if (!Flags.modesUi()) {
return; return;
} }

View File

@@ -86,7 +86,7 @@ public class ShortcutsUpdater {
private static ComponentName maybeGetReplacingComponent(Context context, ComponentName cn) { private static ComponentName maybeGetReplacingComponent(Context context, ComponentName cn) {
// ZenModeSettingsActivity is replaced by ModesSettingsActivity and will be deleted // ZenModeSettingsActivity is replaced by ModesSettingsActivity and will be deleted
// soon (so we shouldn't use ZenModeSettingsActivity.class). // soon (so we shouldn't use ZenModeSettingsActivity.class).
if (Flags.modesApi() && Flags.modesUi() if (Flags.modesUi()
&& cn.getClassName().endsWith("Settings$ZenModeSettingsActivity")) { && cn.getClassName().endsWith("Settings$ZenModeSettingsActivity")) {
return new ComponentName(context, Settings.ModesSettingsActivity.class); return new ComponentName(context, Settings.ModesSettingsActivity.class);
} }

View File

@@ -33,7 +33,7 @@ public class TopLevelSoundPreferenceController extends BasePreferenceController
@Override @Override
public void updateState(Preference preference) { public void updateState(Preference preference) {
super.updateState(preference); super.updateState(preference);
preference.setSummary(Flags.modesApi() && Flags.modesUi() preference.setSummary(Flags.modesUi()
? R.string.sound_dashboard_summary ? R.string.sound_dashboard_summary
: R.string.sound_dashboard_summary_with_dnd); : R.string.sound_dashboard_summary_with_dnd);
} }

View File

@@ -102,7 +102,7 @@ public class DndConditionalCardControllerTest {
private ZenModeConfig getMutedAllConfig() { private ZenModeConfig getMutedAllConfig() {
final ZenModeConfig config = new ZenModeConfig(); final ZenModeConfig config = new ZenModeConfig();
config.applyNotificationPolicy(new NotificationManager.Policy(0, 0, 0)); config.applyNotificationPolicy(new NotificationManager.Policy(0, 0, 0));
config.areChannelsBypassingDnd = false; config.hasPriorityChannels = false;
return config; return config;
} }
} }

View File

@@ -85,7 +85,7 @@ public class ZenModeSetCalendarPreferenceControllerTest {
} }
@Test @Test
@EnableFlags({Flags.FLAG_MODES_API, Flags.FLAG_MODES_UI}) @EnableFlags(Flags.FLAG_MODES_UI)
public void updateEventMode_updatesConditionAndTriggerDescription() { public void updateEventMode_updatesConditionAndTriggerDescription() {
ZenMode mode = new TestModeBuilder() ZenMode mode = new TestModeBuilder()
.setPackage(SystemZenRules.PACKAGE_ANDROID) .setPackage(SystemZenRules.PACKAGE_ANDROID)

View File

@@ -80,7 +80,7 @@ public class ZenModeSetSchedulePreferenceControllerTest {
} }
@Test @Test
@EnableFlags({Flags.FLAG_MODES_API, Flags.FLAG_MODES_UI}) @EnableFlags(Flags.FLAG_MODES_UI)
public void updateScheduleRule_updatesConditionAndTriggerDescription() { public void updateScheduleRule_updatesConditionAndTriggerDescription() {
ZenMode mode = new TestModeBuilder() ZenMode mode = new TestModeBuilder()
.setPackage(SystemZenRules.PACKAGE_ANDROID) .setPackage(SystemZenRules.PACKAGE_ANDROID)

View File

@@ -213,11 +213,7 @@ public class ZenModeBackendTest {
mBackend.saveConversationSenders(CONVERSATION_SENDERS_NONE); mBackend.saveConversationSenders(CONVERSATION_SENDERS_NONE);
ArgumentCaptor<Policy> captor = ArgumentCaptor.forClass(Policy.class); ArgumentCaptor<Policy> captor = ArgumentCaptor.forClass(Policy.class);
if (android.app.Flags.modesApi()) { verify(mNotificationManager).setNotificationPolicy(captor.capture(), eq(true));
verify(mNotificationManager).setNotificationPolicy(captor.capture(), eq(true));
} else {
verify(mNotificationManager).setNotificationPolicy(captor.capture());
}
Policy expected = new Policy( Policy expected = new Policy(
PRIORITY_CATEGORY_CALLS | PRIORITY_CATEGORY_MESSAGES | PRIORITY_CATEGORY_ALARMS, PRIORITY_CATEGORY_CALLS | PRIORITY_CATEGORY_MESSAGES | PRIORITY_CATEGORY_ALARMS,
@@ -241,11 +237,7 @@ public class ZenModeBackendTest {
mBackend.saveConversationSenders(CONVERSATION_SENDERS_ANYONE); mBackend.saveConversationSenders(CONVERSATION_SENDERS_ANYONE);
ArgumentCaptor<Policy> captor = ArgumentCaptor.forClass(Policy.class); ArgumentCaptor<Policy> captor = ArgumentCaptor.forClass(Policy.class);
if (android.app.Flags.modesApi()) { verify(mNotificationManager).setNotificationPolicy(captor.capture(), eq(true));
verify(mNotificationManager).setNotificationPolicy(captor.capture(), eq(true));
} else {
verify(mNotificationManager).setNotificationPolicy(captor.capture());
}
Policy expected = new Policy(PRIORITY_CATEGORY_CONVERSATIONS Policy expected = new Policy(PRIORITY_CATEGORY_CONVERSATIONS
| PRIORITY_CATEGORY_CALLS | PRIORITY_CATEGORY_MESSAGES | PRIORITY_CATEGORY_ALARMS, | PRIORITY_CATEGORY_CALLS | PRIORITY_CATEGORY_MESSAGES | PRIORITY_CATEGORY_ALARMS,
@@ -270,11 +262,7 @@ public class ZenModeBackendTest {
mBackend.saveSenders(PRIORITY_CATEGORY_CALLS, PRIORITY_SENDERS_ANY); mBackend.saveSenders(PRIORITY_CATEGORY_CALLS, PRIORITY_SENDERS_ANY);
ArgumentCaptor<Policy> captor = ArgumentCaptor.forClass(Policy.class); ArgumentCaptor<Policy> captor = ArgumentCaptor.forClass(Policy.class);
if (android.app.Flags.modesApi()) { verify(mNotificationManager).setNotificationPolicy(captor.capture(), eq(true));
verify(mNotificationManager).setNotificationPolicy(captor.capture(), eq(true));
} else {
verify(mNotificationManager).setNotificationPolicy(captor.capture());
}
Policy expected = new Policy(PRIORITY_CATEGORY_CONVERSATIONS Policy expected = new Policy(PRIORITY_CATEGORY_CONVERSATIONS
| PRIORITY_CATEGORY_CALLS | PRIORITY_CATEGORY_MESSAGES | PRIORITY_CATEGORY_ALARMS, | PRIORITY_CATEGORY_CALLS | PRIORITY_CATEGORY_MESSAGES | PRIORITY_CATEGORY_ALARMS,

View File

@@ -107,7 +107,7 @@ public class ZenModeEventRuleSettingsTest {
} }
@Test @Test
@EnableFlags({Flags.FLAG_MODES_API, Flags.FLAG_MODES_UI}) @EnableFlags(Flags.FLAG_MODES_UI)
public void updateEventRule_updatesConditionAndTriggerDescription() { public void updateEventRule_updatesConditionAndTriggerDescription() {
mFragment.setBackend(mBackend); mFragment.setBackend(mBackend);
mFragment.mId = "id"; mFragment.mId = "id";

View File

@@ -107,7 +107,7 @@ public class ZenModeScheduleRuleSettingsTest {
} }
@Test @Test
@EnableFlags({Flags.FLAG_MODES_API, Flags.FLAG_MODES_UI}) @EnableFlags(Flags.FLAG_MODES_UI)
public void updateScheduleRule_updatesConditionAndTriggerDescription() { public void updateScheduleRule_updatesConditionAndTriggerDescription() {
mFragment.setBackend(mBackend); mFragment.setBackend(mBackend);
mFragment.mId = "id"; mFragment.mId = "id";

View File

@@ -117,11 +117,7 @@ public class ZenModeSliceBuilderTest {
ZenModeSliceBuilder.handleUriChange(mContext, intent); ZenModeSliceBuilder.handleUriChange(mContext, intent);
if (android.app.Flags.modesApi()) { verify(mNm).setZenMode(eq(ZEN_MODE_IMPORTANT_INTERRUPTIONS), any(), any(), eq(true));
verify(mNm).setZenMode(eq(ZEN_MODE_IMPORTANT_INTERRUPTIONS), any(), any(), eq(true));
} else {
verify(mNm).setZenMode(eq(ZEN_MODE_IMPORTANT_INTERRUPTIONS), any(), any());
}
} }
@Test @Test
@@ -131,10 +127,6 @@ public class ZenModeSliceBuilderTest {
ZenModeSliceBuilder.handleUriChange(mContext, intent); ZenModeSliceBuilder.handleUriChange(mContext, intent);
if (android.app.Flags.modesApi()) { verify(mNm).setZenMode(eq(ZEN_MODE_OFF), any(), any(), eq(true));
verify(mNm).setZenMode(eq(ZEN_MODE_OFF), any(), any(), eq(true));
} else {
verify(mNm).setZenMode(eq(ZEN_MODE_OFF), any(), any());
}
} }
} }

View File

@@ -28,14 +28,12 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import android.app.AppOpsManager; import android.app.AppOpsManager;
import android.app.Flags;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.pm.ApplicationInfo; import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo; import android.content.pm.PackageInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.platform.test.annotations.EnableFlags;
import android.platform.test.annotations.RequiresFlagsDisabled; import android.platform.test.annotations.RequiresFlagsDisabled;
import android.platform.test.flag.junit.CheckFlagsRule; import android.platform.test.flag.junit.CheckFlagsRule;
import android.platform.test.flag.junit.DeviceFlagsValueProvider; import android.platform.test.flag.junit.DeviceFlagsValueProvider;
@@ -50,7 +48,6 @@ import com.android.settingslib.RestrictedSwitchPreference;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@@ -188,7 +185,6 @@ public class ApprovalPreferenceControllerTest {
} }
@Test @Test
@EnableFlags(Flags.FLAG_MODES_API)
public void disable() { public void disable() {
when(mNm.isNotificationPolicyAccessGrantedForPackage(anyString())).thenReturn(false); when(mNm.isNotificationPolicyAccessGrantedForPackage(anyString())).thenReturn(false);
mController.disable(mCn); mController.disable(mCn);