davinci: parts: Add support for camera popup light
Change-Id: I531123cc6db5e823490c0c5bcf31bafe068a49f5
This commit is contained in:
parent
89e3be0eee
commit
932a2bcad0
@ -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";
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user