package androidx.core.graphics.drawable;

import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.Shader;
import android.graphics.drawable.Icon;
import android.net.Uri;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.Log;
import androidx.versionedparcelable.CustomVersionedParcelable;
import com.google.android.gms.internal.measurement.A1;
import io.flutter.embedding.engine.renderer.FlutterRenderer;

/* JADX INFO: loaded from: classes.dex */
public class IconCompat extends CustomVersionedParcelable {

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    public static final PorterDuff.Mode f3929k = PorterDuff.Mode.SRC_IN;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public int f3930a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public Object f3931b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public byte[] f3932c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public Parcelable f3933d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public int f3934e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public int f3935f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public ColorStateList f3936g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public PorterDuff.Mode f3937h;
    public String i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public String f3938j;

    public IconCompat() {
        this.f3930a = -1;
        this.f3932c = null;
        this.f3933d = null;
        this.f3934e = 0;
        this.f3935f = 0;
        this.f3936g = null;
        this.f3937h = f3929k;
        this.i = null;
    }

    public static IconCompat a(Bundle bundle) {
        int i = bundle.getInt("type");
        IconCompat iconCompat = new IconCompat(i);
        iconCompat.f3934e = bundle.getInt("int1");
        iconCompat.f3935f = bundle.getInt("int2");
        iconCompat.f3938j = bundle.getString("string1");
        if (bundle.containsKey("tint_list")) {
            iconCompat.f3936g = (ColorStateList) bundle.getParcelable("tint_list");
        }
        if (bundle.containsKey("tint_mode")) {
            iconCompat.f3937h = PorterDuff.Mode.valueOf(bundle.getString("tint_mode"));
        }
        switch (i) {
            case FlutterRenderer.ViewportMetrics.unsetValue /* -1 */:
            case 1:
            case 5:
                iconCompat.f3931b = bundle.getParcelable("obj");
                return iconCompat;
            case 0:
            default:
                Log.w("IconCompat", "Unknown type " + i);
                return null;
            case 2:
            case 4:
            case 6:
                iconCompat.f3931b = bundle.getString("obj");
                return iconCompat;
            case 3:
                iconCompat.f3931b = bundle.getByteArray("obj");
                return iconCompat;
        }
    }

    public static IconCompat b(Icon icon) {
        icon.getClass();
        int iO = A1.o(icon);
        if (iO == 2) {
            return e(null, A1.l(icon), A1.k(icon));
        }
        if (iO == 4) {
            Uri uriP = A1.p(icon);
            uriP.getClass();
            String string = uriP.toString();
            string.getClass();
            IconCompat iconCompat = new IconCompat(4);
            iconCompat.f3931b = string;
            return iconCompat;
        }
        if (iO != 6) {
            IconCompat iconCompat2 = new IconCompat(-1);
            iconCompat2.f3931b = icon;
            return iconCompat2;
        }
        Uri uriP2 = A1.p(icon);
        uriP2.getClass();
        String string2 = uriP2.toString();
        string2.getClass();
        IconCompat iconCompat3 = new IconCompat(6);
        iconCompat3.f3931b = string2;
        return iconCompat3;
    }

    public static Bitmap c(Bitmap bitmap, boolean z5) {
        int iMin = (int) (Math.min(bitmap.getWidth(), bitmap.getHeight()) * 0.6666667f);
        Bitmap bitmapCreateBitmap = Bitmap.createBitmap(iMin, iMin, Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmapCreateBitmap);
        Paint paint = new Paint(3);
        float f6 = iMin;
        float f7 = 0.5f * f6;
        float f8 = 0.9166667f * f7;
        if (z5) {
            float f9 = 0.010416667f * f6;
            paint.setColor(0);
            paint.setShadowLayer(f9, 0.0f, f6 * 0.020833334f, 1023410176);
            canvas.drawCircle(f7, f7, f8, paint);
            paint.setShadowLayer(f9, 0.0f, 0.0f, 503316480);
            canvas.drawCircle(f7, f7, f8, paint);
            paint.clearShadowLayer();
        }
        paint.setColor(-16777216);
        Shader.TileMode tileMode = Shader.TileMode.CLAMP;
        BitmapShader bitmapShader = new BitmapShader(bitmap, tileMode, tileMode);
        Matrix matrix = new Matrix();
        matrix.setTranslate((-(bitmap.getWidth() - iMin)) / 2.0f, (-(bitmap.getHeight() - iMin)) / 2.0f);
        bitmapShader.setLocalMatrix(matrix);
        paint.setShader(bitmapShader);
        canvas.drawCircle(f7, f7, f8, paint);
        canvas.setBitmap(null);
        return bitmapCreateBitmap;
    }

