Loading system/btif/src/btif_dm.cc +1 −9 Original line number Diff line number Diff line Loading @@ -1813,7 +1813,6 @@ static void btif_dm_search_services_evt(tBTA_DM_SEARCH_EVT event, } static void btif_dm_update_allowlisted_media_players() { uint8_t num_wlplayers = 0; uint8_t i = 0, buf_len = 0; bt_property_t wlplayers_prop; list_t* wl_players = list_new(nullptr); Loading @@ -1824,19 +1823,12 @@ static void btif_dm_update_allowlisted_media_players() { LOG_DEBUG("btif_dm_update_allowlisted_media_players"); wlplayers_prop.len = 0; if (!interop_get_allowlisted_media_players_list(&wl_players)) { if (!interop_get_allowlisted_media_players_list(wl_players)) { LOG_DEBUG("Allowlisted media players not found"); list_free(wl_players); return; } num_wlplayers = list_length(wl_players); LOG_DEBUG("%d - WL media players found", num_wlplayers); /* Now send the callback */ if (num_wlplayers <= 0) { list_free(wl_players); return; } /*find the total number of bytes and allocate memory */ for (list_node_t* node = list_begin(wl_players); node != list_end(wl_players); node = list_next(node)) { Loading system/device/include/interop.h +1 −1 Original line number Diff line number Diff line Loading @@ -392,7 +392,7 @@ bool interop_match_addr_get_max_lat(const interop_feature_t feature, // This API is used for name based lookups for allowlisted media players. // If allowlisted media players list found it will assign the media players list // pointer to the argument passed and return true else return false. bool interop_get_allowlisted_media_players_list(list_t** p_bl_devices); bool interop_get_allowlisted_media_players_list(list_t* p_bl_devices); // Return feature's enum value according to feature'name. int interop_feature_name_to_feature_id(const char* feature_name); system/device/include/interop_config.h +1 −3 Original line number Diff line number Diff line Loading @@ -83,6 +83,4 @@ bool interop_database_match_addr_get_lmp_ver(const interop_feature_t feature, const RawAddress* addr, uint8_t* lmp_ver, uint16_t* lmp_sub_ver); bool interop_get_allowlisted_media_players_list(list_t** p_bl_devices); bool interop_database_get_allowlisted_media_players_list( const interop_feature_t feature, list_t** p_bl_devices); bool interop_get_allowlisted_media_players_list(list_t* p_bl_devices); system/device/src/interop.cc +38 −16 Original line number Diff line number Diff line Loading @@ -78,6 +78,7 @@ static const char* INTEROP_STATIC_FILE_PATH = return #const; static list_t* interop_list = NULL; static list_t* media_player_list = NULL; bool interop_is_initialized = false; // protects operations on |interop_list| Loading @@ -85,7 +86,7 @@ pthread_mutex_t interop_list_lock; // protects operations on |config| static pthread_mutex_t file_lock; static std::unique_ptr<config_t> config_static; static std::unique_ptr<const config_t> config_static; static std::unique_ptr<config_t> config_dynamic; static const char* UNKNOWN_INTEROP_FEATURE = "UNKNOWN"; // map from feature name to feature id Loading Loading @@ -184,6 +185,8 @@ static void interop_config_cleanup(void); // This function is used to initialize the interop list and load the entries // from file static void load_config(); static void interop_database_save_allowlisted_media_players_list( const config_t* config); static void interop_database_add_(interop_db_entry_t* db_entry, bool persist); static bool interop_database_remove_(interop_db_entry_t* entry); static bool interop_database_match(interop_db_entry_t* entry, Loading @@ -206,13 +209,6 @@ bool interop_match_name(const interop_feature_t feature, const char* name) { return (interop_database_match_name(feature, name)); } bool interop_get_allowlisted_media_players_list(list_t** p_bl_devices) { interop_feature_t feature = INTEROP_BROWSE_PLAYER_ALLOW_LIST; return (interop_database_get_allowlisted_media_players_list(feature, p_bl_devices)); } bool interop_match_addr_or_name(const interop_feature_t feature, const RawAddress* addr, bt_status_t (*get_remote_device_property)( Loading Loading @@ -300,6 +296,8 @@ static future_t* interop_clean_up(void) { pthread_mutex_lock(&interop_list_lock); list_free(interop_list); interop_list = NULL; list_free(media_player_list); media_player_list = NULL; interop_is_initialized = false; pthread_mutex_unlock(&interop_list_lock); pthread_mutex_destroy(&interop_list_lock); Loading Loading @@ -1152,6 +1150,9 @@ static void load_config() { } } } interop_database_save_allowlisted_media_players_list(config_static.get()); // We no longer need the static config file config_static.reset(); for (const section_t& sec : config_dynamic.get()->sections) { int feature = -1; Loading Loading @@ -1661,16 +1662,37 @@ bool interop_database_remove_addr_lmp_version(const interop_feature_t feature, return false; } bool interop_database_get_allowlisted_media_players_list( const interop_feature_t feature, list_t** p_bl_devices) { for (const section_t& sec : config_static.get()->sections) { if (feature == interop_feature_name_to_feature_id(sec.name.c_str())) { static void delete_media_player_node(void* data) { std::string* key = static_cast<std::string*>(data); delete key; } static void interop_database_save_allowlisted_media_players_list( const config_t* config) { media_player_list = list_new(delete_media_player_node); for (const section_t& sec : config->sections) { if (INTEROP_BROWSE_PLAYER_ALLOW_LIST == interop_feature_name_to_feature_id(sec.name.c_str())) { LOG_WARN("found feature - %s", sec.name.c_str()); for (const entry_t& entry : sec.entries) { LOG_WARN("found feature - %s", interop_feature_string_(feature)); list_append(*p_bl_devices, (void*)entry.key.c_str()); list_append(media_player_list, (void*)(new std::string(entry.key))); } return true; break; } } return false; } bool interop_get_allowlisted_media_players_list(list_t* p_bl_devices) { if (media_player_list == nullptr) return false; const list_node_t* node = list_begin(media_player_list); bool found = false; while (node != list_end(media_player_list)) { found = true; std::string* key = (std::string*)list_node(node); list_append(p_bl_devices, (void*)key->c_str()); node = list_next(node); } return found; } system/stack/test/sdp/stack_sdp_utils_test.cc +2 −2 Original line number Diff line number Diff line Loading @@ -69,7 +69,7 @@ class IopMock { (const interop_feature_t, uint16_t)); MOCK_METHOD(bool, InteropMatchAddrGetMaxLat, (const interop_feature_t, const RawAddress*, uint16_t*)); MOCK_METHOD(bool, InteropGetAllowlistedMediaPlayersList, (list_t**)); MOCK_METHOD(bool, InteropGetAllowlistedMediaPlayersList, (list_t*)); MOCK_METHOD(int, InteropFeatureNameToFeatureId, (const char*)); }; Loading Loading @@ -123,7 +123,7 @@ bool interop_match_addr_get_max_lat(const interop_feature_t feature, return localIopMock->InteropMatchAddrGetMaxLat(feature, addr, max_lat); } bool interop_get_allowlisted_media_players_list(list_t** p_bl_devices) { bool interop_get_allowlisted_media_players_list(list_t* p_bl_devices) { return localIopMock->InteropGetAllowlistedMediaPlayersList(p_bl_devices); } Loading Loading
system/btif/src/btif_dm.cc +1 −9 Original line number Diff line number Diff line Loading @@ -1813,7 +1813,6 @@ static void btif_dm_search_services_evt(tBTA_DM_SEARCH_EVT event, } static void btif_dm_update_allowlisted_media_players() { uint8_t num_wlplayers = 0; uint8_t i = 0, buf_len = 0; bt_property_t wlplayers_prop; list_t* wl_players = list_new(nullptr); Loading @@ -1824,19 +1823,12 @@ static void btif_dm_update_allowlisted_media_players() { LOG_DEBUG("btif_dm_update_allowlisted_media_players"); wlplayers_prop.len = 0; if (!interop_get_allowlisted_media_players_list(&wl_players)) { if (!interop_get_allowlisted_media_players_list(wl_players)) { LOG_DEBUG("Allowlisted media players not found"); list_free(wl_players); return; } num_wlplayers = list_length(wl_players); LOG_DEBUG("%d - WL media players found", num_wlplayers); /* Now send the callback */ if (num_wlplayers <= 0) { list_free(wl_players); return; } /*find the total number of bytes and allocate memory */ for (list_node_t* node = list_begin(wl_players); node != list_end(wl_players); node = list_next(node)) { Loading
system/device/include/interop.h +1 −1 Original line number Diff line number Diff line Loading @@ -392,7 +392,7 @@ bool interop_match_addr_get_max_lat(const interop_feature_t feature, // This API is used for name based lookups for allowlisted media players. // If allowlisted media players list found it will assign the media players list // pointer to the argument passed and return true else return false. bool interop_get_allowlisted_media_players_list(list_t** p_bl_devices); bool interop_get_allowlisted_media_players_list(list_t* p_bl_devices); // Return feature's enum value according to feature'name. int interop_feature_name_to_feature_id(const char* feature_name);
system/device/include/interop_config.h +1 −3 Original line number Diff line number Diff line Loading @@ -83,6 +83,4 @@ bool interop_database_match_addr_get_lmp_ver(const interop_feature_t feature, const RawAddress* addr, uint8_t* lmp_ver, uint16_t* lmp_sub_ver); bool interop_get_allowlisted_media_players_list(list_t** p_bl_devices); bool interop_database_get_allowlisted_media_players_list( const interop_feature_t feature, list_t** p_bl_devices); bool interop_get_allowlisted_media_players_list(list_t* p_bl_devices);
system/device/src/interop.cc +38 −16 Original line number Diff line number Diff line Loading @@ -78,6 +78,7 @@ static const char* INTEROP_STATIC_FILE_PATH = return #const; static list_t* interop_list = NULL; static list_t* media_player_list = NULL; bool interop_is_initialized = false; // protects operations on |interop_list| Loading @@ -85,7 +86,7 @@ pthread_mutex_t interop_list_lock; // protects operations on |config| static pthread_mutex_t file_lock; static std::unique_ptr<config_t> config_static; static std::unique_ptr<const config_t> config_static; static std::unique_ptr<config_t> config_dynamic; static const char* UNKNOWN_INTEROP_FEATURE = "UNKNOWN"; // map from feature name to feature id Loading Loading @@ -184,6 +185,8 @@ static void interop_config_cleanup(void); // This function is used to initialize the interop list and load the entries // from file static void load_config(); static void interop_database_save_allowlisted_media_players_list( const config_t* config); static void interop_database_add_(interop_db_entry_t* db_entry, bool persist); static bool interop_database_remove_(interop_db_entry_t* entry); static bool interop_database_match(interop_db_entry_t* entry, Loading @@ -206,13 +209,6 @@ bool interop_match_name(const interop_feature_t feature, const char* name) { return (interop_database_match_name(feature, name)); } bool interop_get_allowlisted_media_players_list(list_t** p_bl_devices) { interop_feature_t feature = INTEROP_BROWSE_PLAYER_ALLOW_LIST; return (interop_database_get_allowlisted_media_players_list(feature, p_bl_devices)); } bool interop_match_addr_or_name(const interop_feature_t feature, const RawAddress* addr, bt_status_t (*get_remote_device_property)( Loading Loading @@ -300,6 +296,8 @@ static future_t* interop_clean_up(void) { pthread_mutex_lock(&interop_list_lock); list_free(interop_list); interop_list = NULL; list_free(media_player_list); media_player_list = NULL; interop_is_initialized = false; pthread_mutex_unlock(&interop_list_lock); pthread_mutex_destroy(&interop_list_lock); Loading Loading @@ -1152,6 +1150,9 @@ static void load_config() { } } } interop_database_save_allowlisted_media_players_list(config_static.get()); // We no longer need the static config file config_static.reset(); for (const section_t& sec : config_dynamic.get()->sections) { int feature = -1; Loading Loading @@ -1661,16 +1662,37 @@ bool interop_database_remove_addr_lmp_version(const interop_feature_t feature, return false; } bool interop_database_get_allowlisted_media_players_list( const interop_feature_t feature, list_t** p_bl_devices) { for (const section_t& sec : config_static.get()->sections) { if (feature == interop_feature_name_to_feature_id(sec.name.c_str())) { static void delete_media_player_node(void* data) { std::string* key = static_cast<std::string*>(data); delete key; } static void interop_database_save_allowlisted_media_players_list( const config_t* config) { media_player_list = list_new(delete_media_player_node); for (const section_t& sec : config->sections) { if (INTEROP_BROWSE_PLAYER_ALLOW_LIST == interop_feature_name_to_feature_id(sec.name.c_str())) { LOG_WARN("found feature - %s", sec.name.c_str()); for (const entry_t& entry : sec.entries) { LOG_WARN("found feature - %s", interop_feature_string_(feature)); list_append(*p_bl_devices, (void*)entry.key.c_str()); list_append(media_player_list, (void*)(new std::string(entry.key))); } return true; break; } } return false; } bool interop_get_allowlisted_media_players_list(list_t* p_bl_devices) { if (media_player_list == nullptr) return false; const list_node_t* node = list_begin(media_player_list); bool found = false; while (node != list_end(media_player_list)) { found = true; std::string* key = (std::string*)list_node(node); list_append(p_bl_devices, (void*)key->c_str()); node = list_next(node); } return found; }
system/stack/test/sdp/stack_sdp_utils_test.cc +2 −2 Original line number Diff line number Diff line Loading @@ -69,7 +69,7 @@ class IopMock { (const interop_feature_t, uint16_t)); MOCK_METHOD(bool, InteropMatchAddrGetMaxLat, (const interop_feature_t, const RawAddress*, uint16_t*)); MOCK_METHOD(bool, InteropGetAllowlistedMediaPlayersList, (list_t**)); MOCK_METHOD(bool, InteropGetAllowlistedMediaPlayersList, (list_t*)); MOCK_METHOD(int, InteropFeatureNameToFeatureId, (const char*)); }; Loading Loading @@ -123,7 +123,7 @@ bool interop_match_addr_get_max_lat(const interop_feature_t feature, return localIopMock->InteropMatchAddrGetMaxLat(feature, addr, max_lat); } bool interop_get_allowlisted_media_players_list(list_t** p_bl_devices) { bool interop_get_allowlisted_media_players_list(list_t* p_bl_devices) { return localIopMock->InteropGetAllowlistedMediaPlayersList(p_bl_devices); } Loading