[automerger skipped] Audio: add system usage to audio policy engine schemas am: d2ab30cbe9 am: 2c17a95ff2 am: 8f6b57b5a8 am: 0dc6c0ab42 am: b3fcc5cf68 am: 461de14d84 -s ours am: 9179efa608 -s ours

am skip reason: Merged-In I49a8d3cfeb45eddc95ad6ab4a33b0adf0585cde2 with SHA-1 e284266e52 is already in history

Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2719503

Change-Id: I8245c93c072debf2c8d7af8540a5d07a53e70fa3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.cpp b/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.cpp
index ee5527e..57a01c9 100644
--- a/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.cpp
+++ b/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.cpp
@@ -440,6 +440,16 @@
 void BluetoothAudioSession::ReportLowLatencyModeAllowedChanged(bool allowed) {
   std::lock_guard<std::recursive_mutex> guard(mutex_);
   low_latency_allowed_ = allowed;
+  // TODO(b/294498919): Remove this after there is API to update latency mode
+  // after audio session started. If low_latency_allowed_ is true, the session
+  // can support LOW_LATENCY and FREE LatencyMode.
+  if (low_latency_allowed_) {
+    if (std::find(latency_modes_.begin(), latency_modes_.end(),
+                  LatencyMode::LOW_LATENCY) == latency_modes_.end()) {
+      LOG(INFO) << __func__ << " - insert LOW_LATENCY LatencyMode";
+      latency_modes_.push_back(LatencyMode::LOW_LATENCY);
+    }
+  }
   if (observers_.empty()) {
     LOG(WARNING) << __func__ << " - SessionType=" << toString(session_type_)
                  << " has NO port state observer";