APK反编译源代码展示 - 南明离火平台提供

应用版本信息
应用名称:MiXplorer
版本号:6.67.3
包名称:com.mixplorer

MD5 校验值:13e9f681f5bed77188ac69741746def0

反编译源代码说明

la1.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。


package libs;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Picture;
import android.graphics.Point;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Icon;
import android.media.ExifInterface;
import android.text.Spanned;
import android.text.TextPaint;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.mixplorer.AppImpl;
import com.mixplorer.R;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.List;
import java.util.Locale;
import org.conscrypt.ct.CTConstants;

public abstract class la1 {
    public static Matrix b;
    public static final int a = zr0.z(-1, 230);
    public static final Matrix c = new Matrix();
    public static final Paint d = new Paint(6);
    public static final int e = zr0.z(Color.parseColor("#070F12"), 25);

    public static bk A(Bitmap bitmap) {
        fx0 d2 = fx0.d();
        d2.getClass();
        if (bitmap == null || bitmap.isRecycled()) {
            return null;
        }
        Bitmap[] bitmapArr = {bitmap};
        if (bitmapArr[0] == null) {
            return null;
        }
        return new bk(bitmapArr, d2.b);
    }

    public static Picture B(InputStream inputStream, int i, int i2) {
        try {
            ea0 p = ea0.p(inputStream);
            tm2 H = tm2.H();
            p.E(i);
            p.D(i2);
            return p.B(H);
        } catch (Throwable th) {
            try {
                xv1.j("ImageUtils", "SVG", ui3.B(th));
                zr0.H(inputStream);
                return null;
            } finally {
                zr0.H(inputStream);
            }
        }
    }

    public static bk C(Object obj, String str, int i, int i2) {
        byte[] i3;
        try {
            uy1 uy1Var = new uy1(null);
            if (uy1Var.z()) {
                if (obj == null) {
                    if (vf3.o()) {
                        if (!ui3.u(str)) {
                            if (yd3.g(str) && "mp3".equalsIgnoreCase(ui3.d(str))) {
                            }
                        }
                        obj = uy1Var.f(is0.v(str, "", hp1.g(str), false));
                    }
                }
                if (obj != null && (i3 = uy1Var.i(obj)) != null) {
                    return q(new xs1(), new op(i3), null, i, i2, ug0.c, 1);
                }
            }
        } catch (Throwable th) {
            xv1.j("ImageUtils", "ARTWORK", ui3.A(th));
        }
        return null;
    }

    public static int D(is0 is0Var) {
        int i;
        long j = is0Var.d2;
        if (vf3.u()) {
            i = 100;
        } else if (vf3.o()) {
            i = 50;
        } else {
            i = 20;
        }
        if (j > i * 1024 && !is0Var.l().endsWith(".9.png")) {
            return 1;
        }
        return 0;
    }

    public static void E(is0 is0Var) {
        Point h = z83.h();
        h.x = (int) (h.x * 1.4f);
        h.y = (int) (h.y * 1.4f);
        ga1 ga1Var = new ga1(is0Var, h);
        ha1 ha1Var = new ha1();
        lm0 lm0Var = fx0.d().f;
        lm0Var.a = false;
        synchronized (lm0Var.b) {
            lm0Var.b.notifyAll();
        }
        fx0.d().f(ga1Var, ha1Var);
    }

    public static Bitmap F(Bitmap bitmap, int i) {
        if (i <= 0) {
            return bitmap;
        }
        try {
            Matrix matrix = new Matrix();
            matrix.postRotate(i);
            return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
        } finally {
            bitmap.recycle();
        }
    }

    public static Bitmap G(Bitmap bitmap, int i, int i2, boolean z) {
        int i3;
        if (bitmap != null && !bitmap.isRecycled()) {
            Point H = H(bitmap.getWidth(), bitmap.getHeight(), i, i2);
            int i4 = H.x;
            if (i4 != 0 && (i3 = H.y) != 0) {
                try {
                    return Bitmap.createScaledBitmap(bitmap, i4, i3, false);
                } finally {
                    if (z) {
                        bitmap.recycle();
                    }
                }
            }
            return bitmap;
        }
        return null;
    }

