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

Commit 4fb84b14 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Fix issue when checking supported sizes" into sc-dev am: 02b8fa4b

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13488171

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I5febe2860cf1e5f39fc21871e8cff71a99dc57b1
parents 06555020 02b8fa4b
Loading
Loading
Loading
Loading
+15 −7
Original line number Diff line number Diff line
@@ -187,7 +187,7 @@ public class ScreenMediaRecorder {
     * @param refreshRate Desired refresh rate
     * @return array with supported width, height, and refresh rate
     */
    private int[] getSupportedSize(int screenWidth, int screenHeight, int refreshRate) {
    private int[] getSupportedSize(final int screenWidth, final int screenHeight, int refreshRate) {
        double maxScale = 0;

        MediaCodecList codecList = new MediaCodecList(MediaCodecList.REGULAR_CODECS);
@@ -207,25 +207,33 @@ public class ScreenMediaRecorder {
                    int width = vc.getSupportedWidths().getUpper();
                    int height = vc.getSupportedHeights().getUpper();

                    if (width >= screenWidth && height >= screenHeight
                            && vc.isSizeSupported(screenWidth, screenHeight)) {
                    int screenWidthAligned = screenWidth;
                    if (screenWidthAligned % vc.getWidthAlignment() != 0) {
                        screenWidthAligned -= (screenWidthAligned % vc.getWidthAlignment());
                    }
                    int screenHeightAligned = screenHeight;
                    if (screenHeightAligned % vc.getHeightAlignment() != 0) {
                        screenHeightAligned -= (screenHeightAligned % vc.getHeightAlignment());
                    }

                    if (width >= screenWidthAligned && height >= screenHeightAligned
                            && vc.isSizeSupported(screenWidthAligned, screenHeightAligned)) {
                        // Desired size is supported, now get the rate
                        int maxRate = vc.getSupportedFrameRatesFor(screenWidth, screenHeight)
                                .getUpper().intValue();
                        int maxRate = vc.getSupportedFrameRatesFor(screenWidthAligned,
                                screenHeightAligned).getUpper().intValue();

                        if (maxRate < refreshRate) {
                            refreshRate = maxRate;
                        }
                        Log.d(TAG, "Screen size supported at rate " + refreshRate);
                        return new int[]{screenWidth, screenHeight, refreshRate};
                        return new int[]{screenWidthAligned, screenHeightAligned, refreshRate};
                    }

                    // Otherwise, continue searching
                    double scale = Math.min(((double) width / screenWidth),
                            ((double) height / screenHeight));
                    if (scale > maxScale) {
                        maxScale = scale;
                        maxScale = Math.min(1, scale);
                        maxInfo = vc;
                    }
                }