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

Commit 1a28857f authored by Yuri Lin's avatar Yuri Lin Committed by Automerger Merge Worker
Browse files

Merge "Update ZenModeHelper & Test for refactor of DND atoms out of...

Merge "Update ZenModeHelper & Test for refactor of DND atoms out of atoms.proto." into udc-dev am: 9a849a65

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21562860



Change-Id: I3c256e0a9076f64788cf1f199aec59a19004db07
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents b4118cd1 9a849a65
Loading
Loading
Loading
Loading
+35 −29
Original line number Diff line number Diff line
@@ -285,22 +285,24 @@ message NotificationRemoteViewsProto {
    repeated PackageRemoteViewInfoProto package_remote_view_info = 1;
}

// Enum used in DNDModeProto to specify the zen mode setting.
enum LoggedZenMode {
    ROOT_CONFIG = -1;  // Used to distinguish config (one per user) from the rules.
    OFF = 0;
    IMPORTANT_INTERRUPTIONS = 1;
    NO_INTERRUPTIONS = 2;
    ALARMS = 3;
}

/**
 * Atom that represents an item in the list of Do Not Disturb rules, pulled from
 * NotificationManagerService.java.
 */
message DNDModeProto {
    enum Mode {
        ROOT_CONFIG = -1;  // Used to distinguish the config (one per user) from the rules.
        ZEN_MODE_OFF = 0;
        ZEN_MODE_IMPORTANT_INTERRUPTIONS = 1;
        ZEN_MODE_NO_INTERRUPTIONS = 2;
        ZEN_MODE_ALARMS = 3;
    }
    optional int32 user = 1;  // Android user ID (0, 1, 10, ...)
    optional bool enabled = 2;  // true for ROOT_CONFIG if a manualRule is enabled
    optional bool channels_bypassing = 3; // only valid for ROOT_CONFIG
    optional Mode zen_mode = 4;
    optional LoggedZenMode zen_mode = 4;
    // id is one of the system default rule IDs, or empty
    // May also be "MANUAL_RULE" to indicate app-activation of the manual rule.
    optional string id = 5;
@@ -308,15 +310,34 @@ message DNDModeProto {
    optional DNDPolicyProto policy = 7;
}

/**
 * Atom that represents a Do Not Disturb policy, an optional detail proto for DNDModeProto.
 */
message DNDPolicyProto {
// Enum used in DNDPolicyProto for a particular policy parameter's state.
enum State {
    STATE_UNSET = 0;
    STATE_ALLOW = 1;
    STATE_DISALLOW = 2;
}

// Enum used in DNDPolicyProto for which people are allowed to break through.
enum PeopleType {
    PEOPLE_UNSET = 0;
    PEOPLE_ANYONE = 1;
    PEOPLE_CONTACTS = 2;
    PEOPLE_STARRED = 3;
    PEOPLE_NONE = 4;
}

// Enum used in DNDPolicyProto for conversation types allowed to break through.
enum ConversationType {
    CONV_UNSET = 0;
    CONV_ANYONE = 1;
    CONV_IMPORTANT = 2;
    CONV_NONE = 3;
}

/**
 * Message that represents a Do Not Disturb policy, an optional detail proto for DNDModeProto.
 */
message DNDPolicyProto {
    optional State calls = 1;
    optional State repeat_callers = 2;
    optional State messages = 3;
@@ -334,23 +355,8 @@ message DNDPolicyProto {
    optional State ambient = 15;
    optional State notification_list = 16;

    enum PeopleType {
        PEOPLE_UNSET = 0;
        PEOPLE_ANYONE = 1;
        PEOPLE_CONTACTS = 2;
        PEOPLE_STARRED = 3;
        PEOPLE_NONE = 4;
    }

    optional PeopleType allow_calls_from = 17;
    optional PeopleType allow_messages_from = 18;

    enum ConversationType {
        CONV_UNSET = 0;
        CONV_ANYONE = 1;
        CONV_IMPORTANT = 2;
        CONV_NONE = 3;
    }

    optional ConversationType allow_conversations_from = 19;
}
+1 −1
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ import static android.app.NotificationManager.AUTOMATIC_RULE_STATUS_DISABLED;
import static android.app.NotificationManager.AUTOMATIC_RULE_STATUS_ENABLED;
import static android.app.NotificationManager.AUTOMATIC_RULE_STATUS_REMOVED;
import static android.app.NotificationManager.Policy.PRIORITY_SENDERS_ANY;
import static android.service.notification.DNDModeProto.ROOT_CONFIG;
import static android.service.notification.NotificationServiceProto.ROOT_CONFIG;
import static android.util.StatsLog.ANNOTATION_ID_IS_UID;

import static com.android.internal.util.FrameworkStatsLog.DND_MODE_RULE;
+7 −7
Original line number Diff line number Diff line
@@ -38,11 +38,12 @@ import static android.service.notification.Condition.STATE_TRUE;
import static android.util.StatsLog.ANNOTATION_ID_IS_UID;

import static com.android.internal.util.FrameworkStatsLog.DND_MODE_RULE;
import static com.android.os.AtomsProto.DNDModeProto.CHANNELS_BYPASSING_FIELD_NUMBER;
import static com.android.os.AtomsProto.DNDModeProto.ENABLED_FIELD_NUMBER;
import static com.android.os.AtomsProto.DNDModeProto.ID_FIELD_NUMBER;
import static com.android.os.AtomsProto.DNDModeProto.UID_FIELD_NUMBER;
import static com.android.os.AtomsProto.DNDModeProto.ZEN_MODE_FIELD_NUMBER;
import static com.android.os.dnd.DNDModeProto.CHANNELS_BYPASSING_FIELD_NUMBER;
import static com.android.os.dnd.DNDModeProto.ENABLED_FIELD_NUMBER;
import static com.android.os.dnd.DNDModeProto.ID_FIELD_NUMBER;
import static com.android.os.dnd.DNDModeProto.UID_FIELD_NUMBER;
import static com.android.os.dnd.DNDModeProto.ZEN_MODE_FIELD_NUMBER;
import static com.android.os.dnd.DNDProtoEnums.ROOT_CONFIG;
import static com.android.server.notification.ZenModeHelper.RULE_LIMIT_PER_PACKAGE;

import static junit.framework.Assert.assertEquals;
@@ -95,7 +96,6 @@ import android.os.UserHandle;
import android.provider.Settings;
import android.provider.Settings.Global;
import android.service.notification.Condition;
import android.service.notification.DNDModeProto;
import android.service.notification.ZenModeConfig;
import android.service.notification.ZenModeConfig.ScheduleInfo;
import android.service.notification.ZenPolicy;
@@ -898,7 +898,7 @@ public class ZenModeHelperTest extends UiServiceTestCase {
        assertEquals(n + 1, events.size());
        for (WrappedSysUiStatsEvent.WrappedBuilder builder : mStatsEventBuilderFactory.builders) {
            if (builder.getAtomId() == DND_MODE_RULE) {
                if (builder.getInt(ZEN_MODE_FIELD_NUMBER) == DNDModeProto.ROOT_CONFIG) {
                if (builder.getInt(ZEN_MODE_FIELD_NUMBER) == ROOT_CONFIG) {
                    assertTrue(builder.getBoolean(ENABLED_FIELD_NUMBER));
                    assertFalse(builder.getBoolean(CHANNELS_BYPASSING_FIELD_NUMBER));
                }