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
Click to show internal directories.
Click to hide internal directories.