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

Commit 9805d2cc authored by Wu-cheng Li's avatar Wu-cheng Li Committed by Android (Google) Code Review
Browse files

Merge "Use back-facing camera as default in camera/camcorder profile."

parents 1ab852fb 5680635f
Loading
Loading
Loading
Loading
+26 −6
Original line number Diff line number Diff line
@@ -16,6 +16,9 @@

package android.media;

import android.hardware.Camera;
import android.hardware.Camera.CameraInfo;

/**
 * The CamcorderProfile class is used to retrieve the
 * predefined camcorder profile settings for camcorder applications.
@@ -177,13 +180,22 @@ public class CamcorderProfile
    public int audioChannels;

    /**
     * Returns the camcorder profile for the default camera at the given
     * quality level.
     * Returns the camcorder profile for the first back-facing camera on the
     * device at the given quality level. If the device has no back-facing
     * camera, this returns null.
     * @param quality the target quality level for the camcorder profile
     * @see #get(int, int)
     */
    public static CamcorderProfile get(int quality) {
        return get(0, quality);
        int numberOfCameras = Camera.getNumberOfCameras();
        CameraInfo cameraInfo = new CameraInfo();
        for (int i = 0; i < numberOfCameras; i++) {
            Camera.getCameraInfo(i, cameraInfo);
            if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) {
                return get(i, quality);
            }
        }
        return null;
    }

    /**
@@ -235,12 +247,20 @@ public class CamcorderProfile
    }

    /**
     * Returns true if camcorder profile exists for the default camera at
     * the given quality level.
     * Returns true if camcorder profile exists for the first back-facing
     * camera at the given quality level.
     * @param quality the target quality level for the camcorder profile
     */
    public static boolean hasProfile(int quality) {
        return hasProfile(0, quality);
        int numberOfCameras = Camera.getNumberOfCameras();
        CameraInfo cameraInfo = new CameraInfo();
        for (int i = 0; i < numberOfCameras; i++) {
            Camera.getCameraInfo(i, cameraInfo);
            if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) {
                return hasProfile(i, quality);
            }
        }
        return false;
    }

    /**
+14 −2
Original line number Diff line number Diff line
@@ -16,6 +16,9 @@

package android.media;

import android.hardware.Camera;
import android.hardware.Camera.CameraInfo;

import java.util.Arrays;
import java.util.HashMap;

@@ -46,12 +49,21 @@ public class CameraProfile
    /**
     * Returns a pre-defined still image capture (jpeg) quality level
     * used for the given quality level in the Camera application for
     * the default camera.
     * the first back-facing camera on the device. If the device has no
     * back-facing camera, this returns 0.
     *
     * @param quality The target quality level
     */
    public static int getJpegEncodingQualityParameter(int quality) {
        return getJpegEncodingQualityParameter(0, quality);
        int numberOfCameras = Camera.getNumberOfCameras();
        CameraInfo cameraInfo = new CameraInfo();
        for (int i = 0; i < numberOfCameras; i++) {
            Camera.getCameraInfo(i, cameraInfo);
            if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) {
                return getJpegEncodingQualityParameter(i, quality);
            }
        }
        return 0;
    }

    /**