Loading system/btif/src/btif_rc.cc +5 −0 Original line number Diff line number Diff line Loading @@ -1959,6 +1959,11 @@ static bt_status_t register_notification_rsp( dump_rc_notification_event_id(event_id)); std::unique_lock<std::mutex> lock(btif_rc_cb.lock); if (event_id > MAX_RC_NOTIFICATIONS) { BTIF_TRACE_ERROR("Invalid event id"); return BT_STATUS_PARM_INVALID; } memset(&(avrc_rsp.reg_notif), 0, sizeof(tAVRC_REG_NOTIF_RSP)); avrc_rsp.reg_notif.event_id = event_id; Loading system/gd/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -412,6 +412,7 @@ cc_test { ":BluetoothShimTestSources", ":BluetoothSecurityUnitTestSources", ":BluetoothStorageUnitTestSources", ":BluetoothBtaaSources_linux_generic_tests", ], generated_headers: [ "BluetoothGeneratedBundlerSchema_h_bfbs", Loading system/gd/btaa/Android.bp +7 −0 Original line number Diff line number Diff line Loading @@ -30,3 +30,10 @@ filegroup { "linux_generic/wakelock_processor.cc", ], } filegroup { name: "BluetoothBtaaSources_linux_generic_tests", srcs: [ "linux_generic/attribution_processor_tests.cc", ], } system/gd/btaa/attribution_processor.h +13 −0 Original line number Diff line number Diff line Loading @@ -82,7 +82,20 @@ class AttributionProcessor { void Dump( std::promise<flatbuffers::Offset<ActivityAttributionData>> promise, flatbuffers::FlatBufferBuilder* fb_builder); using ClockType = std::chrono::time_point<std::chrono::system_clock>; using NowFunc = ClockType (*)(); // by default, we use the std::chrono::system_clock::now implementation to // get the current timestamp AttributionProcessor() : now_func_(std::chrono::system_clock::now) {} // in other cases, we may need to use different implementation // e.g., for testing purposes AttributionProcessor(NowFunc func) : now_func_(func) {} private: // this function is added for testing support in // OnWakelockReleased NowFunc now_func_ = std::chrono::system_clock::now; bool wakeup_ = false; std::unordered_map<AddressActivityKey, BtaaAggregationEntry, AddressActivityKeyHasher> btaa_aggregator_; std::unordered_map<AddressActivityKey, BtaaAggregationEntry, AddressActivityKeyHasher> wakelock_duration_aggregator_; Loading system/gd/btaa/linux_generic/attribution_processor.cc +15 −9 Original line number Diff line number Diff line Loading @@ -69,7 +69,7 @@ void AttributionProcessor::OnWakelockReleased(uint32_t duration_ms) { return; } auto cur_time = std::chrono::system_clock::now(); auto cur_time = now_func_(); for (auto& it : wakelock_duration_aggregator_) { it.second.wakelock_duration_ms = (uint64_t)duration_ms * it.second.byte_count / total_byte_count; if (btaa_aggregator_.find(it.first) == btaa_aggregator_.end()) { Loading Loading @@ -126,23 +126,29 @@ void AttributionProcessor::OnWakelockReleased(uint32_t duration_ms) { } // Trim down the transient entries in the aggregator to avoid that it overgrows if (btaa_aggregator_.size() > kMapSizeTrimDownAggregationEntry) { for (auto& it : btaa_aggregator_) { auto it = btaa_aggregator_.begin(); while (it != btaa_aggregator_.end()) { auto elapsed_time_sec = std::chrono::duration_cast<std::chrono::seconds>(cur_time - it.second.creation_time).count(); std::chrono::duration_cast<std::chrono::seconds>(cur_time - it->second.creation_time).count(); if (elapsed_time_sec > kDurationTransientDeviceActivityEntrySecs && it.second.byte_count < kByteCountTransientDeviceActivityEntry) { btaa_aggregator_.erase(it.first); it->second.byte_count < kByteCountTransientDeviceActivityEntry) { it = btaa_aggregator_.erase(it); } else { it++; } } } if (app_activity_aggregator_.size() > kMapSizeTrimDownAggregationEntry) { for (auto& it : app_activity_aggregator_) { auto it = app_activity_aggregator_.begin(); while (it != app_activity_aggregator_.end()) { auto elapsed_time_sec = std::chrono::duration_cast<std::chrono::seconds>(cur_time - it.second.creation_time).count(); std::chrono::duration_cast<std::chrono::seconds>(cur_time - it->second.creation_time).count(); if (elapsed_time_sec > kDurationTransientDeviceActivityEntrySecs && it.second.byte_count < kByteCountTransientDeviceActivityEntry) { app_activity_aggregator_.erase(it.first); it->second.byte_count < kByteCountTransientDeviceActivityEntry) { it = app_activity_aggregator_.erase(it); } else { it++; } } } Loading Loading
system/btif/src/btif_rc.cc +5 −0 Original line number Diff line number Diff line Loading @@ -1959,6 +1959,11 @@ static bt_status_t register_notification_rsp( dump_rc_notification_event_id(event_id)); std::unique_lock<std::mutex> lock(btif_rc_cb.lock); if (event_id > MAX_RC_NOTIFICATIONS) { BTIF_TRACE_ERROR("Invalid event id"); return BT_STATUS_PARM_INVALID; } memset(&(avrc_rsp.reg_notif), 0, sizeof(tAVRC_REG_NOTIF_RSP)); avrc_rsp.reg_notif.event_id = event_id; Loading
system/gd/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -412,6 +412,7 @@ cc_test { ":BluetoothShimTestSources", ":BluetoothSecurityUnitTestSources", ":BluetoothStorageUnitTestSources", ":BluetoothBtaaSources_linux_generic_tests", ], generated_headers: [ "BluetoothGeneratedBundlerSchema_h_bfbs", Loading
system/gd/btaa/Android.bp +7 −0 Original line number Diff line number Diff line Loading @@ -30,3 +30,10 @@ filegroup { "linux_generic/wakelock_processor.cc", ], } filegroup { name: "BluetoothBtaaSources_linux_generic_tests", srcs: [ "linux_generic/attribution_processor_tests.cc", ], }
system/gd/btaa/attribution_processor.h +13 −0 Original line number Diff line number Diff line Loading @@ -82,7 +82,20 @@ class AttributionProcessor { void Dump( std::promise<flatbuffers::Offset<ActivityAttributionData>> promise, flatbuffers::FlatBufferBuilder* fb_builder); using ClockType = std::chrono::time_point<std::chrono::system_clock>; using NowFunc = ClockType (*)(); // by default, we use the std::chrono::system_clock::now implementation to // get the current timestamp AttributionProcessor() : now_func_(std::chrono::system_clock::now) {} // in other cases, we may need to use different implementation // e.g., for testing purposes AttributionProcessor(NowFunc func) : now_func_(func) {} private: // this function is added for testing support in // OnWakelockReleased NowFunc now_func_ = std::chrono::system_clock::now; bool wakeup_ = false; std::unordered_map<AddressActivityKey, BtaaAggregationEntry, AddressActivityKeyHasher> btaa_aggregator_; std::unordered_map<AddressActivityKey, BtaaAggregationEntry, AddressActivityKeyHasher> wakelock_duration_aggregator_; Loading
system/gd/btaa/linux_generic/attribution_processor.cc +15 −9 Original line number Diff line number Diff line Loading @@ -69,7 +69,7 @@ void AttributionProcessor::OnWakelockReleased(uint32_t duration_ms) { return; } auto cur_time = std::chrono::system_clock::now(); auto cur_time = now_func_(); for (auto& it : wakelock_duration_aggregator_) { it.second.wakelock_duration_ms = (uint64_t)duration_ms * it.second.byte_count / total_byte_count; if (btaa_aggregator_.find(it.first) == btaa_aggregator_.end()) { Loading Loading @@ -126,23 +126,29 @@ void AttributionProcessor::OnWakelockReleased(uint32_t duration_ms) { } // Trim down the transient entries in the aggregator to avoid that it overgrows if (btaa_aggregator_.size() > kMapSizeTrimDownAggregationEntry) { for (auto& it : btaa_aggregator_) { auto it = btaa_aggregator_.begin(); while (it != btaa_aggregator_.end()) { auto elapsed_time_sec = std::chrono::duration_cast<std::chrono::seconds>(cur_time - it.second.creation_time).count(); std::chrono::duration_cast<std::chrono::seconds>(cur_time - it->second.creation_time).count(); if (elapsed_time_sec > kDurationTransientDeviceActivityEntrySecs && it.second.byte_count < kByteCountTransientDeviceActivityEntry) { btaa_aggregator_.erase(it.first); it->second.byte_count < kByteCountTransientDeviceActivityEntry) { it = btaa_aggregator_.erase(it); } else { it++; } } } if (app_activity_aggregator_.size() > kMapSizeTrimDownAggregationEntry) { for (auto& it : app_activity_aggregator_) { auto it = app_activity_aggregator_.begin(); while (it != app_activity_aggregator_.end()) { auto elapsed_time_sec = std::chrono::duration_cast<std::chrono::seconds>(cur_time - it.second.creation_time).count(); std::chrono::duration_cast<std::chrono::seconds>(cur_time - it->second.creation_time).count(); if (elapsed_time_sec > kDurationTransientDeviceActivityEntrySecs && it.second.byte_count < kByteCountTransientDeviceActivityEntry) { app_activity_aggregator_.erase(it.first); it->second.byte_count < kByteCountTransientDeviceActivityEntry) { it = app_activity_aggregator_.erase(it); } else { it++; } } } Loading