From c52b5e533c5ff5ee8588e6adfefdd0264353b118 Mon Sep 17 00:00:00 2001 From: Dean Wheatley Date: Thu, 24 Dec 2020 08:44:04 +1100 Subject: [PATCH] TvInputHardwareManager: always try patch recreate if null TvInputHardwareImpl constructor registers for an audio port update listener which can be triggered causing updateAudioConfigLocked() and for mAudioSource and mAudioSink to be initialized but with mActiveConfig null. On subsequent setSurface(), mActiveConfig is set and updateAudioConfigLocked() called, however sink and source may not be updated. Under such conditions, the audio patch may never be created. Add a mAudioPatch null check for determining whether the audio patch should be created. Test: atest CtsTvTestCases:BundledTvInputServiceTest#testTune on yukawa TV build with 1) mock tv input hal, 2) mock hdmi tv input service and 3) mock primary HAL hdmi in support Change-Id: Ic92d926759d4a87eda4851630bee946af66f6984 --- .../core/java/com/android/server/tv/TvInputHardwareManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/tv/TvInputHardwareManager.java b/services/core/java/com/android/server/tv/TvInputHardwareManager.java index 2314afc787c37..8049c7c48eac2 100755 --- a/services/core/java/com/android/server/tv/TvInputHardwareManager.java +++ b/services/core/java/com/android/server/tv/TvInputHardwareManager.java @@ -950,7 +950,7 @@ class TvInputHardwareManager implements TvInputHal.Callback { AudioPortConfig sourceConfig = mAudioSource.activeConfig(); List sinkConfigs = new ArrayList<>(); AudioPatch[] audioPatchArray = new AudioPatch[] { mAudioPatch }; - boolean shouldRecreateAudioPatch = sourceUpdated || sinkUpdated; + boolean shouldRecreateAudioPatch = sourceUpdated || sinkUpdated || mAudioPatch == null; for (AudioDevicePort audioSink : mAudioSink) { AudioPortConfig sinkConfig = audioSink.activeConfig();