    public static Point H(int i, int i2, int i3, int i4) {
        double d2;
        int min;
        int max = Math.max(i3, i4);
        if (max > 0 && (min = Math.min(i, i2)) > max) {
            double d3 = max;
            double d4 = min;
            Double.isNaN(d3);
            Double.isNaN(d4);
            d2 = d3 / d4;
        } else {
            d2 = -1.0d;
        }
        if (d2 <= 1.0d) {
            return new Point();
        }
        double d5 = i;
        Double.isNaN(d5);
        int ceil = (int) Math.ceil(d5 * d2);
        double d6 = i2;
        Double.isNaN(d6);
        return new Point(ceil, (int) Math.ceil(d6 * d2));
    }

    public static Bitmap I(Spanned spanned, int i, int i2, int i3, int i4) {
        TextView textView = new TextView(tw0.g);
        int i5 = z83.e;
        textView.setSingleLine(false);
        textView.setPadding(i5, i5, i5, i5);
        textView.setGravity(17);
        textView.setBackgroundColor(i4);
        textView.setTextColor(-1);
        textView.setTextSize(0, i3);
        textView.setText(spanned);
        textView.setDrawingCacheEnabled(true);
        textView.setLayoutParams(new ViewGroup.LayoutParams(i, i2));
        textView.setWidth(i);
        textView.setHeight(i2);
        textView.measure(View.MeasureSpec.makeMeasureSpec(0, 0), View.MeasureSpec.makeMeasureSpec(0, 0));
        textView.layout(0, 0, textView.getMeasuredWidth(), textView.getMeasuredHeight());
        textView.buildDrawingCache(true);
        return textView.getDrawingCache();
    }

