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

Commit 7e742066 authored by Jinsuk Kim's avatar Jinsuk Kim
Browse files

System API HdmiControlService.getActiveSource

Added getActiveSource to provide Tv Input Service with the information
on HDMI active source/routing path. TIS side will be handled separately.

Change-Id: I3d7c12a6c9da9f96a7f22ba1f66ac2559928858d
parent f5f45bc2
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -65,6 +65,18 @@ public final class HdmiCecDeviceInfo implements Parcelable {
     */
    public static final int ADDR_INTERNAL = 0;

    /**
     * Physical address used to indicate the source comes from internal device.
     * The physical address of TV(0) is used.
     */
    public static final int PATH_INTERNAL = 0x0000;

    /** Invalid physical address (routing path) */
    public static final int PATH_INVALID = 0xFFFF;

    /** Invalid port ID */
    public static final int PORT_INVALID = -1;

    // Logical address, physical address, device type, vendor id and display name
    // are immutable value.
    private final int mLogicalAddress;
+1 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import java.util.List;
 */
interface IHdmiControlService {
    int[] getSupportedTypes();
    HdmiCecDeviceInfo getActiveSource();
    void oneTouchPlay(IHdmiControlCallback callback);
    void queryDisplayStatus(IHdmiControlCallback callback);
    void addHotplugEventListener(IHdmiHotplugEventListener listener);
+2 −2
Original line number Diff line number Diff line
@@ -178,8 +178,8 @@ final class Constants {
    static final int ROUTING_PATH_TOP_MASK = 0xF000;
    static final int ROUTING_PATH_TOP_SHIFT = 12;

    static final int INVALID_PORT_ID = -1;
    static final int INVALID_PHYSICAL_ADDRESS = 0xFFFF;
    static final int INVALID_PORT_ID = HdmiCecDeviceInfo.PORT_INVALID;
    static final int INVALID_PHYSICAL_ADDRESS = HdmiCecDeviceInfo.PATH_INVALID;

    // Send result codes. It should be consistent with hdmi_cec.h's send_message error code.
    static final int SEND_RESULT_SUCCESS = 0;
+1 −0
Original line number Diff line number Diff line
@@ -148,6 +148,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
            handleSelectInternalSource();
            // Switching to internal source is always successful even when CEC control is disabled.
            setActiveSource(targetAddress, mService.getPhysicalAddress());
            setActivePath(mService.getPhysicalAddress());
            invokeCallback(callback, HdmiControlManager.RESULT_SUCCESS);
            return;
        }
+21 −0
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ import com.android.internal.annotations.GuardedBy;
import com.android.server.SystemService;
import com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly;
import com.android.server.hdmi.HdmiCecController.AllocateAddressCallback;
import com.android.server.hdmi.HdmiCecLocalDevice.ActiveSource;
import com.android.server.hdmi.HdmiCecLocalDevice.PendingActionClearedCallback;

import libcore.util.EmptyArray;
@@ -719,6 +720,26 @@ public final class HdmiControlService extends SystemService {
            return localDevices;
        }

        @Override
        public HdmiCecDeviceInfo getActiveSource() {
            HdmiCecLocalDeviceTv tv = tv();
            if (tv == null) {
                Slog.w(TAG, "Local tv device not available");
                return null;
            }
            ActiveSource activeSource = tv.getActiveSource();
            if (activeSource.isValid()) {
                return new HdmiCecDeviceInfo(activeSource.logicalAddress,
                        activeSource.physicalAddress, HdmiCecDeviceInfo.PORT_INVALID,
                        HdmiCecDeviceInfo.DEVICE_INACTIVE, 0, "");
            }
            int activePath = tv.getActivePath();
            if (activePath != HdmiCecDeviceInfo.PATH_INVALID) {
                return new HdmiCecDeviceInfo(activePath, tv.getActivePortId());
            }
            return null;
        }

        @Override
        public void deviceSelect(final int logicalAddress, final IHdmiControlCallback callback) {
            enforceAccessPermission();