public class

Nexus4AndroidLTargetAspectRatioQuirk

extends java.lang.Object

implements Quirk

 java.lang.Object

↳androidx.camera.camera2.internal.compat.quirk.Nexus4AndroidLTargetAspectRatioQuirk

Gradle dependencies

compile group: 'androidx.camera', name: 'camera-camera2', version: '1.5.0-alpha01'

  • groupId: androidx.camera
  • artifactId: camera-camera2
  • version: 1.5.0-alpha01

Artifact androidx.camera:camera-camera2:1.5.0-alpha01 it located at Google repository (https://maven.google.com/)

Overview

QuirkSummary Bug Id: b/19606058 Description: Quirk that produces stretched preview on Nexus 4 devices running Android L (API levels 21 and 22). There is a Camera1/HAL1 issue on the Nexus 4. The preview will be stretched when configuring a JPEG that doesn't actually have the same aspect ratio as the maximum JPEG resolution. Device(s): Google Nexus 4

Summary

Constructors
publicNexus4AndroidLTargetAspectRatioQuirk()

Methods
public intgetCorrectedAspectRatio()

Get the corrected aspect ratio.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Nexus4AndroidLTargetAspectRatioQuirk()

Methods

public int getCorrectedAspectRatio()

Get the corrected aspect ratio.

Source

/*
 * Copyright 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package androidx.camera.camera2.internal.compat.quirk;

import android.os.Build;

import androidx.camera.camera2.internal.compat.workaround.TargetAspectRatio;
import androidx.camera.core.impl.Quirk;

import java.util.Arrays;
import java.util.List;
import java.util.Locale;

/**
 * <p>QuirkSummary
 *     Bug Id: b/19606058
 *     Description: Quirk that produces stretched preview on Nexus 4 devices running Android L
 *     (API levels 21 and 22). There is a Camera1/HAL1 issue on the Nexus 4. The preview will be
 *     stretched when configuring a JPEG that doesn't actually have the same aspect ratio as the
 *     maximum JPEG resolution.
 *     Device(s): Google Nexus 4
 *     @see androidx.camera.camera2.internal.compat.workaround.TargetAspectRatio
 */
public class Nexus4AndroidLTargetAspectRatioQuirk implements Quirk {
    // List of devices with the issue.
    private static final List<String> DEVICE_MODELS = Arrays.asList(
            "NEXUS 4" // b/158749159
    );

    static boolean load() {
        return "GOOGLE".equalsIgnoreCase(Build.BRAND) && Build.VERSION.SDK_INT < 23
                && DEVICE_MODELS.contains(android.os.Build.MODEL.toUpperCase(Locale.US));
    }

    /**
     * Get the corrected aspect ratio.
     */
    @TargetAspectRatio.Ratio
    public int getCorrectedAspectRatio() {
        return TargetAspectRatio.RATIO_MAX_JPEG;
    }
}