Merge "policy: fix voice volume is mismatch after headset remove"
diff --git a/configs/qssi/qssi.mk b/configs/qssi/qssi.mk
index 629293d..7dce898 100644
--- a/configs/qssi/qssi.mk
+++ b/configs/qssi/qssi.mk
@@ -45,10 +45,6 @@
 DEVICE_PACKAGE_OVERLAYS += hardware/qcom/audio/configs/common/overlay
 endif
 
-# Reduce client buffer size for fast audio output tracks
-PRODUCT_PROPERTY_OVERRIDES += \
-    af.fast_track_multiplier=1
-
 # Low latency audio buffer size in frames
 PRODUCT_PROPERTY_OVERRIDES += \
     vendor.audio_hal.period_size=192
@@ -61,18 +57,10 @@
 PRODUCT_PROPERTY_OVERRIDES += \
 vendor.audio.offload.buffer.size.kb=32
 
-#Enable offload audio video playback by default
-PRODUCT_PROPERTY_OVERRIDES += \
-audio.offload.video=true
-
 #Enable audio track offload by default
 PRODUCT_PROPERTY_OVERRIDES += \
 vendor.audio.offload.track.enable=true
 
-#Enable music through deep buffer
-PRODUCT_PROPERTY_OVERRIDES += \
-audio.deep_buffer.media=true
-
 #enable voice path for PCM VoIP by default
 PRODUCT_PROPERTY_OVERRIDES += \
 vendor.voice.path.for.pcm.voip=true
@@ -107,6 +95,19 @@
 PRODUCT_PROPERTY_OVERRIDES += \
 vendor.audio.hw.aac.encoder=true
 
+ifneq ($(GENERIC_ODM_IMAGE),true)
+# Reduce client buffer size for fast audio output tracks
+PRODUCT_PROPERTY_OVERRIDES += \
+af.fast_track_multiplier=1
+
+#Enable offload audio video playback by default
+PRODUCT_PROPERTY_OVERRIDES += \
+audio.offload.video=true
+
+#Enable music through deep buffer
+PRODUCT_PROPERTY_OVERRIDES += \
+audio.deep_buffer.media=true
+
 #audio becoming noisy intent broadcast delay
 PRODUCT_PRODUCT_PROPERTIES += \
 audio.sys.noisy.broadcast.delay=500
@@ -131,6 +132,13 @@
 PRODUCT_PROPERTY_OVERRIDES += \
 ro.af.client_heap_size_kbyte=7168
 
+#enable deep buffer
+PRODUCT_PROPERTY_OVERRIDES += \
+media.stagefright.audio.deep=false
+
+endif
+#guard for non generic_odm_image
+
 # Enable AAudio MMAP/NOIRQ data path.
 # 2 is AAUDIO_POLICY_AUTO so it will try MMAP then fallback to Legacy path.
 PRODUCT_PROPERTY_OVERRIDES += aaudio.mmap_policy=2
@@ -142,10 +150,6 @@
 PRODUCT_PROPERTY_OVERRIDES += \
 vendor.audio.enable.mirrorlink=false
 
-#enable deep buffer
-PRODUCT_PROPERTY_OVERRIDES += \
-media.stagefright.audio.deep=false
-
 # for HIDL related packages
 PRODUCT_PACKAGES += \
     android.hardware.audio@4.0 \
