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

Commit f715bf95 authored by Wu-cheng Li's avatar Wu-cheng Li
Browse files

Unhide camera focus area and metering area API.

These API are for touch focus.

bug:3475893

Change-Id: I1e213c0bed0c6fe18dcbfb0457c51c52e7cfae30
parent 88eb5c07
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -8624,6 +8624,12 @@ package android.hardware {
    field public static final int CAMERA_ERROR_UNKNOWN = 1; // 0x1
  }
  public static class Camera.Area {
    ctor public Camera.Area(android.graphics.Rect, int);
    field public android.graphics.Rect rect;
    field public int weight;
  }
  public static abstract interface Camera.AutoFocusCallback {
    method public abstract void onAutoFocus(boolean, android.hardware.Camera);
  }
@@ -8653,6 +8659,7 @@ package android.hardware {
    method public float getExposureCompensationStep();
    method public java.lang.String getFlashMode();
    method public float getFocalLength();
    method public java.util.List<android.hardware.Camera.Area> getFocusAreas();
    method public void getFocusDistances(float[]);
    method public java.lang.String getFocusMode();
    method public float getHorizontalViewAngle();
@@ -8661,7 +8668,10 @@ package android.hardware {
    method public int getJpegThumbnailQuality();
    method public android.hardware.Camera.Size getJpegThumbnailSize();
    method public int getMaxExposureCompensation();
    method public int getMaxNumFocusAreas();
    method public int getMaxNumMeteringAreas();
    method public int getMaxZoom();
    method public java.util.List<android.hardware.Camera.Area> getMeteringAreas();
    method public int getMinExposureCompensation();
    method public int getPictureFormat();
    method public android.hardware.Camera.Size getPictureSize();
@@ -8699,6 +8709,7 @@ package android.hardware {
    method public void setColorEffect(java.lang.String);
    method public void setExposureCompensation(int);
    method public void setFlashMode(java.lang.String);
    method public void setFocusAreas(java.util.List<android.hardware.Camera.Area>);
    method public void setFocusMode(java.lang.String);
    method public void setGpsAltitude(double);
    method public void setGpsLatitude(double);
@@ -8708,6 +8719,7 @@ package android.hardware {
    method public void setJpegQuality(int);
    method public void setJpegThumbnailQuality(int);
    method public void setJpegThumbnailSize(int, int);
    method public void setMeteringAreas(java.util.List<android.hardware.Camera.Area>);
    method public void setPictureFormat(int);
    method public void setPictureSize(int, int);
    method public void setPreviewFormat(int);
+41 −34
Original line number Diff line number Diff line
@@ -1088,7 +1088,6 @@ public class Camera {
     *
     * @see #setFocusAreas(List)
     * @see #getFocusAreas()
     * @hide
     */
    public static class Area {
        /**
@@ -1521,6 +1520,9 @@ public class Camera {
        }

        private void set(String key, List<Area> areas) {
            if (areas == null) {
                set(key, "(0,0,0,0,0)");
            } else {
                StringBuilder buffer = new StringBuilder();
                for (int i = 0; i < areas.size(); i++) {
                    Area area = areas.get(i);
@@ -1540,6 +1542,7 @@ public class Camera {
                }
                set(key, buffer.toString());
            }
        }

        /**
         * Returns the value of a String parameter.
@@ -2578,7 +2581,6 @@ public class Camera {
         *
         * @return the maximum number of focus areas supported by the camera.
         * @see #getFocusAreas()
         * @hide
         */
        public int getMaxNumFocusAreas() {
            return getInt(KEY_MAX_NUM_FOCUS_AREAS, 0);
@@ -2607,10 +2609,10 @@ public class Camera {
         * area. Focus areas can partially overlap and the driver will add the
         * weights in the overlap region.
         *
         * A special case of all-zero single focus area means driver to decide
         * the focus area. For example, the driver may use more signals to
         * decide focus areas and change them dynamically. Apps can set all-zero
         * if they want the driver to decide focus areas.
         * A special case of null focus area means driver to decide the focus
         * area. For example, the driver may use more signals to decide focus
         * areas and change them dynamically. Apps can set all-zero if they want
         * the driver to decide focus areas.
         *
         * Focus areas are relative to the current field of view
         * ({@link #getZoom()}). No matter what the zoom level is, (-1000,-1000)
@@ -2623,10 +2625,9 @@ public class Camera {
         * {@link #FOCUS_MODE_CONTINUOUS_VIDEO}.
         *
         * @return a list of current focus areas
         * @hide
         */
        public List<Area> getFocusAreas() {
            return splitArea(KEY_FOCUS_AREAS);
            return splitArea(get(KEY_FOCUS_AREAS));
        }

        /**
@@ -2634,7 +2635,6 @@ public class Camera {
         *
         * @param focusAreas the focus areas
         * @see #getFocusAreas()
         * @hide
         */
        public void setFocusAreas(List<Area> focusAreas) {
            set(KEY_FOCUS_AREAS, focusAreas);
@@ -2647,7 +2647,6 @@ public class Camera {
         *
         * @return the maximum number of metering areas supported by the camera.
         * @see #getMeteringAreas()
         * @hide
         */
        public int getMaxNumMeteringAreas() {
            return getInt(KEY_MAX_NUM_METERING_AREAS, 0);
@@ -2676,10 +2675,10 @@ public class Camera {
         * metering result.  Metering areas can partially overlap and the driver
         * will add the weights in the overlap region.
         *
         * A special case of all-zero single metering area means driver to
         * decide the metering area. For example, the driver may use more
         * signals to decide metering areas and change them dynamically. Apps
         * can set all-zero if they want the driver to decide metering areas.
         * A special case of null metering area means driver to decide the
         * metering area. For example, the driver may use more signals to decide
         * metering areas and change them dynamically. Apps can set all-zero if
         * they want the driver to decide metering areas.
         *
         * Metering areas are relative to the current field of view
         * ({@link #getZoom()}). No matter what the zoom level is, (-1000,-1000)
@@ -2691,7 +2690,6 @@ public class Camera {
         * by {@link #setExposureCompensation(int)}.
         *
         * @return a list of current metering areas
         * @hide
         */
        public List<Area> getMeteringAreas() {
            return splitArea(KEY_METERING_AREAS);
@@ -2703,7 +2701,6 @@ public class Camera {
         *
         * @param meteringAreas the metering areas
         * @see #getMeteringAreas()
         * @hide
         */
        public void setMeteringAreas(List<Area> meteringAreas) {
            set(KEY_METERING_AREAS, meteringAreas);
@@ -2837,7 +2834,7 @@ public class Camera {

        // Splits a comma delimited string to an ArrayList of Area objects.
        // Example string: "(-10,-10,0,0,300),(0,0,10,10,700)". Return null if
        // the passing string is null or the size is 0.
        // the passing string is null or the size is 0 or (0,0,0,0,0).
        private ArrayList<Area> splitArea(String str) {
            if (str == null || str.charAt(0) != '('
                    || str.charAt(str.length() - 1) != ')') {
@@ -2858,6 +2855,16 @@ public class Camera {
            } while (endIndex != str.length() - 1);

            if (result.size() == 0) return null;

            if (result.size() == 1) {
                Area area = (Area) result.get(0);
                Rect rect = area.rect;
                if (rect.left == 0 && rect.top == 0 && rect.right == 0
                        && rect.bottom == 0 && area.weight == 0) {
                    return null;
                }
            }

            return result;
        }
    };