Add a new native interface API, addToWhiteList, that adds a LE device to
the whitelist.
Bug:
129452236
Test: Manual testing with Hearing Aids
Change-Id: I57c327380f07243e484c5c3afedfe60404f883fa
Merged-In: I57c327380f07243e484c5c3afedfe60404f883fa
BTA_GATTC_Open(gatt_if, address, true, GATT_TRANSPORT_LE, false);
}
+ void AddToWhiteList(const RawAddress& address) override {
+ VLOG(2) << __func__ << " address: " << address;
+ hearingDevices.Add(HearingDevice(address, true));
+ BTA_GATTC_Open(gatt_if, address, false, GATT_TRANSPORT_LE, false);
+ }
+
void AddFromStorage(const HearingDevice& dev_info, uint16_t is_white_listed) {
DVLOG(2) << __func__ << " " << dev_info.address
<< ", hiSyncId=" << loghex(dev_info.hi_sync_id)
virtual void Connect(const RawAddress& address) = 0;
virtual void Disconnect(const RawAddress& address) = 0;
+ virtual void AddToWhiteList(const RawAddress& address) = 0;
virtual void SetVolume(int8_t volume) = 0;
};
/** Deletes the bonded hearing aid device info from NVRAM */
void btif_storage_remove_hearing_aid(const RawAddress& address);
-/** Remove the hearing aid device from white list */
-void btif_storage_remove_hearing_aid_white_list(const RawAddress& address);
+/** Set/Unset the hearing aid device HEARING_AID_IS_WHITE_LISTED flag. */
+void btif_storage_set_hearing_aid_white_list(const RawAddress& address,
+ bool add_to_whitelist);
/*******************************************************************************
*
DVLOG(2) << __func__ << " address: " << address;
do_in_main_thread(FROM_HERE, Bind(&HearingAid::Disconnect,
Unretained(HearingAid::Get()), address));
- do_in_jni_thread(
- FROM_HERE, Bind(&btif_storage_remove_hearing_aid_white_list, address));
+ do_in_jni_thread(FROM_HERE, Bind(&btif_storage_set_hearing_aid_white_list,
+ address, false));
+ }
+
+ void AddToWhiteList(const RawAddress& address) override {
+ VLOG(2) << __func__ << " address: " << address;
+ do_in_main_thread(FROM_HERE, Bind(&HearingAid::AddToWhiteList,
+ Unretained(HearingAid::Get()), address));
+ do_in_jni_thread(FROM_HERE, Bind(&btif_storage_set_hearing_aid_white_list,
+ address, true));
}
void SetVolume(int8_t volume) override {
btif_config_save();
}
-/** Remove the hearing aid device from white list */
-void btif_storage_remove_hearing_aid_white_list(const RawAddress& address) {
+/** Set/Unset the hearing aid device HEARING_AID_IS_WHITE_LISTED flag. */
+void btif_storage_set_hearing_aid_white_list(const RawAddress& address,
+ bool add_to_whitelist) {
std::string addrstr = address.ToString();
- btif_config_set_int(addrstr, HEARING_AID_IS_WHITE_LISTED, false);
+ btif_config_set_int(addrstr, HEARING_AID_IS_WHITE_LISTED, add_to_whitelist);
+ btif_config_save();
}
/*******************************************************************************
/** Disconnect from Hearing Aid */
virtual void Disconnect(const RawAddress& address) = 0;
+ /** Add a hearing aid device to white list */
+ virtual void AddToWhiteList(const RawAddress& address) = 0;
+
/** Set the volume */
virtual void SetVolume(int8_t volume) = 0;