Answer "on" to TV querying system audio mode status when the audio
system is still initiating it.

Note that System Audio Mode initiation from AVR side could take a while.
During the process, the internal sam status is false.

When TV queries the sam status, current framework responds with the status
at that moment. Which means it returns false when sam init is not done.

But since AVR is turning the feature on and it knows
that TV supports sam when receiving TV's query. AVR can answer with a
yes in this situation.

Test: manual
Bug: 123287727
Change-Id: I544d2a9af12b71c66cbc24327792993f621b2520
diff --git a/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceAudioSystem.java b/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceAudioSystem.java
index cac1a95..03704aa 100644
--- a/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceAudioSystem.java
+++ b/services/core/java/com/android/server/hdmi/HdmiCecLocalDeviceAudioSystem.java
@@ -458,9 +458,19 @@
     @ServiceThreadOnly
     protected boolean handleGiveSystemAudioModeStatus(HdmiCecMessage message) {
         assertRunOnServiceThread();
+        // If the audio system is initiating the system audio mode on and TV asks the sam status at
+        // the same time, respond with true. Since we know TV supports sam in this situation.
+        // If the query comes from STB, we should respond with the current sam status and the STB
+        // should listen to the <Set System Audio Mode> broadcasting.
+        boolean isSystemAudioModeOnOrTurningOn = isSystemAudioActivated();
+        if (!isSystemAudioModeOnOrTurningOn
+                && message.getSource() == Constants.ADDR_TV
+                && hasAction(SystemAudioInitiationActionFromAvr.class)) {
+            isSystemAudioModeOnOrTurningOn = true;
+        }
         mService.sendCecCommand(
                 HdmiCecMessageBuilder.buildReportSystemAudioMode(
-                        mAddress, message.getSource(), mSystemAudioActivated));
+                        mAddress, message.getSource(), isSystemAudioModeOnOrTurningOn));
         return true;
     }