Support adding an automatic schedule to previously-manual system-owned modes

Bug: 342156843
Bug: 326442408
Flag: android.app.modes_ui
Test: atest com.android.settings.notification.modes
Change-Id: Ib7d15b8fc949fa73015537f03a882ef7eb6b4bcd
This commit is contained in:
Matías Hernández
2024-06-17 16:17:15 +02:00
parent c956160fe7
commit 0bf4899f3e
13 changed files with 430 additions and 88 deletions

View File

@@ -16,14 +16,12 @@
package com.android.settings.notification.modes;
import android.app.Flags;
import android.content.Context;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.CalendarContract;
import android.service.notification.SystemZenRules;
import android.service.notification.ZenModeConfig;
import androidx.annotation.NonNull;
@@ -42,7 +40,7 @@ import java.util.List;
import java.util.Objects;
import java.util.function.Function;
public class ZenModeSetCalendarPreferenceController extends AbstractZenModePreferenceController {
class ZenModeSetCalendarPreferenceController extends AbstractZenModePreferenceController {
@VisibleForTesting
protected static final String KEY_CALENDAR = "calendar";
@VisibleForTesting
@@ -122,11 +120,7 @@ public class ZenModeSetCalendarPreferenceController extends AbstractZenModePrefe
@VisibleForTesting
protected Function<ZenMode, ZenMode> updateEventMode(ZenModeConfig.EventInfo event) {
return (zenMode) -> {
zenMode.getRule().setConditionId(ZenModeConfig.toEventConditionId(event));
if (Flags.modesApi() && Flags.modesUi()) {
zenMode.getRule().setTriggerDescription(
SystemZenRules.getTriggerDescriptionForScheduleEvent(mContext, event));
}
zenMode.setCustomModeConditionId(mContext, ZenModeConfig.toEventConditionId(event));
return zenMode;
};
}