1 /* 2 * Copyright 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package androidx.camera.camera2.internal.compat.quirk; 18 19 import android.hardware.camera2.CameraCharacteristics; 20 21 import androidx.camera.camera2.internal.compat.CameraCharacteristicsCompat; 22 import androidx.camera.core.impl.Quirk; 23 24 import org.jspecify.annotations.NonNull; 25 26 /** 27 * CameraCaptureSession report error when a capture request was submitted in an incorrect state. 28 * 29 * <p>QuirkSummary 30 * Bug Id: 297501750 31 * Description: When quickly configuring two CameraCaptureSession objects in sequence on a legacy 32 * camera hardware device, the second CameraCaptureSession object may fail with an 33 * "Illegal state encountered in camera service" error if the first 34 * CameraCaptureSession object submits a capture request in an incorrect state. 35 * Device(s): Devices in LEGACY camera hardware level. 36 */ 37 public class IncorrectCaptureStateQuirk implements Quirk { 38 load(@onNull CameraCharacteristicsCompat characteristics)39 static boolean load(@NonNull CameraCharacteristicsCompat characteristics) { 40 final Integer level = characteristics.get( 41 CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL); 42 return level != null && level == CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY; 43 } 44 } 45