davinci: parts: Add support for camera popup light

Change-Id: I531123cc6db5e823490c0c5bcf31bafe068a49f5
This commit is contained in:
TheScarastic 2019-09-14 23:31:49 +05:30 committed by Arian
parent 89e3be0eee
commit 932a2bcad0
No known key found for this signature in database
GPG Key ID: 48029380598CE3B9
2 changed files with 16 additions and 0 deletions

View File

@ -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";
}

View File

@ -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);