package epson.scan.i2lib;

import android.content.Context;


import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.epson.lib.escani2.EscanI2Lib;
import com.epson.lib.escani2.I2LibScannerInfoAndCapability;
import com.epson.lib.escani2.ScanI2Params;
import com.epson.lib.escani2.ScanSize;

import java.io.File;
import java.io.IOException;

public class I2ScanParamManager {
    static final int DEFAULT_RESOLUTION = 150;
    private static final String I2SCAN_ALL_INFO_FILE_NAME = "i2_all_info";
    private static final String I2SCAN_PARAM_FILE_NAME = "i2_scan_params.bin";
    private static final String TAG = "I2ScanParamManager";
    private static I2ScanParamManager sI2ScanParamManager;

    public static synchronized I2ScanParamManager getInstance() {
        I2ScanParamManager i2ScanParamManager;
        synchronized (I2ScanParamManager.class) {
            if (sI2ScanParamManager == null) {
                sI2ScanParamManager = new I2ScanParamManager();
            }
            i2ScanParamManager = sI2ScanParamManager;
        }
        return i2ScanParamManager;
    }

    @VisibleForTesting
    protected static void replaceInstance(@Nullable I2ScanParamManager i2ScanParamManager) {
        sI2ScanParamManager = i2ScanParamManager;
    }

    @VisibleForTesting
    protected I2ScanParamManager() {
    }

    public static void saveParams(@NonNull Context context, @NonNull ScanI2Params scanI2Params) throws IOException {
        getInstance().saveParamsNonStatic(context, scanI2Params);
    }


    public void saveParamsNonStatic(@android.support.annotation.NonNull android.content.Context r5, @android.support.annotation.NonNull com.epson.lib.escani2.ScanI2Params r6) throws java.io.IOException {

        throw new UnsupportedOperationException("Method not decompiled: epson.scan.i2lib.I2ScanParamManager.saveParamsNonStatic(android.content.Context, com.epson.lib.escani2.ScanI2Params):void");
    }

    @NonNull
    public static ScanI2Params loadScanI2Params(@NonNull Context context) {
        return getInstance().loadScanI2ParamsNonStatic(context);
    }


    public com.epson.lib.escani2.ScanI2Params loadScanI2ParamsNonStatic(@android.support.annotation.NonNull android.content.Context r4) {

        throw new UnsupportedOperationException("Method not decompiled: epson.scan.i2lib.I2ScanParamManager.loadScanI2ParamsNonStatic(android.content.Context):com.epson.lib.escani2.ScanI2Params");
    }

    public static void deleteScanI2Params(@NonNull Context context) {
        getInstance().deleteAllInfoFileNonStatic(context);
    }

    /* access modifiers changed from: protected */
    @VisibleForTesting
    public void deleteScanI2ParamsNonStatic(@NonNull Context context) {
        File fileStreamPath = context.getFileStreamPath(I2SCAN_PARAM_FILE_NAME);
        if (fileStreamPath.exists()) {
            fileStreamPath.delete();
        }
    }

    public static ScanI2Params getDefaultScanI2Params() {
        ScanI2Params scanI2Params = new ScanI2Params();
        scanI2Params.resolutionMain = 150;
        scanI2Params.resolutionSub = 150;
        scanI2Params.inputUnit = EscanI2Lib.InputUnit.ADF;
        scanI2Params.scanSize = ScanSize.getLocaleDefaultSize();
        scanI2Params.colorMode = EscanI2Lib.ColorMode.COLOR_24BIT;
        scanI2Params.userGamma = EscanI2Lib.Gamma.GAMMA_180;
        scanI2Params.autoCrop = EscanI2Lib.AutoCrop.FALSE;
        scanI2Params.autoSkew = EscanI2Lib.AutoSkew.FALSE;
        scanI2Params.lookupTableNo = 0;
        scanI2Params.duplex = false;
        scanI2Params.overScan = false;
        scanI2Params.density = 128;
        scanI2Params.densityChangeable = false;
        scanI2Params.doubleFeedLevel = EscanI2Lib.DoubleFeedLevel.LEVEL_NONE;
        scanI2Params.maxScanSheets = 30;
        scanI2Params.maxWriteSheets = 30;
        scanI2Params.qualityHW = 90;
        scanI2Params.qualitySW = 90;
        return scanI2Params;
    }

    public static void updateScanSize(Context context, ScanSize scanSize) throws IOException {
        getInstance().updateScanSizeNonStatic(context, scanSize);
    }

    /* access modifiers changed from: protected */
    @VisibleForTesting
    public void updateScanSizeNonStatic(Context context, ScanSize scanSize) throws IOException {
        ScanI2Params loadScanI2Params = loadScanI2Params(context);
        loadScanI2Params.scanSize = scanSize;
        saveParams(context, loadScanI2Params);
    }

    public static void saveI2AllInfo(@NonNull Context context, I2LibScannerInfoAndCapability i2LibScannerInfoAndCapability) throws IOException {
        getInstance().saveI2AllInfoNonStatic(context, i2LibScannerInfoAndCapability);
    }


    public void saveI2AllInfoNonStatic(@android.support.annotation.NonNull android.content.Context r5, com.epson.lib.escani2.I2LibScannerInfoAndCapability r6) throws java.io.IOException {

        throw new UnsupportedOperationException("Method not decompiled: epson.scan.i2lib.I2ScanParamManager.saveI2AllInfoNonStatic(android.content.Context, com.epson.lib.escani2.I2LibScannerInfoAndCapability):void");
    }

    @Nullable
    public static I2LibScannerInfoAndCapability loadI2AllInfo(@NonNull Context context) {
        return getInstance().loadI2AllInfoNonStatic(context);
    }


    public com.epson.lib.escani2.I2LibScannerInfoAndCapability loadI2AllInfoNonStatic(@android.support.annotation.NonNull android.content.Context r4) {

        throw new UnsupportedOperationException("Method not decompiled: epson.scan.i2lib.I2ScanParamManager.loadI2AllInfoNonStatic(android.content.Context):com.epson.lib.escani2.I2LibScannerInfoAndCapability");
    }

    public static void deleteAllInfoFile(@NonNull Context context) {
        getInstance().deleteAllInfoFileNonStatic(context);
    }

    /* access modifiers changed from: protected */
    @VisibleForTesting
    public void deleteAllInfoFileNonStatic(@NonNull Context context) {
        File fileStreamPath = context.getFileStreamPath(I2SCAN_ALL_INFO_FILE_NAME);
        if (fileStreamPath.exists()) {
            fileStreamPath.delete();
        }
    }
}
