package androidx.core.graphics.drawable;

import android.content.res.ColorStateList;
import android.graphics.Bitmap;
import android.graphics.PorterDuff;
import android.graphics.drawable.Icon;
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: a, reason: collision with root package name */
    public static final PorterDuff.Mode f4672a = PorterDuff.Mode.SRC_IN;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public Object f4674c;
    public String k;

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

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

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

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

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

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

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public PorterDuff.Mode f4680i = f4672a;

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

    public int a() {
        int i2 = this.f4673b;
        if (i2 != -1) {
            if (i2 == 2) {
                return this.f4677f;
            }
            throw new IllegalStateException("called getResId() on " + this);
        }
        int i3 = Build.VERSION.SDK_INT;
        Icon icon = (Icon) this.f4674c;
        if (i3 >= 28) {
            return icon.getResId();
        }
        try {
            return ((Integer) icon.getClass().getMethod("getResId", new Class[0]).invoke(icon, new Object[0])).intValue();
        } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e2) {
            Log.e("IconCompat", "Unable to get icon resource", e2);
            return 0;
        }
    }

    public String toString() {
        String str;
        int height;
        if (this.f4673b == -1) {
            return String.valueOf(this.f4674c);
        }
        StringBuilder sb = new StringBuilder("Icon(typ=");
        switch (this.f4673b) {
            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.f4673b) {
            case 1:
            case 5:
                sb.append(" size=");
                sb.append(((Bitmap) this.f4674c).getWidth());
                sb.append("x");
                height = ((Bitmap) this.f4674c).getHeight();
                sb.append(height);
                break;
            case 2:
                sb.append(" pkg=");
                sb.append(this.k);
                sb.append(" id=");
                sb.append(String.format("0x%08x", Integer.valueOf(a())));
                break;
            case 3:
                sb.append(" len=");
                sb.append(this.f4677f);
                if (this.f4678g != 0) {
                    sb.append(" off=");
                    height = this.f4678g;
                    sb.append(height);
                }
                break;
            case 4:
            case 6:
                sb.append(" uri=");
                sb.append(this.f4674c);
                break;
        }
        if (this.f4679h != null) {
            sb.append(" tint=");
            sb.append(this.f4679h);
        }
        if (this.f4680i != f4672a) {
            sb.append(" mode=");
            sb.append(this.f4680i);
        }
        sb.append(")");
        return sb.toString();
    }
}
