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
This commit is contained in:
Venkatarama NG. Avadhani
2021-07-29 18:49:21 +05:30
committed by Nathalie Le Clair
parent 3cdd818489
commit 4cc7739c0b
2 changed files with 25 additions and 7 deletions

View File

@@ -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();
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);
// 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);
}
mService.getHdmiCecNetwork().clearDeviceList();
launchDeviceDiscovery();
startQueuedActions();

View File

@@ -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());