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

Commit b9e48e2f authored by Nick Chalko's avatar Nick Chalko Committed by shubang
Browse files

Improve CEC logging

ag/5338580

Include details for HdmiCecLocalDeviceAudioSystem

Increase the number of CEC messages kept dump history from 20 to 200.
Many CEC devices are chatty.
This increase the memory used for CEC message history from about
600 bytes to a max of 6K bytes.

Bug:117991662
Change-Id: Ib21162d7c166b927db1e6fd0e51de87c13e538f9
Test: m -j; flashall; adb shell dumpsys hdmi_control
parent 79db52fb
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -77,7 +77,7 @@ final class HdmiCecController {

    private static final int NUM_LOGICAL_ADDRESS = 16;

    private static final int MAX_CEC_MESSAGE_HISTORY = 20;
    private static final int MAX_CEC_MESSAGE_HISTORY = 200;

    // Predicate for whether the given logical address is remote device's one or not.
    private final Predicate<Integer> mRemoteDeviceAddressPredicate = new Predicate<Integer>() {
@@ -682,7 +682,7 @@ final class HdmiCecController {

    void dump(final IndentingPrintWriter pw) {
        for (int i = 0; i < mLocalDevices.size(); ++i) {
            pw.println("HdmiCecLocalDevice #" + i + ":");
            pw.println("HdmiCecLocalDevice #" + mLocalDevices.keyAt(i) + ":");
            pw.increaseIndent();
            mLocalDevices.valueAt(i).dump(pw);
            pw.decreaseIndent();
+17 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import android.util.SparseArray;

import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.IndentingPrintWriter;
import com.android.server.hdmi.Constants.AudioCodec;
import com.android.server.hdmi.DeviceDiscoveryAction.DeviceDiscoveryCallback;
import com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly;
@@ -1086,4 +1087,20 @@ public class HdmiCecLocalDeviceAudioSystem extends HdmiCecLocalDeviceSource {
        }
        mDeviceInfos.clear();
    }

    @Override
    protected void dump(IndentingPrintWriter pw) {
        pw.println("HdmiCecLocalDeviceAudioSystem:");
        pw.increaseIndent();
        pw.println("mSystemAudioActivated: " + mSystemAudioActivated);
        pw.println("mSystemAudioControlFeatureEnabled: " + mSystemAudioControlFeatureEnabled);
        pw.println("mTvSystemAudioModeSupport: " + mTvSystemAudioModeSupport);
        pw.println("mArcEstablished: " + mArcEstablished);
        pw.println("mArcIntentUsed: " + mArcIntentUsed);
        HdmiUtils.dumpMap(pw, "mTvInputs:", mTvInputs);
        HdmiUtils.dumpSparseArray(pw, "mDeviceInfos:", mDeviceInfos);
        pw.decreaseIndent();
        super.dump(pw);
    }

}
+14 −13
Original line number Diff line number Diff line
@@ -1890,27 +1890,28 @@ public class HdmiControlService extends SystemService {
            if (!DumpUtils.checkDumpPermission(getContext(), TAG, writer)) return;
            final IndentingPrintWriter pw = new IndentingPrintWriter(writer, "  ");

            pw.println("mHdmiControlEnabled: " + mHdmiControlEnabled);
            pw.println("mProhibitMode: " + mProhibitMode);
            if (mCecController != null) {
                pw.println("mCecController: ");
            pw.println("mPowerStatus: " + mPowerStatus);

            // System settings
            pw.println("System_settings:");
            pw.increaseIndent();
                mCecController.dump(pw);
            pw.println("mHdmiControlEnabled: " + mHdmiControlEnabled);
            pw.println("mMhlInputChangeEnabled: " + mMhlInputChangeEnabled);
            pw.decreaseIndent();
            }

            pw.println("mMhlController: ");
            pw.increaseIndent();
            mMhlController.dump(pw);
            pw.decreaseIndent();

            pw.println("mPortInfo: ");
            HdmiUtils.dumpIterable(pw, "mPortInfo:", mPortInfo);
            if (mCecController != null) {
                pw.println("mCecController: ");
                pw.increaseIndent();
            for (HdmiPortInfo hdmiPortInfo : mPortInfo) {
                pw.println("- " + hdmiPortInfo);
            }
                mCecController.dump(pw);
                pw.decreaseIndent();
            pw.println("mPowerStatus: " + mPowerStatus);
            }
        }
    }

+74 −0
Original line number Diff line number Diff line
@@ -20,9 +20,13 @@ import android.hardware.hdmi.HdmiDeviceInfo;
import android.util.Slog;
import android.util.SparseArray;

import com.android.internal.util.IndentingPrintWriter;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;


/**
 * Various utilities to handle HDMI CEC messages.
@@ -317,4 +321,74 @@ final class HdmiUtils {
                info.getPhysicalAddress(), info.getPortId(), info.getDeviceType(),
                info.getVendorId(), info.getDisplayName(), newPowerStatus);
    }

    /**
     * Dump a {@link SparseArray} to the print writer.
     *
     * <p>The dump is formatted:
     * <pre>
     *     name:
     *        key = value
     *        key = value
     *        ...
     * </pre>
     */
    static <T> void dumpSparseArray(IndentingPrintWriter pw, String name,
            SparseArray<T> sparseArray) {
        printWithTrailingColon(pw, name);
        pw.increaseIndent();
        int size = sparseArray.size();
        for (int i = 0; i < size; i++) {
            int key = sparseArray.keyAt(i);
            T value = sparseArray.get(key);
            pw.printPair(Integer.toString(key), value);
            pw.println();
        }
        pw.decreaseIndent();
    }

    private static void printWithTrailingColon(IndentingPrintWriter pw, String name) {
        pw.println(name.endsWith(":") ? name : name.concat(":"));
    }

    /**
     * Dump a {@link Map} to the print writer.
     *
     * <p>The dump is formatted:
     * <pre>
     *     name:
     *        key = value
     *        key = value
     *        ...
     * </pre>
     */
    static <K, V> void dumpMap(IndentingPrintWriter pw, String name, Map<K, V> map) {
        printWithTrailingColon(pw, name);
        pw.increaseIndent();
        for (Map.Entry<K, V> entry: map.entrySet()) {
            pw.printPair(entry.getKey().toString(), entry.getValue());
            pw.println();
        }
        pw.decreaseIndent();
    }

    /**
     * Dump a {@link Map} to the print writer.
     *
     * <p>The dump is formatted:
     * <pre>
     *     name:
     *        value
     *        value
     *        ...
     * </pre>
     */
    static <T> void dumpIterable(IndentingPrintWriter pw, String name, Iterable<T> values) {
        printWithTrailingColon(pw, name);
        pw.increaseIndent();
        for (T value : values) {
            pw.println(value);
        }
        pw.decreaseIndent();
    }
}