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

Commit 8027c94e authored by Amy's avatar Amy Committed by shubang
Browse files

Add ro.hdmi.property_hdmi_cec_never_assign_logical_addresses

to skip the logical addresses that will not be assigned.

ag/5051723

This is useful when HDMI CEC hardware module can't assign
multiple logical addresses in the range same range of 0-7 or 8-15.

Test: local test
Change-Id: Ibeceb4c4090bf80fda4758e2676a6245556c3573
parent aa57b004
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -333,6 +333,16 @@ final class Constants {
    static final String PROPERTY_HDMI_CEC_NEVER_CLAIM_PLAYBACK_LOGICAL_ADDRESS =
            "ro.hdmi.property_hdmi_cec_never_claim_playback_logical_address";

    /**
     * A comma separated list of logical addresses that HdmiControlService
     * will never assign local CEC devices to.
     *
     * <p> This is useful when HDMI CEC hardware module can't assign multiple logical addresses
     * in the range same range of 0-7 or 8-15.
     */
    static final String PROPERTY_HDMI_CEC_NEVER_ASSIGN_LOGICAL_ADDRESSES =
            "ro.hdmi.property_hdmi_cec_never_assign_logical_addresses";

    /**
     * Property to indicate if the current device is a cec switch device.
     *
+17 −3
Original line number Diff line number Diff line
@@ -22,20 +22,25 @@ import android.hardware.tv.cec.V1_0.SendMessageResult;
import android.os.Handler;
import android.os.Looper;
import android.os.MessageQueue;
import android.os.SystemProperties;
import android.util.Slog;
import android.util.SparseArray;

import com.android.internal.util.IndentingPrintWriter;
import com.android.server.hdmi.HdmiAnnotations.IoThreadOnly;
import com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly;
import com.android.server.hdmi.HdmiControlService.DevicePollingCallback;

import libcore.util.EmptyArray;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.function.Predicate;
import java.util.concurrent.ArrayBlockingQueue;
import libcore.util.EmptyArray;
import java.util.function.Predicate;

import sun.util.locale.LanguageTag;

/**
@@ -112,10 +117,18 @@ final class HdmiCecController {

    private final NativeWrapper mNativeWrapperImpl;

    /** List of logical addresses that should not be assigned to the current device.
     *
     * <p>Parsed from {@link Constants#PROPERTY_HDMI_CEC_NEVER_ASSIGN_LOGICAL_ADDRESSES}
     */
    private final List<Integer> mNeverAssignLogicalAddresses;

    // Private constructor.  Use HdmiCecController.create().
    private HdmiCecController(HdmiControlService service, NativeWrapper nativeWrapper) {
        mService = service;
        mNativeWrapperImpl = nativeWrapper;
        mNeverAssignLogicalAddresses = mService.getIntList(SystemProperties.get(
            Constants.PROPERTY_HDMI_CEC_NEVER_ASSIGN_LOGICAL_ADDRESSES));
    }

    /**
@@ -208,7 +221,8 @@ final class HdmiCecController {
        for (int i = 0; i < NUM_LOGICAL_ADDRESS; ++i) {
            int curAddress = (startAddress + i) % NUM_LOGICAL_ADDRESS;
            if (curAddress != Constants.ADDR_UNREGISTERED
                    && deviceType == HdmiUtils.getTypeFromAddress(curAddress)) {
                    && deviceType == HdmiUtils.getTypeFromAddress(curAddress)
                    && !mNeverAssignLogicalAddresses.contains(curAddress)) {
                boolean acked = false;
                for (int j = 0; j < HdmiConfig.ADDRESS_ALLOCATION_RETRY; ++j) {
                    if (sendPollMessage(curAddress, curAddress, 1)) {
+1 −1
Original line number Diff line number Diff line
@@ -417,7 +417,7 @@ public class HdmiControlService extends SystemService {
        mSettingsObserver = new SettingsObserver(mHandler);
    }

    private static List<Integer> getIntList(String string) {
    protected static List<Integer> getIntList(String string) {
        ArrayList<Integer> list = new ArrayList<>();
        TextUtils.SimpleStringSplitter splitter = new TextUtils.SimpleStringSplitter(',');
        splitter.setString(string);