policy: add dumpsys.

- add dumpsys support.
- usage dumpsys media.audio_policy

Change-Id: Ic3a80d0d06278f83fd30b103b69bec9f13f5bba9
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 5483b5e..7f2f4c3 100644
--- a/policy_hal/AudioPolicyManager.cpp
+++ b/policy_hal/AudioPolicyManager.cpp
@@ -2171,4 +2171,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: