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

Commit bc84aecc authored by Kweku Adams's avatar Kweku Adams
Browse files

Fixing bugs in Notification proto dumping.

Also changing method signatures to be more in line with our convention.
Based on some of the changes I went through, it looks like:
1. We were only legitimately saving the very last NotificationRecord
that was dumped.
2. We weren't dumping any NotificationChannels into
NotificationChannelGroup protos.

Bug: 65750824
Test: Android builds
Change-Id: I8c1ef90cf69d8ea00a7bad0c67445741056e23ef
parent fc027600
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -32,8 +32,6 @@ import android.util.proto.ProtoOutputStream;

import com.android.internal.util.Preconditions;

import com.android.internal.util.Preconditions;

import org.json.JSONException;
import org.json.JSONObject;
import org.xmlpull.v1.XmlPullParser;
@@ -936,7 +934,9 @@ public final class NotificationChannel implements Parcelable {
    }

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

        proto.write(NotificationChannelProto.ID, mId);
        proto.write(NotificationChannelProto.NAME, mName);
        proto.write(NotificationChannelProto.DESCRIPTION, mDesc);
@@ -959,10 +959,10 @@ public final class NotificationChannel implements Parcelable {
        proto.write(NotificationChannelProto.IS_DELETED, mDeleted);
        proto.write(NotificationChannelProto.GROUP, mGroup);
        if (mAudioAttributes != null) {
            long aToken = proto.start(NotificationChannelProto.AUDIO_ATTRIBUTES);
            mAudioAttributes.toProto(proto);
            proto.end(aToken);
            mAudioAttributes.writeToProto(proto, NotificationChannelProto.AUDIO_ATTRIBUTES);
        }
        proto.write(NotificationChannelProto.IS_BLOCKABLE_SYSTEM, mBlockableSystem);

        proto.end(token);
    }
}
+6 −2
Original line number Diff line number Diff line
@@ -298,13 +298,17 @@ public final class NotificationChannelGroup implements Parcelable {
    }

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

        proto.write(NotificationChannelGroupProto.ID, mId);
        proto.write(NotificationChannelGroupProto.NAME, mName.toString());
        proto.write(NotificationChannelGroupProto.DESCRIPTION, mDescription);
        proto.write(NotificationChannelGroupProto.IS_BLOCKED, mBlocked);
        for (NotificationChannel channel : mChannels) {
            channel.toProto(proto);
            channel.writeToProto(proto, NotificationChannelGroupProto.CHANNELS);
        }

        proto.end(token);
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -1133,7 +1133,7 @@ public class NotificationManager {
        }

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

            bitwiseToProtoEnum(proto, PolicyProto.PRIORITY_CATEGORIES, priorityCategories);
+2 −1
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import "frameworks/base/core/proto/android/app/notification_channel.proto";
import "frameworks/base/core/proto/android/app/notification_channel_group.proto";
import "frameworks/base/core/proto/android/app/notificationmanager.proto";
import "frameworks/base/core/proto/android/content/component_name.proto";
import "frameworks/base/core/proto/android/media/audioattributes.proto";

message NotificationServiceDumpProto {
    repeated NotificationRecordProto records = 1;
@@ -55,7 +56,7 @@ message NotificationRecordProto {
    optional int32 flags = 3;
    optional string channelId = 4;
    optional string sound = 5;
    optional int32 sound_usage = 6;
    optional .android.media.AudioAttributesProto audio_attributes = 6;
    optional bool can_vibrate = 7;
    optional bool can_show_light = 8;
    optional string group_key = 9;
+5 −1
Original line number Diff line number Diff line
@@ -880,7 +880,9 @@ public final class AudioAttributes implements Parcelable {
    }

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

        proto.write(AudioAttributesProto.USAGE, mUsage);
        proto.write(AudioAttributesProto.CONTENT_TYPE, mContentType);
        proto.write(AudioAttributesProto.FLAGS, mFlags);
@@ -892,6 +894,8 @@ public final class AudioAttributes implements Parcelable {
            }
        }
        // TODO: is the data in mBundle useful for debugging?

        proto.end(token);
    }

    /** @hide */
Loading