AudioFlinger: Preserve recent RecordThread history for dumpsys

Test: audioflinger dumpsys after record
Bug: 115946219
Change-Id: Ic551ae38a35acc3ed21eee5da3b42d6b07454899
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 7db7d9f..e62156e 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -2549,6 +2549,16 @@
         if (recordThread != 0) {
             ALOGV("closeInput() %d", input);
 
+            {
+                // Dump thread before deleting for history
+                audio_utils::FdToString fdToString;
+                const int fd = fdToString.fd();
+                if (fd >= 0) {
+                    recordThread->dump(fd, {} /* args */);
+                    mThreadLog.logs(-1 /* time */, fdToString.getStringAndClose());
+                }
+            }
+
             // If we still have effect chains, it means that a client still holds a handle
             // on at least one effect. We must either move the chain to an existing thread with the
             // same session ID or put it aside in case a new record thread is opened for a