-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge changes I02cc2057,Icb879814,I468ac585,Idf93afcf,If3006967, ... …
…am: f54f80e am: a6efacd am: beb2aba Original change: https://android-review.googlesource.com/c/platform/system/bt/+/1680525 Change-Id: Ied9619c078bedb4b1bfad9c2ed04eb8d0b3b7d5f
- Loading branch information
Showing
17 changed files
with
1,321 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
namespace bluetooth.activity_attribution; | ||
|
||
attribute "privacy"; | ||
|
||
table WakeupEntry { | ||
wakeup_time:string; | ||
activity:string; | ||
address:string; | ||
} | ||
|
||
table DeviceActivityAggregationEntry { | ||
address:string; | ||
activity:string; | ||
wakeup_count:int; | ||
byte_count:int; | ||
wakelock_duration_ms:int; | ||
creation_time:string; | ||
} | ||
|
||
table ActivityAttributionData { | ||
title_wakeup:string; | ||
num_wakeup:int; | ||
wakeup_attribution:[WakeupEntry]; | ||
title_activity:string; | ||
num_device_activity:int; | ||
device_activity_aggregation:[DeviceActivityAggregationEntry]; | ||
} | ||
|
||
root_type ActivityAttributionData; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright 2020 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <cstdint> | ||
#include <unordered_map> | ||
|
||
#include "hci_processor.h" | ||
|
||
namespace bluetooth { | ||
namespace activity_attribution { | ||
|
||
static constexpr size_t kWakeupAggregatorSize = 200; | ||
|
||
struct AddressActivityKey { | ||
hci::Address address; | ||
Activity activity; | ||
|
||
bool operator==(const AddressActivityKey& other) const { | ||
return (address == other.address && activity == other.activity); | ||
} | ||
}; | ||
|
||
struct AddressActivityKeyHasher { | ||
std::size_t operator()(const AddressActivityKey& key) const { | ||
return ( | ||
(std::hash<std::string>()(key.address.ToString()) ^ | ||
(std::hash<unsigned char>()(static_cast<unsigned char>(key.activity))))); | ||
} | ||
}; | ||
|
||
struct WakeupDescriptor { | ||
Activity activity_; | ||
const hci::Address address_; | ||
WakeupDescriptor(Activity activity, const hci::Address address) : activity_(activity), address_(address) {} | ||
virtual ~WakeupDescriptor() {} | ||
}; | ||
|
||
class AttributionProcessor { | ||
public: | ||
void OnBtaaPackets(std::vector<BtaaHciPacket> btaa_packets); | ||
void OnWakelockReleased(uint32_t duration_ms); | ||
void OnWakeup(); | ||
void Dump( | ||
std::promise<flatbuffers::Offset<ActivityAttributionData>> promise, flatbuffers::FlatBufferBuilder* fb_builder); | ||
|
||
private: | ||
bool wakeup_ = false; | ||
std::unordered_map<AddressActivityKey, BtaaAggregationEntry, AddressActivityKeyHasher> btaa_aggregator_; | ||
std::unordered_map<AddressActivityKey, BtaaAggregationEntry, AddressActivityKeyHasher> wakelock_duration_aggregator_; | ||
common::TimestampedCircularBuffer<WakeupDescriptor> wakeup_aggregator_ = | ||
common::TimestampedCircularBuffer<WakeupDescriptor>(kWakeupAggregatorSize); | ||
const char* ActivityToString(Activity activity); | ||
}; | ||
|
||
} // namespace activity_attribution | ||
} // namespace bluetooth |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright 2021 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "btaa/activity_attribution.h" | ||
#include "hci/hci_packets.h" | ||
|
||
namespace bluetooth { | ||
namespace activity_attribution { | ||
|
||
struct CmdEvtActivityClassification { | ||
Activity activity; | ||
uint16_t connection_handle_pos; | ||
uint16_t address_pos; | ||
}; | ||
|
||
CmdEvtActivityClassification lookup_cmd(hci::OpCode opcode); | ||
CmdEvtActivityClassification lookup_event(hci::EventCode event_code); | ||
CmdEvtActivityClassification lookup_le_event(hci::SubeventCode subevent_code); | ||
|
||
} // namespace activity_attribution | ||
} // namespace bluetooth |
Oops, something went wrong.