From a62a52def0128d9b6f9a9b20ed9269a732d8cfc5 Mon Sep 17 00:00:00 2001
From: Shunkai Yao <yaoshunkai@google.com>
Date: Wed, 28 Feb 2024 20:23:01 +0000
Subject: [PATCH] HalVersionManager: make instance_ptr after static versions
 init

BluetoothAudioHalVersion::VERSION* needs to be initialized before
instance_ptr.

Bug: 326888178
Test: m
Test: Build and test A2DP on Pixel 5a
Test: atest BluetoothAudioHalVersionTest
Change-Id: I0832b91dc13644b30ad32a0ad071cc531916838a
---
 system/audio_hal_interface/hal_version_manager.cc | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/system/audio_hal_interface/hal_version_manager.cc b/system/audio_hal_interface/hal_version_manager.cc
index 8b4f9e9a39f..36672cb32c6 100644
--- a/system/audio_hal_interface/hal_version_manager.cc
+++ b/system/audio_hal_interface/hal_version_manager.cc
@@ -36,10 +36,6 @@ using ::aidl::android::hardware::bluetooth::audio::
 static const std::string kDefaultAudioProviderFactoryInterface =
     std::string() + IBluetoothAudioProviderFactory::descriptor + "/default";
 
-// Ideally HalVersionManager can be a singleton class
-std::unique_ptr<HalVersionManager> HalVersionManager::instance_ptr =
-    std::make_unique<HalVersionManager>();
-
 std::string toString(BluetoothAudioHalTransport transport) {
   switch (transport) {
     case BluetoothAudioHalTransport::UNKNOWN:
@@ -68,6 +64,10 @@ const BluetoothAudioHalVersion BluetoothAudioHalVersion::VERSION_AIDL_V3 =
 const BluetoothAudioHalVersion BluetoothAudioHalVersion::VERSION_AIDL_V4 =
     BluetoothAudioHalVersion(BluetoothAudioHalTransport::AIDL, 4, 0);
 
+// Ideally HalVersionManager can be a singleton class
+std::unique_ptr<HalVersionManager> HalVersionManager::instance_ptr =
+    std::make_unique<HalVersionManager>();
+
 /**
  * A singleton implementation to get the AIDL interface version.
  */
-- 
GitLab