2021-07-24 02:37:17 +00:00
package com.otaliastudios.cameraview ;
import android.annotation.SuppressLint ;
import android.app.Activity ;
import android.content.Context ;
import android.content.ContextWrapper ;
import android.content.pm.PackageManager ;
import android.content.res.TypedArray ;
import android.graphics.PointF ;
import android.graphics.Rect ;
import android.graphics.RectF ;
import android.hardware.display.DisplayManager ;
import android.location.Location ;
import android.media.MediaActionSound ;
import android.os.Build ;
import android.os.Handler ;
import android.os.Looper ;
import android.util.AttributeSet ;
import android.view.MotionEvent ;
import android.view.View ;
import android.view.ViewGroup ;
import android.widget.FrameLayout ;
import androidx.annotation.ColorInt ;
import androidx.annotation.NonNull ;
import androidx.annotation.Nullable ;
import androidx.annotation.VisibleForTesting ;
import androidx.lifecycle.Lifecycle ;
import androidx.lifecycle.LifecycleObserver ;
import androidx.lifecycle.LifecycleOwner ;
import androidx.lifecycle.OnLifecycleEvent ;
import c.o.a.l ;
import c.o.a.m.h ;
import c.o.a.m.j ;
import c.o.a.m.k ;
import c.o.a.m.l ;
import c.o.a.m.m ;
import c.o.a.n.i ;
import c.o.a.p.d ;
import c.o.a.q.c ;
import c.o.a.q.e ;
import c.o.a.q.f ;
import c.o.a.q.g ;
import c.o.a.r.f ;
import c.o.a.s.c ;
import c.o.a.u.c ;
import java.util.ArrayList ;
import java.util.HashMap ;
import java.util.Iterator ;
import java.util.List ;
import java.util.Objects ;
import java.util.concurrent.CopyOnWriteArrayList ;
import java.util.concurrent.Executor ;
import java.util.concurrent.LinkedBlockingQueue ;
import java.util.concurrent.ThreadFactory ;
import java.util.concurrent.ThreadPoolExecutor ;
import java.util.concurrent.TimeUnit ;
import java.util.concurrent.atomic.AtomicInteger ;
public class CameraView extends FrameLayout implements LifecycleObserver {
public static final String i ;
public static final c . o . a . b j ;
public c . o . a . s . a A ;
@VisibleForTesting
public List < c . o . a . a > B = new CopyOnWriteArrayList ( ) ;
@VisibleForTesting
public List < d > C = new CopyOnWriteArrayList ( ) ;
public Lifecycle D ;
@VisibleForTesting
public e E ;
@VisibleForTesting
public g F ;
@VisibleForTesting
public f G ;
@VisibleForTesting
public c . o . a . r . d H ;
@VisibleForTesting
public c I ;
public boolean J ;
public boolean K ;
@VisibleForTesting
public c . o . a . u . c L ;
public boolean k ;
public boolean l ;
public boolean m ;
public HashMap < c . o . a . q . a , c . o . a . q . b > n = new HashMap < > ( 4 ) ;
public k o ;
public c . o . a . m . d p ;
public c . o . a . o . b q ;
public int r ;
/* renamed from: s reason: collision with root package name */
2021-07-27 00:35:07 +00:00
public Handler f2410s ;
2021-07-24 02:37:17 +00:00
public Executor t ;
@VisibleForTesting
public b u ;
public c . o . a . w . a v ;
public c . o . a . r . f w ;
/* renamed from: x reason: collision with root package name */
2021-07-27 00:35:07 +00:00
public i f2411x ;
2021-07-24 02:37:17 +00:00
/* renamed from: y reason: collision with root package name */
2021-07-27 00:35:07 +00:00
public c . o . a . x . b f2412y ;
2021-07-24 02:37:17 +00:00
/* renamed from: z reason: collision with root package name */
2021-07-27 00:35:07 +00:00
public MediaActionSound f2413z ;
2021-07-24 02:37:17 +00:00
public class a implements ThreadFactory {
public final AtomicInteger i = new AtomicInteger ( 1 ) ;
public a ( CameraView cameraView ) {
}
@Override // java.util.concurrent.ThreadFactory
public Thread newThread ( @NonNull Runnable runnable ) {
StringBuilder K = c . d . b . a . a . K ( " FrameExecutor # " ) ;
K . append ( this . i . getAndIncrement ( ) ) ;
return new Thread ( runnable , K . toString ( ) ) ;
}
}
@VisibleForTesting
public class b implements i . g , f . c , c . a {
public final String a ;
public final c . o . a . b b ;
public class a implements Runnable {
public final /* synthetic */ float i ;
public final /* synthetic */ PointF [ ] j ;
public a ( float f , PointF [ ] pointFArr ) {
this . i = f ;
this . j = pointFArr ;
}
@Override // java.lang.Runnable
public void run ( ) {
for ( c . o . a . a aVar : CameraView . this . B ) {
Objects . requireNonNull ( aVar ) ;
}
}
}
/* renamed from: com.otaliastudios.cameraview.CameraView$b$b reason: collision with other inner class name */
public class RunnableC0191b implements Runnable {
public final /* synthetic */ float i ;
public final /* synthetic */ float [ ] j ;
public final /* synthetic */ PointF [ ] k ;
public RunnableC0191b ( float f , float [ ] fArr , PointF [ ] pointFArr ) {
this . i = f ;
this . j = fArr ;
this . k = pointFArr ;
}
@Override // java.lang.Runnable
public void run ( ) {
for ( c . o . a . a aVar : CameraView . this . B ) {
Objects . requireNonNull ( aVar ) ;
}
}
}
public class c implements Runnable {
public final /* synthetic */ c . o . a . p . b i ;
public c ( c . o . a . p . b bVar ) {
this . i = bVar ;
}
@Override // java.lang.Runnable
public void run ( ) {
b . this . b . a ( 0 , " dispatchFrame: executing. Passing " , Long . valueOf ( this . i . a ( ) ) , " to processors. " ) ;
for ( c . o . a . p . d dVar : CameraView . this . C ) {
try {
dVar . a ( this . i ) ;
} catch ( Exception e ) {
b . this . b . a ( 2 , " Frame processor crashed: " , e ) ;
}
}
this . i . b ( ) ;
}
}
public class d implements Runnable {
public final /* synthetic */ CameraException i ;
public d ( CameraException cameraException ) {
this . i = cameraException ;
}
@Override // java.lang.Runnable
public void run ( ) {
for ( c . o . a . a aVar : CameraView . this . B ) {
aVar . b ( this . i ) ;
}
}
}
public class e implements Runnable {
public e ( ) {
}
@Override // java.lang.Runnable
public void run ( ) {
CameraView . this . requestLayout ( ) ;
}
}
public class f implements Runnable {
public final /* synthetic */ PointF i ;
public final /* synthetic */ c . o . a . q . a j ;
public f ( PointF pointF , c . o . a . q . a aVar ) {
this . i = pointF ;
this . j = aVar ;
}
@Override // java.lang.Runnable
public void run ( ) {
c . o . a . s . c cVar = CameraView . this . I ;
PointF [ ] pointFArr = { this . i } ;
View view = cVar . i . get ( 1 ) ;
if ( view ! = null ) {
view . clearAnimation ( ) ;
PointF pointF = pointFArr [ 0 ] ;
view . setTranslationX ( ( float ) ( ( int ) ( pointF . x - ( ( float ) ( view . getWidth ( ) / 2 ) ) ) ) ) ;
view . setTranslationY ( ( float ) ( ( int ) ( pointF . y - ( ( float ) ( view . getHeight ( ) / 2 ) ) ) ) ) ;
}
c . o . a . s . a aVar = CameraView . this . A ;
if ( aVar ! = null ) {
aVar . a ( this . j ! = null ? c . o . a . s . b . GESTURE : c . o . a . s . b . METHOD , this . i ) ;
}
for ( c . o . a . a aVar2 : CameraView . this . B ) {
Objects . requireNonNull ( aVar2 ) ;
}
}
}
public class g implements Runnable {
public final /* synthetic */ boolean i ;
public final /* synthetic */ c . o . a . q . a j ;
public final /* synthetic */ PointF k ;
public g ( boolean z2 , c . o . a . q . a aVar , PointF pointF ) {
this . i = z2 ;
this . j = aVar ;
this . k = pointF ;
}
@Override // java.lang.Runnable
public void run ( ) {
CameraView cameraView ;
boolean z2 ;
if ( this . i & & ( z2 = ( cameraView = CameraView . this ) . k ) & & z2 ) {
2021-07-27 00:35:07 +00:00
if ( cameraView . f2413z = = null ) {
cameraView . f2413z = new MediaActionSound ( ) ;
2021-07-24 02:37:17 +00:00
}
2021-07-27 00:35:07 +00:00
cameraView . f2413z . play ( 1 ) ;
2021-07-24 02:37:17 +00:00
}
c . o . a . s . a aVar = CameraView . this . A ;
if ( aVar ! = null ) {
aVar . c ( this . j ! = null ? c . o . a . s . b . GESTURE : c . o . a . s . b . METHOD , this . i , this . k ) ;
}
for ( c . o . a . a aVar2 : CameraView . this . B ) {
Objects . requireNonNull ( aVar2 ) ;
}
}
}
public b ( ) {
String simpleName = b . class . getSimpleName ( ) ;
this . a = simpleName ;
this . b = new c . o . a . b ( simpleName ) ;
}
public void a ( CameraException cameraException ) {
this . b . a ( 1 , " dispatchError " , cameraException ) ;
2021-07-27 00:35:07 +00:00
CameraView . this . f2410s . post ( new d ( cameraException ) ) ;
2021-07-24 02:37:17 +00:00
}
public void b ( @NonNull c . o . a . p . b bVar ) {
this . b . a ( 0 , " dispatchFrame: " , Long . valueOf ( bVar . a ( ) ) , " processors: " , Integer . valueOf ( CameraView . this . C . size ( ) ) ) ;
if ( CameraView . this . C . isEmpty ( ) ) {
bVar . b ( ) ;
} else {
CameraView . this . t . execute ( new c ( bVar ) ) ;
}
}
public void c ( float f2 , @NonNull float [ ] fArr , @Nullable PointF [ ] pointFArr ) {
this . b . a ( 1 , " dispatchOnExposureCorrectionChanged " , Float . valueOf ( f2 ) ) ;
2021-07-27 00:35:07 +00:00
CameraView . this . f2410s . post ( new RunnableC0191b ( f2 , fArr , pointFArr ) ) ;
2021-07-24 02:37:17 +00:00
}
public void d ( @Nullable c . o . a . q . a aVar , boolean z2 , @NonNull PointF pointF ) {
this . b . a ( 1 , " dispatchOnFocusEnd " , aVar , Boolean . valueOf ( z2 ) , pointF ) ;
2021-07-27 00:35:07 +00:00
CameraView . this . f2410s . post ( new g ( z2 , aVar , pointF ) ) ;
2021-07-24 02:37:17 +00:00
}
public void e ( @Nullable c . o . a . q . a aVar , @NonNull PointF pointF ) {
this . b . a ( 1 , " dispatchOnFocusStart " , aVar , pointF ) ;
2021-07-27 00:35:07 +00:00
CameraView . this . f2410s . post ( new f ( pointF , aVar ) ) ;
2021-07-24 02:37:17 +00:00
}
public void f ( float f2 , @Nullable PointF [ ] pointFArr ) {
this . b . a ( 1 , " dispatchOnZoomChanged " , Float . valueOf ( f2 ) ) ;
2021-07-27 00:35:07 +00:00
CameraView . this . f2410s . post ( new a ( f2 , pointFArr ) ) ;
2021-07-24 02:37:17 +00:00
}
@NonNull
public Context g ( ) {
return CameraView . this . getContext ( ) ;
}
public void h ( ) {
2021-07-27 00:35:07 +00:00
c . o . a . x . b C = CameraView . this . f2411x . C ( c . o . a . n . t . b . VIEW ) ;
2021-07-24 02:37:17 +00:00
if ( C = = null ) {
throw new RuntimeException ( " Preview stream size should not be null here. " ) ;
2021-07-27 00:35:07 +00:00
} else if ( C . equals ( CameraView . this . f2412y ) ) {
2021-07-24 02:37:17 +00:00
this . b . a ( 1 , " onCameraPreviewStreamSizeChanged: " , " swallowing because the preview size has not changed. " , C ) ;
} else {
this . b . a ( 1 , " onCameraPreviewStreamSizeChanged: posting a requestLayout call. " , " Preview stream size: " , C ) ;
2021-07-27 00:35:07 +00:00
CameraView . this . f2410s . post ( new e ( ) ) ;
2021-07-24 02:37:17 +00:00
}
}
}
static {
String simpleName = CameraView . class . getSimpleName ( ) ;
i = simpleName ;
j = new c . o . a . b ( simpleName ) ;
}
public CameraView ( @NonNull Context context , @Nullable AttributeSet attributeSet ) {
super ( context , attributeSet ) ;
int i2 ;
int i3 ;
int i4 ;
int i5 ;
c . o . a . x . c cVar ;
c . o . a . o . b bVar ;
boolean isInEditMode = isInEditMode ( ) ;
this . K = isInEditMode ;
if ( ! isInEditMode ) {
setWillNotDraw ( false ) ;
TypedArray obtainStyledAttributes = context . getTheme ( ) . obtainStyledAttributes ( attributeSet , R . c . CameraView , 0 , 0 ) ;
int integer = obtainStyledAttributes . getInteger ( R . c . CameraView_cameraPreview , k . GL_SURFACE . g ( ) ) ;
int i6 = R . c . CameraView_cameraFacing ;
c . o . a . m . e eVar = c . o . a . m . e . BACK ;
if ( ! c . o . a . e . a ( eVar ) ) {
c . o . a . m . e eVar2 = c . o . a . m . e . FRONT ;
if ( c . o . a . e . a ( eVar2 ) ) {
eVar = eVar2 ;
}
}
int integer2 = obtainStyledAttributes . getInteger ( i6 , eVar . g ( ) ) ;
int integer3 = obtainStyledAttributes . getInteger ( R . c . CameraView_cameraFlash , c . o . a . m . f . OFF . g ( ) ) ;
int integer4 = obtainStyledAttributes . getInteger ( R . c . CameraView_cameraGrid , c . o . a . m . g . OFF . g ( ) ) ;
int integer5 = obtainStyledAttributes . getInteger ( R . c . CameraView_cameraWhiteBalance , m . AUTO . g ( ) ) ;
int integer6 = obtainStyledAttributes . getInteger ( R . c . CameraView_cameraMode , c . o . a . m . i . PICTURE . g ( ) ) ;
int integer7 = obtainStyledAttributes . getInteger ( R . c . CameraView_cameraHdr , h . OFF . g ( ) ) ;
int integer8 = obtainStyledAttributes . getInteger ( R . c . CameraView_cameraAudio , c . o . a . m . a . ON . g ( ) ) ;
int integer9 = obtainStyledAttributes . getInteger ( R . c . CameraView_cameraVideoCodec , l . DEVICE_DEFAULT . g ( ) ) ;
int integer10 = obtainStyledAttributes . getInteger ( R . c . CameraView_cameraAudioCodec , c . o . a . m . b . DEVICE_DEFAULT . g ( ) ) ;
int integer11 = obtainStyledAttributes . getInteger ( R . c . CameraView_cameraEngine , c . o . a . m . d . CAMERA1 . g ( ) ) ;
int integer12 = obtainStyledAttributes . getInteger ( R . c . CameraView_cameraPictureFormat , j . JPEG . g ( ) ) ;
boolean z2 = obtainStyledAttributes . getBoolean ( R . c . CameraView_cameraPlaySounds , true ) ;
boolean z3 = obtainStyledAttributes . getBoolean ( R . c . CameraView_cameraUseDeviceOrientation , true ) ;
this . J = obtainStyledAttributes . getBoolean ( R . c . CameraView_cameraExperimental , false ) ;
this . m = obtainStyledAttributes . getBoolean ( R . c . CameraView_cameraRequestPermissions , true ) ;
this . o = k . f ( integer ) ;
this . p = c . o . a . m . d . f ( integer11 ) ;
int color = obtainStyledAttributes . getColor ( R . c . CameraView_cameraGridColor , c . o . a . r . d . i ) ;
long j2 = ( long ) obtainStyledAttributes . getFloat ( R . c . CameraView_cameraVideoMaxSize , 0 . 0f ) ;
int integer13 = obtainStyledAttributes . getInteger ( R . c . CameraView_cameraVideoMaxDuration , 0 ) ;
int integer14 = obtainStyledAttributes . getInteger ( R . c . CameraView_cameraVideoBitRate , 0 ) ;
int integer15 = obtainStyledAttributes . getInteger ( R . c . CameraView_cameraAudioBitRate , 0 ) ;
float f = obtainStyledAttributes . getFloat ( R . c . CameraView_cameraPreviewFrameRate , 0 . 0f ) ;
boolean z4 = obtainStyledAttributes . getBoolean ( R . c . CameraView_cameraPreviewFrameRateExact , false ) ;
long integer16 = ( long ) obtainStyledAttributes . getInteger ( R . c . CameraView_cameraAutoFocusResetDelay , 3000 ) ;
boolean z5 = obtainStyledAttributes . getBoolean ( R . c . CameraView_cameraPictureMetering , true ) ;
boolean z6 = obtainStyledAttributes . getBoolean ( R . c . CameraView_cameraPictureSnapshotMetering , false ) ;
int integer17 = obtainStyledAttributes . getInteger ( R . c . CameraView_cameraSnapshotMaxWidth , 0 ) ;
int integer18 = obtainStyledAttributes . getInteger ( R . c . CameraView_cameraSnapshotMaxHeight , 0 ) ;
int integer19 = obtainStyledAttributes . getInteger ( R . c . CameraView_cameraFrameProcessingMaxWidth , 0 ) ;
int integer20 = obtainStyledAttributes . getInteger ( R . c . CameraView_cameraFrameProcessingMaxHeight , 0 ) ;
int integer21 = obtainStyledAttributes . getInteger ( R . c . CameraView_cameraFrameProcessingFormat , 0 ) ;
int integer22 = obtainStyledAttributes . getInteger ( R . c . CameraView_cameraFrameProcessingPoolSize , 2 ) ;
int integer23 = obtainStyledAttributes . getInteger ( R . c . CameraView_cameraFrameProcessingExecutors , 1 ) ;
ArrayList arrayList = new ArrayList ( 3 ) ;
int i7 = R . c . CameraView_cameraPictureSizeMinWidth ;
if ( obtainStyledAttributes . hasValue ( i7 ) ) {
i2 = integer15 ;
i3 = 0 ;
arrayList . add ( c . i . a . f . e . o . c . b0 ( obtainStyledAttributes . getInteger ( i7 , 0 ) ) ) ;
} else {
i2 = integer15 ;
i3 = 0 ;
}
int i8 = R . c . CameraView_cameraPictureSizeMaxWidth ;
if ( obtainStyledAttributes . hasValue ( i8 ) ) {
arrayList . add ( c . i . a . f . e . o . c . Z ( obtainStyledAttributes . getInteger ( i8 , i3 ) ) ) ;
}
int i9 = R . c . CameraView_cameraPictureSizeMinHeight ;
if ( obtainStyledAttributes . hasValue ( i9 ) ) {
arrayList . add ( c . i . a . f . e . o . c . a0 ( obtainStyledAttributes . getInteger ( i9 , i3 ) ) ) ;
}
int i10 = R . c . CameraView_cameraPictureSizeMaxHeight ;
if ( obtainStyledAttributes . hasValue ( i10 ) ) {
arrayList . add ( c . i . a . f . e . o . c . Y ( obtainStyledAttributes . getInteger ( i10 , i3 ) ) ) ;
}
int i11 = R . c . CameraView_cameraPictureSizeMinArea ;
if ( obtainStyledAttributes . hasValue ( i11 ) ) {
arrayList . add ( c . i . a . f . e . o . c . p0 ( new c . o . a . x . h ( obtainStyledAttributes . getInteger ( i11 , i3 ) ) ) ) ;
}
int i12 = R . c . CameraView_cameraPictureSizeMaxArea ;
if ( obtainStyledAttributes . hasValue ( i12 ) ) {
arrayList . add ( c . i . a . f . e . o . c . p0 ( new c . o . a . x . g ( obtainStyledAttributes . getInteger ( i12 , 0 ) ) ) ) ;
}
int i13 = R . c . CameraView_cameraPictureSizeAspectRatio ;
if ( obtainStyledAttributes . hasValue ( i13 ) ) {
i4 = integer8 ;
arrayList . add ( c . i . a . f . e . o . c . p0 ( new c . o . a . x . d ( c . o . a . x . a . h ( obtainStyledAttributes . getString ( i13 ) ) . i ( ) , 0 . 0f ) ) ) ;
} else {
i4 = integer8 ;
}
if ( obtainStyledAttributes . getBoolean ( R . c . CameraView_cameraPictureSizeSmallest , false ) ) {
arrayList . add ( new c . o . a . x . f ( ) ) ;
}
if ( obtainStyledAttributes . getBoolean ( R . c . CameraView_cameraPictureSizeBiggest , false ) ) {
arrayList . add ( new c . o . a . x . e ( ) ) ;
}
c . o . a . x . c b2 = ! arrayList . isEmpty ( ) ? c . i . a . f . e . o . c . b ( ( c . o . a . x . c [ ] ) arrayList . toArray ( new c . o . a . x . c [ 0 ] ) ) : new c . o . a . x . e ( ) ;
ArrayList arrayList2 = new ArrayList ( 3 ) ;
int i14 = R . c . CameraView_cameraVideoSizeMinWidth ;
if ( obtainStyledAttributes . hasValue ( i14 ) ) {
i5 = 0 ;
arrayList2 . add ( c . i . a . f . e . o . c . b0 ( obtainStyledAttributes . getInteger ( i14 , 0 ) ) ) ;
} else {
i5 = 0 ;
}
int i15 = R . c . CameraView_cameraVideoSizeMaxWidth ;
if ( obtainStyledAttributes . hasValue ( i15 ) ) {
arrayList2 . add ( c . i . a . f . e . o . c . Z ( obtainStyledAttributes . getInteger ( i15 , i5 ) ) ) ;
}
int i16 = R . c . CameraView_cameraVideoSizeMinHeight ;
if ( obtainStyledAttributes . hasValue ( i16 ) ) {
arrayList2 . add ( c . i . a . f . e . o . c . a0 ( obtainStyledAttributes . getInteger ( i16 , i5 ) ) ) ;
}
int i17 = R . c . CameraView_cameraVideoSizeMaxHeight ;
if ( obtainStyledAttributes . hasValue ( i17 ) ) {
arrayList2 . add ( c . i . a . f . e . o . c . Y ( obtainStyledAttributes . getInteger ( i17 , i5 ) ) ) ;
}
int i18 = R . c . CameraView_cameraVideoSizeMinArea ;
if ( obtainStyledAttributes . hasValue ( i18 ) ) {
arrayList2 . add ( c . i . a . f . e . o . c . p0 ( new c . o . a . x . h ( obtainStyledAttributes . getInteger ( i18 , i5 ) ) ) ) ;
}
int i19 = R . c . CameraView_cameraVideoSizeMaxArea ;
if ( obtainStyledAttributes . hasValue ( i19 ) ) {
arrayList2 . add ( c . i . a . f . e . o . c . p0 ( new c . o . a . x . g ( obtainStyledAttributes . getInteger ( i19 , 0 ) ) ) ) ;
}
int i20 = R . c . CameraView_cameraVideoSizeAspectRatio ;
if ( obtainStyledAttributes . hasValue ( i20 ) ) {
cVar = b2 ;
arrayList2 . add ( c . i . a . f . e . o . c . p0 ( new c . o . a . x . d ( c . o . a . x . a . h ( obtainStyledAttributes . getString ( i20 ) ) . i ( ) , 0 . 0f ) ) ) ;
} else {
cVar = b2 ;
}
if ( obtainStyledAttributes . getBoolean ( R . c . CameraView_cameraVideoSizeSmallest , false ) ) {
arrayList2 . add ( new c . o . a . x . f ( ) ) ;
}
if ( obtainStyledAttributes . getBoolean ( R . c . CameraView_cameraVideoSizeBiggest , false ) ) {
arrayList2 . add ( new c . o . a . x . e ( ) ) ;
}
c . o . a . x . c b3 = ! arrayList2 . isEmpty ( ) ? c . i . a . f . e . o . c . b ( ( c . o . a . x . c [ ] ) arrayList2 . toArray ( new c . o . a . x . c [ 0 ] ) ) : new c . o . a . x . e ( ) ;
int i21 = R . c . CameraView_cameraGestureTap ;
c . o . a . q . b bVar2 = c . o . a . q . b . NONE ;
int integer24 = obtainStyledAttributes . getInteger ( i21 , bVar2 . h ( ) ) ;
int integer25 = obtainStyledAttributes . getInteger ( R . c . CameraView_cameraGestureLongTap , bVar2 . h ( ) ) ;
int integer26 = obtainStyledAttributes . getInteger ( R . c . CameraView_cameraGesturePinch , bVar2 . h ( ) ) ;
int integer27 = obtainStyledAttributes . getInteger ( R . c . CameraView_cameraGestureScrollHorizontal , bVar2 . h ( ) ) ;
int integer28 = obtainStyledAttributes . getInteger ( R . c . CameraView_cameraGestureScrollVertical , bVar2 . h ( ) ) ;
String string = obtainStyledAttributes . getString ( R . c . CameraView_cameraAutoFocusMarker ) ;
c . o . a . s . a aVar = null ;
if ( string ! = null ) {
try {
aVar = ( c . o . a . s . a ) Class . forName ( string ) . newInstance ( ) ;
} catch ( Exception unused ) {
}
}
try {
bVar = ( c . o . a . o . b ) Class . forName ( obtainStyledAttributes . getString ( R . c . CameraView_cameraFilter ) ) . newInstance ( ) ;
} catch ( Exception unused2 ) {
bVar = new c . o . a . o . c ( ) ;
}
obtainStyledAttributes . recycle ( ) ;
this . u = new b ( ) ;
2021-07-27 00:35:07 +00:00
this . f2410s = new Handler ( Looper . getMainLooper ( ) ) ;
2021-07-24 02:37:17 +00:00
this . E = new e ( this . u ) ;
this . F = new g ( this . u ) ;
this . G = new c . o . a . q . f ( this . u ) ;
this . H = new c . o . a . r . d ( context ) ;
this . L = new c . o . a . u . c ( context ) ;
this . I = new c . o . a . s . c ( context ) ;
addView ( this . H ) ;
addView ( this . I ) ;
addView ( this . L ) ;
b ( ) ;
setPlaySounds ( z2 ) ;
setUseDeviceOrientation ( z3 ) ;
setGrid ( c . o . a . m . g . f ( integer4 ) ) ;
setGridColor ( color ) ;
setFacing ( c . o . a . m . e . f ( integer2 ) ) ;
setFlash ( c . o . a . m . f . f ( integer3 ) ) ;
setMode ( c . o . a . m . i . f ( integer6 ) ) ;
setWhiteBalance ( m . f ( integer5 ) ) ;
setHdr ( h . f ( integer7 ) ) ;
setAudio ( c . o . a . m . a . f ( i4 ) ) ;
setAudioBitRate ( i2 ) ;
setAudioCodec ( c . o . a . m . b . f ( integer10 ) ) ;
setPictureSize ( cVar ) ;
setPictureMetering ( z5 ) ;
setPictureSnapshotMetering ( z6 ) ;
setPictureFormat ( j . f ( integer12 ) ) ;
setVideoSize ( b3 ) ;
setVideoCodec ( l . f ( integer9 ) ) ;
setVideoMaxSize ( j2 ) ;
setVideoMaxDuration ( integer13 ) ;
setVideoBitRate ( integer14 ) ;
setAutoFocusResetDelay ( integer16 ) ;
setPreviewFrameRateExact ( z4 ) ;
setPreviewFrameRate ( f ) ;
setSnapshotMaxWidth ( integer17 ) ;
setSnapshotMaxHeight ( integer18 ) ;
setFrameProcessingMaxWidth ( integer19 ) ;
setFrameProcessingMaxHeight ( integer20 ) ;
setFrameProcessingFormat ( integer21 ) ;
setFrameProcessingPoolSize ( integer22 ) ;
setFrameProcessingExecutors ( integer23 ) ;
e ( c . o . a . q . a . TAP , c . o . a . q . b . f ( integer24 ) ) ;
e ( c . o . a . q . a . LONG_TAP , c . o . a . q . b . f ( integer25 ) ) ;
e ( c . o . a . q . a . PINCH , c . o . a . q . b . f ( integer26 ) ) ;
e ( c . o . a . q . a . SCROLL_HORIZONTAL , c . o . a . q . b . f ( integer27 ) ) ;
e ( c . o . a . q . a . SCROLL_VERTICAL , c . o . a . q . b . f ( integer28 ) ) ;
setAutoFocusMarker ( aVar ) ;
setFilter ( bVar ) ;
this . w = new c . o . a . r . f ( context , this . u ) ;
}
}
@SuppressLint ( { " NewApi " } )
public boolean a ( @NonNull c . o . a . m . a aVar ) {
c . o . a . m . a aVar2 = c . o . a . m . a . STEREO ;
c . o . a . m . a aVar3 = c . o . a . m . a . MONO ;
c . o . a . m . a aVar4 = c . o . a . m . a . ON ;
if ( aVar = = aVar4 | | aVar = = aVar3 | | aVar = = aVar2 ) {
try {
for ( String str : getContext ( ) . getPackageManager ( ) . getPackageInfo ( getContext ( ) . getPackageName ( ) , 4096 ) . requestedPermissions ) {
if ( ! str . equals ( " android.permission.RECORD_AUDIO " ) ) {
}
}
throw new IllegalStateException ( j . a ( 3 , " Permission error: when audio is enabled (Audio.ON) the RECORD_AUDIO permission should be added to the app manifest file. " ) ) ;
} catch ( PackageManager . NameNotFoundException unused ) {
}
}
if ( Build . VERSION . SDK_INT < 23 ) {
return true ;
}
Context context = getContext ( ) ;
boolean z2 = aVar = = aVar4 | | aVar = = aVar3 | | aVar = = aVar2 ;
boolean z3 = context . checkSelfPermission ( " android.permission.CAMERA " ) ! = 0 ;
boolean z4 = z2 & & context . checkSelfPermission ( " android.permission.RECORD_AUDIO " ) ! = 0 ;
if ( ! ( z3 | | z4 ) ) {
return true ;
}
if ( this . m ) {
Activity activity = null ;
for ( Context context2 = getContext ( ) ; context2 instanceof ContextWrapper ; context2 = ( ( ContextWrapper ) context2 ) . getBaseContext ( ) ) {
if ( context2 instanceof Activity ) {
activity = ( Activity ) context2 ;
}
}
ArrayList arrayList = new ArrayList ( ) ;
if ( z3 ) {
arrayList . add ( " android.permission.CAMERA " ) ;
}
if ( z4 ) {
arrayList . add ( " android.permission.RECORD_AUDIO " ) ;
}
if ( activity ! = null ) {
activity . requestPermissions ( ( String [ ] ) arrayList . toArray ( new String [ 0 ] ) , 16 ) ;
}
}
return false ;
}
@Override // android.view.ViewGroup
public void addView ( View view , int i2 , ViewGroup . LayoutParams layoutParams ) {
if ( ! this . K ) {
Objects . requireNonNull ( this . L ) ;
if ( layoutParams instanceof c . a ) {
this . L . addView ( view , layoutParams ) ;
return ;
}
}
super . addView ( view , i2 , layoutParams ) ;
}
public final void b ( ) {
i iVar ;
c . o . a . b bVar = j ;
bVar . a ( 2 , " doInstantiateEngine: " , " instantiating. engine: " , this . p ) ;
c . o . a . m . d dVar = this . p ;
b bVar2 = this . u ;
if ( ! this . J | | dVar ! = c . o . a . m . d . CAMERA2 ) {
this . p = c . o . a . m . d . CAMERA1 ;
iVar = new c . o . a . n . b ( bVar2 ) ;
} else {
iVar = new c . o . a . n . d ( bVar2 ) ;
}
2021-07-27 00:35:07 +00:00
this . f2411x = iVar ;
2021-07-24 02:37:17 +00:00
bVar . a ( 2 , " doInstantiateEngine: " , " instantiated. engine: " , iVar . getClass ( ) . getSimpleName ( ) ) ;
2021-07-27 00:35:07 +00:00
this . f2411x . o0 ( this . L ) ;
2021-07-24 02:37:17 +00:00
}
public final boolean c ( ) {
2021-07-27 00:35:07 +00:00
i iVar = this . f2411x ;
2021-07-24 02:37:17 +00:00
return iVar . m . f = = c . o . a . n . v . e . OFF & & ! iVar . O ( ) ;
}
@OnLifecycleEvent ( Lifecycle . Event . ON_PAUSE )
public void close ( ) {
if ( ! this . K ) {
c . o . a . r . f fVar = this . w ;
if ( fVar . h ) {
fVar . h = false ;
fVar . d . disable ( ) ;
( ( DisplayManager ) fVar . b . getSystemService ( " display " ) ) . unregisterDisplayListener ( fVar . f ) ;
fVar . g = - 1 ;
fVar . e = - 1 ;
}
2021-07-27 00:35:07 +00:00
this . f2411x . L0 ( false ) ;
2021-07-24 02:37:17 +00:00
c . o . a . w . a aVar = this . v ;
if ( aVar ! = null ) {
aVar . p ( ) ;
}
}
}
public boolean d ( ) {
2021-07-27 00:35:07 +00:00
c . o . a . n . v . e eVar = this . f2411x . m . f ;
2021-07-24 02:37:17 +00:00
c . o . a . n . v . e eVar2 = c . o . a . n . v . e . ENGINE ;
2021-07-27 00:35:07 +00:00
return eVar . f ( eVar2 ) & & this . f2411x . m . g . f ( eVar2 ) ;
2021-07-24 02:37:17 +00:00
}
@OnLifecycleEvent ( Lifecycle . Event . ON_DESTROY )
public void destroy ( ) {
if ( ! this . K ) {
this . B . clear ( ) ;
boolean z2 = this . C . size ( ) > 0 ;
this . C . clear ( ) ;
if ( z2 ) {
2021-07-27 00:35:07 +00:00
this . f2411x . k0 ( false ) ;
2021-07-24 02:37:17 +00:00
}
2021-07-27 00:35:07 +00:00
this . f2411x . d ( true , 0 ) ;
2021-07-24 02:37:17 +00:00
c . o . a . w . a aVar = this . v ;
if ( aVar ! = null ) {
aVar . o ( ) ;
}
}
}
public boolean e ( @NonNull c . o . a . q . a aVar , @NonNull c . o . a . q . b bVar ) {
c . o . a . q . b bVar2 = c . o . a . q . b . NONE ;
boolean z2 = false ;
if ( aVar . f ( bVar ) ) {
this . n . put ( aVar , bVar ) ;
int ordinal = aVar . ordinal ( ) ;
if ( ordinal = = 0 ) {
e eVar = this . E ;
if ( this . n . get ( c . o . a . q . a . PINCH ) ! = bVar2 ) {
z2 = true ;
}
eVar . a = z2 ;
} else if ( ordinal = = 1 | | ordinal = = 2 ) {
g gVar = this . F ;
if ( ! ( this . n . get ( c . o . a . q . a . TAP ) = = bVar2 & & this . n . get ( c . o . a . q . a . LONG_TAP ) = = bVar2 ) ) {
z2 = true ;
}
gVar . a = z2 ;
} else if ( ordinal = = 3 | | ordinal = = 4 ) {
c . o . a . q . f fVar = this . G ;
if ( ! ( this . n . get ( c . o . a . q . a . SCROLL_HORIZONTAL ) = = bVar2 & & this . n . get ( c . o . a . q . a . SCROLL_VERTICAL ) = = bVar2 ) ) {
z2 = true ;
}
fVar . a = z2 ;
}
return true ;
}
e ( aVar , bVar2 ) ;
return false ;
}
public final String f ( int i2 ) {
if ( i2 = = Integer . MIN_VALUE ) {
return " AT_MOST " ;
}
if ( i2 = = 0 ) {
return " UNSPECIFIED " ;
}
if ( i2 ! = 1073741824 ) {
return null ;
}
return " EXACTLY " ;
}
public final void g ( @NonNull c . o . a . q . c cVar , @NonNull c . o . a . c cVar2 ) {
c . o . a . q . a aVar = cVar . b ;
2021-07-28 07:39:21 +00:00
PointF [ ] pointFArr = cVar . f1502c ;
2021-07-24 02:37:17 +00:00
switch ( this . n . get ( aVar ) . ordinal ( ) ) {
case 1 :
float width = ( float ) getWidth ( ) ;
float height = ( float ) getHeight ( ) ;
RectF a2 = c . o . a . t . b . a ( pointFArr [ 0 ] , width * 0 . 05f , 0 . 05f * height ) ;
ArrayList arrayList = new ArrayList ( ) ;
PointF pointF = new PointF ( a2 . centerX ( ) , a2 . centerY ( ) ) ;
float width2 = a2 . width ( ) ;
float height2 = a2 . height ( ) ;
arrayList . add ( new c . o . a . t . a ( a2 , 1000 ) ) ;
arrayList . add ( new c . o . a . t . a ( c . o . a . t . b . a ( pointF , width2 * 1 . 5f , height2 * 1 . 5f ) , Math . round ( ( ( float ) 1000 ) * 0 . 1f ) ) ) ;
ArrayList arrayList2 = new ArrayList ( ) ;
Iterator it = arrayList . iterator ( ) ;
while ( it . hasNext ( ) ) {
c . o . a . t . a aVar2 = ( c . o . a . t . a ) it . next ( ) ;
Objects . requireNonNull ( aVar2 ) ;
RectF rectF = new RectF ( 0 . 0f , 0 . 0f , width , height ) ;
RectF rectF2 = new RectF ( ) ;
rectF2 . set ( Math . max ( rectF . left , aVar2 . i . left ) , Math . max ( rectF . top , aVar2 . i . top ) , Math . min ( rectF . right , aVar2 . i . right ) , Math . min ( rectF . bottom , aVar2 . i . bottom ) ) ;
arrayList2 . add ( new c . o . a . t . a ( rectF2 , aVar2 . j ) ) ;
}
2021-07-27 00:35:07 +00:00
this . f2411x . I0 ( aVar , new c . o . a . t . b ( arrayList2 ) , pointFArr [ 0 ] ) ;
2021-07-24 02:37:17 +00:00
return ;
case 2 :
2021-07-27 00:35:07 +00:00
this . f2411x . O0 ( new l . a ( ) ) ;
2021-07-24 02:37:17 +00:00
return ;
case 3 :
2021-07-27 00:35:07 +00:00
this . f2411x . P0 ( new l . a ( ) ) ;
2021-07-24 02:37:17 +00:00
return ;
case 4 :
2021-07-27 00:35:07 +00:00
float N = this . f2411x . N ( ) ;
2021-07-24 02:37:17 +00:00
float a3 = cVar . a ( N , 0 . 0f , 1 . 0f ) ;
if ( a3 ! = N ) {
2021-07-27 00:35:07 +00:00
this . f2411x . G0 ( a3 , pointFArr , true ) ;
2021-07-24 02:37:17 +00:00
return ;
}
return ;
case 5 :
2021-07-27 00:35:07 +00:00
float k = this . f2411x . k ( ) ;
2021-07-24 02:37:17 +00:00
float f = cVar2 . m ;
float f2 = cVar2 . n ;
float a4 = cVar . a ( k , f , f2 ) ;
if ( a4 ! = k ) {
2021-07-27 00:35:07 +00:00
this . f2411x . d0 ( a4 , new float [ ] { f , f2 } , pointFArr , true ) ;
2021-07-24 02:37:17 +00:00
return ;
}
return ;
case 6 :
if ( getFilter ( ) instanceof c . o . a . o . d ) {
c . o . a . o . d dVar = ( c . o . a . o . d ) getFilter ( ) ;
float i2 = dVar . i ( ) ;
float a5 = cVar . a ( i2 , 0 . 0f , 1 . 0f ) ;
if ( a5 ! = i2 ) {
dVar . d ( a5 ) ;
return ;
}
return ;
}
return ;
case 7 :
if ( getFilter ( ) instanceof c . o . a . o . e ) {
c . o . a . o . e eVar = ( c . o . a . o . e ) getFilter ( ) ;
float g = eVar . g ( ) ;
float a6 = cVar . a ( g , 0 . 0f , 1 . 0f ) ;
if ( a6 ! = g ) {
eVar . b ( a6 ) ;
return ;
}
return ;
}
return ;
default :
return ;
}
}
@Override // android.widget.FrameLayout, android.view.ViewGroup
public FrameLayout . LayoutParams generateLayoutParams ( AttributeSet attributeSet ) {
if ( ! this . K ) {
c . o . a . u . c cVar = this . L ;
Objects . requireNonNull ( cVar ) ;
boolean z2 = false ;
if ( attributeSet ! = null ) {
TypedArray obtainStyledAttributes = cVar . getContext ( ) . obtainStyledAttributes ( attributeSet , R . c . CameraView_Layout ) ;
if ( obtainStyledAttributes . hasValue ( R . c . CameraView_Layout_layout_drawOnPreview ) | | obtainStyledAttributes . hasValue ( R . c . CameraView_Layout_layout_drawOnPictureSnapshot ) | | obtainStyledAttributes . hasValue ( R . c . CameraView_Layout_layout_drawOnVideoSnapshot ) ) {
z2 = true ;
}
obtainStyledAttributes . recycle ( ) ;
}
if ( z2 ) {
return this . L . generateLayoutParams ( attributeSet ) ;
}
}
return super . generateLayoutParams ( attributeSet ) ;
}
@NonNull
public c . o . a . m . a getAudio ( ) {
2021-07-27 00:35:07 +00:00
return this . f2411x . f ( ) ;
2021-07-24 02:37:17 +00:00
}
public int getAudioBitRate ( ) {
2021-07-27 00:35:07 +00:00
return this . f2411x . g ( ) ;
2021-07-24 02:37:17 +00:00
}
@NonNull
public c . o . a . m . b getAudioCodec ( ) {
2021-07-27 00:35:07 +00:00
return this . f2411x . h ( ) ;
2021-07-24 02:37:17 +00:00
}
public long getAutoFocusResetDelay ( ) {
2021-07-27 00:35:07 +00:00
return this . f2411x . i ( ) ;
2021-07-24 02:37:17 +00:00
}
@Nullable
public c . o . a . c getCameraOptions ( ) {
2021-07-27 00:35:07 +00:00
return this . f2411x . j ( ) ;
2021-07-24 02:37:17 +00:00
}
@NonNull
public c . o . a . m . d getEngine ( ) {
return this . p ;
}
public float getExposureCorrection ( ) {
2021-07-27 00:35:07 +00:00
return this . f2411x . k ( ) ;
2021-07-24 02:37:17 +00:00
}
@NonNull
public c . o . a . m . e getFacing ( ) {
2021-07-27 00:35:07 +00:00
return this . f2411x . l ( ) ;
2021-07-24 02:37:17 +00:00
}
@NonNull
public c . o . a . o . b getFilter ( ) {
c . o . a . w . a aVar = this . v ;
if ( aVar = = null ) {
return this . q ;
}
if ( aVar instanceof c . o . a . w . b ) {
return ( ( c . o . a . w . b ) aVar ) . c ( ) ;
}
StringBuilder K = c . d . b . a . a . K ( " Filters are only supported by the GL_SURFACE preview. Current: " ) ;
K . append ( this . o ) ;
throw new RuntimeException ( K . toString ( ) ) ;
}
@NonNull
public c . o . a . m . f getFlash ( ) {
2021-07-27 00:35:07 +00:00
return this . f2411x . m ( ) ;
2021-07-24 02:37:17 +00:00
}
public int getFrameProcessingExecutors ( ) {
return this . r ;
}
public int getFrameProcessingFormat ( ) {
2021-07-27 00:35:07 +00:00
return this . f2411x . n ( ) ;
2021-07-24 02:37:17 +00:00
}
public int getFrameProcessingMaxHeight ( ) {
2021-07-27 00:35:07 +00:00
return this . f2411x . o ( ) ;
2021-07-24 02:37:17 +00:00
}
public int getFrameProcessingMaxWidth ( ) {
2021-07-27 00:35:07 +00:00
return this . f2411x . p ( ) ;
2021-07-24 02:37:17 +00:00
}
public int getFrameProcessingPoolSize ( ) {
2021-07-27 00:35:07 +00:00
return this . f2411x . q ( ) ;
2021-07-24 02:37:17 +00:00
}
@NonNull
public c . o . a . m . g getGrid ( ) {
return this . H . getGridMode ( ) ;
}
public int getGridColor ( ) {
return this . H . getGridColor ( ) ;
}
@NonNull
public h getHdr ( ) {
2021-07-27 00:35:07 +00:00
return this . f2411x . r ( ) ;
2021-07-24 02:37:17 +00:00
}
@Nullable
public Location getLocation ( ) {
2021-07-27 00:35:07 +00:00
return this . f2411x . s ( ) ;
2021-07-24 02:37:17 +00:00
}
@NonNull
public c . o . a . m . i getMode ( ) {
2021-07-27 00:35:07 +00:00
return this . f2411x . t ( ) ;
2021-07-24 02:37:17 +00:00
}
@NonNull
public j getPictureFormat ( ) {
2021-07-27 00:35:07 +00:00
return this . f2411x . u ( ) ;
2021-07-24 02:37:17 +00:00
}
public boolean getPictureMetering ( ) {
2021-07-27 00:35:07 +00:00
return this . f2411x . v ( ) ;
2021-07-24 02:37:17 +00:00
}
@Nullable
public c . o . a . x . b getPictureSize ( ) {
2021-07-27 00:35:07 +00:00
return this . f2411x . w ( c . o . a . n . t . b . OUTPUT ) ;
2021-07-24 02:37:17 +00:00
}
public boolean getPictureSnapshotMetering ( ) {
2021-07-27 00:35:07 +00:00
return this . f2411x . y ( ) ;
2021-07-24 02:37:17 +00:00
}
public boolean getPlaySounds ( ) {
return this . k ;
}
@NonNull
public k getPreview ( ) {
return this . o ;
}
public float getPreviewFrameRate ( ) {
2021-07-27 00:35:07 +00:00
return this . f2411x . A ( ) ;
2021-07-24 02:37:17 +00:00
}
public boolean getPreviewFrameRateExact ( ) {
2021-07-27 00:35:07 +00:00
return this . f2411x . B ( ) ;
2021-07-24 02:37:17 +00:00
}
public int getSnapshotMaxHeight ( ) {
2021-07-27 00:35:07 +00:00
return this . f2411x . D ( ) ;
2021-07-24 02:37:17 +00:00
}
public int getSnapshotMaxWidth ( ) {
2021-07-27 00:35:07 +00:00
return this . f2411x . E ( ) ;
2021-07-24 02:37:17 +00:00
}
@Nullable
public c . o . a . x . b getSnapshotSize ( ) {
c . o . a . x . b bVar = null ;
if ( ! ( getWidth ( ) = = 0 | | getHeight ( ) = = 0 ) ) {
2021-07-27 00:35:07 +00:00
i iVar = this . f2411x ;
2021-07-24 02:37:17 +00:00
c . o . a . n . t . b bVar2 = c . o . a . n . t . b . VIEW ;
c . o . a . x . b F = iVar . F ( bVar2 ) ;
if ( F = = null ) {
return null ;
}
Rect v = c . i . a . f . e . o . c . v ( F , c . o . a . x . a . f ( getWidth ( ) , getHeight ( ) ) ) ;
bVar = new c . o . a . x . b ( v . width ( ) , v . height ( ) ) ;
2021-07-27 00:35:07 +00:00
if ( this . f2411x . e ( ) . b ( bVar2 , c . o . a . n . t . b . OUTPUT ) ) {
2021-07-24 02:37:17 +00:00
return bVar . f ( ) ;
}
}
return bVar ;
}
public boolean getUseDeviceOrientation ( ) {
return this . l ;
}
public int getVideoBitRate ( ) {
2021-07-27 00:35:07 +00:00
return this . f2411x . G ( ) ;
2021-07-24 02:37:17 +00:00
}
@NonNull
public c . o . a . m . l getVideoCodec ( ) {
2021-07-27 00:35:07 +00:00
return this . f2411x . H ( ) ;
2021-07-24 02:37:17 +00:00
}
public int getVideoMaxDuration ( ) {
2021-07-27 00:35:07 +00:00
return this . f2411x . I ( ) ;
2021-07-24 02:37:17 +00:00
}
public long getVideoMaxSize ( ) {
2021-07-27 00:35:07 +00:00
return this . f2411x . J ( ) ;
2021-07-24 02:37:17 +00:00
}
@Nullable
public c . o . a . x . b getVideoSize ( ) {
2021-07-27 00:35:07 +00:00
return this . f2411x . K ( c . o . a . n . t . b . OUTPUT ) ;
2021-07-24 02:37:17 +00:00
}
@NonNull
public m getWhiteBalance ( ) {
2021-07-27 00:35:07 +00:00
return this . f2411x . M ( ) ;
2021-07-24 02:37:17 +00:00
}
public float getZoom ( ) {
2021-07-27 00:35:07 +00:00
return this . f2411x . N ( ) ;
2021-07-24 02:37:17 +00:00
}
@Override // android.view.View, android.view.ViewGroup
public void onAttachedToWindow ( ) {
c . o . a . w . a aVar ;
super . onAttachedToWindow ( ) ;
if ( ! this . K & & this . v = = null ) {
c . o . a . b bVar = j ;
bVar . a ( 2 , " doInstantiateEngine: " , " instantiating. preview: " , this . o ) ;
k kVar = this . o ;
Context context = getContext ( ) ;
int ordinal = kVar . ordinal ( ) ;
if ( ordinal = = 0 ) {
aVar = new c . o . a . w . h ( context , this ) ;
} else if ( ordinal = = 1 & & isHardwareAccelerated ( ) ) {
aVar = new c . o . a . w . j ( context , this ) ;
} else {
this . o = k . GL_SURFACE ;
aVar = new c . o . a . w . d ( context , this ) ;
}
this . v = aVar ;
bVar . a ( 2 , " doInstantiateEngine: " , " instantiated. preview: " , aVar . getClass ( ) . getSimpleName ( ) ) ;
2021-07-27 00:35:07 +00:00
this . f2411x . u0 ( this . v ) ;
2021-07-24 02:37:17 +00:00
c . o . a . o . b bVar2 = this . q ;
if ( bVar2 ! = null ) {
setFilter ( bVar2 ) ;
this . q = null ;
}
}
}
@Override // android.view.View, android.view.ViewGroup
public void onDetachedFromWindow ( ) {
2021-07-27 00:35:07 +00:00
this . f2412y = null ;
2021-07-24 02:37:17 +00:00
super . onDetachedFromWindow ( ) ;
}
@Override // android.view.ViewGroup
public boolean onInterceptTouchEvent ( MotionEvent motionEvent ) {
return true ;
}
@Override // android.widget.FrameLayout, android.view.View
public void onMeasure ( int i2 , int i3 ) {
if ( this . K ) {
super . onMeasure ( View . MeasureSpec . makeMeasureSpec ( View . MeasureSpec . getSize ( i2 ) , 1073741824 ) , View . MeasureSpec . makeMeasureSpec ( View . MeasureSpec . getSize ( i3 ) , 1073741824 ) ) ;
return ;
}
2021-07-27 00:35:07 +00:00
c . o . a . x . b C = this . f2411x . C ( c . o . a . n . t . b . VIEW ) ;
this . f2412y = C ;
2021-07-24 02:37:17 +00:00
if ( C = = null ) {
j . a ( 2 , " onMeasure: " , " surface is not ready. Calling default behavior. " ) ;
super . onMeasure ( i2 , i3 ) ;
return ;
}
int mode = View . MeasureSpec . getMode ( i2 ) ;
int mode2 = View . MeasureSpec . getMode ( i3 ) ;
int size = View . MeasureSpec . getSize ( i2 ) ;
int size2 = View . MeasureSpec . getSize ( i3 ) ;
2021-07-27 00:35:07 +00:00
c . o . a . x . b bVar = this . f2412y ;
2021-07-24 02:37:17 +00:00
float f = ( float ) bVar . i ;
float f2 = ( float ) bVar . j ;
ViewGroup . LayoutParams layoutParams = getLayoutParams ( ) ;
if ( ! this . v . u ( ) ) {
if ( mode = = 1073741824 ) {
mode = Integer . MIN_VALUE ;
}
if ( mode2 = = 1073741824 ) {
mode2 = Integer . MIN_VALUE ;
}
} else {
if ( mode = = Integer . MIN_VALUE & & layoutParams . width = = - 1 ) {
mode = 1073741824 ;
}
if ( mode2 = = Integer . MIN_VALUE & & layoutParams . height = = - 1 ) {
mode2 = 1073741824 ;
}
}
c . o . a . b bVar2 = j ;
StringBuilder L = c . d . b . a . a . L ( " requested dimensions are ( " , size , " [ " ) ;
L . append ( f ( mode ) ) ;
L . append ( " ]x " ) ;
L . append ( size2 ) ;
L . append ( " [ " ) ;
L . append ( f ( mode2 ) ) ;
L . append ( " ]) " ) ;
bVar2 . a ( 1 , " onMeasure: " , L . toString ( ) ) ;
bVar2 . a ( 1 , " onMeasure: " , " previewSize is " , " ( " + f + " x " + f2 + " ) " ) ;
if ( mode = = 1073741824 & & mode2 = = 1073741824 ) {
bVar2 . a ( 1 , " onMeasure: " , " both are MATCH_PARENT or fixed value. We adapt. " , " This means CROP_CENTER. " , c . d . b . a . a . n ( " ( " , size , " x " , size2 , " ) " ) ) ;
super . onMeasure ( i2 , i3 ) ;
} else if ( mode = = 0 & & mode2 = = 0 ) {
bVar2 . a ( 1 , " onMeasure: " , " both are completely free. " , " We respect that and extend to the whole preview size. " , " ( " + f + " x " + f2 + " ) " ) ;
super . onMeasure ( View . MeasureSpec . makeMeasureSpec ( ( int ) f , 1073741824 ) , View . MeasureSpec . makeMeasureSpec ( ( int ) f2 , 1073741824 ) ) ;
} else {
float f3 = f2 / f ;
if ( mode = = 0 | | mode2 = = 0 ) {
if ( mode = = 0 ) {
size = Math . round ( ( ( float ) size2 ) / f3 ) ;
} else {
size2 = Math . round ( ( ( float ) size ) * f3 ) ;
}
bVar2 . a ( 1 , " onMeasure: " , " one dimension was free, we adapted it to fit the ratio. " , c . d . b . a . a . n ( " ( " , size , " x " , size2 , " ) " ) ) ;
super . onMeasure ( View . MeasureSpec . makeMeasureSpec ( size , 1073741824 ) , View . MeasureSpec . makeMeasureSpec ( size2 , 1073741824 ) ) ;
} else if ( mode = = 1073741824 | | mode2 = = 1073741824 ) {
if ( mode = = Integer . MIN_VALUE ) {
size = Math . min ( Math . round ( ( ( float ) size2 ) / f3 ) , size ) ;
} else {
size2 = Math . min ( Math . round ( ( ( float ) size ) * f3 ) , size2 ) ;
}
bVar2 . a ( 1 , " onMeasure: " , " one dimension was EXACTLY, another AT_MOST. " , " We have TRIED to fit the aspect ratio, but it's not guaranteed. " , c . d . b . a . a . n ( " ( " , size , " x " , size2 , " ) " ) ) ;
super . onMeasure ( View . MeasureSpec . makeMeasureSpec ( size , 1073741824 ) , View . MeasureSpec . makeMeasureSpec ( size2 , 1073741824 ) ) ;
} else {
float f4 = ( float ) size2 ;
float f5 = ( float ) size ;
if ( f4 / f5 > = f3 ) {
size2 = Math . round ( f5 * f3 ) ;
} else {
size = Math . round ( f4 / f3 ) ;
}
bVar2 . a ( 1 , " onMeasure: " , " both dimension were AT_MOST. " , " We fit the preview aspect ratio. " , c . d . b . a . a . n ( " ( " , size , " x " , size2 , " ) " ) ) ;
super . onMeasure ( View . MeasureSpec . makeMeasureSpec ( size , 1073741824 ) , View . MeasureSpec . makeMeasureSpec ( size2 , 1073741824 ) ) ;
}
}
}
@Override // android.view.View
@SuppressLint ( { " ClickableViewAccessibility " } )
public boolean onTouchEvent ( MotionEvent motionEvent ) {
if ( ! d ( ) ) {
return true ;
}
2021-07-27 00:35:07 +00:00
c . o . a . c j2 = this . f2411x . j ( ) ;
2021-07-24 02:37:17 +00:00
if ( j2 ! = null ) {
e eVar = this . E ;
if ( ! eVar . a ? false : eVar . c ( motionEvent ) ) {
j . a ( 1 , " onTouchEvent " , " pinch! " ) ;
g ( this . E , j2 ) ;
} else {
c . o . a . q . f fVar = this . G ;
if ( ! fVar . a ? false : fVar . c ( motionEvent ) ) {
j . a ( 1 , " onTouchEvent " , " scroll! " ) ;
g ( this . G , j2 ) ;
} else {
g gVar = this . F ;
if ( ! gVar . a ? false : gVar . c ( motionEvent ) ) {
j . a ( 1 , " onTouchEvent " , " tap! " ) ;
g ( this . F , j2 ) ;
}
}
}
return true ;
}
throw new IllegalStateException ( " Options should not be null here. " ) ;
}
@OnLifecycleEvent ( Lifecycle . Event . ON_RESUME )
public void open ( ) {
if ( ! this . K ) {
c . o . a . w . a aVar = this . v ;
if ( aVar ! = null ) {
aVar . q ( ) ;
}
if ( a ( getAudio ( ) ) ) {
c . o . a . r . f fVar = this . w ;
if ( ! fVar . h ) {
fVar . h = true ;
fVar . g = fVar . a ( ) ;
( ( DisplayManager ) fVar . b . getSystemService ( " display " ) ) . registerDisplayListener ( fVar . f , fVar . a ) ;
fVar . d . enable ( ) ;
}
2021-07-27 00:35:07 +00:00
c . o . a . n . t . a e = this . f2411x . e ( ) ;
2021-07-24 02:37:17 +00:00
int i2 = this . w . g ;
e . e ( i2 ) ;
e . d = i2 ;
e . d ( ) ;
2021-07-27 00:35:07 +00:00
this . f2411x . H0 ( ) ;
2021-07-24 02:37:17 +00:00
}
}
}
@Override // android.view.ViewGroup, android.view.ViewManager
public void removeView ( View view ) {
ViewGroup . LayoutParams layoutParams = view . getLayoutParams ( ) ;
if ( ! this . K & & layoutParams ! = null ) {
Objects . requireNonNull ( this . L ) ;
if ( layoutParams instanceof c . a ) {
this . L . removeView ( view ) ;
return ;
}
}
super . removeView ( view ) ;
}
public void set ( @NonNull c . o . a . m . c cVar ) {
if ( cVar instanceof c . o . a . m . a ) {
setAudio ( ( c . o . a . m . a ) cVar ) ;
} else if ( cVar instanceof c . o . a . m . e ) {
setFacing ( ( c . o . a . m . e ) cVar ) ;
} else if ( cVar instanceof c . o . a . m . f ) {
setFlash ( ( c . o . a . m . f ) cVar ) ;
} else if ( cVar instanceof c . o . a . m . g ) {
setGrid ( ( c . o . a . m . g ) cVar ) ;
} else if ( cVar instanceof h ) {
setHdr ( ( h ) cVar ) ;
} else if ( cVar instanceof c . o . a . m . i ) {
setMode ( ( c . o . a . m . i ) cVar ) ;
} else if ( cVar instanceof m ) {
setWhiteBalance ( ( m ) cVar ) ;
} else if ( cVar instanceof c . o . a . m . l ) {
setVideoCodec ( ( c . o . a . m . l ) cVar ) ;
} else if ( cVar instanceof c . o . a . m . b ) {
setAudioCodec ( ( c . o . a . m . b ) cVar ) ;
} else if ( cVar instanceof k ) {
setPreview ( ( k ) cVar ) ;
} else if ( cVar instanceof c . o . a . m . d ) {
setEngine ( ( c . o . a . m . d ) cVar ) ;
} else if ( cVar instanceof j ) {
setPictureFormat ( ( j ) cVar ) ;
}
}
public void setAudio ( @NonNull c . o . a . m . a aVar ) {
if ( aVar = = getAudio ( ) | | c ( ) ) {
2021-07-27 00:35:07 +00:00
this . f2411x . Z ( aVar ) ;
2021-07-24 02:37:17 +00:00
} else if ( a ( aVar ) ) {
2021-07-27 00:35:07 +00:00
this . f2411x . Z ( aVar ) ;
2021-07-24 02:37:17 +00:00
} else {
close ( ) ;
}
}
public void setAudioBitRate ( int i2 ) {
2021-07-27 00:35:07 +00:00
this . f2411x . a0 ( i2 ) ;
2021-07-24 02:37:17 +00:00
}
public void setAudioCodec ( @NonNull c . o . a . m . b bVar ) {
2021-07-27 00:35:07 +00:00
this . f2411x . b0 ( bVar ) ;
2021-07-24 02:37:17 +00:00
}
public void setAutoFocusMarker ( @Nullable c . o . a . s . a aVar ) {
View b2 ;
this . A = aVar ;
c . o . a . s . c cVar = this . I ;
View view = cVar . i . get ( 1 ) ;
if ( view ! = null ) {
cVar . removeView ( view ) ;
}
if ( aVar ! = null & & ( b2 = aVar . b ( cVar . getContext ( ) , cVar ) ) ! = null ) {
cVar . i . put ( 1 , b2 ) ;
cVar . addView ( b2 ) ;
}
}
public void setAutoFocusResetDelay ( long j2 ) {
2021-07-27 00:35:07 +00:00
this . f2411x . c0 ( j2 ) ;
2021-07-24 02:37:17 +00:00
}
public void setEngine ( @NonNull c . o . a . m . d dVar ) {
if ( c ( ) ) {
this . p = dVar ;
2021-07-27 00:35:07 +00:00
i iVar = this . f2411x ;
2021-07-24 02:37:17 +00:00
b ( ) ;
c . o . a . w . a aVar = this . v ;
if ( aVar ! = null ) {
2021-07-27 00:35:07 +00:00
this . f2411x . u0 ( aVar ) ;
2021-07-24 02:37:17 +00:00
}
setFacing ( iVar . l ( ) ) ;
setFlash ( iVar . m ( ) ) ;
setMode ( iVar . t ( ) ) ;
setWhiteBalance ( iVar . M ( ) ) ;
setHdr ( iVar . r ( ) ) ;
setAudio ( iVar . f ( ) ) ;
setAudioBitRate ( iVar . g ( ) ) ;
setAudioCodec ( iVar . h ( ) ) ;
setPictureSize ( iVar . x ( ) ) ;
setPictureFormat ( iVar . u ( ) ) ;
setVideoSize ( iVar . L ( ) ) ;
setVideoCodec ( iVar . H ( ) ) ;
setVideoMaxSize ( iVar . J ( ) ) ;
setVideoMaxDuration ( iVar . I ( ) ) ;
setVideoBitRate ( iVar . G ( ) ) ;
setAutoFocusResetDelay ( iVar . i ( ) ) ;
setPreviewFrameRate ( iVar . A ( ) ) ;
setPreviewFrameRateExact ( iVar . B ( ) ) ;
setSnapshotMaxWidth ( iVar . E ( ) ) ;
setSnapshotMaxHeight ( iVar . D ( ) ) ;
setFrameProcessingMaxWidth ( iVar . p ( ) ) ;
setFrameProcessingMaxHeight ( iVar . o ( ) ) ;
setFrameProcessingFormat ( 0 ) ;
setFrameProcessingPoolSize ( iVar . q ( ) ) ;
2021-07-27 00:35:07 +00:00
this . f2411x . k0 ( ! this . C . isEmpty ( ) ) ;
2021-07-24 02:37:17 +00:00
}
}
public void setExperimental ( boolean z2 ) {
this . J = z2 ;
}
public void setExposureCorrection ( float f ) {
c . o . a . c cameraOptions = getCameraOptions ( ) ;
if ( cameraOptions ! = null ) {
float f2 = cameraOptions . m ;
float f3 = cameraOptions . n ;
if ( f < f2 ) {
f = f2 ;
}
if ( f > f3 ) {
f = f3 ;
}
2021-07-27 00:35:07 +00:00
this . f2411x . d0 ( f , new float [ ] { f2 , f3 } , null , false ) ;
2021-07-24 02:37:17 +00:00
}
}
public void setFacing ( @NonNull c . o . a . m . e eVar ) {
2021-07-27 00:35:07 +00:00
this . f2411x . e0 ( eVar ) ;
2021-07-24 02:37:17 +00:00
}
public void setFilter ( @NonNull c . o . a . o . b bVar ) {
c . o . a . w . a aVar = this . v ;
if ( aVar = = null ) {
this . q = bVar ;
return ;
}
boolean z2 = aVar instanceof c . o . a . w . b ;
if ( ! ( bVar instanceof c . o . a . o . c ) & & ! z2 ) {
StringBuilder K = c . d . b . a . a . K ( " Filters are only supported by the GL_SURFACE preview. Current preview: " ) ;
K . append ( this . o ) ;
throw new RuntimeException ( K . toString ( ) ) ;
} else if ( z2 ) {
( ( c . o . a . w . b ) aVar ) . a ( bVar ) ;
}
}
public void setFlash ( @NonNull c . o . a . m . f fVar ) {
2021-07-27 00:35:07 +00:00
this . f2411x . f0 ( fVar ) ;
2021-07-24 02:37:17 +00:00
}
public void setFrameProcessingExecutors ( int i2 ) {
if ( i2 > = 1 ) {
this . r = i2 ;
ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor ( i2 , i2 , 4 , TimeUnit . SECONDS , new LinkedBlockingQueue ( ) , new a ( this ) ) ;
threadPoolExecutor . allowCoreThreadTimeOut ( true ) ;
this . t = threadPoolExecutor ;
return ;
}
throw new IllegalArgumentException ( c . d . b . a . a . j ( " Need at least 1 executor, got " , i2 ) ) ;
}
public void setFrameProcessingFormat ( int i2 ) {
2021-07-27 00:35:07 +00:00
this . f2411x . g0 ( i2 ) ;
2021-07-24 02:37:17 +00:00
}
public void setFrameProcessingMaxHeight ( int i2 ) {
2021-07-27 00:35:07 +00:00
this . f2411x . h0 ( i2 ) ;
2021-07-24 02:37:17 +00:00
}
public void setFrameProcessingMaxWidth ( int i2 ) {
2021-07-27 00:35:07 +00:00
this . f2411x . i0 ( i2 ) ;
2021-07-24 02:37:17 +00:00
}
public void setFrameProcessingPoolSize ( int i2 ) {
2021-07-27 00:35:07 +00:00
this . f2411x . j0 ( i2 ) ;
2021-07-24 02:37:17 +00:00
}
public void setGrid ( @NonNull c . o . a . m . g gVar ) {
this . H . setGridMode ( gVar ) ;
}
public void setGridColor ( @ColorInt int i2 ) {
this . H . setGridColor ( i2 ) ;
}
public void setHdr ( @NonNull h hVar ) {
2021-07-27 00:35:07 +00:00
this . f2411x . l0 ( hVar ) ;
2021-07-24 02:37:17 +00:00
}
public void setLifecycleOwner ( @Nullable LifecycleOwner lifecycleOwner ) {
if ( lifecycleOwner = = null ) {
Lifecycle lifecycle = this . D ;
if ( lifecycle ! = null ) {
lifecycle . removeObserver ( this ) ;
this . D = null ;
return ;
}
return ;
}
Lifecycle lifecycle2 = this . D ;
if ( lifecycle2 ! = null ) {
lifecycle2 . removeObserver ( this ) ;
this . D = null ;
}
Lifecycle lifecycle3 = lifecycleOwner . getLifecycle ( ) ;
this . D = lifecycle3 ;
lifecycle3 . addObserver ( this ) ;
}
public void setLocation ( @Nullable Location location ) {
2021-07-27 00:35:07 +00:00
this . f2411x . m0 ( location ) ;
2021-07-24 02:37:17 +00:00
}
public void setMode ( @NonNull c . o . a . m . i iVar ) {
2021-07-27 00:35:07 +00:00
this . f2411x . n0 ( iVar ) ;
2021-07-24 02:37:17 +00:00
}
public void setPictureFormat ( @NonNull j jVar ) {
2021-07-27 00:35:07 +00:00
this . f2411x . p0 ( jVar ) ;
2021-07-24 02:37:17 +00:00
}
public void setPictureMetering ( boolean z2 ) {
2021-07-27 00:35:07 +00:00
this . f2411x . q0 ( z2 ) ;
2021-07-24 02:37:17 +00:00
}
public void setPictureSize ( @NonNull c . o . a . x . c cVar ) {
2021-07-27 00:35:07 +00:00
this . f2411x . r0 ( cVar ) ;
2021-07-24 02:37:17 +00:00
}
public void setPictureSnapshotMetering ( boolean z2 ) {
2021-07-27 00:35:07 +00:00
this . f2411x . s0 ( z2 ) ;
2021-07-24 02:37:17 +00:00
}
public void setPlaySounds ( boolean z2 ) {
this . k = z2 ;
2021-07-27 00:35:07 +00:00
this . f2411x . t0 ( z2 ) ;
2021-07-24 02:37:17 +00:00
}
public void setPreview ( @NonNull k kVar ) {
c . o . a . w . a aVar ;
boolean z2 = true ;
if ( kVar ! = this . o ) {
this . o = kVar ;
if ( getWindowToken ( ) = = null ) {
z2 = false ;
}
if ( ! z2 & & ( aVar = this . v ) ! = null ) {
aVar . o ( ) ;
this . v = null ;
}
}
}
public void setPreviewFrameRate ( float f ) {
2021-07-27 00:35:07 +00:00
this . f2411x . v0 ( f ) ;
2021-07-24 02:37:17 +00:00
}
public void setPreviewFrameRateExact ( boolean z2 ) {
2021-07-27 00:35:07 +00:00
this . f2411x . w0 ( z2 ) ;
2021-07-24 02:37:17 +00:00
}
public void setPreviewStreamSize ( @NonNull c . o . a . x . c cVar ) {
2021-07-27 00:35:07 +00:00
this . f2411x . x0 ( cVar ) ;
2021-07-24 02:37:17 +00:00
}
public void setRequestPermissions ( boolean z2 ) {
this . m = z2 ;
}
public void setSnapshotMaxHeight ( int i2 ) {
2021-07-27 00:35:07 +00:00
this . f2411x . y0 ( i2 ) ;
2021-07-24 02:37:17 +00:00
}
public void setSnapshotMaxWidth ( int i2 ) {
2021-07-27 00:35:07 +00:00
this . f2411x . z0 ( i2 ) ;
2021-07-24 02:37:17 +00:00
}
public void setUseDeviceOrientation ( boolean z2 ) {
this . l = z2 ;
}
public void setVideoBitRate ( int i2 ) {
2021-07-27 00:35:07 +00:00
this . f2411x . A0 ( i2 ) ;
2021-07-24 02:37:17 +00:00
}
public void setVideoCodec ( @NonNull c . o . a . m . l lVar ) {
2021-07-27 00:35:07 +00:00
this . f2411x . B0 ( lVar ) ;
2021-07-24 02:37:17 +00:00
}
public void setVideoMaxDuration ( int i2 ) {
2021-07-27 00:35:07 +00:00
this . f2411x . C0 ( i2 ) ;
2021-07-24 02:37:17 +00:00
}
public void setVideoMaxSize ( long j2 ) {
2021-07-27 00:35:07 +00:00
this . f2411x . D0 ( j2 ) ;
2021-07-24 02:37:17 +00:00
}
public void setVideoSize ( @NonNull c . o . a . x . c cVar ) {
2021-07-27 00:35:07 +00:00
this . f2411x . E0 ( cVar ) ;
2021-07-24 02:37:17 +00:00
}
public void setWhiteBalance ( @NonNull m mVar ) {
2021-07-27 00:35:07 +00:00
this . f2411x . F0 ( mVar ) ;
2021-07-24 02:37:17 +00:00
}
public void setZoom ( float f ) {
if ( f < 0 . 0f ) {
f = 0 . 0f ;
}
if ( f > 1 . 0f ) {
f = 1 . 0f ;
}
2021-07-27 00:35:07 +00:00
this . f2411x . G0 ( f , null , false ) ;
2021-07-24 02:37:17 +00:00
}
}