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.
The app demonstrates 4 key hardware interactions through Android's HAL (Hardware Abstraction Layer):
- Turns your device's camera flash on/off
- Flow: App →
CameraManager.setTorchMode()→ CameraService → Camera HAL → Kernel → LED
- Records audio and shows real-time sound level measurements
- Flow: App →
AudioRecord→ AudioFlinger → Audio HAL → Kernel → Microphone
- Displays live accelerometer sensor data (x, y, z coordinates)
- Flow: App →
SensorManager→ SensorService → Sensors HAL → Kernel → Sensor
- Triggers device vibration motor
- Flow: App →
Vibrator/VibratorManager→ VibratorService → Vibrator HAL → Kernel → Motor
Each action logs the complete path from your app through Android services to the hardware, helping you understand the Android system architecture.
- Android Studio (latest version)
- Physical Android device (recommended - flashlight and sensors work best on real hardware)
- Android 8.0+ (API 26+) device
-
Import Project
- Open Android Studio
- Select "Open an Existing Project"
- Navigate to and select the
ART_HAL_Demofolder
-
Connect Device
- Enable Developer Options on your Android device
- Enable USB Debugging
- Connect via USB cable
-
Build & Run
- Click the green "Run" button in Android Studio
- Select your connected device
- Wait for the app to install and launch
-
Grant Permissions
- When prompted, grant Camera and Microphone permissions
- These are required for flashlight and audio features
- Tap any button to test hardware features
- Watch the log area at the bottom - it shows the complete system call path
- 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
- Real-time logging of each hardware call
- Audio level measurements in dBFS
- Live accelerometer readings (x, y, z values)
- Complete Android system stack visualization
- 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)