    public static IconCompat d(Bitmap bitmap) {
        bitmap.getClass();
        IconCompat iconCompat = new IconCompat(1);
        iconCompat.f3931b = bitmap;
        return iconCompat;
    }

    public static IconCompat e(Resources resources, String str, int i) {
        str.getClass();
        if (i == 0) {
            throw new IllegalArgumentException("Drawable resource ID must not be 0");
        }
        IconCompat iconCompat = new IconCompat(2);
        iconCompat.f3934e = i;
        if (resources != null) {
            try {
                iconCompat.f3931b = resources.getResourceName(i);
            } catch (Resources.NotFoundException unused) {
                throw new IllegalArgumentException("Icon resource cannot be found");
            }
        } else {
            iconCompat.f3931b = str;
        }
        iconCompat.f3938j = str;
        return iconCompat;
    }

    public final int f() {
        int i = this.f3930a;
        if (i == -1) {
            return A1.k(this.f3931b);
        }
        if (i == 2) {
            return this.f3934e;
        }
        throw new IllegalStateException("called getResId() on " + this);
    }

    public final Uri g() {
        int i = this.f3930a;
        if (i == -1) {
            return A1.p(this.f3931b);
        }
        if (i == 4 || i == 6) {
            return Uri.parse((String) this.f3931b);
        }
        throw new IllegalStateException("called getUri() on " + this);
    }

    /* JADX WARN: Removed duplicated region for block: B:25:0x007d  */
    /* JADX WARN: Removed duplicated region for block: B:28:0x0097  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct code enable 'Show inconsistent code' option in preferences
    */
    public final android.graphics.drawable.Icon h(android.content.Context r8) {
        /*
            Method dump skipped, instruction units count: 366
            To view this dump change 'Code comments level' option to 'DEBUG'
        */
        throw new UnsupportedOperationException("Method not decompiled: androidx.core.graphics.drawable.IconCompat.h(android.content.Context):android.graphics.drawable.Icon");
    }

    public final String toString() {
        String str;
        if (this.f3930a == -1) {
            return String.valueOf(this.f3931b);
        }
        StringBuilder sb = new StringBuilder("Icon(typ=");
        switch (this.f3930a) {
            case 1:
                str = "BITMAP";
                break;
            case 2:
                str = "RESOURCE";
                break;
            case 3:
                str = "DATA";
                break;
            case 4:
                str = "URI";
                break;
            case 5:
                str = "BITMAP_MASKABLE";
                break;
            case 6:
                str = "URI_MASKABLE";
                break;
            default:
                str = "UNKNOWN";
                break;
        }
        sb.append(str);
        switch (this.f3930a) {
            case 1:
            case 5:
                sb.append(" size=");
                sb.append(((Bitmap) this.f3931b).getWidth());
                sb.append("x");
                sb.append(((Bitmap) this.f3931b).getHeight());
                break;
            case 2:
                sb.append(" pkg=");
                sb.append(this.f3938j);
                sb.append(" id=");
                sb.append(String.format("0x%08x", Integer.valueOf(f())));
                break;
            case 3:
                sb.append(" len=");
                sb.append(this.f3934e);
                if (this.f3935f != 0) {
                    sb.append(" off=");
                    sb.append(this.f3935f);
                }
                break;
            case 4:
            case 6:
                sb.append(" uri=");
                sb.append(this.f3931b);
                break;
        }
        if (this.f3936g != null) {
            sb.append(" tint=");
            sb.append(this.f3936g);
        }
        if (this.f3937h != f3929k) {
            sb.append(" mode=");
            sb.append(this.f3937h);
        }
        sb.append(")");
        return sb.toString();
    }

    public IconCompat(int i) {
        this.f3932c = null;
        this.f3933d = null;
        this.f3934e = 0;
        this.f3935f = 0;
        this.f3936g = null;
        this.f3937h = f3929k;
        this.i = null;
        this.f3930a = i;
    }
}
