mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-12-02 02:30:21 +01:00
126 lines
4.4 KiB
Java
126 lines
4.4 KiB
Java
package androidx.camera.camera2.internal.compat;
|
|
|
|
import android.hardware.camera2.CameraCharacteristics;
|
|
import android.hardware.camera2.params.StreamConfigurationMap;
|
|
import android.os.Build;
|
|
import androidx.annotation.GuardedBy;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.annotation.VisibleForTesting;
|
|
import androidx.camera.camera2.internal.compat.workaround.OutputSizesCorrector;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
import java.util.Set;
|
|
import rx.Single$$ExternalSyntheticBUOutline0;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
/* loaded from: classes.dex */
|
|
public class CameraCharacteristicsCompat {
|
|
|
|
@NonNull
|
|
private final CameraCharacteristicsCompatImpl mCameraCharacteristicsImpl;
|
|
|
|
@NonNull
|
|
private final String mCameraId;
|
|
|
|
@NonNull
|
|
@GuardedBy("this")
|
|
private final Map<CameraCharacteristics.Key<?>, Object> mValuesCache = new HashMap();
|
|
|
|
@Nullable
|
|
private StreamConfigurationMapCompat mStreamConfigurationMapCompat = null;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public interface CameraCharacteristicsCompatImpl {
|
|
@Nullable
|
|
<T> T get(@NonNull CameraCharacteristics.Key<T> key);
|
|
|
|
@NonNull
|
|
Set<String> getPhysicalCameraIds();
|
|
|
|
@NonNull
|
|
CameraCharacteristics unwrap();
|
|
}
|
|
|
|
private CameraCharacteristicsCompat(@NonNull CameraCharacteristics cameraCharacteristics, @NonNull String str) {
|
|
this.mCameraCharacteristicsImpl = new CameraCharacteristicsApi28Impl(cameraCharacteristics);
|
|
this.mCameraId = str;
|
|
}
|
|
|
|
private boolean isKeyNonCacheable(@NonNull CameraCharacteristics.Key<?> key) {
|
|
return key.equals(CameraCharacteristics.SENSOR_ORIENTATION);
|
|
}
|
|
|
|
@NonNull
|
|
@VisibleForTesting
|
|
public static CameraCharacteristicsCompat toCameraCharacteristicsCompat(@NonNull CameraCharacteristics cameraCharacteristics, @NonNull String str) {
|
|
return new CameraCharacteristicsCompat(cameraCharacteristics, str);
|
|
}
|
|
|
|
@Nullable
|
|
public <T> T get(@NonNull CameraCharacteristics.Key<T> key) {
|
|
if (isKeyNonCacheable(key)) {
|
|
return (T) this.mCameraCharacteristicsImpl.get(key);
|
|
}
|
|
synchronized (this) {
|
|
try {
|
|
T t = (T) this.mValuesCache.get(key);
|
|
if (t != null) {
|
|
return t;
|
|
}
|
|
T t2 = (T) this.mCameraCharacteristicsImpl.get(key);
|
|
if (t2 != null) {
|
|
this.mValuesCache.put(key, t2);
|
|
}
|
|
return t2;
|
|
} catch (Throwable th) {
|
|
throw th;
|
|
}
|
|
}
|
|
}
|
|
|
|
@NonNull
|
|
public String getCameraId() {
|
|
return this.mCameraId;
|
|
}
|
|
|
|
@NonNull
|
|
public Set<String> getPhysicalCameraIds() {
|
|
return this.mCameraCharacteristicsImpl.getPhysicalCameraIds();
|
|
}
|
|
|
|
@NonNull
|
|
public StreamConfigurationMapCompat getStreamConfigurationMapCompat() {
|
|
if (this.mStreamConfigurationMapCompat == null) {
|
|
try {
|
|
StreamConfigurationMap streamConfigurationMap = (StreamConfigurationMap) get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
|
|
if (streamConfigurationMap == null) {
|
|
Single$$ExternalSyntheticBUOutline0.m$3("StreamConfigurationMap is null!");
|
|
return null;
|
|
}
|
|
this.mStreamConfigurationMapCompat = StreamConfigurationMapCompat.toStreamConfigurationMapCompat(streamConfigurationMap, new OutputSizesCorrector(this.mCameraId));
|
|
} catch (AssertionError | NullPointerException e) {
|
|
Single$$ExternalSyntheticBUOutline0.m$3(e.getMessage());
|
|
return null;
|
|
}
|
|
}
|
|
return this.mStreamConfigurationMapCompat;
|
|
}
|
|
|
|
public boolean isZoomOverrideAvailable() {
|
|
int[] iArr;
|
|
if (Build.VERSION.SDK_INT >= 34 && (iArr = (int[]) this.mCameraCharacteristicsImpl.get(CameraCharacteristics.CONTROL_AVAILABLE_SETTINGS_OVERRIDES)) != null) {
|
|
for (int i : iArr) {
|
|
if (i == 1) {
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@NonNull
|
|
public CameraCharacteristics toCameraCharacteristics() {
|
|
return this.mCameraCharacteristicsImpl.unwrap();
|
|
}
|
|
}
|