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

Commit 26b1e96c authored by Ricardo Cerqueira's avatar Ricardo Cerqueira
Browse files

Add an option to maintain the focus mode when using touch-to-focus

There's at least one family of camera HALs that gets "confused" when
the focus mode forcefully changes to auto after setting focus /
exposure area options.

Sticking with the current focus mode still results in effective use
of the focus region, so don't force a switch to auto. The default
behavior remains the original, this needs to be explicitly enabled
on affected devices

Change-Id: Icdb1eb628f5ae4432bf03a64b38bbf054ba005a0
parent 0522555a
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -47,4 +47,7 @@
    <bool name="needsHTCCamMode">false</bool>
    <!-- Always use recording dimensions for preview -->
    <bool name="useVideoSizeForPreview">false</bool>
    <!-- Stay in continuous focus even if touch-to-focus is used
         This option doesn't make sense if wantsFocusModes is on -->
    <bool name="useContinuosFocusForTouch">false</bool>
</resources>
+2 −1
Original line number Diff line number Diff line
@@ -428,7 +428,8 @@ public class FocusOverlayManager {
        if (mParameters == null) return Parameters.FOCUS_MODE_AUTO;
        List<String> supportedFocusModes = mParameters.getSupportedFocusModes();

        if (mFocusAreaSupported && !mFocusDefault) {
        if (mFocusAreaSupported && !mFocusDefault
                 && !Util.noFocusModeChangeForTouch()) {
            // Always use autofocus in tap-to-focus.
            mFocusMode = Parameters.FOCUS_MODE_AUTO;
        } else {
+11 −0
Original line number Diff line number Diff line
@@ -157,6 +157,9 @@ public class Util {
    // HTC camcorder mode
    private static boolean sHTCCamMode;

    // Do not change the focus mode when TTF is used
    private static boolean sNoFocusModeChangeForTouch;

    private Util() {
    }

@@ -182,6 +185,10 @@ public class Util {
        sEarlyVideoSize = context.getResources().getBoolean(R.bool.needsEarlyVideoSize);
        sSamsungCamMode = context.getResources().getBoolean(R.bool.needsSamsungCamMode);
        sHTCCamMode = context.getResources().getBoolean(R.bool.needsHTCCamMode);

        sNoFocusModeChangeForTouch = context.getResources().getBoolean(
                R.bool.useContinuosFocusForTouch);

    }

    public static int dpToPixel(int dp) {
@@ -215,6 +222,10 @@ public class Util {
        return sSamsungCamMode;
    }

    public static boolean noFocusModeChangeForTouch() {
        return sNoFocusModeChangeForTouch;
    }

    // Rotates the bitmap by the specified degree.
    // If a new bitmap is created, the original bitmap is recycled.
    public static Bitmap rotate(Bitmap b, int degrees) {