package com.seewo.factoryaging.camera811;

import android.annotation.TargetApi;
import android.graphics.SurfaceTexture;
import android.hardware.Camera;
import android.view.TextureView;
import j.p0.d.r;

/* JADX INFO: compiled from: CameraPresenter.kt */
/* JADX INFO: loaded from: classes.dex */
@TargetApi(14)
public final class e extends d {
    private volatile Camera c;
    private volatile boolean d;

    @Override // com.seewo.factoryaging.camera811.d
    public void l() {
        if (this.c == null) {
            return;
        }
        try {
            try {
                Camera camera = this.c;
                if (camera != null) {
                    camera.release();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        } finally {
            this.c = null;
            this.d = false;
        }
    }

    @Override // com.seewo.factoryaging.camera811.d
    public void m(TextureView textureView) {
        r.f(textureView, "texture");
    }

    @Override // com.seewo.factoryaging.camera811.d
    public void n(SurfaceTexture surfaceTexture) {
        r.f(surfaceTexture, "surfaceTexture");
        if (this.c == null || this.d || !com.seewo.factoryaging.e1.d.a.a()) {
            return;
        }
        this.d = true;
        try {
            Camera camera = this.c;
            if (camera != null) {
                camera.setPreviewTexture(surfaceTexture);
            }
            Camera camera2 = this.c;
            if (camera2 != null) {
                camera2.startPreview();
            }
        } catch (Exception e) {
            this.c = null;
            this.d = false;
            e.printStackTrace();
        }
    }
}