    public static Bitmap J(Bitmap bitmap, int i) {
        if (bitmap == null || bitmap.isRecycled()) {
            return null;
        }
        try {
            Paint paint = new Paint();
            paint.setColorFilter(new PorterDuffColorFilter(i, PorterDuff.Mode.SRC_IN));
            paint.setFilterBitmap(true);
            try {
                Bitmap d2 = d(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
                Canvas canvas = new Canvas();
                canvas.setBitmap(d2);
                canvas.drawBitmap(bitmap, 0.0f, 0.0f, paint);
                bitmap.recycle();
                return d2;
            } catch (Throwable th) {
                bitmap.recycle();
                try {
                    throw th;
                } catch (Throwable th2) {
                    th = th2;
                    bitmap = null;
                    xv1.h("ImageUtils", ui3.A(th));
                    return bitmap;
                }
            }
        } catch (Throwable th3) {
            th = th3;
        }
    }

    public static Matrix K(int i, int i2, float f, float f2, float f3, float f4, int i3) {
        float f5;
        float f6;
        Matrix matrix;
        if (b == null) {
            if (vf3.w()) {
                matrix = Matrix.IDENTITY_MATRIX;
            } else {
                matrix = null;
            }
            b = new Matrix(matrix);
        }
        b.set(null);
        float f7 = 0.0f;
        if (i3 != 1 ? i2 * f4 > i * f3 : i * f4 > i2 * f3) {
            f5 = f4 / i2;
            f7 = (f3 - (i * f5)) * 0.5f;
            f6 = 0.0f;
        } else {
            float f8 = f3 / i;
            float f9 = (f4 - (i2 * f8)) * 0.5f;
            f5 = f8;
            f6 = f9;
        }
        b.setScale(f5, f5);
        b.postTranslate(((int) (f7 + 0.5f)) + f, ((int) (f6 + 0.5f)) + f2);
        return b;
    }

    public static Matrix L(int i, int i2, Rect rect, int i3) {
        return K(i, i2, rect.left, rect.top, rect.width(), rect.height(), i3);
    }

    public static bk a(Bitmap bitmap) {
        if (bitmap != null && !bitmap.isRecycled()) {
            int width = bitmap.getWidth();
            int height = bitmap.getHeight();
            try {
                Bitmap createBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
                Canvas canvas = new Canvas(createBitmap);
                canvas.drawColor(e);
                Matrix matrix = c;
                matrix.setScale(width / bitmap.getWidth(), height / bitmap.getHeight());
                matrix.postTranslate(0 / 2.0f, 0 / 2.0f);
                canvas.drawBitmap(bitmap, matrix, d);
                bitmap.recycle();
                return A(createBitmap);
            } catch (Throwable th) {
                bitmap.recycle();
                throw th;
            }
        }
        return A(bitmap);
    }

    public static Bitmap b(Bitmap bitmap) {
        if (bitmap != null && !bitmap.isRecycled()) {
            Bitmap createBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
            Canvas canvas = new Canvas(createBitmap);
            canvas.drawARGB(0, 0, 0, 0);
            Paint paint = new Paint(1);
            paint.setColor(-12434878);
            paint.setAlpha(255);
            if (d93.q > 0.0f) {
                RectF rectF = new RectF(0.0f, 0.0f, bitmap.getWidth(), bitmap.getHeight());
                float width = rectF.width() * d93.q;
                canvas.drawRoundRect(rectF, width, width, paint);
            } else {
                float width2 = bitmap.getWidth() / 2.0f;
                canvas.drawCircle(width2, bitmap.getHeight() / 2.0f, width2, paint);
            }
            paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
            Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
            canvas.drawBitmap(bitmap, rect, rect, paint);
            return createBitmap;
        }
        return null;
    }

    public static void c() {
        fx0 d2 = fx0.d();
        d2.getClass();
        xv1.d("ImageDecoder", "Clear memory.");
        try {
            d2.b.t();
            d2.c.a();
        } catch (Throwable th) {
            xv1.s("ImageDecoder", ui3.B(th));
        }
    }

    public static Bitmap d(int i, int i2, Bitmap.Config config) {
        for (int i3 = 0; i3 < 3; i3++) {
            try {
                return Bitmap.createBitmap(i, i2, config);
            } catch (OutOfMemoryError unused) {
                AppImpl.b();
                nl0.y0(1000L);
            } catch (Throwable th) {
                xv1.j("ImageUtils", "CREATE_BITMAP", ui3.A(th));
                return null;
            }
        }
        return null;
    }

    public static Bitmap e(Integer[] numArr, int i, int i2, int i3) {
        Rect rect;
        Paint paint = new Paint();
        Bitmap d2 = d(i2, i2, Bitmap.Config.ARGB_8888);
        if (d2 == null) {
            return null;
        }
        Canvas canvas = new Canvas(d2);
        int i4 = 1;
        for (Integer num : numArr) {
            int intValue = num.intValue();
            if (i4 == 1) {
                int i5 = i2 - i3;
                rect = new Rect(i3, i3, i5, i5);
            } else if (i4 == 2) {
                int i6 = i2 - i3;
                rect = new Rect(i2 / 2, i3, i6, i6);
            } else if (i4 == 3) {
                int i7 = i2 - i3;
                rect = new Rect(i3, i2 / 2, i7, i7);
            } else {
                if (i4 != 4) {
                    break;
                }
                int i8 = i2 / 2;
                int i9 = i2 - i3;
                rect = new Rect(i8, i8, i9, i9);
            }
            paint.setColor(intValue);
            paint.setStrokeWidth(z83.e);
            paint.setAlpha(i);
            canvas.drawRect(rect, paint);
            i4++;
        }
        return d2;
    }

    public static Bitmap f(String str, int i, int i2, Typeface typeface, int i3, int i4, int i5) {
        int i6;
        int i7;
        float measureText;
        Bitmap bitmap = null;
        if (ui3.x(str)) {
            return null;
        }
        if (typeface == null) {
            typeface = Typeface.create(Typeface.SANS_SERIF, 1);
        }
        List list = iw1.e;
        Locale locale = vf3.c;
        if (list.contains(str.toLowerCase(locale))) {
            str = "@";
        }
        boolean k = iw1.k(str);
        if (str.length() > i3) {
            str = str.substring(0, i3);
        }
        String upperCase = str.toUpperCase(locale);
        if (k) {
            i6 = R.drawable.file_icon_script;
        } else {
            i6 = R.drawable.file_icon_auto;
        }
        Bitmap a2 = d93.a(i6, null);
        if (a2 == null) {
            return null;
        }
        Bitmap createScaledBitmap = Bitmap.createScaledBitmap(a2, i4, i5, false);
        if (createScaledBitmap != null) {
            if (!createScaledBitmap.isMutable()) {
                Bitmap copy = createScaledBitmap.copy(Bitmap.Config.ARGB_8888, true);
                if (!createScaledBitmap.equals(copy)) {
                    createScaledBitmap.recycle();
                }
                bitmap = copy;
            } else {
                bitmap = createScaledBitmap;
            }
        }
        int width = bitmap.getWidth();
        if (!k && i != 1001) {
            bitmap = J(bitmap, i);
        }
        Canvas canvas = new Canvas(bitmap);
        TextPaint textPaint = new TextPaint(5);
        textPaint.setStyle(Paint.Style.FILL);
        textPaint.setColor(i2);
        if (typeface != null) {
            textPaint.setTypeface(typeface);
        }
        textPaint.setTextAlign(Paint.Align.CENTER);
        int i8 = width / 3;
        if (upperCase.length() == 1) {
            i7 = width - ((z83.f * 2) + z83.e);
        } else {
            i7 = width;
        }
        do {
            textPaint.setTextSize(i7);
            measureText = textPaint.measureText(upperCase);
            i7 -= i3;
            if (i7 <= 12) {
                break;
            }
        } while (measureText >= width - i8);
        canvas.drawText(upperCase, width / 2, (int) ((canvas.getHeight() / 2) - ((textPaint.ascent() + textPaint.descent()) / 2.0f)), textPaint);
        return bitmap;
    }

    public static Bitmap g() {
        Drawable drawable = tw0.g.getResources().getDrawable(R.drawable.icon_mix_background);
        Drawable drawable2 = tw0.g.getResources().getDrawable(R.drawable.icon_mix_foreground);
        int i = z83.z;
        Bitmap x = c92.x(drawable, i, i);
        Bitmap x2 = c92.x(drawable2, i, i);
        try {
            new Canvas(x).drawBitmap(x2, 0.0f, 0.0f, new Paint(1));
            z90.p(x, false);
        } catch (Throwable unused) {
            if (x != null) {
                x2.recycle();
            }
        }
        return x;
    }

    public static Object h(Bitmap bitmap) {
        Icon createWithResource;
        Icon createWithBitmap;
        if (bitmap != null) {
            try {
                if (vf3.p()) {
                    createWithBitmap = Icon.createWithBitmap(bitmap);
                    return createWithBitmap;
                }
            } catch (Throwable th) {
                xv1.j("ImageUtils", "CWB1", ui3.A(th));
            }
        }
        try {
            if (vf3.p()) {
                createWithResource = Icon.createWithResource(tw0.g, R.mipmap.icon_mix);
                return createWithResource;
            }
            return null;
        } catch (Throwable th2) {
            xv1.j("ImageUtils", "CWB2", ui3.A(th2));
            return null;
        }
    }

    public static Bitmap i(Bitmap bitmap, boolean z) {
        int height;
        Bitmap createBitmap;
        Bitmap bitmap2 = null;
        if (bitmap != null && !bitmap.isRecycled()) {
            try {
                if (bitmap.getWidth() >= bitmap.getHeight()) {
                    createBitmap = Bitmap.createBitmap(bitmap, (bitmap.getWidth() - bitmap.getHeight()) / 2, 0, bitmap.getHeight(), bitmap.getHeight());
                } else {
                    if (z) {
                        height = 0;
                    } else {
                        height = (bitmap.getHeight() - bitmap.getWidth()) / 2;
                    }
                    createBitmap = Bitmap.createBitmap(bitmap, 0, height, bitmap.getWidth(), bitmap.getWidth());
                }
                bitmap2 = createBitmap;
                if (!bitmap2.equals(bitmap)) {
                    bitmap.recycle();
                }
            } catch (Throwable th) {
                xv1.j("ImageUtils", "CROPPED", ui3.A(th));
            }
        }
        return bitmap2;
    }

    public static bk j(bk bkVar, boolean z) {
        if (bkVar == null) {
            return null;
        }
        Bitmap bitmap = bkVar.a;
        Bitmap i = i(bitmap, z);
        if (!bitmap.equals(i)) {
            return A(i);
        }
        return bkVar;
    }

    public static Bitmap[] k(InputStream inputStream, BitmapFactory.Options options, int i, boolean z) {
        int i2 = 1;
        try {
            if (d7.d.e(null) && vf3.k()) {
                return new ya(i2).i(inputStream, options, i, z);
            }
        } catch (Throwable th) {
            xv1.j("ImageUtils", "AVIF", ui3.A(th));
        }
        return null;
    }

    public static bk l(xs1 xs1Var, File file, Integer num, ug0 ug0Var, int i) {
        try {
            return q(xs1Var, new FileInputStream(file), num, 0, 0, ug0Var, i);
        } catch (Throwable unused) {
            return null;
        }
    }

    public static Bitmap m(InputStream inputStream, int i, int i2) {
        if (inputStream == null) {
            return null;
        }
        try {
            Bitmap bitmap = null;
            for (Bitmap bitmap2 : i61.a(inputStream)) {
                if (bitmap2 != null) {
                    if (bitmap != null) {
                        if (bitmap.getWidth() < bitmap2.getWidth()) {
                            bitmap.recycle();
                        } else {
                            bitmap2.recycle();
                        }
                    }
                    bitmap = bitmap2;
                }
            }
            if (bitmap != null) {
                return G(bitmap, i, i2, true);
            }
        } finally {
            try {
                return null;
            } finally {
            }
        }
        return null;
    }

    public static Bitmap n(InputStream inputStream, int i, int i2) {
        try {
            Bitmap i3 = new u6(inputStream).i();
            if (i3 != null) {
                return G(i3, i, i2, true);
            }
        } finally {
            try {
                return null;
            } finally {
            }
        }
        return null;
    }

    public static bk o(InputStream inputStream, String str, int i, int i2, Integer num) {
        int i3;
        int i4;
        File file;
        boolean z;
        int i5 = 1;
        if (i != 0 && i2 != 0) {
            i4 = i;
            i3 = i2;
        } else {
            try {
                Point h = z83.h();
                int i6 = h.x;
                i3 = h.y;
                i4 = i6;
            } finally {
                try {
                    return null;
                } finally {
                }
            }
        }
        if (d7.d.e(null)) {
            if (ui3.u(str)) {
                file = new File(str);
            } else {
                file = null;
            }
            if (file == null || !fp2.I0(file) || !file.canRead()) {
                file = new File(xo3.I(), "raw-" + ui3.t(str) + "." + ui3.d(str));
                if (!file.exists()) {
                    v33.l(inputStream, fp2.R0(file, false), 262144);
                }
            }
            ya yaVar = new ya(i5);
            String path = file.getPath();
            if (num != null && num.intValue() == 1) {
                z = true;
            } else {
                z = false;
            }
            return A(yaVar.l(i4, i3, path, z, false));
        }
        return null;
    }

    public static Bitmap p(InputStream inputStream, int i, int i2, int i3) {
        try {
            int max = Math.max(Math.min(i, i2), z83.z);
            Bitmap createBitmap = Bitmap.createBitmap(max, max, Bitmap.Config.ARGB_8888);
            try {
                new Canvas(createBitmap).drawPicture(B(inputStream, max, max));
                int i4 = 1001;
                if (i3 != 1001) {
                    int width = createBitmap.getWidth();
                    int height = createBitmap.getHeight();
                    int i5 = 0;
                    int i6 = 1001;
                    loop0: while (true) {
                        if (i5 >= width) {
                            break;
                        }
                        int i7 = 0;
                        while (i7 < height) {
                            int pixel = createBitmap.getPixel(i5, i7);
                            if (pixel != 0) {
                                if (pixel != i6 && i6 != i4) {
                                    int red = Color.red(pixel);
                                    int green = Color.green(pixel);
                                    int blue = Color.blue(pixel);
                                    double d2 = red;
                                    Double.isNaN(d2);
                                    double d3 = green;
                                    Double.isNaN(d3);
                                    double d4 = blue;
                                    Double.isNaN(d4);
                                    double d5 = (d4 * 0.114d) + (d3 * 0.587d) + (d2 * 0.299d) + 0.0d + 0.0d + 0.0d;
                                    if (d5 > 5.0d && d5 < 245.0d) {
                                        break loop0;
                                    }
                                }
                                i6 = pixel;
                            }
                            i7 += 6;
                            i4 = 1001;
                        }
                        i5 += 6;
                        i4 = 1001;
                    }
                }
                return createBitmap;
            } catch (Throwable th) {
                th = th;
                try {
                    xv1.j("ImageUtils", "SVG", ui3.B(th));
                    zr0.H(inputStream);
                    return null;
                } finally {
                    zr0.H(inputStream);
                }
            }
        } catch (Throwable th2) {
            th = th2;
        }
    }

    public static bk q(xs1 xs1Var, InputStream inputStream, Integer num, int i, int i2, ug0 ug0Var, int i3) {
        int i4;
        int i5;
        if (inputStream == null) {
            return null;
        }
        try {
            if (!(inputStream instanceof ku0)) {
                inputStream = new ku0(inputStream);
            }
        } catch (Throwable th) {
            th = th;
            inputStream = null;
        }
        try {
            gb0 gb0Var = new gb0();
            gb0Var.b(tg0.d, Integer.valueOf(i3));
            if (i > 0 && i2 > 0) {
                gb0Var.b(tg0.e, ug0Var);
                i4 = i;
                i5 = i2;
                return fx0.d().c(xs1Var, inputStream, num, i4, i5, gb0Var);
            }
            gb0Var.b(tg0.e, ug0.e);
            i4 = 0;
            i5 = 0;
            return fx0.d().c(xs1Var, inputStream, num, i4, i5, gb0Var);
        } catch (Throwable th2) {
            th = th2;
            try {
                xv1.j("ImageUtils", "DECODE_STREAM", ui3.B(th));
                return null;
            } finally {
                zr0.H(inputStream);
            }
        }
    }

    public static Bitmap r(InputStream inputStream, int i, int i2, int i3) {
        try {
            Bitmap n = j82.n(x91.J(inputStream, 65536));
            if (n != null) {
                return G(n, i, i2, true);
            }
        } finally {
            try {
                return null;
            } finally {
            }
        }
        return null;
    }

    public static bk s(InputStream inputStream, int i, int i2, int i3) {
        try {
            Bitmap j = new ya(1).j(inputStream, i, i2, new ra(2));
            if (j != null) {
                return A(G(j, i, i2, true));
            }
        } finally {
            try {
                return null;
            } finally {
            }
        }
        return null;
    }

    public static Bitmap[] t(InputStream inputStream, String str, BitmapFactory.Options options, int i, boolean z) {
        ko koVar;
        int i2 = 1;
        try {
            if (d7.d.e(null)) {
                File file = new File(xo3.I(), "temp-tiff-" + str);
                if (!file.exists()) {
                    try {
                        koVar = fp2.R0(file, false);
                        try {
                            v33.m(inputStream, koVar, 0L, 0L, 262144, null, false);
                            zr0.H(koVar);
                        } catch (Throwable th) {
                            th = th;
                            zr0.H(koVar);
                            throw th;
                        }
                    } catch (Throwable th2) {
                        th = th2;
                        koVar = null;
                    }
                }
                return new ya(i2).k(file.getPath(), options, i, z);
            }
        } catch (Throwable th3) {
            xv1.j("ImageUtils", "TIFF", ui3.A(th3));
        }
        return null;
    }

    public static bk u(InputStream inputStream, int i, int i2, int i3) {
        InputStream inputStream2;
        boolean z;
        InputStream inputStream3;
        Bitmap bitmap;
        int i4 = 1;
        try {
            boolean j = vf3.j();
            z = !j;
            if (j) {
                try {
                    if (!inputStream.markSupported()) {
                        inputStream2 = inputStream;
                        try {
                            inputStream3 = new jo(inputStream2, 16384);
                        } catch (Throwable unused) {
                            if (!z) {
                            }
                        }
                    } else {
                        inputStream3 = inputStream;
                    }
                    try {
                        z = zq3.a(inputStream3);
                    } catch (Throwable unused2) {
                    }
                    inputStream2 = inputStream3;
                } catch (Throwable unused3) {
                    inputStream2 = inputStream;
                }
            } else {
                inputStream2 = inputStream;
            }
            try {
            } catch (Throwable th) {
                th = th;
                try {
                    xv1.j("ImageUtils", "WEBP", ui3.A(th));
                    return null;
                } finally {
                    zr0.H(inputStream2);
                }
            }
        } catch (Throwable th2) {
            th = th2;
            inputStream2 = inputStream;
        }
        if (!z) {
            ra raVar = new ra(i4);
            ya yaVar = new ya(i4);
            try {
                Class cls = Integer.TYPE;
                bitmap = (Bitmap) yaVar.d("decodeWebp", new Class[]{InputStream.class, cls, cls, Object.class}, new Object[]{inputStream2, Integer.valueOf(i), Integer.valueOf(i2), raVar});
            } catch (Throwable unused4) {
                bitmap = null;
            }
            if (bitmap != null) {
                return A(G(bitmap, i, i2, true));
            }
            return null;
        }
        return q(new xs1(), inputStream2, null, i, i2, ug0.c, i3);
    }

    public static bk v(is0 is0Var, int i, int i2, boolean z) {
        bk bkVar;
        InputStream inputStream;
        ug0 ug0Var = ug0.c;
        if (is0Var == null) {
            return null;
        }
        try {
            if (!is0Var.N1 && !ui3.x(is0Var.v2)) {
                try {
                    inputStream = is0Var.D().t0(i, i2, is0Var.v2);
                } catch (Throwable th) {
                    th = th;
                    inputStream = null;
                }
                try {
                    bkVar = q(new xs1(), inputStream, null, i, i2, ug0Var, 1);
                    try {
                        zr0.H(inputStream);
                        return bkVar;
                    } catch (Throwable unused) {
                    }
                } catch (Throwable th2) {
                    th = th2;
                    zr0.H(inputStream);
                    throw th;
                }
            }
        } catch (Throwable unused2) {
        }
        bkVar = null;
        try {
            bkVar = mq1.c(is0Var, i, i2);
        } catch (Throwable unused3) {
        }
        if (bkVar == null && is0Var.N1) {
            bkVar = C(null, is0Var.c2, i, i2);
        }
        if (bkVar == null && z) {
            return A(d(1, 1, Bitmap.Config.RGB_565));
        }
        return bkVar;
    }

    public static bk w(InputStream inputStream, is0 is0Var, int i, int i2) {
        Integer num;
        Bitmap r;
        fx0 d2;
        int a2;
        int i3 = 1;
        try {
        } catch (Throwable th) {
            th = th;
            try {
                xv1.j("ImageUtils", "RAW", ui3.A(th));
                return null;
            } finally {
                zr0.H(inputStream);
            }
        }
        if (d7.d.e(null) && is0Var.N1) {
            File file = new File(is0Var.c2);
            if (!file.exists() || !file.canRead()) {
                file = new File(xo3.I(), "raw-" + ui3.t(is0Var.c2) + "." + is0Var.P1);
                if (!file.exists()) {
                    v33.l(inputStream, fp2.R0(file, false), 262144);
                }
            }
            zr0.H(inputStream);
            return A(new ya(i3).l(i, i2, file.getPath(), true, true));
        }
        int i4 = 180;
        if (is0Var.N1) {
            try {
                d2 = fx0.d();
                d2.getClass();
            } catch (Throwable unused) {
                num = null;
            }
            try {
                if (inputStream != null) {
                    try {
                        a2 = new ea1(inputStream, d2.c).a();
                    } catch (Throwable unused2) {
                    }
                    if (a2 < 0) {
                        num = Integer.valueOf(a2);
                    } else {
                        num = null;
                    }
                    zr0.H(inputStream);
                    if (!is0Var.l2 && vf3.r() && r != null) {
                        if (num != null) {
                            try {
                                if (num.intValue() > 0) {
                                    int intValue = num.intValue();
                                    Paint paint = ml3.a;
                                    switch (intValue) {
                                        case CTConstants.CERTIFICATE_LENGTH_BYTES:
                                        case 4:
                                            break;
                                        case 5:
                                        case 6:
                                            i4 = 90;
                                            break;
                                        case 7:
                                        case CTConstants.TIMESTAMP_LENGTH:
                                            i4 = 270;
                                            break;
                                        default:
                                            i4 = 0;
                                            break;
                                    }
                                    r = F(r, i4);
                                }
                            } catch (Throwable unused3) {
                            }
                        }
                        return A(r);
                    }
                    inputStream = null;
                }
                if (!is0Var.l2) {
                }
                inputStream = null;
            } catch (Throwable th2) {
                th = th2;
                inputStream = null;
                xv1.j("ImageUtils", "RAW", ui3.A(th));
                return null;
            }
            a2 = 0;
            if (a2 < 0) {
            }
            zr0.H(inputStream);
        } else {
            num = null;
        }
        if (inputStream == null) {
            inputStream = is0Var.T(0L);
        }
        io0 io0Var = new io0(inputStream, true);
        if (io0Var.u()) {
            Bitmap q = io0Var.q();
            if (q != null && num != null && num.intValue() > 0) {
                int intValue2 = num.intValue();
                Paint paint2 = ml3.a;
                switch (intValue2) {
                    case CTConstants.CERTIFICATE_LENGTH_BYTES:
                    case 4:
                        break;
                    case 5:
                    case 6:
                        i4 = 90;
                        break;
                    case 7:
                    case CTConstants.TIMESTAMP_LENGTH:
                        i4 = 270;
                        break;
                    default:
                        i4 = 0;
                        break;
                }
                q = F(q, i4);
            }
            return A(q);
        }
        return null;
    }

    public static bk x(h42 h42Var) {
        fx0.d().getClass();
        return fx0.g(h42Var);
    }

    public static Object[] y(InputStream inputStream, xs1 xs1Var) {
        try {
            BitmapFactory.Options options = new BitmapFactory.Options();
            options.inJustDecodeBounds = true;
            inputStream.mark(5242880);
            if (xs1Var.a) {
                t(inputStream, xs1Var.d, options, 0, false);
            } else if (xs1Var.b) {
                k(inputStream, options, 0, false);
                if (options.inJustDecodeBounds && options.outWidth <= 0) {
                    inputStream.reset();
                    inputStream.mark(5242880);
                    xs1Var.b = false;
                    BitmapFactory.decodeStream(inputStream, null, options);
                }
            } else {
                BitmapFactory.decodeStream(inputStream, null, options);
            }
            int i = options.outWidth;
            int i2 = options.outHeight;
            Object[] objArr = {Integer.valueOf(i), Integer.valueOf(i2), options.outMimeType};
            zr0.H(inputStream);
            return objArr;
        } catch (Throwable unused) {
            zr0.H(inputStream);
            return null;
        }
    }

    public static int z(InputStream inputStream, xs1 xs1Var) {
        int i = 0;
        int i2 = 1;
        int i3 = -1;
        try {
            inputStream.mark(5242880);
            if (xs1Var.b && d7.d.e(null)) {
                try {
                    i = ((Integer) new ya(i2).d("getOrientation", new Class[]{InputStream.class, Integer.TYPE}, new Object[]{inputStream, Integer.valueOf(xs1Var.c)})).intValue();
                } catch (Throwable unused) {
                }
                i3 = i;
            } else if (vf3.r()) {
                i3 = new ExifInterface(inputStream).getAttributeInt("Orientation", -1);
            } else {
                jo0 jo0Var = new jo0(inputStream);
                do0 e2 = jo0Var.e("Orientation");
                if (e2 != null) {
                    i3 = e2.f(jo0Var.e);
                }
            }
        } catch (Throwable unused2) {
        }
        try {
            inputStream.reset();
        } catch (Throwable unused3) {
        }
        return i3;
    }
}