package androidx.core.graphics.drawable;

import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.PorterDuff;
import android.graphics.drawable.AdaptiveIconDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Icon;
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;
import java.util.Objects;

/* JADX INFO: loaded from: classes.dex */
public class IconCompat extends CustomVersionedParcelable {
    public static final PorterDuff.Mode a = PorterDuff.Mode.SRC_IN;

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

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

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

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

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

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

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

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

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

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

    public static class a {
        public static int a(Object obj) {
            if (Build.VERSION.SDK_INT >= 28) {
                return c.a(obj);
            }
            try {
                return ((Integer) obj.getClass().getMethod("getResId", new Class[0]).invoke(obj, new Object[0])).intValue();
            } catch (IllegalAccessException e2) {
                Log.e("IconCompat", "Unable to get icon resource", e2);
                return 0;
            } catch (NoSuchMethodException e3) {
                Log.e("IconCompat", "Unable to get icon resource", e3);
                return 0;
            } catch (InvocationTargetException e4) {
                Log.e("IconCompat", "Unable to get icon resource", e4);
                return 0;
            }
        }

        public static String b(Object obj) {
            if (Build.VERSION.SDK_INT >= 28) {
                return c.b(obj);
            }
            try {
                return (String) obj.getClass().getMethod("getResPackage", new Class[0]).invoke(obj, new Object[0]);
            } catch (IllegalAccessException e2) {
                Log.e("IconCompat", "Unable to get icon package", e2);
                return null;
            } catch (NoSuchMethodException e3) {
                Log.e("IconCompat", "Unable to get icon package", e3);
                return null;
            } catch (InvocationTargetException e4) {
                Log.e("IconCompat", "Unable to get icon package", e4);
                return null;
            }
        }

        public static int c(Object obj) {
            StringBuilder sb;
            if (Build.VERSION.SDK_INT >= 28) {
                return c.c(obj);
            }
            try {
                return ((Integer) obj.getClass().getMethod("getType", new Class[0]).invoke(obj, new Object[0])).intValue();
            } catch (IllegalAccessException e2) {
                e = e2;
                sb = new StringBuilder();
                sb.append("Unable to get icon type ");
                sb.append(obj);
                Log.e("IconCompat", sb.toString(), e);
                return -1;
            } catch (NoSuchMethodException e3) {
                e = e3;
                sb = new StringBuilder();
                sb.append("Unable to get icon type ");
                sb.append(obj);
                Log.e("IconCompat", sb.toString(), e);
                return -1;
            } catch (InvocationTargetException e4) {
                e = e4;
                sb = new StringBuilder();
                sb.append("Unable to get icon type ");
                sb.append(obj);
                Log.e("IconCompat", sb.toString(), e);
                return -1;
            }
        }

        public static Uri d(Object obj) {
            if (Build.VERSION.SDK_INT >= 28) {
                return c.d(obj);
            }
            try {
                return (Uri) obj.getClass().getMethod("getUri", new Class[0]).invoke(obj, new Object[0]);
            } catch (IllegalAccessException e2) {
                Log.e("IconCompat", "Unable to get icon uri", e2);
                return null;
            } catch (NoSuchMethodException e3) {
                Log.e("IconCompat", "Unable to get icon uri", e3);
                return null;
            } catch (InvocationTargetException e4) {
                Log.e("IconCompat", "Unable to get icon uri", e4);
                return null;
            }
        }

        public static Drawable e(Icon icon, Context context) {
            return icon.loadDrawable(context);
        }

        /* JADX WARN: Removed duplicated region for block: B:25:0x0073  */
        /* JADX WARN: Removed duplicated region for block: B:26:0x0078  */
        /* JADX WARN: Removed duplicated region for block: B:52:0x0117  */
        /* JADX WARN: Removed duplicated region for block: B:55:0x0120  */
        /*
            Code decompiled incorrectly, please refer to instructions dump.
            To view partially-correct add '--show-bad-code' argument
        */
        public static android.graphics.drawable.Icon f(androidx.core.graphics.drawable.IconCompat r3, android.content.Context r4) {
            /*
                Method dump skipped, instruction units count: 318
                To view this dump add '--comments-level debug' option
            */
            throw new UnsupportedOperationException("Method not decompiled: androidx.core.graphics.drawable.IconCompat.a.f(androidx.core.graphics.drawable.IconCompat, android.content.Context):android.graphics.drawable.Icon");
        }
    }

