package androidx.core.graphics.drawable;

import B.a;
import Z.g;
import android.content.res.ColorStateList;
import android.graphics.Bitmap;
import android.graphics.PorterDuff;
import android.net.Uri;
import android.os.Build;
import android.os.Parcelable;
import android.util.Log;
import androidx.versionedparcelable.CustomVersionedParcelable;
import java.lang.reflect.InvocationTargetException;

/* 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 f7948k = PorterDuff.Mode.SRC_IN;

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

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

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public int f7949a = -1;

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

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

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

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

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

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

    public static IconCompat a(int i) {
        if (i == 0) {
            throw new IllegalArgumentException("Drawable resource ID must not be 0");
        }
        IconCompat iconCompat = new IconCompat();
        iconCompat.f7951c = null;
        iconCompat.f7952d = null;
        iconCompat.f7954f = 0;
        iconCompat.f7955g = null;
        iconCompat.f7956h = f7948k;
        iconCompat.i = null;
        iconCompat.f7949a = 2;
        iconCompat.f7953e = i;
        iconCompat.f7950b = "";
        iconCompat.f7957j = "";
        return iconCompat;
    }

    public final int b() {
        int i = this.f7949a;
        if (i != -1) {
            if (i == 2) {
                return this.f7953e;
            }
            throw new IllegalStateException("called getResId() on " + this);
        }
        int i5 = Build.VERSION.SDK_INT;
        Object obj = this.f7950b;
        if (i5 >= 28) {
            return a.c(obj);
        }
        try {
            return ((Integer) obj.getClass().getMethod("getResId", null).invoke(obj, null)).intValue();
        } catch (IllegalAccessException e8) {
            Log.e("IconCompat", "Unable to get icon resource", e8);
            return 0;
        } catch (NoSuchMethodException e9) {
            Log.e("IconCompat", "Unable to get icon resource", e9);
            return 0;
        } catch (InvocationTargetException e10) {
            Log.e("IconCompat", "Unable to get icon resource", e10);
            return 0;
        }
    }

    public final Uri c() {
        int i = this.f7949a;
        if (i != -1) {
            if (i == 4 || i == 6) {
                return Uri.parse((String) this.f7950b);
            }
            throw new IllegalStateException("called getUri() on " + this);
        }
        int i5 = Build.VERSION.SDK_INT;
        Object obj = this.f7950b;
        if (i5 >= 28) {
            return a.h(obj);
        }
        try {
            return (Uri) obj.getClass().getMethod("getUri", null).invoke(obj, null);
        } catch (IllegalAccessException e8) {
            Log.e("IconCompat", "Unable to get icon uri", e8);
            return null;
        } catch (NoSuchMethodException e9) {
            Log.e("IconCompat", "Unable to get icon uri", e9);
            return null;
        } catch (InvocationTargetException e10) {
            Log.e("IconCompat", "Unable to get icon uri", e10);
            return null;
        }
    }

    public final String toString() {
        String str;
        if (this.f7949a == -1) {
            return String.valueOf(this.f7950b);
        }
        StringBuilder sb = new StringBuilder("Icon(typ=");
        switch (this.f7949a) {
            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 g.STRING_SET_FIELD_NUMBER /* 6 */:
                str = "URI_MASKABLE";
                break;
            default:
                str = "UNKNOWN";
                break;
        }
        sb.append(str);
        switch (this.f7949a) {
            case 1:
            case 5:
                sb.append(" size=");
                sb.append(((Bitmap) this.f7950b).getWidth());
                sb.append("x");
                sb.append(((Bitmap) this.f7950b).getHeight());
                break;
            case 2:
                sb.append(" pkg=");
                sb.append(this.f7957j);
                sb.append(" id=");
                sb.append(String.format("0x%08x", Integer.valueOf(b())));
                break;
            case 3:
                sb.append(" len=");
                sb.append(this.f7953e);
                if (this.f7954f != 0) {
                    sb.append(" off=");
                    sb.append(this.f7954f);
                }
                break;
            case 4:
            case g.STRING_SET_FIELD_NUMBER /* 6 */:
                sb.append(" uri=");
                sb.append(this.f7950b);
                break;
        }
        if (this.f7955g != null) {
            sb.append(" tint=");
            sb.append(this.f7955g);
        }
        if (this.f7956h != f7948k) {
            sb.append(" mode=");
            sb.append(this.f7956h);
        }
        sb.append(")");
        return sb.toString();
    }
}
