Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 826a487d authored by Andre Eisenbach's avatar Andre Eisenbach
Browse files

Remove absolute volume control whitelist

Remove the absolute volume control whitelist to enable absolute volume
control for all compatible devices.

Bug: 25081918
Change-Id: Iab0e4b4c4fd3dac0fefdf62ec80419dd64b56c0c
parent 1b77893f
Loading
Loading
Loading
Loading
+8 −66
Original line number Diff line number Diff line
@@ -145,7 +145,6 @@ static int uinput_driver_check();
static int  uinput_create(char *name);
static int  init_uinput (void);
static void close_uinput (void);
static BOOLEAN dev_blacklisted_for_absolute_volume(BD_ADDR peer_dev);

static const struct {
    const char *name;
@@ -163,27 +162,6 @@ static const struct {
    { NULL,           0,                0,                0 }
};

/* the rc_black_addr_prefix and rc_white_addr_prefix are used to correct
 * IOP issues of absolute volume feature
 * We encoutered A2DP headsets/carkits advertising absolute volume but buggy.
 * We would like to blacklist those devices.
 * But we donot have a full list of the bad devices. So as a temp fix, we
 * are blacklisting all the devices except the devices we have well tested,
 * the ones in the whitelist.
 *
 * For now, only the rc_white_addr_prefix is used in the code while
 * rc_black_addr_prefix is kept here for future long term solution.
 */
static const UINT8 rc_white_addr_prefix[][3] = {
    {0x94, 0xCE, 0x2C}, // Sony SBH50
    {0x30, 0x17, 0xC8} // Sony wm600
};

static const char* rc_white_name[] = {
    "SBH50",
    "MW600"
};

static void send_reject_response (UINT8 rc_handle, UINT8 label,
    UINT8 pdu, UINT8 status);
static UINT8 opcode_from_pdu(UINT8 pdu);
@@ -346,24 +324,28 @@ void handle_rc_features()
    bt_bdaddr_t rc_addr;
    bdcpy(rc_addr.address, btif_rc_cb.rc_addr);

    if (dev_blacklisted_for_absolute_volume(btif_rc_cb.rc_addr))
    {
        btif_rc_cb.rc_features &= ~BTA_AV_FEAT_ADV_CTRL;
    }
    // TODO(eisenbach): If devices need to be blacklisted for absolute
    // volume, it should be added to device/include/interop_database.h
    // For now, everything goes... If blacklisting is necessary, exclude
    // the following bit here:
    //    btif_rc_cb.rc_features &= ~BTA_AV_FEAT_ADV_CTRL;

    if (btif_rc_cb.rc_features & BTA_AV_FEAT_BROWSE)
    {
        rc_features |= BTRC_FEAT_BROWSE;
    }

    if ( (btif_rc_cb.rc_features & BTA_AV_FEAT_ADV_CTRL) &&
         (btif_rc_cb.rc_features & BTA_AV_FEAT_RCTG))
    {
        rc_features |= BTRC_FEAT_ABSOLUTE_VOLUME;
    }

    if (btif_rc_cb.rc_features & BTA_AV_FEAT_METADATA)
    {
        rc_features |= BTRC_FEAT_METADATA;
    }

    BTIF_TRACE_DEBUG("%s: rc_features=0x%x", __FUNCTION__, rc_features);
    HAL_CBACK(bt_rc_callbacks, remote_features_cb, &rc_addr, rc_features)

@@ -1884,43 +1866,3 @@ void lbl_destroy()
{
    pthread_mutex_destroy(&(device.lbllock));
}

/*******************************************************************************
**      Function       dev_blacklisted_for_absolute_volume
**
**      Description    Blacklist Devices that donot handle absolute volume well
**                     We are blacklisting all the devices that are not in whitelist
**
**      Returns        True if the device is in the list
*******************************************************************************/
static BOOLEAN dev_blacklisted_for_absolute_volume(BD_ADDR peer_dev)
{
    int i;
    char *dev_name_str = NULL;
    int whitelist_size = sizeof(rc_white_addr_prefix)/sizeof(rc_white_addr_prefix[0]);

    for (i = 0; i < whitelist_size; i++) {
        if (rc_white_addr_prefix[i][0] == peer_dev[0] &&
            rc_white_addr_prefix[i][1] == peer_dev[1] &&
            rc_white_addr_prefix[i][2] == peer_dev[2]) {
            BTIF_TRACE_DEBUG("whitelist absolute volume for %02x:%02x:%02x",
                              peer_dev[0], peer_dev[1], peer_dev[2]);
            return FALSE;
        }
    }

    dev_name_str = BTM_SecReadDevName(peer_dev);
    whitelist_size = sizeof(rc_white_name)/sizeof(char*);
    if (dev_name_str != NULL) {
        for (i = 0; i < whitelist_size; i++) {
            if (strcmp(dev_name_str, rc_white_name[i]) == 0) {
                BTIF_TRACE_DEBUG("whitelist absolute volume for %s", dev_name_str);
                return FALSE;
            }
        }
    }

    BTIF_TRACE_WARNING("blacklist absolute volume for %02x:%02x:%02x, name = %s",
                        peer_dev[0], peer_dev[1], peer_dev[2], dev_name_str);
    return TRUE;
}