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

Commit 2192c2d3 authored by Yuncheol Heo's avatar Yuncheol Heo Committed by Android Git Automerger
Browse files

am 41824e71: Merge "Make it not to go to sleep when changing TV\'s input to...

am 41824e71: Merge "Make it not to go to sleep when changing TV\'s input to the others." into lmp-dev

* commit '41824e71fb88d87bb8efa4c3ef63b01abb329555':
  Make it not to go to sleep when changing TV's input to the others.
parents 680c64cb 6d739863
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -210,6 +210,8 @@ abstract class HdmiCecLocalDevice {
                return handleReportPhysicalAddress(message);
            case Constants.MESSAGE_ROUTING_CHANGE:
                return handleRoutingChange(message);
            case Constants.MESSAGE_ROUTING_INFORMATION:
                return handleRoutingInformation(message);
            case Constants.MESSAGE_INITIATE_ARC:
                return handleInitiateArc(message);
            case Constants.MESSAGE_TERMINATE_ARC:
@@ -331,6 +333,10 @@ abstract class HdmiCecLocalDevice {
        return false;
    }

    protected boolean handleRoutingInformation(HdmiCecMessage message) {
        return false;
    }

    protected boolean handleReportPhysicalAddress(HdmiCecMessage message) {
        return false;
    }
+57 −12
Original line number Diff line number Diff line
@@ -16,8 +16,8 @@

package com.android.server.hdmi;

import android.hardware.hdmi.HdmiDeviceInfo;
import android.hardware.hdmi.HdmiControlManager;
import android.hardware.hdmi.HdmiDeviceInfo;
import android.hardware.hdmi.IHdmiControlCallback;
import android.os.RemoteException;
import android.os.SystemProperties;
@@ -137,14 +137,14 @@ final class HdmiCecLocalDevicePlayback extends HdmiCecLocalDevice {
    protected boolean handleActiveSource(HdmiCecMessage message) {
        assertRunOnServiceThread();
        int physicalAddress = HdmiUtils.twoBytesToInt(message.getParams());
        mayResetActiveSource(physicalAddress);
        return true;  // Broadcast message.
    }

    private void mayResetActiveSource(int physicalAddress) {
        if (physicalAddress != mService.getPhysicalAddress()) {
            mIsActiveSource = false;
            if (mService.isPowerOnOrTransient()) {
                mService.nap();
        }
            return true;
        }
        return false;
    }

    @Override
@@ -152,13 +152,58 @@ final class HdmiCecLocalDevicePlayback extends HdmiCecLocalDevice {
    protected boolean handleSetStreamPath(HdmiCecMessage message) {
        assertRunOnServiceThread();
        int physicalAddress = HdmiUtils.twoBytesToInt(message.getParams());
        maySetActiveSource(physicalAddress);
        maySendActiveSource();
        wakeUpIfActiveSource();
        return true;  // Broadcast message.
    }

    // Samsung model, we tested, sends <RoutingChange> and <RequestActiveSource> consecutively,
    // Then if there is no <ActiveSource> response, it will change the input to
    // the internal source.  To handle this, we'll set ActiveSource aggressively.
    @Override
    @ServiceThreadOnly
    protected boolean handleRoutingChange(HdmiCecMessage message) {
        assertRunOnServiceThread();
        int newPath = HdmiUtils.twoBytesToInt(message.getParams(), 2);
        maySetActiveSource(newPath);
        return true;  // Broadcast message.
    }

    @Override
    @ServiceThreadOnly
    protected boolean handleRoutingInformation(HdmiCecMessage message) {
        assertRunOnServiceThread();
        int physicalAddress = HdmiUtils.twoBytesToInt(message.getParams());
        maySetActiveSource(physicalAddress);
        return true;  // Broadcast message.
    }

    private void maySetActiveSource(int physicalAddress) {
        if (physicalAddress == mService.getPhysicalAddress()) {
            if (mService.isPowerStandbyOrTransient()) {
            mIsActiveSource = true;
        }
    }

    private void wakeUpIfActiveSource() {
        if (mIsActiveSource && mService.isPowerStandbyOrTransient()) {
            mService.wakeUp();
        }
            return true;
    }
        return false;

    private void maySendActiveSource() {
        if (mIsActiveSource) {
            mService.sendCecCommand(HdmiCecMessageBuilder.buildActiveSource(
                    mAddress, mService.getPhysicalAddress()));
        }
    }

    @Override
    @ServiceThreadOnly
    protected boolean handleRequestActiveSource(HdmiCecMessage message) {
        assertRunOnServiceThread();
        maySendActiveSource();
        return true;  // Broadcast message.
    }

    @Override