From 613330ef617ad2b5a841b68bb0abdb17a8ee87cf Mon Sep 17 00:00:00 2001 From: Amy Date: Fri, 22 Mar 2019 16:53:59 -0700 Subject: [PATCH] Make mTvSystemAudioModeSupport originally null and fix related logic Note that before the Android device queries if the TV supports SAM, we should set mTvSystemAudioModeSupport to null. After quried, set it to true or false accordingly. Also we devices goes to standby or loses its logical address, this boolean should be reset to null Test: manual Change-Id: Id39dc2a9b0ee9de010268914a745a6aaae0287ea (cherry picked from commit 05f01112f9931a058d9fcecb956c1ff35630ed0c) --- .../hdmi/HdmiCecLocalDeviceAudioSystem.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceAudioSystem.java b/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceAudioSystem.java index a2882de7ee7ac..9e2fd4e9e91ef 100644 --- a/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceAudioSystem.java +++ b/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceAudioSystem.java @@ -74,7 +74,15 @@ public class HdmiCecLocalDeviceAudioSystem extends HdmiCecLocalDeviceSource { @GuardedBy("mLock") private boolean mSystemAudioControlFeatureEnabled; - private boolean mTvSystemAudioModeSupport; + /** + * Indicates if the TV that the current device is connected to supports System Audio Mode or not + * + *

If the current device has no information on this, keep mTvSystemAudioModeSupport null + * + *

The boolean will be reset to null every time when the current device goes to standby + * or loses its physical address. + */ + private Boolean mTvSystemAudioModeSupport = null; // Whether ARC is available or not. "true" means that ARC is established between TV and // AVR as audio receiver. @@ -321,7 +329,7 @@ public class HdmiCecLocalDeviceAudioSystem extends HdmiCecLocalDeviceSource { @ServiceThreadOnly protected void onStandby(boolean initiatedByCec, int standbyAction) { assertRunOnServiceThread(); - mTvSystemAudioModeSupport = false; + mTvSystemAudioModeSupport = null; // Record the last state of System Audio Control before going to standby synchronized (mLock) { mService.writeStringSystemProperty( @@ -1029,12 +1037,11 @@ public class HdmiCecLocalDeviceAudioSystem extends HdmiCecLocalDeviceSource { *

The result of the query may be cached until Audio device type is put in standby or loses * its physical address. */ - // TODO(amyjojo): making mTvSystemAudioModeSupport null originally and fix the logic. void queryTvSystemAudioModeSupport(TvSystemAudioModeSupportedCallback callback) { - if (!mTvSystemAudioModeSupport) { + if (mTvSystemAudioModeSupport == null) { addAndStartAction(new DetectTvSystemAudioModeSupportAction(this, callback)); } else { - callback.onResult(true); + callback.onResult(mTvSystemAudioModeSupport); } }