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

Commit c3371611 authored by Amy's avatar Amy Committed by Amy Zhang
Browse files

Reallocate logical address of the local device when there is a remote

device with same logcial address showed up

Note that we are handling logcial address allocation in the Android
Framework with CEC HAL 1.0. This could introduce some delay between the
logical address allocation and notifying the driver that the logical
address is occupied. This fix can prevent this case.

Test: manual
Bug: 134063991
Change-Id: I1943361c01cc66e83edcc32794a678809ffd1949
(cherry picked from commit d0b810d14806a4362bcbd2a192622bf7412c9e7d)
parent 32515e5f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -233,6 +233,7 @@ public class HdmiCecLocalDeviceAudioSystem extends HdmiCecLocalDeviceSource {
    @VisibleForTesting
    protected HdmiDeviceInfo addDeviceInfo(HdmiDeviceInfo deviceInfo) {
        assertRunOnServiceThread();
        mService.checkLogicalAddressConflictAndReallocate(deviceInfo.getLogicalAddress());
        HdmiDeviceInfo oldDeviceInfo = getCecDeviceInfo(deviceInfo.getLogicalAddress());
        if (oldDeviceInfo != null) {
            removeDeviceInfo(deviceInfo.getId());
+23 −0
Original line number Diff line number Diff line
@@ -1172,6 +1172,29 @@ public class HdmiControlService extends SystemService {
        return mCecController.getLocalDeviceList();
    }

    /**
     * Check if a logical address is conflict with the current device's. Reallocate the logical
     * address of the current device if there is conflict.
     *
     * Android HDMI CEC 1.4 is handling logical address allocation in the framework side. This could
     * introduce delay between the logical address allocation and notifying the driver that the
     * address is occupied. Adding this check to avoid such case.
     *
     * @param logicalAddress logical address of the remote device that might have the same logical
     * address as the current device.
     */
    protected void checkLogicalAddressConflictAndReallocate(int logicalAddress) {
        for (HdmiCecLocalDevice device : getAllLocalDevices()) {
            if (device.getDeviceInfo().getLogicalAddress() == logicalAddress) {
                HdmiLogger.debug("allocate logical address for " + device.getDeviceInfo());
                ArrayList<HdmiCecLocalDevice> localDevices = new ArrayList<>();
                localDevices.add(device);
                allocateLogicalAddress(localDevices, HdmiControlService.INITIATED_BY_HOTPLUG);
                return;
            }
        }
    }

    Object getServiceLock() {
        return mLock;
    }