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

Commit 7e337582 authored by Pablo Gamito's avatar Pablo Gamito
Browse files

Add getId method to IProtoLogGroup

So that at runtime we can dump the id of the group when using protolog without pre-processing the source code.

Test: n/a
Change-Id: If7441fb408203b79193d6e3d9080290edae5dcda
parent b63ed2d4
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package com.android.internal.protolog;

import com.android.internal.protolog.common.IProtoLogGroup;

import java.util.UUID;

/**
 * Defines logging groups for ProtoLog.
 *
@@ -153,10 +155,18 @@ public enum ProtoLogGroup implements IProtoLogGroup {
        this.mLogToLogcat = logToLogcat;
    }

    @Override
    public int getId() {
        return Consts.START_ID + this.ordinal();
    }

    private static class Consts {
        private static final String TAG_WM = "WindowManager";

        private static final boolean ENABLE_DEBUG = true;
        private static final boolean ENABLE_LOG_TO_PROTO_DEBUG = true;
        private static final int START_ID = (int) (
                UUID.nameUUIDFromBytes(ProtoLogGroup.class.getName().getBytes())
                        .getMostSignificantBits() % Integer.MAX_VALUE);
    }
}
+5 −0
Original line number Diff line number Diff line
@@ -64,4 +64,9 @@ public interface IProtoLogGroup {
     * returns name of the logging group.
     */
    String name();

    /**
     * returns the id of the logging group (unique for each group).
     */
    int getId();
}
+11 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package com.android.wm.shell.protolog;

import com.android.internal.protolog.common.IProtoLogGroup;

import java.util.UUID;

/**
 * Defines logging groups for ProtoLog.
 *
@@ -116,6 +118,11 @@ public enum ShellProtoLogGroup implements IProtoLogGroup {
        this.mLogToLogcat = logToLogcat;
    }

    @Override
    public int getId() {
        return Consts.START_ID + this.ordinal();
    }

    private static class Consts {
        private static final String TAG_WM_SHELL = "WindowManagerShell";
        private static final String TAG_WM_STARTING_WINDOW = "ShellStartingWindow";
@@ -124,5 +131,9 @@ public enum ShellProtoLogGroup implements IProtoLogGroup {

        private static final boolean ENABLE_DEBUG = true;
        private static final boolean ENABLE_LOG_TO_PROTO_DEBUG = true;

        private static final int START_ID = (int) (
                UUID.nameUUIDFromBytes(ShellProtoLogGroup.class.getName().getBytes())
                        .getMostSignificantBits() % Integer.MAX_VALUE);
    }
}
+5 −0
Original line number Diff line number Diff line
@@ -393,5 +393,10 @@ public class LegacyProtoLogImplTest {
            this.mLogToLogcat = logToLogcat;
        }

        @Override
        public int getId() {
            return ordinal();
        }

    }
}
+5 −0
Original line number Diff line number Diff line
@@ -725,5 +725,10 @@ public class PerfettoProtoLogImplTest {
            this.mLogToLogcat = logToLogcat;
        }

        @Override
        public int getId() {
            return ordinal();
        }

    }
}
Loading