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

Commit ba779ca7 authored by Beverly Tai's avatar Beverly Tai Committed by Android (Google) Code Review
Browse files

Merge "Added ZenPolicyProto"

parents 611f2ac7 ac3159fc
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -1551,7 +1551,9 @@ public class ZenModeConfig implements Parcelable {
            if (component != null) {
                component.writeToProto(proto, ZenRuleProto.COMPONENT);
            }
            // TODO:  write zenPolicy to proto (b/115370281)
            if (zenPolicy != null) {
                zenPolicy.writeToProto(proto, ZenRuleProto.ZEN_POLICY);
            }
            proto.end(token);
        }

+29 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.app.Notification;
import android.app.NotificationChannel;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.proto.ProtoOutputStream;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -851,6 +852,34 @@ public final class ZenPolicy implements Parcelable {
        }
    }

    /**
     * @hide
     */
    public void writeToProto(ProtoOutputStream proto, long fieldId) {
        final long token = proto.start(fieldId);

        proto.write(ZenPolicyProto.REMINDERS, getPriorityCategoryReminders());
        proto.write(ZenPolicyProto.EVENTS, getPriorityCategoryEvents());
        proto.write(ZenPolicyProto.MESSAGES, getPriorityCategoryMessages());
        proto.write(ZenPolicyProto.CALLS, getPriorityCategoryCalls());
        proto.write(ZenPolicyProto.REPEAT_CALLERS, getPriorityCategoryRepeatCallers());
        proto.write(ZenPolicyProto.ALARMS, getPriorityCategoryAlarms());
        proto.write(ZenPolicyProto.MEDIA, getPriorityCategoryMedia());
        proto.write(ZenPolicyProto.SYSTEM, getPriorityCategorySystem());

        proto.write(ZenPolicyProto.FULL_SCREEN_INTENT, getVisualEffectFullScreenIntent());
        proto.write(ZenPolicyProto.LIGHTS, getVisualEffectLights());
        proto.write(ZenPolicyProto.PEEK, getVisualEffectPeek());
        proto.write(ZenPolicyProto.STATUS_BAR, getVisualEffectStatusBar());
        proto.write(ZenPolicyProto.BADGE, getVisualEffectBadge());
        proto.write(ZenPolicyProto.AMBIENT, getVisualEffectAmbient());
        proto.write(ZenPolicyProto.NOTIFICATION_LIST, getVisualEffectNotificationList());

        proto.write(ZenPolicyProto.PRIORITY_MESSAGES, getPriorityMessageSenders());
        proto.write(ZenPolicyProto.PRIORITY_CALLS, getPriorityCallSenders());
        proto.end(token);
    }

    /**
     * Makes deep copy of this ZenPolicy.
     * @hide
+45 −0
Original line number Diff line number Diff line
@@ -200,6 +200,7 @@ message ZenRuleProto {
    optional string condition_id = 8;
    optional ConditionProto condition = 9;
    optional android.content.ComponentNameProto component = 10;
    optional ZenPolicyProto zenPolicy = 11;
}

// A dump from com.android.server.notification.ZenModeHelper.
@@ -212,3 +213,47 @@ message ZenModeProto {
    repeated android.content.ComponentNameProto suppressors = 4;
    optional android.app.PolicyProto policy = 5;
}

// An android.service.notification.ZenPolicy object
message ZenPolicyProto {
    option (android.msg_privacy).dest = DEST_AUTOMATIC;

    enum State {
        STATE_UNSET = 0;
        STATE_ALLOW = 1;
        STATE_DISALLOW = 2;
    }

    // Notifications and sounds allowed/disallowed when DND is active
    optional State reminders = 1;
    optional State events = 2;
    optional State messages = 3;
    optional State calls = 4;
    optional State repeat_callers = 5;
    optional State alarms = 6;
    optional State media = 7;
    optional State system = 8;

    // Visual effects allowed/disallowed for intercepted notifications when DND is active
    optional State full_screen_intent = 9;
    optional State lights = 10;
    optional State peek = 11;
    optional State status_bar = 12;
    optional State badge= 13;
    optional State ambient = 14;
    optional State notification_list = 15;

    enum Sender {
        SENDER_UNSET = 0;
        // Any sender is prioritized.
        SENDER_ANY = 1;
        // Saved contacts are prioritized.
        SENDER_CONTACTS = 2;
        // Only starred contacts are prioritized.
        SENDER_STARRED = 3;
        // No calls/messages are prioritized.
        SENDER_NONE = 4;
    }
    optional Sender priority_calls = 16;
    optional Sender priority_messages = 17;
}