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.pipe.integration.compat.quirk
18 
19 import android.annotation.SuppressLint
20 import androidx.camera.camera2.pipe.CameraMetadata
21 import androidx.camera.camera2.pipe.CameraMetadata.Companion.isHardwareLevelLegacy
22 import androidx.camera.camera2.pipe.integration.compat.quirk.Device.isSamsungDevice
23 import androidx.camera.core.impl.Quirk
24 
25 /**
26  * Quirk about still image (non-repeating) capture quickly succeeding a repeating request leading to
27  * failures.
28  *
29  * QuirkSummary
30  * - Bug Id: 356792665
31  * - Description: On some legacy devices from Samsung J1 Mini, this can lead to an invalid parameter
32  *   in the repeating request resulting in a variety of failures. Waiting for the repeating request
33  *   start to be completed before image capture submission can workaround such issues.
34  * - Device(s): All Samsung legacy devices
35  */
36 @SuppressLint("CameraXQuirksClassDetector") // TODO(b/270421716): enable when kotlin is supported.
37 public class QuickSuccessiveImageCaptureFailsRepeatingRequestQuirk : Quirk {
38     public companion object {
isEnablednull39         public fun isEnabled(cameraMetadata: CameraMetadata): Boolean =
40             isSamsungDevice() && cameraMetadata.isHardwareLevelLegacy
41     }
42 }
43