Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f9996319 authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Treat manual zen rule more like automatic rules

And store policy and deviceeffects info in the manual
rule rather than directly on the config.

This means the manual rule will always exist, and its
condition will be used to determine if it's active or
not.

This cl continues to store the original config policy
values even when the flag is on so it's possible to rollback
the flag without losing user settings.

Test: ZenModeHelperTest (esp the logging tests)
Test: ZenModeDiffTest
Test: ZenModeConfigTest
Test: NotificationManagerZenTest
Bug: 333530553
Flag: android.app.modes_ui
Change-Id: I961d28f01affdcfae9bbf69b16699137188e50e3
parent f06ff25d
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ import android.service.notification.StatusBarNotification;
import android.service.notification.ZenPolicy;
import android.app.AutomaticZenRule;
import android.service.notification.ZenModeConfig;
import android.service.notification.ZenDeviceEffects;

/** {@hide} */
interface INotificationManager
@@ -227,6 +228,7 @@ interface INotificationManager
    int getRuleInstanceCount(in ComponentName owner);
    int getAutomaticZenRuleState(String id);
    void setAutomaticZenRuleState(String id, in Condition condition);
    void setManualZenRuleDeviceEffects(in ZenDeviceEffects effects);

    byte[] getBackupPayload(int user);
    void applyRestore(in byte[] payload, int user);
+13 −0
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ import android.provider.Settings.Global;
import android.service.notification.Adjustment;
import android.service.notification.Condition;
import android.service.notification.StatusBarNotification;
import android.service.notification.ZenDeviceEffects;
import android.service.notification.ZenModeConfig;
import android.service.notification.ZenPolicy;
import android.util.Log;
@@ -1828,6 +1829,18 @@ public class NotificationManager {
            throw e.rethrowFromSystemServer();
        }
    }
    /**
     * @hide
     */
    @FlaggedApi(Flags.FLAG_MODES_UI)
    public void setManualZenRuleDeviceEffects(@NonNull ZenDeviceEffects effects) {
        INotificationManager service = getService();
        try {
            service.setManualZenRuleDeviceEffects(effects);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * For apps targeting {@link Build.VERSION_CODES#VANILLA_ICE_CREAM} and above, the
+4 −4
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ public class ZenAdapters {
                .allowAlarms(policy.allowAlarms())
                .allowCalls(
                        policy.allowCalls()
                                ? notificationPolicySendersToZenPolicyPeopleType(
                                ? prioritySendersToPeopleType(
                                        policy.allowCallsFrom())
                        : ZenPolicy.PEOPLE_TYPE_NONE)
                .allowConversations(
@@ -45,7 +45,7 @@ public class ZenAdapters {
                .allowMedia(policy.allowMedia())
                .allowMessages(
                        policy.allowMessages()
                                ? notificationPolicySendersToZenPolicyPeopleType(
                                ? prioritySendersToPeopleType(
                                        policy.allowMessagesFrom())
                                : ZenPolicy.PEOPLE_TYPE_NONE)
                .allowReminders(policy.allowReminders())
@@ -71,7 +71,7 @@ public class ZenAdapters {

    /** Maps {@link ZenPolicy.PeopleType} enum to {@link Policy.PrioritySenders}. */
    @Policy.PrioritySenders
    public static int zenPolicyPeopleTypeToNotificationPolicySenders(
    public static int peopleTypeToPrioritySenders(
            @ZenPolicy.PeopleType int zpPeopleType, @Policy.PrioritySenders int defaultResult) {
        switch (zpPeopleType) {
            case ZenPolicy.PEOPLE_TYPE_ANYONE:
@@ -87,7 +87,7 @@ public class ZenAdapters {

    /** Maps {@link Policy.PrioritySenders} enum to {@link ZenPolicy.PeopleType}. */
    @ZenPolicy.PeopleType
    public static int notificationPolicySendersToZenPolicyPeopleType(
    public static int prioritySendersToPeopleType(
            @Policy.PrioritySenders int npPrioritySenders) {
        switch (npPrioritySenders) {
            case Policy.PRIORITY_SENDERS_ANY:
+20 −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 android.service.notification;

parcelable ZenDeviceEffects;
+613 −180

File changed.

Preview size limit exceeded, changes collapsed.

Loading