    public static class b {
        public static Drawable a(Drawable drawable, Drawable drawable2) {
            return new AdaptiveIconDrawable(drawable, drawable2);
        }

        public static Icon b(Bitmap bitmap) {
            return Icon.createWithAdaptiveBitmap(bitmap);
        }
    }

    public static class c {
        public static int a(Object obj) {
            return ((Icon) obj).getResId();
        }

        public static String b(Object obj) {
            return ((Icon) obj).getResPackage();
        }

        public static int c(Object obj) {
            return ((Icon) obj).getType();
        }

        public static Uri d(Object obj) {
            return ((Icon) obj).getUri();
        }
    }

    public static class d {
        public static Icon a(Uri uri) {
            return Icon.createWithAdaptiveBitmapContentUri(uri);
        }
    }

    public IconCompat() {
        this.f661b = -1;
        this.f663d = null;
        this.f664e = null;
        this.f665f = 0;
        this.f666g = 0;
        this.f667h = null;
        this.f668i = a;
        this.f669j = null;
    }

    public IconCompat(int i2) {
        this.f661b = -1;
        this.f663d = null;
        this.f664e = null;
        this.f665f = 0;
        this.f666g = 0;
        this.f667h = null;
        this.f668i = a;
        this.f669j = null;
        this.f661b = i2;
    }

    public static IconCompat a(Resources resources, String str, int i2) {
        Objects.requireNonNull(str);
        if (i2 == 0) {
            throw new IllegalArgumentException("Drawable resource ID must not be 0");
        }
        IconCompat iconCompat = new IconCompat(2);
        iconCompat.f665f = i2;
        iconCompat.f662c = str;
        iconCompat.f670k = str;
        return iconCompat;
    }

    public int b() {
        int i2 = this.f661b;
        if (i2 == -1) {
            return a.a(this.f662c);
        }
        if (i2 == 2) {
            return this.f665f;
        }
        throw new IllegalStateException("called getResId() on " + this);
    }

    public Uri c() {
        int i2 = this.f661b;
        if (i2 == -1) {
            return a.d(this.f662c);
        }
        if (i2 == 4 || i2 == 6) {
            return Uri.parse((String) this.f662c);
        }
        throw new IllegalStateException("called getUri() on " + this);
    }

    @Deprecated
    public Icon d() {
        return a.f(this, null);
    }

    public String toString() {
        String str;
        int height;
        if (this.f661b == -1) {
            return String.valueOf(this.f662c);
        }
        StringBuilder sb = new StringBuilder("Icon(typ=");
        switch (this.f661b) {
            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.f661b) {
            case 1:
            case 5:
                sb.append(" size=");
                sb.append(((Bitmap) this.f662c).getWidth());
                sb.append("x");
                height = ((Bitmap) this.f662c).getHeight();
                sb.append(height);
                break;
            case 2:
                sb.append(" pkg=");
                sb.append(this.f670k);
                sb.append(" id=");
                sb.append(String.format("0x%08x", Integer.valueOf(b())));
                break;
            case 3:
                sb.append(" len=");
                sb.append(this.f665f);
                if (this.f666g != 0) {
                    sb.append(" off=");
                    height = this.f666g;
                    sb.append(height);
                }
                break;
            case 4:
            case 6:
                sb.append(" uri=");
                sb.append(this.f662c);
                break;
        }
        if (this.f667h != null) {
            sb.append(" tint=");
            sb.append(this.f667h);
        }
        if (this.f668i != a) {
            sb.append(" mode=");
            sb.append(this.f668i);
        }
        sb.append(")");
        return sb.toString();
    }
}
