flashlight_torch

command
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2026 License: CC0-1.0 Imports: 10 Imported by: 0

Documentation

Overview

Toggle the Android flashlight/torch on and off via the camera service binder.

Uses ICameraService.SetTorchMode to control the torch for camera "0". By default, turns the torch ON for 3 seconds, then turns it OFF. Pass "on" or "off" as a command-line argument to set a specific state.

Note: the framework camera service (media.camera) requires the caller to hold android.permission.CAMERA. From the adb shell context this typically fails with a permission error. Run from an app context or with elevated privileges for full functionality.

Build:

GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -o build/flashlight_torch ./examples/flashlight_torch/
adb push build/flashlight_torch /data/local/tmp/ && adb shell /data/local/tmp/flashlight_torch

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL