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

Commit 4cc7739c authored by Venkatarama NG. Avadhani's avatar Venkatarama NG. Avadhani Committed by Nathalie Le Clair
Browse files

CEC: Do not wake device on quiescent boot

In audio system, try to turn on the system audio mode only if device is
not in quiescent state.

Bug: 194790930
Test: cts-tradefed run commandAndExit cts -m CtsOsHostTestCases --test android.os.cts.QuiescentBootTests
Change-Id: Ic5a4bb74e04990edcf42cc3dd066ae1f8b6c3ee6
parent 3cdd8184
Loading
Loading
Loading
Loading
+14 −7
Original line number Diff line number Diff line
@@ -265,13 +265,20 @@ public class HdmiCecLocalDeviceAudioSystem extends HdmiCecLocalDeviceSource {
        // to request Short Audio Descriptor. Since ARC and SAM are independent,
        // we can turn on ARC anyways when audio system device just boots up.
        initArcOnFromAvr();

        // This prevents turning on of System Audio Mode during a quiescent boot. If the quiescent
        // boot is exited just after this check, this code will be executed only at the next
        // wake-up.
        if (!mService.isScreenOff()) {
            int systemAudioControlOnPowerOnProp =
                    SystemProperties.getInt(
                            PROPERTY_SYSTEM_AUDIO_CONTROL_ON_POWER_ON,
                            ALWAYS_SYSTEM_AUDIO_CONTROL_ON_POWER_ON);
            boolean lastSystemAudioControlStatus =
                    SystemProperties.getBoolean(Constants.PROPERTY_LAST_SYSTEM_AUDIO_CONTROL, true);
        systemAudioControlOnPowerOn(systemAudioControlOnPowerOnProp, lastSystemAudioControlStatus);
            systemAudioControlOnPowerOn(
                    systemAudioControlOnPowerOnProp, lastSystemAudioControlStatus);
        }
        mService.getHdmiCecNetwork().clearDeviceList();
        launchDeviceDiscovery();
        startQueuedActions();
+11 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.database.ContentObserver;
import android.hardware.display.DisplayManager;
import android.hardware.hdmi.HdmiControlManager;
import android.hardware.hdmi.HdmiDeviceInfo;
import android.hardware.hdmi.HdmiHotplugEvent;
@@ -81,6 +82,7 @@ import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.Slog;
import android.util.SparseArray;
import android.view.Display;

import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
@@ -410,6 +412,9 @@ public class HdmiControlService extends SystemService {
    @Nullable
    private Looper mIoLooper;

    @Nullable
    private DisplayManager mDisplayManager;

    @HdmiControlManager.HdmiCecVersion
    private int mCecVersion;

@@ -676,6 +681,11 @@ public class HdmiControlService extends SystemService {
                }, mServiceThreadExecutor);
    }

    /** Returns true if the device screen is off */
    boolean isScreenOff() {
        return mDisplayManager.getDisplay(Display.DEFAULT_DISPLAY).getState() == Display.STATE_OFF;
    }

    private void bootCompleted() {
        // on boot, if device is interactive, set HDMI CEC state as powered on as well
        if (mPowerManager.isInteractive() && isPowerStandbyOrTransient()) {
@@ -731,6 +741,7 @@ public class HdmiControlService extends SystemService {
    @Override
    public void onBootPhase(int phase) {
        if (phase == SystemService.PHASE_SYSTEM_SERVICES_READY) {
            mDisplayManager = getContext().getSystemService(DisplayManager.class);
            mTvInputManager = (TvInputManager) getContext().getSystemService(
                    Context.TV_INPUT_SERVICE);
            mPowerManager = new PowerManagerWrapper(getContext());