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

Commit 0f584c0f authored by Apurva Rajguru's avatar Apurva Rajguru Committed by Ricardo Cerqueira
Browse files

Camera: Adding frameworks support for Touch AF/AEC feature.

Change-Id: I5bd64d29d249979738d023aed3ce48b0889d76c5
parent 73a998a3
Loading
Loading
Loading
Loading
+68 −1
Original line number Diff line number Diff line
@@ -73538,6 +73538,47 @@
>
</field>
</class>
<class name="Camera.Coordinate"
 extends="java.lang.Object"
 abstract="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<constructor name="Camera.Coordinate"
 type="android.hardware.Camera.Coordinate"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="x" type="int">
</parameter>
<parameter name="y" type="int">
</parameter>
</constructor>
<field name="xCoordinate"
 type="int"
 transient="false"
 volatile="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="yCoordinate"
 type="int"
 transient="false"
 volatile="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</field>
</class>
<interface name="Camera.ErrorCallback"
 abstract="true"
 static="true"
@@ -74285,7 +74326,18 @@
>
</method>
<method name="getTouchIndexAec"
 return="android.hardware.Camera.Size"
 return="android.hardware.Camera.Coordinate"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getTouchIndexAf"
 return="android.hardware.Camera.Coordinate"
 abstract="false"
 native="false"
 synchronized="false"
@@ -74865,6 +74917,21 @@
<parameter name="y" type="int">
</parameter>
</method>
<method name="setTouchIndexAf"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="x" type="int">
</parameter>
<parameter name="y" type="int">
</parameter>
</method>
<method name="setWhiteBalance"
 return="void"
 abstract="false"
