HFP: Refactor HFP version flags

* Move common HFP flags to `bta_hfp_api.h`
* Let HF Client always reads BTA_HFP_VERSION for SDP advertising

Tag: #feature
Bug: 176778277
Test: atest BluetoothInstrumentationTests
Change-Id: Ie96668df4bd5480b2bae6ad55e025bee543bdd0b
diff --git a/system/bta/hf_client/bta_hf_client_int.h b/system/bta/hf_client/bta_hf_client_int.h
index a685c76..27879b5 100755
--- a/system/bta/hf_client/bta_hf_client_int.h
+++ b/system/bta/hf_client/bta_hf_client_int.h
@@ -25,10 +25,6 @@
 /*****************************************************************************
  *  Constants
  ****************************************************************************/
-#define HFP_VERSION_1_1 0x0101
-#define HFP_VERSION_1_5 0x0105
-#define HFP_VERSION_1_6 0x0106
-#define HFP_VERSION_1_7 0x0107
 
 /* RFCOMM MTU SIZE */
 #define BTA_HF_CLIENT_MTU 256
diff --git a/system/bta/hf_client/bta_hf_client_sdp.cc b/system/bta/hf_client/bta_hf_client_sdp.cc
index afbdaed..322cab0 100755
--- a/system/bta/hf_client/bta_hf_client_sdp.cc
+++ b/system/bta/hf_client/bta_hf_client_sdp.cc
@@ -124,10 +124,7 @@
 
   /* add profile descriptor list */
   profile_uuid = UUID_SERVCLASS_HF_HANDSFREE;
-  version = HFP_VERSION_1_6;
-
-  if (osi_property_get_bool("persist.bluetooth.hfpclient.sco_s4_supported", false))
-    version = HFP_VERSION_1_7;
+  version = BTA_HFP_VERSION;
 
   result &= SDP_AddProfileDescriptorList(sdp_handle, profile_uuid, version);
 
diff --git a/system/bta/include/bta_ag_api.h b/system/bta/include/bta_ag_api.h
index 8d86345..578ebf2 100644
--- a/system/bta/include/bta_ag_api.h
+++ b/system/bta/include/bta_ag_api.h
@@ -25,7 +25,9 @@
 #ifndef BTA_AG_API_H
 #define BTA_AG_API_H
 
-#include <cstdint>
+#include "bta_api.h"
+#include "bta_hfp_api.h"
+
 #include <string>
 #include <vector>
 
@@ -39,25 +41,6 @@
 /* Number of SCBs (AG service instances that can be registered) */
 #define BTA_AG_MAX_NUM_CLIENTS 6
 
-#define HFP_HSP_VERSION_UNKNOWN 0x0000
-#define HFP_VERSION_1_1 0x0101
-#define HFP_VERSION_1_5 0x0105
-#define HFP_VERSION_1_6 0x0106
-#define HFP_VERSION_1_7 0x0107
-
-#define HSP_VERSION_1_0 0x0100
-#define HSP_VERSION_1_2 0x0102
-
-#define HFP_VERSION_CONFIG_KEY "HfpVersion"
-#define HFP_SDP_FEATURES_CONFIG_KEY "HfpSdpFeatures"
-
-/* Note, if you change the default version here, please also change the one in
- * bta_hs_api.h, they are meant to be the same.
- */
-#ifndef BTA_HFP_VERSION
-#define BTA_HFP_VERSION HFP_VERSION_1_7
-#endif
-
 /* AG feature masks */
 #define BTA_AG_FEAT_3WAY 0x00000001   /* Three-way calling */
 #define BTA_AG_FEAT_ECNR 0x00000002   /* Echo cancellation/noise reduction */
diff --git a/system/bta/include/bta_hf_client_api.h b/system/bta/include/bta_hf_client_api.h
index 28be67c..412c334 100755
--- a/system/bta/include/bta_hf_client_api.h
+++ b/system/bta/include/bta_hf_client_api.h
@@ -27,7 +27,8 @@
 
 #include <cstdint>
 
-#include "bta/include/bta_api.h"
+#include "bta_api.h"
+#include "bta_hfp_api.h"
 #include "types/raw_address.h"
 
 /*****************************************************************************
diff --git a/system/bta/include/bta_hfp_api.h b/system/bta/include/bta_hfp_api.h
new file mode 100644
index 0000000..a3dd3a9
--- /dev/null
+++ b/system/bta/include/bta_hfp_api.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef BTA_HFP_API_H
+#define BTA_HFP_API_H
+
+/* HFP Versions */
+#define HFP_HSP_VERSION_UNKNOWN 0x0000
+#define HFP_HSP_VERSION_DONT_CARE 0xFFFF
+#define HFP_VERSION_1_1 0x0101
+#define HFP_VERSION_1_5 0x0105
+#define HFP_VERSION_1_6 0x0106
+#define HFP_VERSION_1_7 0x0107
+
+#define HSP_VERSION_1_0 0x0100
+#define HSP_VERSION_1_2 0x0102
+
+#define HFP_VERSION_CONFIG_KEY "HfpVersion"
+#define HFP_SDP_FEATURES_CONFIG_KEY "HfpSdpFeatures"
+
+/* Default HFP Version */
+#ifndef BTA_HFP_VERSION
+#define BTA_HFP_VERSION HFP_VERSION_1_7
+#endif
+
+#endif /* BTA_HFP_API_H */
\ No newline at end of file
diff --git a/system/bta/test/bta_hf_client_add_record_test.cc b/system/bta/test/bta_hf_client_add_record_test.cc
index 68d6111..36d527d 100644
--- a/system/bta/test/bta_hf_client_add_record_test.cc
+++ b/system/bta/test/bta_hf_client_add_record_test.cc
@@ -2,6 +2,7 @@
 #include <gtest/gtest.h>
 
 #include "bta/hf_client/bta_hf_client_sdp.cc"
+#include "bta/include/bta_hf_client_api.h"
 #include "btif/src/btif_hf_client.cc"
 
 static uint16_t gVersion;
@@ -47,13 +48,7 @@
   uint32_t sdp_handle = 0;
   uint8_t scn = 0;
 
-  osi_property_set("persist.bluetooth.hfpclient.sco_s4_supported", "true");
   bta_hf_client_add_record("Handsfree", scn, features, sdp_handle);
-  EXPECT_EQ(gVersion, 0x0107);
-  sdp_handle++;
-  scn++;
-  osi_property_set("persist.bluetooth.hfpclient.sco_s4_supported", "false");
-  bta_hf_client_add_record("Handsfree", scn, features, sdp_handle);
-  EXPECT_EQ(gVersion, 0x0106);
+  ASSERT_EQ(gVersion, BTA_HFP_VERSION);
 }