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

Commit 682d1ad9 authored by Andre Eisenbach's avatar Andre Eisenbach
Browse files

Add GATT debug information to dumpsys/bugreport

Bug: 17894347
Change-Id: I70a2e237e4aa6a1057e5ff519f3f6148a27b3a98
parent 9c5a7cee
Loading
Loading
Loading
Loading
+6 −11
Original line number Diff line number Diff line
@@ -291,28 +291,23 @@ import java.util.UUID;
    /**
     * Logs debug information.
     */
    void dump() {
        StringBuilder b = new StringBuilder();
        b.append(  "-------------- GATT Context Map ----------------");
        b.append("\nEntries: " + mApps.size());
    void dump(StringBuilder sb) {
        sb.append("  Entries: " + mApps.size() + "\n");

        Iterator<App> i = mApps.iterator();
        while(i.hasNext()) {
            App entry = i.next();
            List<Connection> connections = getConnectionByApp(entry.id);

            b.append("\n\nApplication Id: " + entry.id);
            b.append("\nUUID: " + entry.uuid);
            b.append("\nConnections: " + connections.size());
            sb.append("\n  Application Id: " + entry.id + "\n");
            sb.append("  UUID: " + entry.uuid + "\n");
            sb.append("  Connections: " + connections.size() + "\n");

            Iterator<Connection> ii = connections.iterator();
            while(ii.hasNext()) {
                Connection connection = ii.next();
                b.append("\n  " + connection.connId + ": " + connection.address);
                sb.append("    " + connection.connId + ": " + connection.address + "\n");
            }
        }

        b.append("\n------------------------------------------------");
        Log.d(TAG, b.toString());
    }
}
+1 −21
Original line number Diff line number Diff line
@@ -28,13 +28,6 @@ import java.util.UUID;
    private static final String TAG = GattServiceConfig.TAG_PREFIX + "DebugUtils";
    private static final boolean DEBUG_ADMIN = GattServiceConfig.DEBUG_ADMIN;

    private static final String ACTION_DEBUG_DUMP_CLIENTMAP =
                                "android.bluetooth.action.DEBUG_DUMP_CLIENTMAP";
    private static final String ACTION_DEBUG_DUMP_SERVERMAP =
                                "android.bluetooth.action.DEBUG_DUMP_SERVERMAP";
    private static final String ACTION_DEBUG_DUMP_HANDLEMAP =
                                "android.bluetooth.action.DEBUG_DUMP_HANDLEMAP";

    private static final String ACTION_GATT_PAIRING_CONFIG =
                                "android.bluetooth.action.GATT_PAIRING_CONFIG";

@@ -81,24 +74,11 @@ import java.util.UUID;
        String action = intent.getAction();
        Log.d(TAG, "handleDebugAction() action=" + action);

        /*
         * Debug log functinos
         */

        if (ACTION_DEBUG_DUMP_CLIENTMAP.equals(action)) {
            svc.mClientMap.dump();

        } else if (ACTION_DEBUG_DUMP_SERVERMAP.equals(action)) {
            svc.mServerMap.dump();

        } else if (ACTION_DEBUG_DUMP_HANDLEMAP.equals(action)) {
            svc.mHandleMap.dump();

        /*
         * PTS test commands
         */

        } else if (ACTION_GATT_TEST_USAGE.equals(action)) {
        if (ACTION_GATT_TEST_USAGE.equals(action)) {
            logUsageInfo();

        } else if (ACTION_GATT_TEST_ENABLE.equals(action)) {
+9 −0
Original line number Diff line number Diff line
@@ -2197,6 +2197,15 @@ public class GattService extends ProfileService {
            println(sb, "  " + declaration);
        }
        println(sb, "mMaxScanFilters: " + mMaxScanFilters);

        sb.append("\nGATT Client Map\n");
        mClientMap.dump(sb);

        sb.append("\nGATT Server Map\n");
        mServerMap.dump(sb);

        sb.append("\nGATT Handle Map\n");
        mHandleMap.dump(sb);
    }

    /**************************************************************************
+10 −13
Original line number Diff line number Diff line
@@ -196,31 +196,28 @@ class HandleMap {
    /**
     * Logs debug information.
     */
    void dump() {
        StringBuilder b = new StringBuilder();
        b.append(  "-------------- GATT Handle Map -----------------");
        b.append("\nEntries: " + mEntries.size());
        b.append("\nRequests: " + mRequestMap.size());
    void dump(StringBuilder sb) {
        sb.append("  Entries: " + mEntries.size() + "\n");
        sb.append("  Requests: " + mRequestMap.size() + "\n");

        for (Entry entry : mEntries) {
            b.append("\n" + entry.serverIf + ": [" + entry.handle + "] ");
            sb.append("  " + entry.serverIf + ": [" + entry.handle + "] ");
            switch(entry.type) {
                case TYPE_SERVICE:
                    b.append("Service " + entry.uuid);
                    b.append(", started " + entry.started);
                    sb.append("Service " + entry.uuid);
                    sb.append(", started " + entry.started);
                    break;

                case TYPE_CHARACTERISTIC:
                    b.append("  Characteristic " + entry.uuid);
                    sb.append("  Characteristic " + entry.uuid);
                    break;

                case TYPE_DESCRIPTOR:
                    b.append("    Descriptor " + entry.uuid);
                    sb.append("    Descriptor " + entry.uuid);
                    break;
            }
        }

        b.append("\n------------------------------------------------");
        Log.d(TAG, b.toString());
            sb.append("\n");
        }
    }
}