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

Commit 8a9eae71 authored by Amy's avatar Amy Committed by Amy Zhang
Browse files

Fix getActiveSource api in HdmiControlService

The previous logic does not take an unregistered Active Source as a
valid one. Change it to be able to return with an HdmiDeviceInfo with
unregistered logical address or when the device is not updated in the
local remote device list.

Test: manual
Bug: 131618184
Change-Id: I64c9cbcdb812c16b42daccfa8da87d502b7f733f
(cherry picked from commit bcde21b0c6be81432930fe53840af218af9748c8)
parent d23f79e7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -876,7 +876,7 @@ abstract class HdmiCecLocalDevice {
    }

    ActiveSource getActiveSource() {
        return mService.getActiveSource();
        return mService.getLocalActiveSource();
    }

    void setActiveSource(ActiveSource newActive) {
+18 −9
Original line number Diff line number Diff line
@@ -1461,25 +1461,34 @@ public class HdmiControlService extends SystemService {
                        return playback().getDeviceInfo();
                    }
                    // Otherwise get the active source and look for it from the device list
                    ActiveSource activeSource = mActiveSource;
                    // If the active source is not set yet, return null
                    if (!activeSource.isValid()) {
                    ActiveSource activeSource = getLocalActiveSource();
                    // If the physical address is not set yet, return null
                    if (activeSource.physicalAddress == Constants.INVALID_PHYSICAL_ADDRESS) {
                        return null;
                    }
                    if (audioSystem() != null) {
                        HdmiCecLocalDeviceAudioSystem audioSystem = audioSystem();
                        for (HdmiDeviceInfo info : audioSystem.getSafeCecDevicesLocked()) {
                            if (info.getLogicalAddress() == activeSource.logicalAddress) {
                            if (info.getPhysicalAddress() == activeSource.physicalAddress) {
                                return info;
                            }
                        }
                    }
                    // If the device info is not in the list yet, return a device info with minimum
                    // information from mActiveSource.
                    return new HdmiDeviceInfo(activeSource.logicalAddress,
                        activeSource.physicalAddress, pathToPortId(activeSource.physicalAddress),
                    // If the Active Source has unregistered logical address, return with an
                    // HdmiDeviceInfo built from physical address information only.
                    return HdmiUtils.isValidAddress(activeSource.logicalAddress)
                        ?
                        new HdmiDeviceInfo(activeSource.logicalAddress,
                            activeSource.physicalAddress,
                            pathToPortId(activeSource.physicalAddress),
                            HdmiUtils.getTypeFromAddress(activeSource.logicalAddress), 0,
                        HdmiUtils.getDefaultDeviceName(activeSource.logicalAddress));
                            HdmiUtils.getDefaultDeviceName(activeSource.logicalAddress))
                        :
                            new HdmiDeviceInfo(activeSource.physicalAddress,
                                pathToPortId(activeSource.physicalAddress));

                }
                return null;
            }
@@ -2808,7 +2817,7 @@ public class HdmiControlService extends SystemService {
        setLastInputForMhl(Constants.INVALID_PORT_ID);
    }

    ActiveSource getActiveSource() {
    ActiveSource getLocalActiveSource() {
        synchronized (mLock) {
            return mActiveSource;
        }