package com.kofax.kmc.ken.engines.data; import android.graphics.Point; import com.google.android.gms.maps.model.BitmapDescriptorFactory; import com.kofax.BuildConfig; import com.kofax.kmc.ken.engines.data.BoundingTetragon; import com.kofax.kmc.ken.engines.version.KenVersion; import com.kofax.kmc.kut.utilities.SdkVersion; import com.kofax.kmc.kut.utilities.error.ErrorInfo; import com.kofax.kmc.kut.utilities.error.KmcException; import com.kofax.kmc.kut.utilities.error.KmcRuntimeException; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import o.gjJ; @Deprecated /* loaded from: classes3.dex */ public class BasicSettingsProfile implements Serializable, Cloneable { private static final String TAG = "BasicSettingsProfile"; private static final long serialVersionUID = -9103212200093175144L; private transient RotateType bZ = RotateType.ROTATE_NONE; private transient CropType ca = CropType.CROP_NONE; private transient BoundingTetragon cb = null; private transient Boolean cc = Boolean.FALSE; private transient Integer outputDPI = null; private transient OutputBitDepth cd = OutputBitDepth.COLOR; private transient Float ce = null; private transient Float cf = null; /* loaded from: classes3.dex */ public enum CropType { CROP_NONE, CROP_AUTO, CROP_TETRAGON, CROP_QUICKANALYSIS } /* loaded from: classes3.dex */ public enum OutputBitDepth { BITONAL, GRAYSCALE, COLOR } /* loaded from: classes3.dex */ public enum RotateType { ROTATE_NONE, ROTATE_90, ROTATE_180, ROTATE_270, ROTATE_AUTO } /* renamed from: clone, reason: merged with bridge method [inline-methods] */ public BasicSettingsProfile m267clone() { try { BasicSettingsProfile basicSettingsProfile = (BasicSettingsProfile) super.clone(); BoundingTetragon boundingTetragon = basicSettingsProfile.cb; if (boundingTetragon != null) { basicSettingsProfile.cb = boundingTetragon.m268clone(); } return basicSettingsProfile; } catch (CloneNotSupportedException unused) { throw new InternalError("BasicSettingsProfile: unexpected clone not supported exception"); } } public void setRotateType(RotateType rotateType) { a(rotateType, "rotateType"); this.bZ = rotateType; } public void setCropType(CropType cropType) { a(cropType, "cropType"); this.ca = cropType; } public BoundingTetragon getCroppingTetragon() { BoundingTetragon boundingTetragon = this.cb; if (boundingTetragon != null) { return new BoundingTetragon(boundingTetragon.getTopLeft(), this.cb.getTopRight(), this.cb.getBottomLeft(), this.cb.getBottomRight()); } return null; } public void setCroppingTetragon(BoundingTetragon boundingTetragon) { if (boundingTetragon == null) { this.cb = null; return; } f(boundingTetragon); if (this.cb == null) { this.cb = new BoundingTetragon(); } this.cb.setTopLeft(boundingTetragon.getTopLeft()); this.cb.setTopRight(boundingTetragon.getTopRight()); this.cb.setBottomLeft(boundingTetragon.getBottomLeft()); this.cb.setBottomRight(boundingTetragon.getBottomRight()); } public boolean getDoDeskew() { return this.cc.booleanValue(); } public void setDoDeskew(boolean z) { a(Boolean.valueOf(z), "doDeskew"); this.cc = Boolean.valueOf(z); } public void setOutputDPI(Integer num) { if (num != null) { a(num, "outputDPI"); } this.outputDPI = num; } public void setInputDocLongEdge(Float f) { if (f != null) { a(f, "inputDocLongEdge"); } this.ce = f; } public void setInputDocShortEdge(Float f) { if (f != null) { a(f, "inputDocShortEdge"); } this.cf = f; } private void a(Object obj, String str) { if (obj == null) { StringBuilder sb = new StringBuilder("'"); sb.append(str); sb.append("' parameter is null"); throw new NullPointerException(sb.toString()); } if ((!obj.getClass().getSimpleName().equals("Integer") || ((Integer) obj).intValue() >= 0) && (!obj.getClass().getSimpleName().equals("Float") || ((Float) obj).floatValue() >= BitmapDescriptorFactory.HUE_RED)) { return; } ErrorInfo errorInfo = ErrorInfo.KMC_GN_PARAM_NEGATIVE; StringBuilder sb2 = new StringBuilder("'"); sb2.append(str); sb2.append("' parameter is negative"); errorInfo.setErrCause(sb2.toString()); throw new KmcRuntimeException(errorInfo); } /* JADX INFO: Access modifiers changed from: private */ public boolean a(Float f) { return f != null && Math.abs(f.floatValue()) >= 1.0E-6f; } private void writeObject(ObjectOutputStream objectOutputStream) throws IOException { objectOutputStream.defaultWriteObject(); objectOutputStream.writeObject(BasicSettingsProfile.class.getName()); objectOutputStream.writeObject(KenVersion.getPackageVersion()); objectOutputStream.writeObject(this.bZ); objectOutputStream.writeObject(this.ca); objectOutputStream.writeObject(this.cb); objectOutputStream.writeObject(this.cc); objectOutputStream.writeObject(this.outputDPI); objectOutputStream.writeObject(this.cd); objectOutputStream.writeObject(this.ce); objectOutputStream.writeObject(this.cf); } private void readObject(ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException, KmcRuntimeException { objectInputStream.defaultReadObject(); if (BasicSettingsProfile.class.getName().compareToIgnoreCase((String) objectInputStream.readObject()) == 0) { if (SdkVersion.versionCompatible(KenVersion.getPackageVersion(), (String) objectInputStream.readObject()).booleanValue()) { this.bZ = (RotateType) objectInputStream.readObject(); this.ca = (CropType) objectInputStream.readObject(); this.cb = (BoundingTetragon) objectInputStream.readObject(); this.cc = (Boolean) objectInputStream.readObject(); this.outputDPI = (Integer) objectInputStream.readObject(); this.cd = (OutputBitDepth) objectInputStream.readObject(); this.ce = (Float) objectInputStream.readObject(); this.cf = (Float) objectInputStream.readObject(); return; } throw new KmcRuntimeException(ErrorInfo.KMC_GN_DESERIALIZE_VERSION_ERROR); } throw new KmcRuntimeException(ErrorInfo.KMC_GN_DESERIALIZE_OBJECT_ERROR); } private void f(BoundingTetragon boundingTetragon) { Point topLeft = boundingTetragon.getTopLeft(); Point topRight = boundingTetragon.getTopRight(); Point bottomLeft = boundingTetragon.getBottomLeft(); Point bottomRight = boundingTetragon.getBottomRight(); if (topLeft.x >= topRight.x - 24 || bottomLeft.x >= bottomRight.x - 24 || topLeft.y >= bottomLeft.y - 24 || topRight.y >= bottomRight.y - 24) { throw new IllegalArgumentException("Cropping tetragon must be larger than 24 pixels"); } } /* loaded from: classes3.dex */ public class FriendBSP { private static final String DO_BINARIZATION = "_DoBinarization_"; private static final String DO_CROP_CORRECTION = "_DoCropCorrection_"; private static final String DO_ENHANCED_BINARIZATION = "_DoEnhancedBinarization_"; private static final String DO_GRAY_OUTPUT = "_DoGrayOutput_"; private static final String DO_SKEW_CORRECTION_PAGE = "_DoSkewCorrectionPage_"; private static final String ch = "_Do90DegreeRotation_0"; private static final String ci = "_Do90DegreeRotation_3"; private static final String cj = "_Do90DegreeRotation_2"; private static final String ck = "_Do90DegreeRotation_1"; private static final String cl = "_Do90DegreeRotation_4"; private static final String cm = "_DoScaleBWImageToDPI_"; private static final String cn = "_DoScaleCGImageToDPI_"; private static final String co = "_DocDimLarge_"; private static final String cp = "_DocDimSmall_"; private static final String cq = "_LoadSetting_"; private static final int cr = 300; final BasicSettingsProfile cs; public FriendBSP(BasicSettingsProfile basicSettingsProfile, String str) throws KmcException { this.cs = basicSettingsProfile; if (!gjJ.c((CharSequence) str, (CharSequence) BuildConfig.APPLICATION_ID)) { throw new KmcException(ErrorInfo.KMC_GN_UNSUPPORTED_OPERATION); } } public String toFinalOpString() { String str; String str2; if (this.cs.bZ != RotateType.ROTATE_NONE) { BasicSettingsProfile basicSettingsProfile = this.cs; basicSettingsProfile.bZ = basicSettingsProfile.bZ; if (this.cs.bZ == RotateType.ROTATE_90) { str = "_DeviceType_2_Do90DegreeRotation_3"; } else if (this.cs.bZ == RotateType.ROTATE_180) { str = "_DeviceType_2_Do90DegreeRotation_2"; } else if (this.cs.bZ == RotateType.ROTATE_270) { str = "_DeviceType_2_Do90DegreeRotation_1"; } else { if (this.cs.bZ != RotateType.ROTATE_AUTO) { throw new IllegalArgumentException("unable to recognize rotateType"); } str = "_DeviceType_2_Do90DegreeRotation_4"; } } else { str = "_DeviceType_2"; } if (this.cs.ca != CropType.CROP_NONE) { if (this.cs.ca != CropType.CROP_AUTO) { if (this.cs.ca == CropType.CROP_TETRAGON) { BasicSettingsProfile basicSettingsProfile2 = this.cs; basicSettingsProfile2.cb = basicSettingsProfile2.cb; BoundingTetragon.FriendBT friendBT = null; if (this.cs.cb == null) { str2 = "CropType requires non-null tetragon"; } else { str2 = (this.cs.cb.getTopLeft() == null || this.cs.cb.getTopRight() == null || this.cs.cb.getBottomLeft() == null || this.cs.cb.getBottomRight() == null) ? "CropType requires non-null points" : null; } if (str2 != null) { throw new IllegalArgumentException(str2); } try { friendBT = new BoundingTetragon.FriendBT(this.cs.cb, BuildConfig.APPLICATION_ID); } catch (KmcException unused) { str2 = "Unable to convert croppingTetragon"; } if (str2 != null) { throw new IllegalArgumentException(str2); } if (!friendBT.isValid()) { throw new IllegalArgumentException("Specified tetragon is unsorted"); } StringBuilder sb = new StringBuilder(); sb.append(str); sb.append("_DoCropCorrection_"); String obj = sb.toString(); StringBuilder sb2 = new StringBuilder(); sb2.append(obj); sb2.append(friendBT.toExtCornersOpString(cq)); str = sb2.toString(); } else if (this.cs.ca == CropType.CROP_QUICKANALYSIS) { StringBuilder sb3 = new StringBuilder(); sb3.append(str); sb3.append("_DoCropCorrection_"); str = sb3.toString(); } else { throw new IllegalArgumentException("Unable to recognize crop type"); } } else { StringBuilder sb4 = new StringBuilder(); sb4.append(str); sb4.append("_DoCropCorrection_"); str = sb4.toString(); } } if (this.cs.cc.booleanValue()) { StringBuilder sb5 = new StringBuilder(); sb5.append(str); sb5.append("_DoSkewCorrectionPage_"); str = sb5.toString(); } OutputBitDepth outputBitDepth = this.cs.cd; if (outputBitDepth == null) { outputBitDepth = OutputBitDepth.COLOR; } if (outputBitDepth != OutputBitDepth.COLOR) { if (outputBitDepth == OutputBitDepth.GRAYSCALE) { StringBuilder sb6 = new StringBuilder(); sb6.append(str); sb6.append("_DoGrayOutput_"); str = sb6.toString(); } else if (outputBitDepth != OutputBitDepth.BITONAL) { throw new IllegalArgumentException("unable to recognize outputBitDepth"); } } int intValue = (this.cs.outputDPI == null || this.cs.outputDPI.intValue() == 0) ? 0 : this.cs.outputDPI.intValue(); if (outputBitDepth != OutputBitDepth.BITONAL) { if (intValue > 0) { StringBuilder sb7 = new StringBuilder(); sb7.append(str); sb7.append(cn); sb7.append(intValue); str = sb7.toString(); } } else if (intValue == 0) { StringBuilder sb8 = new StringBuilder(); sb8.append(str); sb8.append("_DoBinarization_"); str = sb8.toString(); } else if (intValue < cr) { StringBuilder sb9 = new StringBuilder(); sb9.append(str); sb9.append("_DoBinarization__DoScaleBWImageToDPI_"); sb9.append(intValue); str = sb9.toString(); } else { StringBuilder sb10 = new StringBuilder(); sb10.append(str); sb10.append("_DoEnhancedBinarization__DoScaleBWImageToDPI_"); sb10.append(intValue); str = sb10.toString(); } BasicSettingsProfile basicSettingsProfile3 = this.cs; if (basicSettingsProfile3.a(basicSettingsProfile3.ce)) { StringBuilder sb11 = new StringBuilder(); sb11.append(str); sb11.append(co); sb11.append(String.valueOf(this.cs.ce)); str = sb11.toString(); } BasicSettingsProfile basicSettingsProfile4 = this.cs; if (!basicSettingsProfile4.a(basicSettingsProfile4.cf)) { return str; } StringBuilder sb12 = new StringBuilder(); sb12.append(str); sb12.append(cp); sb12.append(String.valueOf(this.cs.cf)); return sb12.toString(); } } public void setOutputBitDepth(OutputBitDepth outputBitDepth) { this.cd = outputBitDepth; } public RotateType getRotateType() { return this.bZ; } public Integer getOutputDPI() { return this.outputDPI; } public OutputBitDepth getOutputBitDepth() { return this.cd; } public Float getInputDocShortEdge() { return this.cf; } public Float getInputDocLongEdge() { return this.ce; } public CropType getCropType() { return this.ca; } }