package com.epson.p007sd.common.apf;

import android.media.ExifInterface;
import java.io.IOException;
import java.util.Arrays;

/* renamed from: com.epson.sd.common.apf.apflib */
public class apflib {
    public static final int EPS_APF_INCREMENT_OF_CORRECTION_VALUE = 10;
    public static final int EPS_APF_SHRPNESS_OPTIMUN_VALUE = 30;
    private static final int EPS_CM_COLOR = 0;

    private native int autoCorrectFile(String str, int i, String str2, String str3, boolean z, boolean z2, boolean z3);

    private native int autoCorrectFileWithValue(String str, int i, String str2, String str3, boolean z, boolean z2, int i2, int i3, int i4);

    private native void setInterruptionFlg();

    static {
        System.loadLibrary("apf");
    }

    public boolean apfFile(String str, int i, String str2, String str3) {
        if (isEmpty(str2) || isEmpty(str3) || i > 8) {
            return false;
        }
        if (autoCorrectFile(str, i < 0 ? exifOrientation(str) : i, str2, str3, true, false, false) == 0) {
            return true;
        }
        return false;
    }

    public boolean apfFile(String str, int i, String str2, String str3, boolean z, boolean z2, boolean z3) {
        int i2 = i;
        if (isEmpty(str2) || isEmpty(str3) || i2 > 8 || (!z && !z2)) {
            return false;
        }
        if (autoCorrectFile(str, i2 < 0 ? exifOrientation(str) : i2, str2, str3, z, z2, z3) == 0) {
            return true;
        }
        return false;
    }

    public boolean apfFile(String str, int i, String str2, String str3, boolean z, boolean z2, int i2, int i3, int i4) {
        int i5 = i;
        int i6 = i2;
        if (isEmpty(str2) || isEmpty(str3) || i5 > 8 || ((!z && !z2) || (z2 && (i6 > 127 || i6 < -128)))) {
            return false;
        }
        if (autoCorrectFileWithValue(str, i5 < 0 ? exifOrientation(str) : i5, str2, str3, z, z2, i2, i3, i4) == 0) {
            return true;
        }
        return false;
    }

    public int exifOrientation(String str) {
        try {
            return new ExifInterface(str).getAttributeInt(android.support.media.ExifInterface.TAG_ORIENTATION, 0);
        } catch (IOException unused) {
            return 0;
        }
    }

    public void interrupt() {
        setInterruptionFlg();
    }

    public boolean isDspEpsonColorLogo(String str, int i, int i2, boolean z) {
        if (z && i2 == 0 && Arrays.asList(EpsonColorLogoList.getMediatypeidlist()).contains(Integer.valueOf(i)) && Arrays.asList(EpsonColorLogoList.getDeviceIDList()).contains(str)) {
            return true;
        }
        return false;
    }

    private static boolean isEmpty(String str) {
        return str == null || str.length() == 0;
    }
}
