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

Commit 14149ee2 authored by Jinsuk Kim's avatar Jinsuk Kim Committed by Android (Google) Code Review
Browse files

Merge "Send TV app the intent for the new active source" into lmp-dev

parents edeb0d21 b2b3151a
Loading
Loading
Loading
Loading
+43 −7
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@ import android.os.Parcelable;
 * A class to encapsulate device information for HDMI-CEC. This container
 * include basic information such as logical address, physical address and
 * device type, and additional information like vendor id and osd name.
 * Also used to keep the information of non-CEC devices for which only
 * port ID, physical address are meaningful.
 *
 * @hide
 */
@@ -71,6 +73,7 @@ public final class HdmiCecDeviceInfo implements Parcelable {
    private final int mDeviceType;
    private final int mVendorId;
    private final String mDisplayName;
    private final boolean mIsCecDevice;

    /**
     * A helper class to deserialize {@link HdmiCecDeviceInfo} for a parcel.
@@ -96,7 +99,7 @@ public final class HdmiCecDeviceInfo implements Parcelable {
            };

    /**
     * Constructor.
     * Constructor. Used to initialize the instance for CEC device.
     *
     * @param logicalAddress logical address of HDMI-CEC device
     * @param physicalAddress physical address of HDMI-CEC device
@@ -114,6 +117,24 @@ public final class HdmiCecDeviceInfo implements Parcelable {
        mDeviceType = deviceType;
        mDisplayName = displayName;
        mVendorId = vendorId;
        mIsCecDevice = true;
    }

    /**
     * Constructor. Used to initialize the instance for non-CEC device.
     *
     * @param physicalAddress physical address of HDMI device
     * @param portId HDMI port ID (1 for HDMI1)
     * @hide
     */
    public HdmiCecDeviceInfo(int physicalAddress, int portId) {
        mLogicalAddress = -1;
        mPhysicalAddress = physicalAddress;
        mPortId = portId;
        mDeviceType = DEVICE_RESERVED;
        mDisplayName = null;
        mVendorId = 0;
        mIsCecDevice = false;
    }

    /**
@@ -154,6 +175,14 @@ public final class HdmiCecDeviceInfo implements Parcelable {
                || mDeviceType == DEVICE_TUNER;
    }

    /**
     * Return {@code true} if the device represents an HDMI-CEC device. {@code false}
     * if the device is either MHL or non-CEC device.
     */
    public boolean isCecDevice() {
        return mIsCecDevice;
    }

    /**
     * Return display (OSD) name of the device.
     */
@@ -199,12 +228,19 @@ public final class HdmiCecDeviceInfo implements Parcelable {
    @Override
    public String toString() {
        StringBuffer s = new StringBuffer();
        if (isCecDevice()) {
            s.append("CEC: ");
            s.append("logical_address: ").append(mLogicalAddress).append(", ");
            s.append("physical_address: ").append(mPhysicalAddress).append(", ");
            s.append("port_id: ").append(mPortId).append(", ");
            s.append("device_type: ").append(mDeviceType).append(", ");
            s.append("vendor_id: ").append(mVendorId).append(", ");
            s.append("display_name: ").append(mDisplayName);
        } else {
            s.append("Non-CEC: ");
            s.append("physical_address: ").append(mPhysicalAddress).append(", ");
            s.append("port_id: ").append(mPortId).append(", ");
        }
        return s.toString();
    }

+17 −2
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static android.media.tv.TvInputManager.INPUT_STATE_CONNECTED;
import static android.media.tv.TvInputManager.INPUT_STATE_DISCONNECTED;

import android.content.Context;
import android.content.Intent;
import android.hardware.hdmi.HdmiCecDeviceInfo;
import android.hardware.hdmi.HdmiHotplugEvent;
import android.hardware.hdmi.IHdmiControlService;
@@ -34,6 +35,7 @@ import android.media.AudioPortConfig;
import android.media.tv.ITvInputHardware;
import android.media.tv.ITvInputHardwareCallback;
import android.media.tv.TvInputHardwareInfo;
import android.media.tv.TvContract;
import android.media.tv.TvInputInfo;
import android.media.tv.TvStreamConfig;
import android.os.Handler;
@@ -759,8 +761,21 @@ class TvInputHardwareManager implements TvInputHal.Callback {
    private final class HdmiInputChangeListener extends IHdmiInputChangeListener.Stub {
        @Override
        public void onChanged(HdmiCecDeviceInfo device) throws RemoteException {
            // TODO: Build a channel Uri for the TvInputInfo associated with the logical device
            //       and send an intent to TV app
            String inputId;
            synchronized (mLock) {
                if (device.isCecDevice()) {
                    inputId = mHdmiCecInputIdMap.get(device.getLogicalAddress());
                } else {
                    inputId = findInputIdForHdmiPortLocked(device.getPortId());
                }
            }
            if (inputId != null) {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(TvContract.buildChannelUriForPassthroughTvInput(inputId));
                mContext.startActivity(intent);
            } else {
                Slog.w(TAG, "onChanged: InputId cannot be found for :" + device);
            }
        }
    }
}