Add Developer menu entry to disable Bluetooth absolute volume

Bug: 27078729
Change-Id: I24ac605c6d02dc3fe3904c441ec416cb66b63168
diff --git a/btif/src/btif_rc.c b/btif/src/btif_rc.c
index d971d33..8f77b73 100644
--- a/btif/src/btif_rc.c
+++ b/btif/src/btif_rc.c
@@ -34,6 +34,15 @@
 #include <hardware/bluetooth.h>
 #include <hardware/bt_rc.h>
 
+/**
+ * TODO(eisenbach): cutils/properties.h is only being used to pull-in runtime
+ * settings on Android. Remove this conditional include once we have a generic
+ * way to obtain system properties.
+ */
+#if !defined(OS_GENERIC)
+#include <cutils/properties.h>
+#endif  /* !defined(OS_GENERIC) */
+
 #include "avrc_defs.h"
 #include "bta_api.h"
 #include "bta_av_api.h"
@@ -271,6 +280,7 @@
 static void btif_rc_upstreams_evt(UINT16 event, tAVRC_COMMAND* p_param, UINT8 ctype, UINT8 label);
 static void btif_rc_upstreams_rsp_evt(UINT16 event, tAVRC_RESPONSE *pavrc_resp, UINT8 ctype, UINT8 label);
 static void rc_start_play_status_timer(void);
+static bool absolute_volume_disabled(void);
 
 /*****************************************************************************
 **  Static variables
@@ -461,7 +471,8 @@
     bt_bdaddr_t rc_addr;
     bdcpy(rc_addr.address, btif_rc_cb.rc_addr);
 
-    if (interop_match(INTEROP_DISABLE_ABSOLUTE_VOLUME, &rc_addr))
+    if (interop_match(INTEROP_DISABLE_ABSOLUTE_VOLUME, &rc_addr)
+        || absolute_volume_disabled())
         btif_rc_cb.rc_features &= ~BTA_AV_FEAT_ADV_CTRL;
 
     if (btif_rc_cb.rc_features & BTA_AV_FEAT_BROWSE)
@@ -4240,3 +4251,15 @@
         err = nanosleep(&delay, &delay);
     } while (err == -1 && errno == EINTR);
 }
+
+static bool absolute_volume_disabled() {
+#if !defined(OS_GENERIC)
+    char volume_disabled[PROPERTY_VALUE_MAX] = {0};
+    property_get("persist.bluetooth.disableabsvol", volume_disabled, "false");
+    if (strncmp(volume_disabled, "true", 4) == 0) {
+        BTIF_TRACE_WARNING("%s: Absolute volume disabled by property", __func__);
+        return true;
+    }
+#endif  /* !defined(OS_GENERIC) */
+    return false;
+}