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

Commit 060deca2 authored by William Escande's avatar William Escande
Browse files

SystemServer: Add trunk stable to dumpsys info

Example of the output after this CL (flag are alphabetically sorted):

```
🚩Flag dump:
        [ ]: aCoolFlag
        [ ]: anotherNiceFlag
        [■]: woawThisFlagIsEnabled
```

Bug: 321313362
Fix: 321313362
Flag: Exempt, debug tool that is protected by a complete try catch
Test: m Bluetooth
Test: adb shell dumpsys bluetooth_manager | Then check that your flags
      are correctly displayed (and with the expected value)
Change-Id: I4ec9d40d46b7c983ce1be90d95e72a954f63e540
parent 384d9ff9
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ import android.util.proto.ProtoOutputStream;

import com.android.bluetooth.BluetoothStatsLog;
import com.android.bluetooth.flags.FeatureFlags;
import com.android.bluetooth.flags.Flags;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.server.BluetoothManagerServiceDumpProto;
@@ -86,6 +87,8 @@ import kotlin.time.TimeSource;
import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.time.Duration;
import java.time.Instant;
import java.time.ZoneId;
@@ -2429,6 +2432,12 @@ class BluetoothManagerService {
            args[0] = "--print";
        }

        try {
            dumpBluetoothFlags(writer);
        } catch (Exception e) {
            writer.println("Exception while dumping Bluetooth Flags");
        }

        if (mAdapter == null) {
            errorMsg = "Bluetooth Service not connected";
        } else {
@@ -2443,6 +2452,16 @@ class BluetoothManagerService {
        }
    }

    void dumpBluetoothFlags(PrintWriter writer)
            throws IllegalAccessException, InvocationTargetException {
        writer.println("🚩Flag dump:");
        for (Method m : Flags.class.getDeclaredMethods()) {
            String flagStatus = ((Boolean) m.invoke(null)) ? "[■]" : "[ ]";
            writer.println("\t" + flagStatus + ": " + m.getName());
        }
        writer.println("");
    }

    private void dumpProto(FileDescriptor fd) {
        final ProtoOutputStream proto = new ProtoOutputStream(new FileOutputStream(fd));
        proto.write(BluetoothManagerServiceDumpProto.ENABLED, isEnabled());