Alexa Auto Device Usage¶
Alexa Auto Device Usage library provides an implementation that enables the Alexa Auto App to capture network usage data using Android NetworkStatsManager. The data is logged as a metric and is sent to Amazon endpoints.
The library consists of the following components:
AASBReceiver. This Android BroadcastReceiver subscribes to AASB StartService message and AASB StopService message, based on which the
DeviceUsageHandlercan start or stop the network data recording.
DeviceUsageHandler. The handler is responsible for starting and stopping the
NetworkStatsManagerRunner. It starts the
NetworkStatsManagerRunnerin an executor thread which queries the network usage every 5 minutes and publishes the data via DeviceUsage
ReportNetworkDataUsageMessagemessage to the Auto SDK engine.
NetworkStatsManagerRunner. This class captures the network usage data using
NetworkStatsManagerAPIs and calls the
DeviceUsageHandlerto report the data.
Providing Permissions for Alexa Auto Device Usage Library¶
Using the Alexa Auto Device Usage Library requires the Alexa Auto App to hold certain Android permissions.
If the Android version of your device is lower than 10 (Android Q): The Alexa application needs the
android.permission.READ_PHONE_STATEpermission to access the
subscriber id(associated to the eSIM of a user), which is required to query the network consumption over the
MOBILEinterface. You can grant this permission to Alexa Auto App in "Settings" -> "Apps & notifications" -> "Alexa" -> "Permissions" -> "Phone".
If the Android version of your device is 10 (Android Q) or higher: The Alexa application must be installed as a privileged system application and it must have the
android.permission.READ_PRIVILEGED_PHONE_STATEprivileged permission in order to be able to get the
Note The Alexa Auto Device Usage Library carries all the Android permissions (
PACKAGE_USAGE_STATS) your application needs in order to enable the network usage data recording. To use this library, make sure your Alexa Auto App is built with the
-PenabledDeviceUsageoption, as specified in the Building Alexa Auto App with Alexa Auto Device Usage Library section. If your device is on Android 10 or higher version, install Alexa Auto App as a system privileged app, and place the following
privapp-permissions-com.amazon.alexa.auto.app.xmlfile under the
/etc/permissionsdirectory on your device:
<?xml version="1.0" encoding="utf-8"?> <permissions> <privapp-permissions package="com.amazon.alexa.auto.app"> <permission name="android.permission.READ_PRIVILEGED_PHONE_STATE" /> <permission name="android.permission.PACKAGE_USAGE_STATS" /> </privapp-permissions> </permissions>