Mask out HFP 1.7 feature bits if peer version is <1.7

Bug: 32378402
Merged-In: I568e8c4c584d56d744cf7a30273feac1d8d4c4df
Change-Id: Iac8684bdfd02b18cce260bedefb829e8f7285361
(cherry picked from commit 1ad2678e2ff5fa3dbfae9dc76ab646db10794e4e)
(cherry picked from commit 571f23ca31cdbc87cae8c078b5885246dd779498)
(cherry picked from commit ebba3ef2ea5061a48aa0de49ebfdb98df64d803f)
diff --git a/bta/ag/bta_ag_cmd.c b/bta/ag/bta_ag_cmd.c
index 110b531..973e26e 100644
--- a/bta/ag/bta_ag_cmd.c
+++ b/bta/ag/bta_ag_cmd.c
@@ -1346,19 +1346,24 @@
             break;
 
         case BTA_AG_HF_CMD_BRSF:
+        {
             /* store peer features */
             p_scb->peer_features = (uint16_t) int_arg;
-#if (BTA_HFP_VERSION < HFP_VERSION_1_7 || BTA_HFP_HF_IND_SUPPORTED != true)
-            p_scb->features &= ~BTA_AG_FEAT_HF_IND;
-#endif
+
+            tBTA_AG_FEAT features = p_scb->features;
+            if (p_scb->peer_version < HFP_VERSION_1_7)
+            {
+                features &= HFP_1_6_FEAT_MASK;
+            }
+
             APPL_TRACE_DEBUG("%s BRSF HF: 0x%x, phone: 0x%x", __func__,
-                p_scb->peer_features, p_scb->features);
+                p_scb->peer_features, features);
 
             /* send BRSF, send OK */
-            bta_ag_send_result(p_scb, BTA_AG_RES_BRSF, NULL,
-                               (INT16) (p_scb->features & BTA_AG_BSRF_FEAT_SPEC));
+            bta_ag_send_result(p_scb, BTA_AG_RES_BRSF, NULL, (int16_t) features);
             bta_ag_send_ok(p_scb);
             break;
+        }
 
         case BTA_AG_HF_CMD_NREC:
             /* if feature send OK, else don't call callback, send ERROR */
diff --git a/bta/include/bta_ag_api.h b/bta/include/bta_ag_api.h
index fa76a57..e281fb1 100644
--- a/bta/include/bta_ag_api.h
+++ b/bta/include/bta_ag_api.h
@@ -45,10 +45,6 @@
 #define BTA_HFP_VERSION         HFP_VERSION_1_7
 #endif
 
-#ifndef BTA_HFP_HF_IND_SUPPORTED
-#define BTA_HFP_HF_IND_SUPPORTED    TRUE
-#endif
-
 /* AG feature masks */
 #define BTA_AG_FEAT_3WAY    0x00000001   /* Three-way calling */
 #define BTA_AG_FEAT_ECNR    0x00000002   /* Echo cancellation and/or noise reduction */
@@ -60,9 +56,14 @@
 #define BTA_AG_FEAT_ECC     0x00000080   /* Enhanced Call Control */
 #define BTA_AG_FEAT_EXTERR  0x00000100   /* Extended error codes */
 #define BTA_AG_FEAT_CODEC   0x00000200   /* Codec Negotiation */
+
+#define HFP_1_6_FEAT_MASK   0x000003FF   /* Valid feature bit mask for HFP 1.6 (and below) */
+
+/* HFP 1.7+ */
 #define BTA_AG_FEAT_HF_IND  0x00000400   /* HF Indicators */
 #define BTA_AG_FEAT_ESCO    0x00000800   /* eSCO S4 (and T2) setting supported */
 
+
 /* Proprietary features: using 31 ~ 16 bits */
 #define BTA_AG_FEAT_BTRH    0x00010000   /* CCAP incoming call hold */
 #define BTA_AG_FEAT_UNAT    0x00020000   /* Pass unknown AT commands to application */