package androidx.core.app;

import android.app.Notification;
import android.os.Build;
import android.os.Bundle;
import android.os.Parcelable;
import java.util.ArrayList;
import java.util.Iterator;

/* JADX INFO: loaded from: classes.dex */
public final class B extends C {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final ArrayList f11187a = new ArrayList();

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final ArrayList f11188b = new ArrayList();

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

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

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

    @Override // androidx.core.app.C
    public final void addCompatExtras(Bundle bundle) {
        super.addCompatExtras(bundle);
        bundle.putCharSequence("android.selfDisplayName", this.f11189c.f11217a);
        bundle.putBundle("android.messagingStyleUser", this.f11189c.b());
        bundle.putCharSequence("android.hiddenConversationTitle", this.f11190d);
        if (this.f11190d != null && this.f11191e.booleanValue()) {
            bundle.putCharSequence("android.conversationTitle", this.f11190d);
        }
        ArrayList arrayList = this.f11187a;
        if (!arrayList.isEmpty()) {
            bundle.putParcelableArray("android.messages", A.a(arrayList));
        }
        ArrayList arrayList2 = this.f11188b;
        if (!arrayList2.isEmpty()) {
            bundle.putParcelableArray("android.messages.historic", A.a(arrayList2));
        }
        Boolean bool = this.f11191e;
        if (bool != null) {
            bundle.putBoolean("android.isGroupConversation", bool.booleanValue());
        }
    }

    @Override // androidx.core.app.C
    public final void apply(InterfaceC1001h interfaceC1001h) {
        Notification.MessagingStyle messagingStyleB;
        C1007n c1007n = this.mBuilder;
        boolean zBooleanValue = false;
        if (c1007n == null || c1007n.f11249a.getApplicationInfo().targetSdkVersion >= 28 || this.f11191e != null) {
            Boolean bool = this.f11191e;
            if (bool != null) {
                zBooleanValue = bool.booleanValue();
            }
        } else if (this.f11190d != null) {
            zBooleanValue = true;
        }
        this.f11191e = Boolean.valueOf(zBooleanValue);
        if (Build.VERSION.SDK_INT >= 28) {
            O o6 = this.f11189c;
            o6.getClass();
            messagingStyleB = x.a(E.d(o6));
        } else {
            messagingStyleB = v.b(this.f11189c.f11217a);
        }
        Iterator it = this.f11187a.iterator();
        while (it.hasNext()) {
            v.a(messagingStyleB, ((A) it.next()).c());
        }
        if (Build.VERSION.SDK_INT >= 26) {
            Iterator it2 = this.f11188b.iterator();
            while (it2.hasNext()) {
                w.a(messagingStyleB, ((A) it2.next()).c());
            }
        }
        if (this.f11191e.booleanValue() || Build.VERSION.SDK_INT >= 28) {
            v.c(messagingStyleB, this.f11190d);
        }
        if (Build.VERSION.SDK_INT >= 28) {
            x.b(messagingStyleB, this.f11191e.booleanValue());
        }
        messagingStyleB.setBuilder(((G) interfaceC1001h).f11193b);
    }

    @Override // androidx.core.app.C
    public final void clearCompatExtraKeys(Bundle bundle) {
        super.clearCompatExtraKeys(bundle);
        bundle.remove("android.messagingStyleUser");
        bundle.remove("android.selfDisplayName");
        bundle.remove("android.conversationTitle");
        bundle.remove("android.hiddenConversationTitle");
        bundle.remove("android.messages");
        bundle.remove("android.messages.historic");
        bundle.remove("android.isGroupConversation");
    }

    @Override // androidx.core.app.C
    public final String getClassName() {
        return "androidx.core.app.NotificationCompat$MessagingStyle";
    }

    @Override // androidx.core.app.C
    public final void restoreFromCompatExtras(Bundle bundle) {
        super.restoreFromCompatExtras(bundle);
        ArrayList arrayList = this.f11187a;
        arrayList.clear();
        if (bundle.containsKey("android.messagingStyleUser")) {
            this.f11189c = O.a(bundle.getBundle("android.messagingStyleUser"));
        } else {
            String string = bundle.getString("android.selfDisplayName");
            O o6 = new O();
            o6.f11217a = string;
            o6.f11218b = null;
            o6.f11219c = null;
            o6.f11220d = null;
            o6.f11221e = false;
            o6.f11222f = false;
            this.f11189c = o6;
        }
        CharSequence charSequence = bundle.getCharSequence("android.conversationTitle");
        this.f11190d = charSequence;
        if (charSequence == null) {
            this.f11190d = bundle.getCharSequence("android.hiddenConversationTitle");
        }
        Parcelable[] parcelableArray = bundle.getParcelableArray("android.messages");
        if (parcelableArray != null) {
            arrayList.addAll(A.b(parcelableArray));
        }
        Parcelable[] parcelableArray2 = bundle.getParcelableArray("android.messages.historic");
        if (parcelableArray2 != null) {
            this.f11188b.addAll(A.b(parcelableArray2));
        }
        if (bundle.containsKey("android.isGroupConversation")) {
            this.f11191e = Boolean.valueOf(bundle.getBoolean("android.isGroupConversation"));
        }
    }
}
