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

Commit 17f5d9c8 authored by Doris Liu's avatar Doris Liu
Browse files

Set default video quality to the highest

Bug: 9886141

Change-Id: I4741d5c898ac666923cfc12abc78d5d3517cb05f
parent db875474
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -125,9 +125,6 @@ public class ApiHelper {
    public static final boolean HAS_CAMERA_METERING_AREA =
            Build.VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH;

    public static final boolean HAS_FINE_RESOLUTION_QUALITY_LEVELS =
            Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB;

    public static final boolean HAS_MOTION_EVENT_TRANSFORM =
            Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB;

+0 −1
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@
        camera:title="@string/pref_camcorder_settings_category">
    <ListPreference
            camera:key="pref_video_quality_key"
            camera:defaultValue="@string/pref_video_quality_default"
            camera:title="@string/pref_video_quality_title"
            camera:entries="@array/pref_video_quality_entries"
            camera:entryValues="@array/pref_video_quality_entryvalues"/>
+15 −33
Original line number Diff line number Diff line
@@ -93,16 +93,16 @@ public class CameraSettings {
        return group;
    }

    @TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB)
    public static String getDefaultVideoQuality(int cameraId,
    public static String getSupportedHighestVideoQuality(int cameraId,
            String defaultQuality) {
        if (ApiHelper.HAS_FINE_RESOLUTION_QUALITY_LEVELS) {
            if (CamcorderProfile.hasProfile(
                    cameraId, Integer.valueOf(defaultQuality))) {
        // When launching the camera app first time, we will set the video quality
        // to the first one (i.e. highest quality) in the supported list
        List<String> supported = getSupportedVideoQuality(cameraId);
        if (supported == null) {
            Log.e(TAG, "No supported video quality is found");
            return defaultQuality;
        }
        }
        return Integer.toString(CamcorderProfile.QUALITY_HIGH);
        return supported.get(0);
    }

    public static void initialCameraPictureSize(
@@ -177,7 +177,7 @@ public class CameraSettings {
        // Since the screen could be loaded from different resources, we need
        // to check if the preference is available here
        if (videoQuality != null) {
            filterUnsupportedOptions(group, videoQuality, getSupportedVideoQuality());
            filterUnsupportedOptions(group, videoQuality, getSupportedVideoQuality(mCameraId));
        }

        if (pictureSize != null) {
@@ -532,37 +532,19 @@ public class CameraSettings {
        writePreferredCameraId(preferences, currentCameraId);
    }

    private ArrayList<String> getSupportedVideoQuality() {
    private static ArrayList<String> getSupportedVideoQuality(int cameraId) {
        ArrayList<String> supported = new ArrayList<String>();
        // Check for supported quality
        if (ApiHelper.HAS_FINE_RESOLUTION_QUALITY_LEVELS) {
            getFineResolutionQuality(supported);
        } else {
            supported.add(Integer.toString(CamcorderProfile.QUALITY_HIGH));
            CamcorderProfile high = CamcorderProfile.get(
                    mCameraId, CamcorderProfile.QUALITY_HIGH);
            CamcorderProfile low = CamcorderProfile.get(
                    mCameraId, CamcorderProfile.QUALITY_LOW);
            if (high.videoFrameHeight * high.videoFrameWidth >
                    low.videoFrameHeight * low.videoFrameWidth) {
                supported.add(Integer.toString(CamcorderProfile.QUALITY_LOW));
            }
        }

        return supported;
    }

    @TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB)
    private void getFineResolutionQuality(ArrayList<String> supported) {
        if (CamcorderProfile.hasProfile(mCameraId, CamcorderProfile.QUALITY_1080P)) {
        if (CamcorderProfile.hasProfile(cameraId, CamcorderProfile.QUALITY_1080P)) {
            supported.add(Integer.toString(CamcorderProfile.QUALITY_1080P));
        }
        if (CamcorderProfile.hasProfile(mCameraId, CamcorderProfile.QUALITY_720P)) {
        if (CamcorderProfile.hasProfile(cameraId, CamcorderProfile.QUALITY_720P)) {
            supported.add(Integer.toString(CamcorderProfile.QUALITY_720P));
        }
        if (CamcorderProfile.hasProfile(mCameraId, CamcorderProfile.QUALITY_480P)) {
        if (CamcorderProfile.hasProfile(cameraId, CamcorderProfile.QUALITY_480P)) {
            supported.add(Integer.toString(CamcorderProfile.QUALITY_480P));
        }
        return supported;
    }

    private void initVideoEffect(PreferenceGroup group, ListPreference videoEffect) {
+11 −18
Original line number Diff line number Diff line
@@ -472,20 +472,10 @@ public class VideoModule implements CameraModule,
        if (effectsActive()) {
            mUI.overrideSettings(
                    CameraSettings.KEY_VIDEO_QUALITY,
                    Integer.toString(getLowVideoQuality()));
                    Integer.toString(CamcorderProfile.QUALITY_480P));
        }
    }

    @TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB)
    private static int getLowVideoQuality() {
        if (ApiHelper.HAS_FINE_RESOLUTION_QUALITY_LEVELS) {
            return CamcorderProfile.QUALITY_480P;
        } else {
            return CamcorderProfile.QUALITY_LOW;
        }
    }


    @Override
    public void onOrientationChanged(int orientation) {
        // We keep the last known orientation. So if the user first orient
@@ -613,11 +603,14 @@ public class VideoModule implements CameraModule,
    private void readVideoPreferences() {
        // The preference stores values from ListPreference and is thus string type for all values.
        // We need to convert it to int manually.
        String defaultQuality = CameraSettings.getDefaultVideoQuality(mCameraId,
        String videoQuality = mPreferences.getString(CameraSettings.KEY_VIDEO_QUALITY,
                        null);
        if (videoQuality == null) {
            // check for highest quality before setting default value
            videoQuality = CameraSettings.getSupportedHighestVideoQuality(mCameraId,
                    mActivity.getResources().getString(R.string.pref_video_quality_default));
        String videoQuality =
                mPreferences.getString(CameraSettings.KEY_VIDEO_QUALITY,
                        defaultQuality);
            mPreferences.edit().putString(CameraSettings.KEY_VIDEO_QUALITY, videoQuality);
        }
        int quality = Integer.valueOf(videoQuality);

        // Set video quality.
@@ -649,7 +642,7 @@ public class VideoModule implements CameraModule,
            // Set quality to be no higher than 480p.
            CamcorderProfile profile = CamcorderProfile.get(mCameraId, quality);
            if (profile.videoFrameHeight > 480) {
                quality = getLowVideoQuality();
                quality = CamcorderProfile.QUALITY_480P;
            }
        } else {
            mEffectParameter = null;