package epson.print.inkrpln;

import android.content.Context;

import com.epson.mobilephone.common.maintain2.MaintainPrinter2;

import epson.print.IprintApplication;

public class PrintSettingDependencyBuilder extends DependencyBuilder {
    private final String mEscprLibPrinterId;
    private final String mPrinterIpAddress;
    private final int mPrinterLocation;
    private final String mPrinterModelName;
    private final String mPrinterSerialNumber;

    public PrintSettingDependencyBuilder(String str, String str2, String str3, int i, String str4) {
        mEscprLibPrinterId = str;
        mPrinterIpAddress = str2;
        mPrinterSerialNumber = str3;
        mPrinterLocation = i;
        mPrinterModelName = str4;
    }

    public PrinterAdapter createPrinterAdapter() {
        return new PsPrinterAdapter();
    }

    public InkRplnRepository createInkRplnRepository() {
        return new InkRplnRepository(true);
    }

    class PsPrinterAdapter extends PrinterAdapter {
        PsPrinterAdapter() {
        }

        public String getSerialNo(@NonNull Context context) {
            return PrintSettingDependencyBuilder.this.mPrinterSerialNumber;
        }

        public String getNonRemotePrinterDeviceId(@NonNull Context context) {
            return PrintSettingDependencyBuilder.this.mPrinterModelName;
        }

        public boolean isRemotePrinter(@NonNull Context context) {
            return PrintSettingDependencyBuilder.this.mPrinterLocation == 2;
        }

        public void activateEma() {
            MaintainPrinter2 instance = MaintainPrinter2.getInstance();
            instance.doInitDriver(IprintApplication.getInstance(), 2);
            if (instance.doProbePrinter(60, PrintSettingDependencyBuilder.this.mEscprLibPrinterId, PrintSettingDependencyBuilder.this.mPrinterIpAddress, PrintSettingDependencyBuilder.this.mPrinterLocation) == 0) {
                instance.setMSearchPos(0);
                instance.doSetPrinter();
                super.activateEma();
            }
        }
    }
}
