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

Commit 9af8f281 authored by Shubang Lu's avatar Shubang Lu Committed by Android (Google) Code Review
Browse files

Merge changes I7bfdcbaf,I260b354b,I42ca55eb,If38d5443,I3fbc3368, ...

* changes:
  Atom: initPortInfo when receive hotplug from tx for audiosystem device[1/3]
  handle manual port switching
  Claim Active Source during System Audio Mode init by AVR when the device also has playback type and can't get Active Source.
  Switch away from ARC input when ARC is terminated.
  Request Active Source when ARC is enabled in ArcInitiationActionFromAvr.
  Refactor the Active Source updating logic in CEC devices.
  Fix tests failure on com.android.server.hdmi
  Making functions visible for testing com.android.server.hdmi
  Back out unneeded ag/4808863. Standby has been handled in ag/4881453.
parents a1d7b180 066db152
Loading
Loading
Loading
Loading
+1 −11
Original line number Diff line number Diff line
@@ -9369,8 +9369,7 @@ public final class Settings {
                "hdmi_control_auto_wakeup_enabled";
        /**
         * Whether TV or Audio System will also turn off other CEC devices when it goes to standby
         * mode.
         * Whether TV will also turn off other CEC devices when it goes to standby mode.
         * (0 = false, 1 = true)
         *
         * @hide
@@ -9378,15 +9377,6 @@ public final class Settings {
        public static final String HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED =
                "hdmi_control_auto_device_off_enabled";
        /**
         * Whether Audio System will also turn off TV when it goes to standby mode.
         * (0 = false, 1 = true)
         *
         * @hide
         */
        public static final String HDMI_CONTROL_AUTO_TV_OFF_ENABLED =
                "hdmi_control_auto_tv_off_enabled";
        /**
         * If <b>true</b>, enables out-of-the-box execution for priv apps.
         * Default: false
+0 −1
Original line number Diff line number Diff line
@@ -271,7 +271,6 @@ public class SettingsBackupTest {
                    Settings.Global.GNSS_SATELLITE_BLACKLIST,
                    Settings.Global.GPRS_REGISTER_CHECK_PERIOD_MS,
                    Settings.Global.HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED,
                    Settings.Global.HDMI_CONTROL_AUTO_TV_OFF_ENABLED,
                    Settings.Global.HDMI_CONTROL_AUTO_WAKEUP_ENABLED,
                    Settings.Global.HDMI_CONTROL_ENABLED,
                    Settings.Global.HDMI_SYSTEM_AUDIO_CONTROL_ENABLED,
+24 −3
Original line number Diff line number Diff line
@@ -21,14 +21,15 @@ import android.hardware.tv.cec.V1_0.SendMessageResult;
 * Feature action that handles Audio Return Channel initiated by AVR devices.
 */
public class ArcInitiationActionFromAvr extends HdmiCecFeatureAction {
    // TODO(shubang): add tests

    // State in which waits for ARC response.
    private static final int STATE_WAITING_FOR_INITIATE_ARC_RESPONSE = 1;
    private static final int STATE_ARC_INITIATED = 2;

    // the required maximum response time specified in CEC 9.2
    private static final int TIMEOUT_MS = 1000;
    private static final int MAX_RETRY_COUNT = 5;

    private int mSendRequestActiveSourceRetryCount = 0;

    ArcInitiationActionFromAvr(HdmiCecLocalDevice source) {
        super(source);
@@ -56,7 +57,12 @@ public class ArcInitiationActionFromAvr extends HdmiCecFeatureAction {
                return true;
            case Constants.MESSAGE_REPORT_ARC_INITIATED:
                mState = STATE_ARC_INITIATED;
                if (audioSystem().getActiveSource().physicalAddress != getSourcePath()
                        && audioSystem().isSystemAudioActivated()) {
                    sendRequestActiveSource();
                } else {
                    finish();
                }
                return true;
        }
        return false;
@@ -91,4 +97,19 @@ public class ArcInitiationActionFromAvr extends HdmiCecFeatureAction {
        finish();
    }

    protected void sendRequestActiveSource() {
        sendCommand(HdmiCecMessageBuilder.buildRequestActiveSource(getSourceAddress()),
                result -> {
                    if (result != SendMessageResult.SUCCESS) {
                        if (mSendRequestActiveSourceRetryCount < MAX_RETRY_COUNT) {
                            mSendRequestActiveSourceRetryCount++;
                            sendRequestActiveSource();
                        } else {
                            finish();
                        }
                    } else {
                        finish();
                    }
                });
    }
}
+3 −0
Original line number Diff line number Diff line
@@ -50,6 +50,9 @@ public class ArcTerminationActionFromAvr extends HdmiCecFeatureAction {
            case Constants.MESSAGE_REPORT_ARC_TERMINATED:
                mState = STATE_ARC_TERMINATED;
                audioSystem().setArcStatus(false);
                if (audioSystem().getLocalActivePort() == Constants.CEC_SWITCH_ARC) {
                    audioSystem().routeToInputFromPortId(audioSystem().getRoutingPort());
                }
                finish();
                return true;
        }
+18 −11
Original line number Diff line number Diff line
@@ -18,10 +18,12 @@ package com.android.server.hdmi;

import android.annotation.Nullable;
import android.hardware.hdmi.HdmiDeviceInfo;
import android.hardware.hdmi.IHdmiControlCallback;
import android.hardware.input.InputManager;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.RemoteException;
import android.os.SystemClock;
import android.util.Slog;
import android.view.InputDevice;
@@ -133,9 +135,6 @@ abstract class HdmiCecLocalDevice {
            return s.toString();
        }
    }
    // Logical address of the active source.
    @GuardedBy("mLock")
    protected final ActiveSource mActiveSource = new ActiveSource();

    // Active routing path. Physical address of the active source but not all the time, such as
    // when the new active source does not claim itself to be one. Note that we don't keep
@@ -867,9 +866,7 @@ abstract class HdmiCecLocalDevice {
    }

    ActiveSource getActiveSource() {
        synchronized (mLock) {
            return mActiveSource;
        }
        return mService.getActiveSource();
    }

    void setActiveSource(ActiveSource newActive) {
@@ -881,10 +878,7 @@ abstract class HdmiCecLocalDevice {
    }

    void setActiveSource(int logicalAddress, int physicalAddress) {
        synchronized (mLock) {
            mActiveSource.logicalAddress = logicalAddress;
            mActiveSource.physicalAddress = physicalAddress;
        }
        mService.setActiveSource(logicalAddress, physicalAddress);
        mService.setLastInputForMhl(Constants.INVALID_PORT_ID);
    }

@@ -1029,6 +1023,19 @@ abstract class HdmiCecLocalDevice {
        return Constants.ADDR_INVALID;
    }

    @ServiceThreadOnly
    void invokeCallback(IHdmiControlCallback callback, int result) {
        assertRunOnServiceThread();
        if (callback == null) {
            return;
        }
        try {
            callback.onComplete(result);
        } catch (RemoteException e) {
            Slog.e(TAG, "Invoking callback failed:" + e);
        }
    }

    void sendUserControlPressedAndReleased(int targetAddress, int cecKeycode) {
        mService.sendCecCommand(
                HdmiCecMessageBuilder.buildUserControlPressed(mAddress, targetAddress, cecKeycode));
@@ -1042,7 +1049,7 @@ abstract class HdmiCecLocalDevice {
        pw.println("mAddress: " + mAddress);
        pw.println("mPreferredAddress: " + mPreferredAddress);
        pw.println("mDeviceInfo: " + mDeviceInfo);
        pw.println("mActiveSource: " + mActiveSource);
        pw.println("mActiveSource: " + getActiveSource());
        pw.println(String.format("mActiveRoutingPath: 0x%04x", mActiveRoutingPath));
    }

Loading