From b4dca743ea1172e9b545ccd7d2808c46e11f974b Mon Sep 17 00:00:00 2001 From: jhenrique09 Date: Sun, 5 Apr 2020 15:47:01 -0300 Subject: [PATCH] davinci: parts: Try to take the motor back on boot when opened Co-authored-by: Arian Change-Id: I36ff53e23221b6704f0fa5e108329722cf71f504 --- .../settings/popupcamera/PopupCameraService.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/parts/src/org/lineageos/settings/popupcamera/PopupCameraService.java b/parts/src/org/lineageos/settings/popupcamera/PopupCameraService.java index 265e088..7b50adf 100644 --- a/parts/src/org/lineageos/settings/popupcamera/PopupCameraService.java +++ b/parts/src/org/lineageos/settings/popupcamera/PopupCameraService.java @@ -134,9 +134,23 @@ public class PopupCameraService extends Service implements Handler.Callback { } } + private void onBootCompleted(){ + try { + int status = mMotor.getMotorStatus(); + if (status == Constants.MOTOR_STATUS_POPUP || + status == Constants.MOTOR_STATUS_TAKEBACK_JAM) { + if (DEBUG) Log.d(TAG, "Opened front camera detected, taking back"); + mMotor.takebackMotor(1); + } + } catch (RemoteException e) { + // Do nothing + } + } + @Override public int onStartCommand(Intent intent, int flags, int startId) { if (DEBUG) Log.d(TAG, "Starting service"); + onBootCompleted(); return START_STICKY; }