package androidx.core.app;

import V.AbstractC0624s;
import android.app.Notification;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Parcelable;
import java.util.ArrayList;

/* JADX INFO: loaded from: classes.dex */
public final class A {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final CharSequence f11181a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final long f11182b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final O f11183c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final Bundle f11184d = new Bundle();

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

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

    public A(CharSequence charSequence, long j4, O o6) {
        this.f11181a = charSequence;
        this.f11182b = j4;
        this.f11183c = o6;
    }

    public static Bundle[] a(ArrayList arrayList) {
        Bundle[] bundleArr = new Bundle[arrayList.size()];
        int size = arrayList.size();
        for (int i6 = 0; i6 < size; i6++) {
            A a6 = (A) arrayList.get(i6);
            a6.getClass();
            Bundle bundle = new Bundle();
            CharSequence charSequence = a6.f11181a;
            if (charSequence != null) {
                bundle.putCharSequence("text", charSequence);
            }
            bundle.putLong("time", a6.f11182b);
            O o6 = a6.f11183c;
            if (o6 != null) {
                bundle.putCharSequence("sender", o6.f11217a);
                if (Build.VERSION.SDK_INT >= 28) {
                    bundle.putParcelable("sender_person", z.a(E.d(o6)));
                } else {
                    bundle.putBundle("person", o6.b());
                }
            }
            String str = a6.f11185e;
            if (str != null) {
                bundle.putString("type", str);
            }
            Uri uri = a6.f11186f;
            if (uri != null) {
                bundle.putParcelable("uri", uri);
            }
            Bundle bundle2 = a6.f11184d;
            if (bundle2 != null) {
                bundle.putBundle("extras", bundle2);
            }
            bundleArr[i6] = bundle;
        }
        return bundleArr;
    }

    public static ArrayList b(Parcelable[] parcelableArr) {
        O oB;
        ArrayList arrayList = new ArrayList(parcelableArr.length);
        for (Parcelable parcelable : parcelableArr) {
            if (parcelable instanceof Bundle) {
                Bundle bundle = (Bundle) parcelable;
                A a6 = null;
                try {
                    if (bundle.containsKey("text") && bundle.containsKey("time")) {
                        if (bundle.containsKey("person")) {
                            oB = O.a(bundle.getBundle("person"));
                        } else if (bundle.containsKey("sender_person") && Build.VERSION.SDK_INT >= 28) {
                            oB = E.b(AbstractC0624s.c(bundle.getParcelable("sender_person")));
                        } else if (bundle.containsKey("sender")) {
                            CharSequence charSequence = bundle.getCharSequence("sender");
                            O o6 = new O();
                            o6.f11217a = charSequence;
                            o6.f11218b = null;
                            o6.f11219c = null;
                            o6.f11220d = null;
                            o6.f11221e = false;
                            o6.f11222f = false;
                            oB = o6;
                        } else {
                            oB = null;
                        }
                        A a7 = new A(bundle.getCharSequence("text"), bundle.getLong("time"), oB);
                        if (bundle.containsKey("type") && bundle.containsKey("uri")) {
                            String string = bundle.getString("type");
                            Uri uri = (Uri) bundle.getParcelable("uri");
                            a7.f11185e = string;
                            a7.f11186f = uri;
                        }
                        if (bundle.containsKey("extras")) {
                            a7.f11184d.putAll(bundle.getBundle("extras"));
                        }
                        a6 = a7;
                    }
                } catch (ClassCastException unused) {
                }
                if (a6 != null) {
                    arrayList.add(a6);
                }
            }
        }
        return arrayList;
    }

    public final Notification.MessagingStyle.Message c() {
        Notification.MessagingStyle.Message messageA;
        int i6 = Build.VERSION.SDK_INT;
        long j4 = this.f11182b;
        CharSequence charSequence = this.f11181a;
        O o6 = this.f11183c;
        if (i6 >= 28) {
            messageA = z.b(charSequence, j4, o6 != null ? E.d(o6) : null);
        } else {
            messageA = y.a(charSequence, j4, o6 != null ? o6.f11217a : null);
        }
        String str = this.f11185e;
        if (str != null) {
            y.b(messageA, str, this.f11186f);
        }
        return messageA;
    }
}
