The Dashcam app is designed to integrate with AAOS, providing drivers with video recording capabilities for enhanced safety and security. This guide outlines the technical requirements, integration steps, and best practices to ensure a successful implementation.
Prerequisites
Before you continue, ensure these preconditions are fulfilled:
SDK:
- SDK 31 or higher is required.
Hardware:
- EVS or Camera2 cameras available to AAOS.
- Sufficient internal storage space or support for removable external storage
must be available for video recordings.
Software requirements:
- Unbundled support. To learn more, see Unbundled Apps.
- Permissions. Dashcam requires system permissions.
Get the source code
Find the source code in Android Code Search at:
Source code is provided in these three modules:
- Dashcam Service. Streaming, recording, and triggering logic.
- Dashcam Manager. Connects to the Dashcam Service and exposes a stable API to clients
- Dashcam App. Reference Dashcam application using the Dashcam Manager API
Build Dashcam
Use Soong or Gradle to build Dashcam.
Soong
Before building from Soong, be sure to clean the .cxx
directories.
On Soong:
mma DashcamService DashcamManager-lib DashcamApp
The APKs are located in out/target/product/[lunch-target]/system/priv-app/
Gradle
On Gradle:
./gradlew :dashcam-app:assemble
./gradlew :dashcam-manager:assemble
./gradlew :dashcam-service:assemble
The APKs are located in out/aaos-apps-gradle-build/
Detailed instructions for building Dashcam with Gradle are provided in the
README
file.
Permissions
Several system permissions are required for the Dashcam Service and the Dashcam App.
The most staight-forward way to grant these permissions is to include them in a prebuilt setup using either Blueprint or Make.
In Blueprint:
Android.bp
android_app_import {
name: "DashcamApp-prebuilt",
apk: "DashcamApp.apk",
privileged: true,
certificate: "platform",
required: ["allowed_privapp_com.android.car.dashcam"],
}
In Make:
dashcam.mk
PRODUCT_PACKAGES += \
DashcamApp
PRODUCT_COPY_FILES :=\
vendor/[path-to-vendor-prebuilts]/apps/CarCatApp/allowed_privapp_com.android.car.dashcam:$(TARGET_COPY_OUT_PRODUCT)/etc/permissions/com.android.car.dashcam.xml \
Create a permissions file named allowed_privapp_com.android.car.dashcam.xml
:
<permissions>
<privapp-permissions package="com.android.car.dashcam.service">
<permission name="" />
</privapp-permissions>
<privapp-permissions package="com.android.car.dashcam.app">
<permission name="" />
</privapp-permissions>
</permissions>
Add permissions from Manifest to the permissions file.
To learn more, see Prebuilt into a system image.
Sideload
The permissions file can also be sideloaded. Use this method when the prebuilt Dashcam is not configured.
Using the permissions file created in the prebuilts section previously, run:
adb root
adb remount
adb push allowed_privapp_com.android.car.dashcam.xml /etc/permissions/allowed_privapp_com.android.car.dashcam.xml
adb shell chmod 644 /etc/permissions/allowed_privapp_com.android.car.dashcam.xml
Configure overlays
Dashcam service has overlayable configurations.
Service configuration
dashcam-service/res/values/config.xml
This file contains configurations for the service:
allow_internal_storage
Allow recordings to internal storagesave_location
The directory name to save recordings. Defaults to dashcammax_storage_mb
How much storage to allow dashcam to usemax_age_days
How long to hold onto a file before pruningboot_startup_enabled
Dashcam service start on device boot upnotifications_on
Show notifications when recording startsnative_recorder
Use NDK APIs, defaults to Java APIsnative_renderer
Use NDK APIs, defaults to Java APIsdefault_app_component
The default dashcam application, this application has global recordings access and global trigger accessrecording_module
ComponentName of IRecordingModule implementationstreaming_module
ComponentName of IRecordingModule implementationtrigger_module
ComponentName of IRecordingModule implementation
Configure a trigger
To trigger the configuration, run:
dashcam-service/src/assets/config.xml
This file contains configurations for recording triggers. The trigger configuration consists of two parts:
Pre roll ID. The ID of the camera either EVS or Camera2 depending on what is supported.
prerollLengthMs
Length of the pre roll to stored with each event.
<Preroll>
<Camera
ID="0"
prerollLengthMs="10000" />
</Preroll>
This example shows camera Id 0 with a 10 second pre roll.
name
The unique trigger namecamera
Id of the camera either EVS or Camera2 depending on what is supportedsensorPropertyID
Id of the sensordescription
Description of the trigger that is displayed in the UIrecordingLengthMs
Duration after the event to record in milliseconds.sensorType
Which type of sensor. Options areVHAL
orSENSOR_MANAGER
sensorValueType
Type of data produced by the sensor. Options areINT
,INT_ARRAY
,FLOAT
,FLOAT_ARRAY
, andBOOLEAN, STRING
thresholdType
How to evaluate the sensor value. Options areAVERAGE
,BOOLEAN
,EQUALS
,LEAP
,LEAP_AVERAGE
,LEAP_OVER
,PEAK
, andPEAK_HOLD
thresholdValue
The value to compare the sensor value to with the threshold typethresholdExtra
Extra value needed for some threshold types such as range forAVERAGE
triggerCooldown
Cool-down before firing another event of this type in millseconds.
<EventTriggers>
<EventTrigger
name="AEB"
camera="1 2"
sensorPropertyID="289411073"
description="Automatic Emergency Braking"
recordingLengthMs="20000"
sensorType="VHAL"
sensorValueType="INT"
thresholdType="EQUALS"
thresholdValue="2"
triggerCooldown="5000"/>
</EventTriggers>
This example shows a VHAL sensor producing integer values where we compare an equality to the threshold value. When the equality condition is met, a trigger records on cameras 1 and 2.
<EventTrigger
name="SPEED"
camera="1 2 3 4"
sensorPropertyID="291504648"
description="Over speed"
recordingLengthMs="10000"
sensorType="VHAL"
sensorValueType="FLOAT"
thresholdType="AVERAGE"
thresholdValue="20.0"
thresholdExtra="1000"
triggerCooldown="2000"/>
This example shows a VHAL sensor producing float values where we evaluate
the average over a range of samples against the threshold value. The sample
range is set in thresholdExtra
Modules
The Dashcam Service consists of three modules:
Stream contains the logic for handling streams from cameras.
Recording contains the logic for handling recordings.
Trigger contains the logic for triggering a recording from sensor data. The module APIs are defined in their corresponding interfaces,
IStreamModule
,IRecorderModule
, andITriggerModule
and exposed to the DashcamManager throughDashcamServiceAPI
Overlay modules
Dashcam Service uses dashcam-service/res/values/config.xml
to determine where
to find the module implementations. We provide default implementations for each
module. However, each module can be overlaid by setting its component in the
corresponding config value.
Set OEM implementation component name of
IRecorderModule
torecording_module
Set OEM implementation component name of
IStreamModule
to the streaming module.Set OEM implementation component name of
ITriggerModule
totrigger_module
At runtime, the Dashcam service instantiates the component name set in
config.xml
for each module.
App developer's guide
Dashcam is a production ready and customizable dashcam solution. Dashcam
uses Dashcam Manager APIs to communicate with Dashcam service
. The Dashcam
Manager API can be found at IDashcamManager
. Any app with the required
permissions can use Dashcam Manager.
Permissions
Camera2 and EVS are supported.
Prebuilt
The easiest way to grant these permissions is to include them in the prebuilt setup using either Blueprint or Make.
OverlayUI
The app can be customized with Runtime Resource Overlays. To learn more, see Runtime Resource Overlays. To see the list of overlayable elements, see overlayable.xml.
Extend triggers
Triggers can be extended for the current session with a call
to DashcamManager.addTrigger()
. Added triggers persist for the current session
only.
Autostart
Autostart recording is not supported. However, a manual trigger can be
started onBoot
with a call to DashcamManager.startRecording()
Best practices
Storage. External removable storage is highly recommended.
User experience. Design the Dashcam app's UI to be intuitive and user-friendly, adhering to AAOS design guidelines.
Performance optimization. Optimize the app's performance to minimize resource usage and ensure smooth operation in AAOS.
Troubleshooting
Camera Connectivity Issues. EVS or Camera2 must be supported and available in AAOS IVI.
Storage errors. Verify available storage space and manage recordings. External storage is highly recommended since using internal storage can prematurely cause storage to wear out.