Skip to content

DriveSense

Android CI License Android

DriveSense is an experimental Android research app that estimates driver eye state from a front camera, optionally recognizes coarse road-object categories from a rear camera, and produces an on-device sound/vibration alert after eyes appear closed continuously for 1.5 seconds.

Caution

DriveSense is not a certified medical device, advanced driver-assistance system, or safety product. It can miss events, produce false alerts, and fail on unsupported hardware. Never rely on it to operate a vehicle or replace attentive driving.

Version 0.1.0 is the first source-only public release. No prebuilt or debug-signed APK is distributed.

Current device snapshot

DriveSense running on a physical Android device with driving detection and experimental road-object controls

The screenshot above is a current physical-device capture of DriveSense showing the vehicle-motion gate, driver preview, and experimental road-object controls. The app remains experimental and must not be used as a safety system. A separate clean-emulator smoke test verifies that denying camera permission leaves a readable error state.

DriveSense camera permission prompt during first launch

Runtime architecture

DriveSense on-device runtime architecture

The front-camera path combines ML Kit face signals and MediaPipe landmarks. Each available signal is smoothed and classified as open, closed, or unknown; a conservative vote resolves equal open/closed evidence as open. A monotonic clock changes the state to drowsy only after the closed result persists for at least 1.5 seconds. Open eyes or no face reset both the timer and smoothing state.

Road-object detection is optional and experimental. It requires a device that can operate the front and rear cameras concurrently. Activity Recognition can gate alertness reporting to detected IN_VEHICLE transitions, but it is optional and can be disabled in the app.

Reproducible source build

DriveSense source-only build and release flow

The MediaPipe task model is deliberately excluded from Git. Its URL and SHA-256 are pinned in app/build.gradle.

Prerequisites

  • JDK 17.
  • Android SDK Platform 34 and a configured ANDROID_HOME or ANDROID_SDK_ROOT.
  • A physical Android 7.0+ device with a front camera for camera behavior.
  • Git and an internet connection for the first dependency/model preparation.

Prepare the model

macOS/Linux:

./gradlew prepareModels
./gradlew verifyModels

Windows PowerShell:

.\gradlew.bat prepareModels
.\gradlew.bat verifyModels

prepareModels is the only task that downloads the model. preBuild runs verifyModels and never downloads silently. A missing or mismatched file fails with the command needed to repair it.

Build and test

macOS/Linux:

./gradlew testDebugUnitTest lintDebug assembleDebug

Windows PowerShell:

.\gradlew.bat testDebugUnitTest lintDebug assembleDebug

CI uses JDK 17 and also runs a permission-denied instrumentation test on a clean emulator. Camera detection, tone, vibration, lifecycle, and concurrent-camera behavior still require manual testing on physical hardware.

Permissions

Permission Why it is requested Required?
Camera Analyze driver-facing frames and, on supported devices, optional road-facing frames. Required for alertness estimates
Physical activity Receive IN_VEHICLE enter/exit transitions used by the optional driving gate. Optional
Vibration Produce a local drowsiness alert. Optional feedback

DriveSense does not request wake-lock, storage, location, microphone, or its own internet permission. Some bundled Google SDKs inherit network capabilities and may use network access for metrics, configuration, or updates.

Privacy

  • Camera frames are processed on the device and are not recorded by DriveSense.
  • DriveSense does not upload frames or detection results.
  • Only local UI settings are stored in shared preferences; Android backup and device transfer are disabled for them.
  • Google SDK behavior is governed by the relevant Google terms and may include network access for metrics, configuration, or updates. See PRIVACY.md and THIRD_PARTY_NOTICES.md.

Supported hardware and known limitations

  • Alertness estimation requires a front camera and faces/eyes visible under adequate lighting.
  • Optional road overlays require a front+rear concurrent camera combination reported by CameraX/Camera2. Unsupported devices keep that feature disabled.
  • ML Kit's base object classifier recognizes only coarse categories; overlays are not traffic-sign, lane, collision, or hazard detection.
  • Glasses, occlusion, head pose, vibration, low light, camera placement, model bias, and thermal throttling can degrade results.
  • The app is portrait-oriented and has no background service; camera analysis stops with the activity lifecycle.
  • Current pinned MediaPipe/ML Kit native libraries trigger Android 16's 16 KB page-size compatibility warning on affected devices. This is a known v0.1.0 limitation; dependency upgrades will be reviewed separately.
  • No calibration, controlled driving study, safety validation, medical validation, accessibility certification, or broad device matrix has been completed.

Project layout

app/src/main/                 Android app, resources, and internal evaluators
app/src/test/                 Deterministic JVM tests
app/src/androidTest/          Permission-denied launch smoke test
docs/                         Reviewed diagrams and screenshots
.github/workflows/            Build, emulator, CodeQL, and dependency checks
gradle/verification-metadata.xml  Reviewed dependency checksums

Contributing and security

Read CONTRIBUTING.md before opening a pull request. Use GitHub Issues for reproducible bugs and feature proposals. Report vulnerabilities privately according to SECURITY.md. Safety and privacy expectations are documented in SAFETY.md and PRIVACY.md.

License

DriveSense is licensed under the Apache License 2.0. Attribution and dependency terms are in NOTICE and THIRD_PARTY_NOTICES.md.

About

Experimental on-device Android app for driver drowsiness and road-scene awareness.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

8 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages