diff --git a/parts/src/org/lineageos/settings/popupcamera/Constants.java b/parts/src/org/lineageos/settings/popupcamera/Constants.java index 169188e..ec5cca6 100644 --- a/parts/src/org/lineageos/settings/popupcamera/Constants.java +++ b/parts/src/org/lineageos/settings/popupcamera/Constants.java @@ -32,4 +32,6 @@ public class Constants { public static final String OPEN_CAMERA_STATE = "1"; public static final String FRONT_CAMERA_ID = "1"; + public static final String BLUE_LED_PATH = "/sys/class/leds/blue/brightness"; + public static final String GREEN_LED_PATH = "/sys/class/leds/green/brightness"; } diff --git a/parts/src/org/lineageos/settings/popupcamera/PopupCameraService.java b/parts/src/org/lineageos/settings/popupcamera/PopupCameraService.java index 2d7781c..27598d7 100644 --- a/parts/src/org/lineageos/settings/popupcamera/PopupCameraService.java +++ b/parts/src/org/lineageos/settings/popupcamera/PopupCameraService.java @@ -137,11 +137,13 @@ public class PopupCameraService extends Service implements Handler.Callback { try { if (cameraState.equals(Constants.OPEN_CAMERA_STATE) && mMotor.getMotorStatus() == Constants.MOTOR_STATUS_TAKEBACK) { + lightUp(); mMotor.popupMotor(1); mSensorManager.registerListener(mFreeFallListener, mFreeFallSensor, SensorManager.SENSOR_DELAY_NORMAL); } else if (cameraState.equals(Constants.CLOSE_CAMERA_STATE) && mMotor.getMotorStatus() == Constants.MOTOR_STATUS_POPUP) { + lightUp(); mMotor.takebackMotor(1); mSensorManager.unregisterListener(mFreeFallListener, mFreeFallSensor); } @@ -150,6 +152,18 @@ public class PopupCameraService extends Service implements Handler.Callback { } } + private void lightUp() { + if (mPopupCameraPreferences.isLedAllowed()) { + FileUtils.writeLine(Constants.GREEN_LED_PATH, "255"); + FileUtils.writeLine(Constants.BLUE_LED_PATH, "255"); + + mHandler.postDelayed(() -> { + FileUtils.writeLine(Constants.GREEN_LED_PATH, "0"); + FileUtils.writeLine(Constants.BLUE_LED_PATH, "0"); + }, 1200); + } + } + public void goBackHome() { Intent homeIntent = new Intent(Intent.ACTION_MAIN); homeIntent.addCategory(Intent.CATEGORY_HOME);