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

Commit 63c3a154 authored by William Escande's avatar William Escande Committed by Gerrit Code Review
Browse files

Merge "SystemServer: Add snake case flag in dumpsys" into main

parents c98571cc 0f617ae3
Loading
Loading
Loading
Loading
+17 −2
Original line number Original line Diff line number Diff line
@@ -94,6 +94,7 @@ import java.time.Instant;
import java.time.ZoneId;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.LinkedList;
import java.util.List;
import java.util.List;
import java.util.Locale;
import java.util.Locale;
@@ -2452,12 +2453,26 @@ class BluetoothManagerService {
        }
        }
    }
    }


    void dumpBluetoothFlags(PrintWriter writer)
    private void dumpBluetoothFlags(PrintWriter writer)
            throws IllegalAccessException, InvocationTargetException {
            throws IllegalAccessException, InvocationTargetException {
        writer.println("🚩Flag dump:");
        writer.println("🚩Flag dump:");

        // maxLen is used to align the flag output
        int maxLen =
                Arrays.stream(Flags.class.getDeclaredMethods())
                        .map(Method::getName)
                        .map(String::length)
                        .max(Integer::compare)
                        .get();

        String fmt = "\t%s: %-" + maxLen + "s %s";

        for (Method m : Flags.class.getDeclaredMethods()) {
        for (Method m : Flags.class.getDeclaredMethods()) {
            String flagStatus = ((Boolean) m.invoke(null)) ? "[■]" : "[ ]";
            String flagStatus = ((Boolean) m.invoke(null)) ? "[■]" : "[ ]";
            writer.println("\t" + flagStatus + ": " + m.getName());
            String name = m.getName();
            String snakeCaseName =
                    name.replaceAll("([a-z])([A-Z]+)", "$1_$2").toLowerCase(Locale.US);
            writer.println(String.format(fmt, flagStatus, name, snakeCaseName));
        }
        }
        writer.println("");
        writer.println("");
    }
    }