+96 −3
Original line number Diff line number Diff line
@@ -970,6 +970,43 @@ public class Camera {
        public int height;
    };

    /**
     * Handles the Touch Co-ordinate.
     */
    public class Coordinate {
        /**
         * Sets the x,y co-ordinates for a touch event
         *
         * @param x the x co-ordinate (pixels)
         * @param y the y co-ordinate (pixels)
         */
        public Coordinate(int x, int y) {
            xCoordinate = x;
            yCoordinate = y;
        }
        /**
         * Compares {@code obj} to this co-ordinate.
         *
         * @param obj the object to compare this co-ordinate with.
         * @return {@code true} if the xCoordinate and yCoordinate of {@code obj} is the
         *         same as those of this coordinate. {@code false} otherwise.
         */
        @Override
        public boolean equals(Object obj) {
            if (!(obj instanceof Coordinate)) {
                return false;
            }
            Coordinate c = (Coordinate) obj;
            return xCoordinate == c.xCoordinate && yCoordinate == c.yCoordinate;
        }

        /** x co-ordinate for the touch event*/
        public int xCoordinate;

        /** y co-ordinate for the touch event */
        public int yCoordinate;
    };

    /**
     * Camera service settings.
     *
@@ -1013,6 +1050,7 @@ public class Camera {
        private static final String KEY_EFFECT = "effect";
        private static final String KEY_TOUCH_AF_AEC = "touch-af-aec";
        private static final String KEY_TOUCH_INDEX_AEC = "touch-index-aec";
        private static final String KEY_TOUCH_INDEX_AF = "touch-index-af";
        private static final String KEY_ANTIBANDING = "antibanding";
        private static final String KEY_SCENE_MODE = "scene-mode";
        private static final String KEY_FLASH_MODE = "flash-mode";
@@ -2054,7 +2092,7 @@ public class Camera {
        }

        /**
         * Sets the touch co-ordinate for Touch AF/AEC.
         * Sets the touch co-ordinate for Touch AEC.
         *
         * @param x  the x co-ordinate of the touch event
         * @param y the y co-ordinate of the touch event
@@ -2072,9 +2110,33 @@ public class Camera {
         *          for the touch event
         *
         */
        public Size getTouchIndexAec() {
        public Coordinate getTouchIndexAec() {
            String pair = get(KEY_TOUCH_INDEX_AEC);
            return strToSize(pair);
            return strToCoordinate(pair);
        }

        /**
         * Sets the touch co-ordinate for Touch AF.
         *
         * @param x  the x co-ordinate of the touch event
         * @param y the y co-ordinate of the touch event
         *
         */
        public void setTouchIndexAf(int x, int y) {
            String v = Integer.toString(x) + "x" + Integer.toString(y);
            set(KEY_TOUCH_INDEX_AF, v);
        }

        /**
         * Returns the touch co-ordinates of the touch event.
         *
         * @return a Index object with the x and y co-ordinated
         *          for the touch event
         *
         */
        public Coordinate getTouchIndexAf() {
            String pair = get(KEY_TOUCH_INDEX_AF);
            return strToCoordinate(pair);
        }

        /**
@@ -2904,5 +2966,36 @@ public class Camera {
            if (rangeList.size() == 0) return null;
            return rangeList;
        }

        // Splits a comma delimited string to an ArrayList of Coordinate.
        // Return null if the passing string is null or the Coordinate is 0.
        private ArrayList<Coordinate> splitCoordinate(String str) {
            if (str == null) return null;

            StringTokenizer tokenizer = new StringTokenizer(str, ",");
            ArrayList<Coordinate> coordinateList = new ArrayList<Coordinate>();
            while (tokenizer.hasMoreElements()) {
                Coordinate c = strToCoordinate(tokenizer.nextToken());
                if (c != null) coordinateList.add(c);
            }
            if (coordinateList.size() == 0) return null;
            return coordinateList;
        }

        // Parses a string (ex: "500x500") to Coordinate object.
        // Return null if the passing string is null.
        private Coordinate strToCoordinate(String str) {
            if (str == null) return null;

            int pos = str.indexOf('x');
            if (pos != -1) {
                String x = str.substring(0, pos);
                String y = str.substring(pos + 1);
                return new Coordinate(Integer.parseInt(x),
                                Integer.parseInt(y));
            }
            Log.e(TAG, "Invalid Coordinate parameter string=" + str);
            return null;
        }
    };
}
+4 −0
Original line number Diff line number Diff line
@@ -73,6 +73,8 @@ public:
    const char *getPictureFormat() const;
    void setTouchIndexAec(int x, int y);
    void getTouchIndexAec(int *x, int *y) const;
    void setTouchIndexAf(int x, int y);
    void getTouchIndexAf(int *x, int *y) const;

    void dump() const;
    status_t dump(int fd, const Vector<String16>& args) const;
@@ -233,6 +235,8 @@ public:
    static const char KEY_SUPPORTED_TOUCH_AF_AEC[];
    //Touch Index for AEC.
    static const char KEY_TOUCH_INDEX_AEC[];
    //Touch Index for AF.
    static const char KEY_TOUCH_INDEX_AF[];
    // Current antibanding setting.
    // Example value: "auto" or ANTIBANDING_XXX constants. Read/write.
    static const char KEY_ANTIBANDING[];
+25 −0
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ const char CameraParameters::KEY_SUPPORTED_EFFECTS[] = "effect-values";
const char CameraParameters::KEY_TOUCH_AF_AEC[] = "touch-af-aec";
const char CameraParameters::KEY_SUPPORTED_TOUCH_AF_AEC[] = "touch-af-aec-values";
const char CameraParameters::KEY_TOUCH_INDEX_AEC[] = "touch-index-aec";
const char CameraParameters::KEY_TOUCH_INDEX_AF[] = "touch-index-af";
const char CameraParameters::KEY_ANTIBANDING[] = "antibanding";
const char CameraParameters::KEY_SUPPORTED_ANTIBANDING[] = "antibanding-values";
const char CameraParameters::KEY_SCENE_MODE[] = "scene-mode";
@@ -502,6 +503,30 @@ void CameraParameters::getTouchIndexAec(int *x, int *y) const
    }
}

void CameraParameters::setTouchIndexAf(int x, int y)
{
    char str[32];
    sprintf(str, "%dx%d", x, y);
    set(KEY_TOUCH_INDEX_AF, str);
}

void CameraParameters::getTouchIndexAf(int *x, int *y) const
{
    *x = -1;
    *y = -1;

    // Get the current string, if it doesn't exist, leave the -1x-1
    const char *p = get(KEY_TOUCH_INDEX_AF);
    if (p == 0)
        return;

    int tempX, tempY;
    if (parse_pair(p, &tempX, &tempY, 'x') == 0) {
        *x = tempX;
        *y = tempY;
    }
}

status_t CameraParameters::dump(int fd, const Vector<String16>& args) const
{
    const size_t SIZE = 256;