summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Lesinski <adamlesinski@google.com>2015-12-03 11:40:47 -0800
committerAdam Lesinski <adamlesinski@google.com>2016-01-20 16:47:00 -0800
commite2d316d2c9885b63e69c6cc85fabf564ea04cb76 (patch)
treefbd52dd360cb90dbe01cf62930cd390221a6db6c
parentc045e7b8ca9b915e33a12df81ea07dac85e3c454 (diff)
downloadlibhardware-e2d316d2c9885b63e69c6cc85fabf564ea04cb76.tar.gz
Add Bluetooth network traffic accounting to HAL API
Introduces a UID traffic struct and includes it in the API for querying energy usage data. Also adds the calling UID as a parameter for starting sockets so that network traffic can be tracked. Bug:26039657 Change-Id: I9f4a130adc2846467063e7a9a4ea2231af06a80b
-rw-r--r--include/hardware/bluetooth.h14
-rw-r--r--include/hardware/bt_sock.h10
2 files changed, 19 insertions, 5 deletions
diff --git a/include/hardware/bluetooth.h b/include/hardware/bluetooth.h
index 683e369c..8ddc2517 100644
--- a/include/hardware/bluetooth.h
+++ b/include/hardware/bluetooth.h
@@ -107,6 +107,12 @@ typedef struct {
uint64_t energy_used; /* a product of mA, V and ms */
} __attribute__((packed))bt_activity_energy_info;
+typedef struct {
+ int32_t app_uid;
+ uint64_t tx_bytes;
+ uint64_t rx_bytes;
+} __attribute__((packed))bt_uid_traffic_t;
+
/** Bluetooth Adapter Discovery state */
typedef enum {
BT_DISCOVERY_STOPPED,
@@ -378,8 +384,12 @@ typedef void (*le_test_mode_callback)(bt_status_t status, uint16_t num_packets);
* If the ctrl_state value is 0, it means the API call failed
* Time values-In milliseconds as returned by the controller
* Energy used-Value as returned by the controller
- * Status-Provides the status of the read_energy_info API call */
-typedef void (*energy_info_callback)(bt_activity_energy_info *energy_info);
+ * Status-Provides the status of the read_energy_info API call
+ * uid_data provides an array of bt_uid_traffic_t, where the array is terminated by an element with
+ * app_uid set to -1.
+ */
+typedef void (*energy_info_callback)(bt_activity_energy_info *energy_info,
+ bt_uid_traffic_t *uid_data);
/** TODO: Add callbacks for Link Up/Down and other generic
* notifications/callbacks */
diff --git a/include/hardware/bt_sock.h b/include/hardware/bt_sock.h
index 5d206d7f..8d1a9e0f 100644
--- a/include/hardware/bt_sock.h
+++ b/include/hardware/bt_sock.h
@@ -56,16 +56,20 @@ typedef struct {
* If neither a UUID nor a channel is provided, a channel will be allocated
* and a service record can be created providing the channel number to
* create_sdp_record(...) in bt_sdp.
+ * The callingUid is the UID of the application which is requesting the socket. This is
+ * used for traffic accounting purposes.
*/
bt_status_t (*listen)(btsock_type_t type, const char* service_name,
- const uint8_t* service_uuid, int channel, int* sock_fd, int flags);
+ const uint8_t* service_uuid, int channel, int* sock_fd, int flags, int callingUid);
/**
* Connect to a RFCOMM UUID channel of remote device, It returns the socket fd from which
- * the btsock_connect_signal and a new socket fd to be accepted can be read out when connected
+ * the btsock_connect_signal and a new socket fd to be accepted can be read out when connected.
+ * The callingUid is the UID of the application which is requesting the socket. This is
+ * used for traffic accounting purposes.
*/
bt_status_t (*connect)(const bt_bdaddr_t *bd_addr, btsock_type_t type, const uint8_t* uuid,
- int channel, int* sock_fd, int flags);
+ int channel, int* sock_fd, int flags, int callingUid);
} btsock_interface_t;
__END_DECLS