alexandroid/decompiled/jadx/sources/androidx/camera/camera2/internal/CaptureSessionRepository.java
KaKi87 a47fad5135 📦 Add decompiled Alexa 2.2.730155.0 (jadx, apktool, Hermes strings)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 00:04:16 +01:00

195 lines
7.5 KiB
Java

package androidx.camera.camera2.internal;
import android.hardware.camera2.CameraDevice;
import androidx.annotation.GuardedBy;
import androidx.annotation.NonNull;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.Executor;
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
/* loaded from: classes.dex */
class CaptureSessionRepository {
@NonNull
final Executor mExecutor;
final Object mLock = new Object();
@GuardedBy("mLock")
final Set<SynchronizedCaptureSession> mCaptureSessions = new LinkedHashSet();
@GuardedBy("mLock")
final Set<SynchronizedCaptureSession> mClosingCaptureSession = new LinkedHashSet();
@GuardedBy("mLock")
final Set<SynchronizedCaptureSession> mCreatingCaptureSessions = new LinkedHashSet();
private final CameraDevice.StateCallback mCameraStateCallback = new AnonymousClass1();
public CaptureSessionRepository(@NonNull Executor executor) {
this.mExecutor = executor;
}
private void forceFinishCloseStaleSessions(@NonNull SynchronizedCaptureSession synchronizedCaptureSession) {
SynchronizedCaptureSession next;
Iterator<SynchronizedCaptureSession> it2 = getSessionsInOrder().iterator();
while (it2.hasNext() && (next = it2.next()) != synchronizedCaptureSession) {
next.finishClose();
}
}
public static void forceOnClosed(@NonNull Set<SynchronizedCaptureSession> set) {
for (SynchronizedCaptureSession synchronizedCaptureSession : set) {
synchronizedCaptureSession.getStateCallback().onClosed(synchronizedCaptureSession);
}
}
@NonNull
public CameraDevice.StateCallback getCameraStateCallback() {
return this.mCameraStateCallback;
}
@NonNull
public List<SynchronizedCaptureSession> getCaptureSessions() {
ArrayList arrayList;
synchronized (this.mLock) {
arrayList = new ArrayList(this.mCaptureSessions);
}
return arrayList;
}
@NonNull
public List<SynchronizedCaptureSession> getClosingCaptureSession() {
ArrayList arrayList;
synchronized (this.mLock) {
arrayList = new ArrayList(this.mClosingCaptureSession);
}
return arrayList;
}
@NonNull
public List<SynchronizedCaptureSession> getCreatingCaptureSessions() {
ArrayList arrayList;
synchronized (this.mLock) {
arrayList = new ArrayList(this.mCreatingCaptureSessions);
}
return arrayList;
}
@NonNull
public List<SynchronizedCaptureSession> getSessionsInOrder() {
ArrayList arrayList;
synchronized (this.mLock) {
arrayList = new ArrayList();
arrayList.addAll(getCaptureSessions());
arrayList.addAll(getCreatingCaptureSessions());
}
return arrayList;
}
public void onCaptureSessionClosed(@NonNull SynchronizedCaptureSession synchronizedCaptureSession) {
synchronized (this.mLock) {
this.mCaptureSessions.remove(synchronizedCaptureSession);
this.mClosingCaptureSession.remove(synchronizedCaptureSession);
}
}
public void onCaptureSessionClosing(@NonNull SynchronizedCaptureSession synchronizedCaptureSession) {
synchronized (this.mLock) {
this.mClosingCaptureSession.add(synchronizedCaptureSession);
}
}
public void onCaptureSessionConfigureFail(@NonNull SynchronizedCaptureSession synchronizedCaptureSession) {
forceFinishCloseStaleSessions(synchronizedCaptureSession);
synchronized (this.mLock) {
this.mCreatingCaptureSessions.remove(synchronizedCaptureSession);
}
}
public void onCaptureSessionCreated(@NonNull SynchronizedCaptureSession synchronizedCaptureSession) {
synchronized (this.mLock) {
this.mCaptureSessions.add(synchronizedCaptureSession);
this.mCreatingCaptureSessions.remove(synchronizedCaptureSession);
}
forceFinishCloseStaleSessions(synchronizedCaptureSession);
}
public void onCreateCaptureSession(@NonNull SynchronizedCaptureSession synchronizedCaptureSession) {
synchronized (this.mLock) {
this.mCreatingCaptureSessions.add(synchronizedCaptureSession);
}
}
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
/* renamed from: androidx.camera.camera2.internal.CaptureSessionRepository$1, reason: invalid class name */
public class AnonymousClass1 extends CameraDevice.StateCallback {
public AnonymousClass1() {
}
private void cameraClosed() {
List<SynchronizedCaptureSession> sessionsInOrder;
synchronized (CaptureSessionRepository.this.mLock) {
sessionsInOrder = CaptureSessionRepository.this.getSessionsInOrder();
CaptureSessionRepository.this.mCreatingCaptureSessions.clear();
CaptureSessionRepository.this.mCaptureSessions.clear();
CaptureSessionRepository.this.mClosingCaptureSession.clear();
}
Iterator<SynchronizedCaptureSession> it2 = sessionsInOrder.iterator();
while (it2.hasNext()) {
it2.next().finishClose();
}
}
private void dispatchOnError(int i) {
LinkedHashSet linkedHashSet = new LinkedHashSet();
synchronized (CaptureSessionRepository.this.mLock) {
linkedHashSet.addAll(CaptureSessionRepository.this.mCreatingCaptureSessions);
linkedHashSet.addAll(CaptureSessionRepository.this.mCaptureSessions);
}
CaptureSessionRepository.this.mExecutor.execute(new CaptureSessionRepository$1$$ExternalSyntheticLambda1(linkedHashSet, i, 0));
}
private void forceOnClosedCaptureSessions() {
LinkedHashSet linkedHashSet = new LinkedHashSet();
synchronized (CaptureSessionRepository.this.mLock) {
linkedHashSet.addAll(CaptureSessionRepository.this.mCreatingCaptureSessions);
linkedHashSet.addAll(CaptureSessionRepository.this.mCaptureSessions);
}
CaptureSessionRepository.this.mExecutor.execute(new CaptureSession$$ExternalSyntheticLambda3(linkedHashSet, 3));
}
/* JADX INFO: Access modifiers changed from: private */
public static /* synthetic */ void lambda$dispatchOnError$1(LinkedHashSet linkedHashSet, int i) {
Iterator it2 = linkedHashSet.iterator();
while (it2.hasNext()) {
((SynchronizedCaptureSession) it2.next()).onCameraDeviceError(i);
}
}
@Override // android.hardware.camera2.CameraDevice.StateCallback
public void onClosed(@NonNull CameraDevice cameraDevice) {
forceOnClosedCaptureSessions();
cameraClosed();
}
@Override // android.hardware.camera2.CameraDevice.StateCallback
public void onDisconnected(@NonNull CameraDevice cameraDevice) {
forceOnClosedCaptureSessions();
cameraClosed();
}
@Override // android.hardware.camera2.CameraDevice.StateCallback
public void onError(@NonNull CameraDevice cameraDevice, int i) {
forceOnClosedCaptureSessions();
dispatchOnError(i);
cameraClosed();
}
@Override // android.hardware.camera2.CameraDevice.StateCallback
public void onOpened(@NonNull CameraDevice cameraDevice) {
}
}
}