diff --git a/policy_hal/APMConfigHelper.cpp b/policy_hal/APMConfigHelper.cpp
index 1815e77..5b17096 100644
--- a/policy_hal/APMConfigHelper.cpp
+++ b/policy_hal/APMConfigHelper.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2019-2020, The Linux Foundation. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -37,6 +37,36 @@
 
 namespace android {
 
+void APMConfigHelper::dump(String8 *dst) const
+{
+    // apmconfig struct dump
+    dst->appendFormat("\nAudioPolicyManagerCustom Dump: %p\n", this);
+    dst->appendFormat("audio_offload_video: %d \n", mConfigs.audio_offload_video);
+    dst->appendFormat("audio_offload_disable: %d \n", mConfigs.audio_offload_disable);
+    dst->appendFormat("audio_deepbuffer_media: %d \n", mConfigs.audio_deepbuffer_media);
+    dst->appendFormat("audio_av_streaming_offload_enable: %d \n", mConfigs.audio_av_streaming_offload_enable);
+    dst->appendFormat("audio_offload_track_enable: %d \n", mConfigs.audio_offload_track_enable);
+    dst->appendFormat("audio_offload_multiple_enabled: %d \n", mConfigs.audio_offload_multiple_enabled);
+    dst->appendFormat("voice_dsd_playback_conc_disabled: %d \n", mConfigs.voice_dsd_playback_conc_disabled);
+    dst->appendFormat("audio_sva_conc_enabled: %d \n", mConfigs.audio_sva_conc_enabled);
+    dst->appendFormat("audio_va_concurrency_enabled: %d \n", mConfigs.audio_va_concurrency_enabled);
+    dst->appendFormat("audio_rec_playback_conc_disabled: %d \n", mConfigs.audio_rec_playback_conc_disabled);
+    dst->appendFormat("voice_path_for_pcm_voip: %d \n", mConfigs.voice_path_for_pcm_voip);
+    dst->appendFormat("voice_playback_conc_disabled: %d \n", mConfigs.voice_playback_conc_disabled);
+    dst->appendFormat("voice_record_conc_disabled: %d \n", mConfigs.voice_record_conc_disabled);
+    dst->appendFormat("voice_voip_conc_disabled: %d \n", mConfigs.voice_voip_conc_disabled);
+    dst->appendFormat("audio_offload_min_duration_secs: %u \n", mConfigs.audio_offload_min_duration_secs);
+    dst->appendFormat("voice_conc_fallbackpath: %s \n", mConfigs.voice_conc_fallbackpath.c_str());
+    dst->appendFormat("audio_extn_hdmi_spk_enabled: %d \n", mConfigs.audio_extn_hdmi_spk_enabled);
+    dst->appendFormat("audio_extn_formats_enabled: %d \n", mConfigs.audio_extn_formats_enabled);
+    dst->appendFormat("audio_extn_afe_proxy_enabled: %d \n", mConfigs.audio_extn_afe_proxy_enabled);
+    dst->appendFormat("compress_voip_enabled: %d \n", mConfigs.compress_voip_enabled);
+    dst->appendFormat("fm_power_opt: %d \n", mConfigs.fm_power_opt);
+    dst->appendFormat("voice_concurrency: %d \n", mConfigs.voice_concurrency);
+    dst->appendFormat("record_play_concurrency: %d \n", mConfigs.record_play_concurrency);
+    dst->appendFormat("use_xml_audio_policy_conf: %d \n", mConfigs.use_xml_audio_policy_conf);
+}
+
 void APMConfigHelper::retrieveConfigs()
 {
 #ifdef AHAL_EXT_ENABLED
diff --git a/policy_hal/APMConfigHelper.h b/policy_hal/APMConfigHelper.h
index 137f2d7..e92fcaa 100644
--- a/policy_hal/APMConfigHelper.h
+++ b/policy_hal/APMConfigHelper.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2019-2020, The Linux Foundation. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -31,6 +31,7 @@
 #define _APM_CONFIG_HELPER_H_
 
 #include <string>
+#include <utils/String8.h>
 #include <media/stagefright/foundation/ABase.h>
 #include <utils/RefBase.h>
 
@@ -109,7 +110,7 @@
     bool isVoiceConcEnabled();
     bool isRecPlayConcEnabled();
     bool useXMLAudioPolicyConf();
-
+    void dump(String8 *dst) const;
 private:
     inline void retrieveConfigs();
 
diff --git a/policy_hal/AudioPolicyManager.cpp b/policy_hal/AudioPolicyManager.cpp
index 4660e12..5ab6067 100644
--- a/policy_hal/AudioPolicyManager.cpp
+++ b/policy_hal/AudioPolicyManager.cpp
@@ -1871,7 +1871,7 @@
             ALOGI("FLAG None hence request for a primary output");
         }
 
-        output = selectOutput(outputs, *flags, config->format);
+        output = selectOutput(outputs, *flags, config->format, channelMask);
     }
 
     ALOGW_IF((output == 0), "getOutputForDevice() could not find output for stream %d, "
@@ -2172,4 +2172,13 @@
         mFallBackflag = getFallBackPath();
 }
 
+status_t AudioPolicyManagerCustom::dump(int fd)
+{
+    AudioPolicyManager::dump(fd);
+    String8 result;
+    mApmConfigs->dump(&result);
+    write(fd, result.string(), result.size());
+    return NO_ERROR;
+}
+
 }
diff --git a/policy_hal/AudioPolicyManager.h b/policy_hal/AudioPolicyManager.h
index 0ad9c33..494f354 100644
--- a/policy_hal/AudioPolicyManager.h
+++ b/policy_hal/AudioPolicyManager.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2019 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2020 The Linux Foundation. All rights reserved.
  * Not a contribution.
  *
  * Copyright (C) 2009 The Android Open Source Project
@@ -112,6 +112,7 @@
         // indicates to the audio policy manager that the input stops being used.
         virtual status_t stopInput(audio_port_handle_t portId);
 
+        status_t dump(int fd) override;
         static sp<APMConfigHelper> mApmConfigs;
 
 protected: