Skip to content

pycodeslab/ART-HAL-Demo

Repository files navigation

ART–HAL Demo (Android Studio project)

This minimal app demonstrates how your code running in Android Runtime (ART) talks to hardware indirectly via the Android Framework → System Services → HAL → Linux kernel pipeline.

Features

The app demonstrates 4 key hardware interactions through Android's HAL (Hardware Abstraction Layer):

🔦 Toggle Flashlight

  • Turns your device's camera flash on/off
  • Flow: App → CameraManager.setTorchMode()CameraServiceCamera HALKernel → LED

🎤 Audio Capture (RMS meter)

  • Records audio and shows real-time sound level measurements
  • Flow: App → AudioRecordAudioFlingerAudio HALKernel → Microphone

📱 Accelerometer Readout

  • Displays live accelerometer sensor data (x, y, z coordinates)
  • Flow: App → SensorManagerSensorServiceSensors HALKernel → Sensor

📳 Vibration

  • Triggers device vibration motor
  • Flow: App → Vibrator/VibratorManagerVibratorServiceVibrator HALKernel → Motor

Each action logs the complete path from your app through Android services to the hardware, helping you understand the Android system architecture.

How to Run

Prerequisites

  • Android Studio (latest version)
  • Physical Android device (recommended - flashlight and sensors work best on real hardware)
  • Android 8.0+ (API 26+) device

Setup Steps

  1. Import Project

    • Open Android Studio
    • Select "Open an Existing Project"
    • Navigate to and select the ART_HAL_Demo folder
  2. Connect Device

    • Enable Developer Options on your Android device
    • Enable USB Debugging
    • Connect via USB cable
  3. Build & Run

    • Click the green "Run" button in Android Studio
    • Select your connected device
    • Wait for the app to install and launch
  4. Grant Permissions

    • When prompted, grant Camera and Microphone permissions
    • These are required for flashlight and audio features

Using the App

  1. Tap any button to test hardware features
  2. Watch the log area at the bottom - it shows the complete system call path
  3. Try each feature:
    • "Toggle Flashlight" - turns camera flash on/off
    • "Start Audio Capture" - begins recording and shows audio levels
    • "Stop Audio Capture" - stops recording
    • "Vibrate" - triggers a short vibration
    • Accelerometer data updates automatically

What You'll See

  • Real-time logging of each hardware call
  • Audio level measurements in dBFS
  • Live accelerometer readings (x, y, z values)
  • Complete Android system stack visualization

Requirements

  • Min SDK: Android 8.0 (API 26)
  • Target SDK: Android 14 (API 34)
  • Permissions: Camera, Record Audio, Vibrate
  • Hardware: Camera flash, microphone, accelerometer (all optional - app handles missing hardware gracefully)

About

Android app demonstrating ART → Framework → System Services → HAL → Kernel pipeline

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages