Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 04ef5b5f authored by Roman Birg's avatar Roman Birg
Browse files

TorchService: improve state management



Always dispatch state when tearing torch down.

Change-Id: Ia2fbab421e552bf48f951625dd4eea48ace20363
Signed-off-by: default avatarRoman Birg <roman@cyngn.com>
parent 0f4bcc4a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -588,9 +588,9 @@ public class Camera {
     * <p>You must call this as soon as you're done with the Camera object.</p>
     */
    public final void release() {
        notifyTorch(false);
        native_release();
        mFaceDetectionRunning = false;
        notifyTorch(false);
    }

    /**
+1 −3
Original line number Diff line number Diff line
@@ -347,6 +347,7 @@ public class TorchService extends ITorchService.Stub {
    }

    private void teardownTorch() {
        dispatchStateChange(false);
        if (mCameraDevice != null) {
            mCameraDevice.close();
            mCameraDevice = null;
@@ -367,7 +368,6 @@ public class TorchService extends ITorchService.Stub {
            mTorchEnabled = false;
        }
        dispatchError();
        dispatchStateChange(false);
        updateFlashlight(true /* forceDisable */);
    }

@@ -386,7 +386,6 @@ public class TorchService extends ITorchService.Stub {
                mTorchEnabled = false;
            }
            updateFlashlight(true /* forceDisable */);
            dispatchStateChange(false);
        }
    };

@@ -439,7 +438,6 @@ public class TorchService extends ITorchService.Stub {
        @Override
        public void onDisconnected(CameraDevice camera) {
            if (mCameraDevice == camera) {
                dispatchStateChange(false);
                teardownTorch();
            }
        }