小黄书™.apk(点击下载) / e.java


package ly.img.android;

import android.os.Handler;
import android.os.Looper;
import android.util.Base64;
import android.util.Log;
import com.bumptech.glide.load.Key;
import com.facebook.appevents.AppEventsConstants;
import com.facebook.internal.ServerProtocol;
import com.fasterxml.jackson.core.util.MinimalPrettyPrinter;
import java.io.InputStream;
import java.text.ParseException;
import java.util.Date;
import java.util.regex.MatchResult;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import ly.img.android.pesdk.backend.exif.IOUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public final class e {
    private static final Feature[] a = {Feature.TEXT, Feature.BRUSH, Feature.FOCUS, Feature.FRAME, Feature.MAGIC, Feature.CAMERA, Feature.FILTER, Feature.STICKER, Feature.OVERLAY, Feature.TRANSFORM, Feature.ADJUSTMENTS, Feature.TEXT_DESIGN, Feature.ALLOW_CUSTOM_ASSET};
    private static final Feature[] b = {Feature.TRIM, Feature.TEXT, Feature.BRUSH, Feature.FOCUS, Feature.FRAME, Feature.MAGIC, Feature.CAMERA, Feature.FILTER, Feature.STICKER, Feature.OVERLAY, Feature.TRANSFORM, Feature.ADJUSTMENTS, Feature.TEXT_DESIGN, Feature.ALLOW_CUSTOM_ASSET};
    private final String[] c;
    private final String d;
    private final String e;
    private final String[] f;
    private final String g;
    private final String h;
    private final String i;
    private final boolean j;
    private final String k;

    /* renamed from: l  reason: collision with root package name */
    final String f492l;
    private final boolean m;
    private final boolean n;
    private final boolean o;
    private final Feature[] p;

    /* renamed from: q  reason: collision with root package name */
    private g[] f493q;

    static class a implements Comparable<a> {
        private static Pattern a = Pattern.compile("([0-9]+)[.]?([0-9]*)[.]?([0-9]*)");
        int b;
        int c;
        int d;

        a(int i, int i2, int i3) {
            this.b = i;
            this.c = i2;
            this.d = i3;
        }

        static a a(String str) {
            Matcher matcher = a.matcher(str);
            try {
                if (matcher.find()) {
                    MatchResult matchResult = matcher.toMatchResult();
                    String group = matchResult.groupCount() >= 1 ? matchResult.group(1) : AppEventsConstants.EVENT_PARAM_VALUE_YES;
                    String group2 = matchResult.groupCount() >= 2 ? matchResult.group(2) : AppEventsConstants.EVENT_PARAM_VALUE_NO;
                    String group3 = matchResult.groupCount() >= 3 ? matchResult.group(3) : AppEventsConstants.EVENT_PARAM_VALUE_NO;
                    int parseInt = Integer.parseInt(AppEventsConstants.EVENT_PARAM_VALUE_NO + group);
                    int parseInt2 = Integer.parseInt(AppEventsConstants.EVENT_PARAM_VALUE_NO + group2);
                    return new a(parseInt, parseInt2, Integer.parseInt(AppEventsConstants.EVENT_PARAM_VALUE_NO + group3));
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            throw new ParseException("Version string \"" + str + "\" is not in SemVersion Format", 0);
        }

        /* renamed from: a */
        public int compareTo(a aVar) {
            int i = this.b;
            int i2 = aVar.b;
            if (i < i2) {
                return -1;
            }
            if (i > i2) {
                return 1;
            }
            int i3 = this.c;
            int i4 = aVar.c;
            if (i3 < i4) {
                return -1;
            }
            if (i3 > i4) {
                return 1;
            }
            int i5 = this.d;
            int i6 = aVar.d;
            if (i5 < i6) {
                return -1;
            }
            return i5 > i6 ? 1 : 0;
        }
    }

    e(int i2) {
        this(a(i2), true);
    }

    e(String str) {
        this(str, false);
    }

    /* JADX WARNING: Removed duplicated region for block: B:41:0x013d A[Catch:{ ParseException -> 0x015f }] */
    /* JADX WARNING: Removed duplicated region for block: B:45:0x015c A[Catch:{ ParseException -> 0x015f }] */
    /* JADX WARNING: Removed duplicated region for block: B:50:0x0167  */
    /* JADX WARNING: Removed duplicated region for block: B:54:0x018e  */
    /* JADX WARNING: Removed duplicated region for block: B:58:0x0198 A[Catch:{ Exception -> 0x01c3 }] */
    /* JADX WARNING: Removed duplicated region for block: B:62:0x01ba A[Catch:{ Exception -> 0x01c3 }] */
    private e(String str, boolean z) {
        Feature[] featureArr;
        boolean z2;
        String trim = str.trim();
        if (!trim.startsWith("{")) {
            trim = new String(Base64.decode(trim, 0)).trim();
        } else if (trim.indexOf(IOUtils.LINE_SEPARATOR_UNIX) >= 0) {
            trim = trim.replace(IOUtils.LINE_SEPARATOR_UNIX, "").replace("\r", "").replace(MinimalPrettyPrinter.DEFAULT_ROOT_VALUE_SEPARATOR, "");
        }
        try {
            this.i = c(trim);
            JSONObject jSONObject = new JSONObject(trim);
            this.e = d(jSONObject.getString("signature"));
            JSONArray jSONArray = jSONObject.getJSONArray("domains");
            this.c = new String[jSONArray.length()];
            for (int i2 = 0; i2 < this.c.length; i2++) {
                this.c[i2] = jSONArray.getString(i2);
            }
            this.d = jSONObject.getString("owner");
            this.k = jSONObject.has(ServerProtocol.FALLBACK_DIALOG_PARAM_VERSION) ? jSONObject.getString(ServerProtocol.FALLBACK_DIALOG_PARAM_VERSION) : "2.0";
            this.g = jSONObject.getString("platform");
            this.h = jSONObject.getString("api_token");
            this.j = jSONObject.getBoolean("enterprise_license");
            this.f492l = jSONObject.has("minimum_sdk_version") ? jSONObject.getString("minimum_sdk_version") : null;
            JSONArray jSONArray2 = jSONObject.getJSONArray("app_identifiers");
            this.f = new String[jSONArray2.length()];
            for (int i3 = 0; i3 < jSONArray2.length(); i3++) {
                this.f[i3] = jSONArray2.getString(i3);
            }
            long j2 = (!jSONObject.has("expires_at") || jSONObject.isNull("expires_at")) ? Long.MAX_VALUE : jSONObject.getLong("expires_at");
            long time = new Date().getTime() / 1000;
            if (j2 < time) {
                this.n = true;
                this.m = false;
                z2 = true;
            } else if (j2 - 172800000 < time) {
                this.n = false;
                this.m = true;
                this.o = false;
                new Handler(Looper.getMainLooper()).post(new d(this, j2));
                featureArr = a.a(this.k).compareTo(new a(2, 4, 0)) >= 0 ? this.j ? new Feature[]{Feature.NO_EXPORT_TRACKING, Feature.ALLOW_CUSTOM_ASSET, Feature.WHITE_LABEL} : new Feature[]{Feature.ALLOW_CUSTOM_ASSET, Feature.WHITE_LABEL} : new Feature[0];
                if (!jSONObject.has("features")) {
                    JSONArray jSONArray3 = jSONObject.getJSONArray("features");
                    int length = jSONArray3.length();
                    this.p = new Feature[(featureArr.length + length)];
                    for (int i4 = 0; i4 < length; i4++) {
                        this.p[i4] = Feature.parse(jSONArray3.getString(i4));
                    }
                    System.arraycopy(featureArr, 0, this.p, length, featureArr.length);
                } else {
                    this.p = new Feature[0];
                }
                if (!jSONObject.has("products")) {
                    JSONArray jSONArray4 = jSONObject.getJSONArray("products");
                    this.f493q = new g[jSONArray4.length()];
                    for (int i5 = 0; i5 < jSONArray4.length(); i5++) {
                        this.f493q[i5] = g.a(jSONArray4.getString(i5));
                    }
                    return;
                }
                this.f493q = new g[]{g.PESDK};
                return;
            } else {
                this.n = false;
                this.m = false;
                z2 = false;
            }
            this.o = z2;
            try {
                if (a.a(this.k).compareTo(new a(2, 4, 0)) >= 0) {
                }
            } catch (ParseException unused) {
                featureArr = new Feature[0];
            }
            if (!jSONObject.has("features")) {
            }
            try {
                if (!jSONObject.has("products")) {
                }
            } catch (Exception unused2) {
                this.f493q = new g[]{g.PESDK};
            }
        } catch (JSONException e2) {
            throw new LicenseInvalidException("The license file could not be parsed.", e2);
        }
    }

    e(g gVar) {
        this.c = new String[]{"https://api.photoeditorsdk.com"};
        this.d = "DEMO";
        this.e = null;
        this.f = null;
        this.g = "android";
        this.h = c.d();
        this.i = null;
        this.j = false;
        this.m = false;
        this.n = false;
        this.o = true;
        this.k = "2.4";
        this.f492l = null;
        this.p = gVar == g.PESDK ? a : b;
        this.f493q = new g[]{gVar};
    }

    static String a(int i2) {
        return PESDK.getAppContext().getString(i2);
    }

    static String b(String str) {
        InputStream open = c.c().getAssets().open(str);
        byte[] bArr = new byte[open.available()];
        open.read(bArr);
        open.close();
        return new String(bArr, Key.STRING_CHARSET_NAME);
    }

    private String c(String str) {
        int indexOf = str.indexOf("\"signature\"");
        if (indexOf < 0) {
            return "";
        }
        StringBuilder sb = new StringBuilder(str);
        sb.delete(indexOf - 1, str.length() - 1);
        return sb.toString();
    }

    private String d(String str) {
        return str.replace(IOUtils.LINE_SEPARATOR_UNIX, "").replace("\r", "");
    }

    /* access modifiers changed from: package-private */
    public final String a() {
        return this.h;
    }

    /* access modifiers changed from: package-private */
    public final boolean a(String str) {
        if (this.o) {
            return true;
        }
        int i2 = 0;
        while (true) {
            String[] strArr = this.f;
            if (i2 < strArr.length) {
                if (strArr[i2].equalsIgnoreCase(str)) {
                    break;
                }
                if ((this.f[i2] + ".test").equalsIgnoreCase(str)) {
                    break;
                }
                i2++;
            } else {
                return false;
            }
        }
        return true;
    }

    /* access modifiers changed from: package-private */
    public final boolean a(Feature feature) {
        if (this.n) {
            for (int i2 = 0; i2 < 10; i2++) {
                Log.e("IMGLY", "Your trial license has expired. Please contact our sales staff at sales@photoeditorsdk.com.");
            }
        }
        if (this.p.length != 0) {
            int i3 = 0;
            while (true) {
                Feature[] featureArr = this.p;
                if (i3 >= featureArr.length) {
                    return false;
                }
                if (featureArr[i3] == feature) {
                    return true;
                }
                i3++;
            }
        } else {
            throw new AuthorizationException("Please update your Licence version");
        }
    }

    /* access modifiers changed from: package-private */
    public final boolean a(g gVar) {
        for (g gVar2 : this.f493q) {
            if (gVar == gVar2) {
                return true;
            }
        }
        return false;
    }

    /* access modifiers changed from: package-private */
    public final String[] b() {
        return this.c;
    }

    /* access modifiers changed from: package-private */
    public final String c() {
        return this.i;
    }

    /* access modifiers changed from: package-private */
    public final String d() {
        return this.g;
    }

    /* access modifiers changed from: package-private */
    public final String e() {
        return this.e;
    }

    /* access modifiers changed from: package-private */
    public final boolean f() {
        return this.o;
    }

    /* access modifiers changed from: protected */
    public final void finalize() {
        super.finalize();
        System.exit(0);
    }
}