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

Commit 77a8a123 authored by Sherry Huang's avatar Sherry Huang
Browse files

HDMI: Add dumpsys info for active source caller

Partner reported it is difficult to tell active source client, adding a
line in hdmi dumpsys to make it clear. Given it is for debugging
purpose, we only store the last three caller.

Test: test on device and verify by partner
Bug: b/436125596
Flag: EXEMPT minor feature update w/ no api change

Change-Id: I5d6821f883e3eefa3cfbcabc2a74bc9dcc6a5e65
parent c4063535
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -131,6 +131,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -579,6 +580,10 @@ public class HdmiControlService extends SystemService {
    // Whether a CEC-enabled sink is connected to the playback device
    private boolean mIsCecAvailable = false;

    // Last three caller that init change of the input source
    private final LinkedList<Integer> mLastUpdateSourceCallerRecord = new LinkedList<>();
    private final int mMaxUpdateSourceCallerRecordNum = 3;

    // Object that handles logging statsd atoms.
    // Use getAtomWriter() instead of accessing directly, to allow dependency injection for testing.
    private HdmiCecAtomWriter mAtomWriter = new HdmiCecAtomWriter();
@@ -2371,6 +2376,7 @@ public class HdmiControlService extends SystemService {
        @Override
        public void deviceSelect(final int deviceId, final IHdmiControlCallback callback) {
            initBinderCall();
            updateLastActiveSourceCall(Binder.getCallingPid());
            runOnServiceThread(new Runnable() {
                @Override
                public void run() {
@@ -2418,6 +2424,7 @@ public class HdmiControlService extends SystemService {
        @Override
        public void portSelect(final int portId, final IHdmiControlCallback callback) {
            initBinderCall();
            updateLastActiveSourceCall(Binder.getCallingPid());
            runOnServiceThread(new Runnable() {
                @Override
                public void run() {
@@ -3022,6 +3029,7 @@ public class HdmiControlService extends SystemService {
            pw.println("mIsCecAvailable: " + mIsCecAvailable);
            pw.println("mCecVersion: " + mCecVersion);
            pw.println("mIsAbsoluteVolumeBehaviorEnabled: " + isAbsoluteVolumeBehaviorEnabled());
            pw.println("mLastUpdateSourceCallerRecord: " + mLastUpdateSourceCallerRecord.toString());

            // System settings
            pw.println("System_settings:");
@@ -3184,6 +3192,13 @@ public class HdmiControlService extends SystemService {
        }
    }

    private void updateLastActiveSourceCall(int clientPid) {
        if (mLastUpdateSourceCallerRecord.size() == mMaxUpdateSourceCallerRecordNum) {
            mLastUpdateSourceCallerRecord.removeFirst();
        }
        mLastUpdateSourceCallerRecord.add(clientPid);
    }

    @VisibleForTesting
    void setHdmiCecVolumeControlEnabledInternal(
            @HdmiControlManager.VolumeControl int hdmiCecVolumeControl) {