Correct Audio System device unplug behavior on SAM and ARC

We should internally turn off System Audio Mode and ARC when
unplug happens on the HDMI out port.
Also we should reset the TV support SAM to null in this case.

Since we reinit System Audio Mode regardless when replug in HDMI out,
we should keep the internal SAM and ARC on/off state synced.

Test: manual
Bug: 123157607
Change-Id: Ifea1545b05b81acad591d4b2e9b207dbb05e1889
(cherry picked from commit 91c8466f9365604d55a18a822f7a1b4cc2658411)
diff --git a/services/core/java/com/android/server/hdmi/ArcTerminationActionFromAvr.java b/services/core/java/com/android/server/hdmi/ArcTerminationActionFromAvr.java
index eb7c0cd..dedf2e2 100644
--- a/services/core/java/com/android/server/hdmi/ArcTerminationActionFromAvr.java
+++ b/services/core/java/com/android/server/hdmi/ArcTerminationActionFromAvr.java
@@ -76,6 +76,11 @@
         sendCommand(HdmiCecMessageBuilder.buildTerminateArc(getSourceAddress(), Constants.ADDR_TV),
             result -> {
                 if (result != SendMessageResult.SUCCESS) {
+                    // If the physical connection is already off or TV does not handle
+                    // Terminate ARC, turn off ARC internally.
+                    if (result == SendMessageResult.NACK) {
+                        audioSystem().setArcStatus(false);
+                    }
                     HdmiLogger.debug("Terminate ARC was not successfully sent.");
                     finish();
                 }