audio policy: return input source updates to audio flinger

Make sure the input source updated by getInputForAttr() is also used by
audio flinger for consistency of source metadata forwarded to the audio HAL.

Bug: 363831992
Test: atest audiopolicymanager_test
Flag: EXEMPT bug fix
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:0064ac30d8437d19eb69f828ce2e8809c122dc13)
Merged-In: I4d59d271deab5c1f4b06dc1c5642c1135a487132
Change-Id: I4d59d271deab5c1f4b06dc1c5642c1135a487132
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index c67fa13..68c3626 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -646,12 +646,15 @@
                  "%s does not support secondary outputs, ignoring them", __func__);
     } else {
         audio_port_handle_t deviceId = getFirstDeviceId(*deviceIds);
+        audio_source_t source = AUDIO_SOURCE_DEFAULT;
         ret = AudioSystem::getInputForAttr(&localAttr, &io,
                                               RECORD_RIID_INVALID,
                                               actualSessionId,
                                               adjAttributionSource,
                                               config,
-                                              AUDIO_INPUT_FLAG_MMAP_NOIRQ, &deviceId, &portId);
+                                              AUDIO_INPUT_FLAG_MMAP_NOIRQ,
+                                              &deviceId, &portId, &source);
+        localAttr.source = source;
         deviceIds->clear();
         if (deviceId != AUDIO_PORT_HANDLE_NONE) {
             deviceIds->push_back(deviceId);
@@ -2534,17 +2537,19 @@
         output.selectedDeviceId = input.selectedDeviceId;
         portId = AUDIO_PORT_HANDLE_NONE;
     }
+    audio_source_t source = AUDIO_SOURCE_DEFAULT;
     lStatus = AudioSystem::getInputForAttr(&input.attr, &output.inputId,
                                       input.riid,
                                       sessionId,
                                     // FIXME compare to AudioTrack
                                       adjAttributionSource,
                                       &input.config,
-                                      output.flags, &output.selectedDeviceId, &portId);
+                                      output.flags, &output.selectedDeviceId, &portId, &source);
     if (lStatus != NO_ERROR) {
         ALOGE("createRecord() getInputForAttr return error %d", lStatus);
         goto Exit;
     }
+    input.attr.source = source;
 
     {
         audio_utils::lock_guard _l(mutex());