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

Commit 570427ba authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Android (Google) Code Review
Browse files

Merge "More `android.util` internals, with tests." into main

parents 4181facf ce9f0d06
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import java.util.concurrent.TimeUnit;
 *
 * @hide
 */
@android.ravenwood.annotation.RavenwoodKeepWholeClass
public enum DataUnit {
    KILOBYTES { @Override public long toBytes(long v) { return v * 1_000; } },
    MEGABYTES { @Override public long toBytes(long v) { return v * 1_000_000; } },
+21 −2
Original line number Diff line number Diff line
@@ -48,6 +48,9 @@ import java.util.regex.Pattern;
 * They carry a payload of one or more int, long, or String values.  The
 * event-log-tags file defines the payload contents for each type code.
 */
@android.ravenwood.annotation.RavenwoodKeepWholeClass
@android.ravenwood.annotation.RavenwoodNativeSubstitutionClass(
        "com.android.hoststubgen.nativesubstitution.EventLog_host")
public class EventLog {
    /** @hide */ public EventLog() {}

@@ -416,6 +419,7 @@ public class EventLog {
    /**
     * Read TAGS_FILE, populating sTagCodes and sTagNames, if not already done.
     */
    @android.ravenwood.annotation.RavenwoodReplace
    private static synchronized void readTagsFile() {
        if (sTagCodes != null && sTagNames != null) return;

@@ -441,8 +445,7 @@ public class EventLog {
                try {
                    int num = Integer.parseInt(m.group(1));
                    String name = m.group(2);
                    sTagCodes.put(name, num);
                    sTagNames.put(num, name);
                    registerTagLocked(num, name);
                } catch (NumberFormatException e) {
                    Log.wtf(TAG, "Error in " + TAGS_FILE + ": " + line, e);
                }
@@ -454,4 +457,20 @@ public class EventLog {
            try { if (reader != null) reader.close(); } catch (IOException e) {}
        }
    }

    private static void registerTagLocked(int num, String name) {
        sTagCodes.put(name, num);
        sTagNames.put(num, name);
    }

    private static synchronized void readTagsFile$ravenwood() {
        // TODO: restore parsing logic once we carry into runtime
        sTagCodes = new HashMap<String, Integer>();
        sTagNames = new HashMap<Integer, String>();

        // Hard-code a few common tags
        registerTagLocked(524288, "sysui_action");
        registerTagLocked(524290, "sysui_count");
        registerTagLocked(524291, "sysui_histogram");
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import java.util.Arrays;
 *
 * @hide
 */
@android.ravenwood.annotation.RavenwoodKeepWholeClass
public class IntArray implements Cloneable {
    private static final int MIN_CAPACITY_INCREMENT = 12;

+1 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import java.util.Arrays;
 *
 * @hide
 */
@android.ravenwood.annotation.RavenwoodKeepWholeClass
public class LongArray implements Cloneable {
    private static final int MIN_CAPACITY_INCREMENT = 12;

+6 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import android.os.Build;
 * @hide
 */
@SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
@android.ravenwood.annotation.RavenwoodKeepWholeClass
public final class Slog {

    private Slog() {
@@ -216,6 +217,7 @@ public final class Slog {
     * @see Log#wtf(String, String)
     */
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    @android.ravenwood.annotation.RavenwoodThrow
    public static int wtf(@Nullable String tag, @NonNull String msg) {
        return Log.wtf(Log.LOG_ID_SYSTEM, tag, msg, null, false, true);
    }
@@ -223,6 +225,7 @@ public final class Slog {
    /**
     * Similar to {@link #wtf(String, String)}, but does not output anything to the log.
     */
    @android.ravenwood.annotation.RavenwoodThrow
    public static void wtfQuiet(@Nullable String tag, @NonNull String msg) {
        Log.wtfQuiet(Log.LOG_ID_SYSTEM, tag, msg, true);
    }
@@ -241,6 +244,7 @@ public final class Slog {
     * @see Log#wtfStack(String, String)
     */
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
    @android.ravenwood.annotation.RavenwoodThrow
    public static int wtfStack(@Nullable String tag, @NonNull String msg) {
        return Log.wtf(Log.LOG_ID_SYSTEM, tag, msg, null, true, true);
    }
@@ -259,6 +263,7 @@ public final class Slog {
     *
     * @see Log#wtf(String, Throwable)
     */
    @android.ravenwood.annotation.RavenwoodThrow
    public static int wtf(@Nullable String tag, @Nullable Throwable tr) {
        return Log.wtf(Log.LOG_ID_SYSTEM, tag, tr.getMessage(), tr, false, true);
    }
@@ -279,6 +284,7 @@ public final class Slog {
     * @see Log#wtf(String, String, Throwable)
     */
    @UnsupportedAppUsage
    @android.ravenwood.annotation.RavenwoodThrow
    public static int wtf(@Nullable String tag, @NonNull String msg, @Nullable Throwable tr) {
        return Log.wtf(Log.LOG_ID_SYSTEM, tag, msg, tr, false, true);
    }
Loading