package epson.scan.lib;

import android.content.Context;
import com.epson.lib.escani2.EscanI2Lib;
import com.epson.lib.escani2.ScanI2Params;
import epson.scan.i2lib.I2ScanParamManager;

public abstract class ScanCommonParams {
    public static boolean convertYesNo(int i) {
        return i == 1;
    }

    public abstract int getScanSourceUnit();

    public abstract int getTwoSideValue();

    public static ScanCommonParams load(Context context) {
        if (ScanInfoStorage.loadEscIVersion(context) != 2) {
            return I1ParamWrapper.load(context);
        }
        return I2ParamWrapper.load(context);
    }

    public EscanI2Lib.InputUnit getI2ScanSourceUnit() {
        return convertInputUnit(getScanSourceUnit());
    }

    public boolean getI2Duplex() {
        return convertYesNo(getTwoSideValue());
    }

    public static EscanI2Lib.InputUnit convertInputUnit(int i) {
        if (i != 1) {
            return EscanI2Lib.InputUnit.FLATBED;
        }
        return EscanI2Lib.InputUnit.ADF;
    }

    public static class I1ParamWrapper extends ScanCommonParams {
        private ScannerInfo mI1ScannerInfo = ScannerInfo.getInstance();

        public static I1ParamWrapper load(Context context) {
            I1ParamWrapper i1ParamWrapper = new I1ParamWrapper();
            ScanInfoStorage instance = ScanInfoStorage.getInstance();
            i1ParamWrapper.mI1ScannerInfo.setSourceValue(instance.getScanSourceUnit(context));
            i1ParamWrapper.mI1ScannerInfo.setTwoSidedScanningValue(instance.getTwoSideValue(context));
            return i1ParamWrapper;
        }

        private I1ParamWrapper() {
        }

        public int getScanSourceUnit() {
            return mI1ScannerInfo.getSourceValue();
        }

        public int getTwoSideValue() {
            return mI1ScannerInfo.getTwoSidedScanningValue();
        }
    }

    public static class I2ParamWrapper extends ScanCommonParams {
        private ScanI2Params mScanI2Params = new ScanI2Params();

        public static I2ParamWrapper load(Context context) {
            I2ParamWrapper i2ParamWrapper = new I2ParamWrapper();
            i2ParamWrapper.mScanI2Params = I2ScanParamManager.loadScanI2Params(context);
            return i2ParamWrapper;
        }

        private I2ParamWrapper() {
        }

        public int getScanSourceUnit() {
            return C24461.$SwitchMap$com$epson$lib$escani2$EscanI2Lib$InputUnit[mScanI2Params.inputUnit.ordinal()] != 1 ? 1 : 0;
        }

        public int getTwoSideValue() {
            return mScanI2Params.duplex ? 1 : 0;
        }
    }

    /* renamed from: epson.scan.lib.ScanCommonParams$1 */
    static /* synthetic */ class C24461 {
        static final /* synthetic */ int[] $SwitchMap$com$epson$lib$escani2$EscanI2Lib$InputUnit = new int[EscanI2Lib.InputUnit.values().length];

        static {
            try {
                $SwitchMap$com$epson$lib$escani2$EscanI2Lib$InputUnit[EscanI2Lib.InputUnit.FLATBED.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
        }
    }
}
