• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ANDROID_INCLUDE_BT_ACTIVITY_ATTRIBUTION_H
18 #define ANDROID_INCLUDE_BT_ACTIVITY_ATTRIBUTION_H
19 
20 #include <vector>
21 
22 #include "raw_address.h"
23 
24 namespace bluetooth {
25 namespace activity_attribution {
26 
27 class ActivityAttributionCallbacks {
28  public:
29   enum class Activity : uint8_t {
30     UNKNOWN = 0,
31     ACL,
32     ADVERTISE,
33     CONNECT,
34     CONTROL,
35     HFP,
36     ISO,
37     SCAN,
38     VENDOR,
39   };
40 
41   struct BtaaAggregationEntry {
42     RawAddress address;
43     Activity activity;
44     uint16_t wakeup_count;
45     uint32_t byte_count;
46     uint32_t wakelock_duration;
47   };
48 
49   virtual ~ActivityAttributionCallbacks() = default;
50 
51   /** Callback when Bluetooth woke up the system */
52   virtual void OnWakeup(const Activity activity, const RawAddress& address) = 0;
53 
54   /** Callback when Bluetooth activity logs are ready to be moved */
55   virtual void OnActivityLogsReady(
56       const std::vector<BtaaAggregationEntry> logs) = 0;
57 };
58 
59 class ActivityAttributionInterface {
60  public:
61   virtual ~ActivityAttributionInterface() = default;
62 
63   /** Init the interface. */
64   virtual void Init(void) = 0;
65 
66   /** Register JNI callbacks with the interface. */
67   virtual void RegisterCallbacks(ActivityAttributionCallbacks* callbacks) = 0;
68 
69   /** Closes the interface. */
70   virtual void Cleanup(void) = 0;
71 };
72 
73 }  // namespace activity_attribution
74 }  // namespace bluetooth
75 
76 #endif /* ANDROID_INCLUDE_BT_ACTIVITY_ATTRIBUTION_H */
77