@Override
    public void onSensorChanged(SensorEvent sensorEvent) {
        float ambientLightLux = sensorEvent.values[0];
        if (cameraManager != null) {
            if (ambientLightLux <= TOO_DARK_LUX) {
                setTorch(true);
            } else if (ambientLightLux >= BRIGHT_ENOUGH_LUX) {
                setTorch(false);
            }
        }
    }
Detects ambient light and switches on the front light when very dark, and off again when sufficiently light.

@author Sean Owen
@author Nikolaus Huber
zxing-android-embedded/src/com/google/zxing/client/android/AmbientLightManager.java