package d.h.b;

import android.app.Notification;
import android.app.RemoteInput;
import android.graphics.Bitmap;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import androidx.core.graphics.drawable.IconCompat;
import d.h.b.p;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;

/* JADX INFO: loaded from: classes.dex */
public class m {
    public final Notification.Builder a;

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

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final List<Bundle> f2617c = new ArrayList();

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

    public m(l lVar) {
        this.f2616b = lVar;
        Notification.Builder builder = new Notification.Builder(lVar.a, lVar.f2612o);
        this.a = builder;
        Notification notification = lVar.f2614q;
        builder.setWhen(notification.when).setSmallIcon(notification.icon, notification.iconLevel).setContent(notification.contentView).setTicker(notification.tickerText, null).setVibrate(notification.vibrate).setLights(notification.ledARGB, notification.ledOnMS, notification.ledOffMS).setOngoing((notification.flags & 2) != 0).setOnlyAlertOnce((notification.flags & 8) != 0).setAutoCancel((notification.flags & 16) != 0).setDefaults(notification.defaults).setContentTitle(lVar.f2602e).setContentText(lVar.f2603f).setContentInfo(null).setContentIntent(lVar.f2604g).setDeleteIntent(notification.deleteIntent).setFullScreenIntent(null, (notification.flags & 128) != 0).setLargeIcon((Bitmap) null).setNumber(0).setProgress(lVar.f2607j, lVar.f2608k, lVar.f2609l);
        builder.setSubText(null).setUsesChronometer(false).setPriority(lVar.f2605h);
        for (k kVar : lVar.f2599b) {
            IconCompat iconCompatA = kVar.a();
            Notification.Action.Builder builder2 = new Notification.Action.Builder(iconCompatA != null ? iconCompatA.d() : null, kVar.f2596j, kVar.f2597k);
            q[] qVarArr = kVar.f2589c;
            if (qVarArr != null) {
                int length = qVarArr.length;
                RemoteInput[] remoteInputArr = new RemoteInput[length];
                if (qVarArr.length > 0) {
                    q qVar = qVarArr[0];
                    throw null;
                }
                for (int i2 = 0; i2 < length; i2++) {
                    builder2.addRemoteInput(remoteInputArr[i2]);
                }
            }
            Bundle bundle = kVar.a != null ? new Bundle(kVar.a) : new Bundle();
            bundle.putBoolean("android.support.allowGeneratedReplies", kVar.f2591e);
            int i3 = Build.VERSION.SDK_INT;
            builder2.setAllowGeneratedReplies(kVar.f2591e);
            bundle.putInt("android.support.action.semanticAction", kVar.f2593g);
            if (i3 >= 28) {
                builder2.setSemanticAction(kVar.f2593g);
            }
            if (i3 >= 29) {
                builder2.setContextual(kVar.f2594h);
            }
            if (i3 >= 31) {
                builder2.setAuthenticationRequired(kVar.f2598l);
            }
            bundle.putBoolean("android.support.action.showsUserInterface", kVar.f2592f);
            builder2.addExtras(bundle);
            this.a.addAction(builder2.build());
        }
        Bundle bundle2 = lVar.f2610m;
        if (bundle2 != null) {
            this.f2618d.putAll(bundle2);
        }
        int i4 = Build.VERSION.SDK_INT;
        this.a.setShowWhen(lVar.f2606i);
        this.a.setLocalOnly(false).setGroup(null).setGroupSummary(false).setSortKey(null);
        this.a.setCategory(null).setColor(lVar.f2611n).setVisibility(0).setPublicVersion(null).setSound(notification.sound, notification.audioAttributes);
        List listA = i4 < 28 ? a(b(lVar.f2600c), lVar.f2615r) : lVar.f2615r;
        if (listA != null && !listA.isEmpty()) {
            Iterator it = listA.iterator();
            while (it.hasNext()) {
                this.a.addPerson((String) it.next());
            }
        }
        if (lVar.f2601d.size() > 0) {
            if (lVar.f2610m == null) {
                lVar.f2610m = new Bundle();
            }
            Bundle bundle3 = lVar.f2610m.getBundle("android.car.EXTENSIONS");
            bundle3 = bundle3 == null ? new Bundle() : bundle3;
            Bundle bundle4 = new Bundle(bundle3);
            Bundle bundle5 = new Bundle();
            for (int i5 = 0; i5 < lVar.f2601d.size(); i5++) {
                String string = Integer.toString(i5);
                k kVar2 = lVar.f2601d.get(i5);
                Object obj = n.a;
                Bundle bundle6 = new Bundle();
                IconCompat iconCompatA2 = kVar2.a();
                bundle6.putInt("icon", iconCompatA2 != null ? iconCompatA2.b() : 0);
                bundle6.putCharSequence("title", kVar2.f2596j);
                bundle6.putParcelable("actionIntent", kVar2.f2597k);
                Bundle bundle7 = kVar2.a != null ? new Bundle(kVar2.a) : new Bundle();
                bundle7.putBoolean("android.support.allowGeneratedReplies", kVar2.f2591e);
                bundle6.putBundle("extras", bundle7);
                bundle6.putParcelableArray("remoteInputs", n.a(kVar2.f2589c));
                bundle6.putBoolean("showsUserInterface", kVar2.f2592f);
                bundle6.putInt("semanticAction", kVar2.f2593g);
                bundle5.putBundle(string, bundle6);
            }
            bundle3.putBundle("invisible_actions", bundle5);
            bundle4.putBundle("invisible_actions", bundle5);
            if (lVar.f2610m == null) {
                lVar.f2610m = new Bundle();
            }
            lVar.f2610m.putBundle("android.car.EXTENSIONS", bundle3);
            this.f2618d.putBundle("android.car.EXTENSIONS", bundle4);
        }
        int i6 = Build.VERSION.SDK_INT;
        this.a.setExtras(lVar.f2610m).setRemoteInputHistory(null);
        this.a.setBadgeIconType(0).setSettingsText(null).setShortcutId(null).setTimeoutAfter(0L).setGroupAlertBehavior(0);
        if (!TextUtils.isEmpty(lVar.f2612o)) {
            this.a.setSound(null).setDefaults(0).setLights(0, 0, 0).setVibrate(null);
        }
        if (i6 >= 28) {
            for (p pVar : lVar.f2600c) {
                Notification.Builder builder3 = this.a;
                Objects.requireNonNull(pVar);
                builder3.addPerson(p.a.b(pVar));
            }
        }
        if (Build.VERSION.SDK_INT >= 29) {
            this.a.setAllowSystemGeneratedContextualActions(lVar.f2613p);
            this.a.setBubbleMetadata(null);
        }
    }

    public static List<String> a(List<String> list, List<String> list2) {
        if (list == null) {
            return list2;
        }
        if (list2 == null) {
            return list;
        }
        d.e.c cVar = new d.e.c(list2.size() + list.size());
        cVar.addAll(list);
        cVar.addAll(list2);
        return new ArrayList(cVar);
    }

    public static List<String> b(List<p> list) {
        if (list == null) {
            return null;
        }
        ArrayList arrayList = new ArrayList(list.size());
        for (p pVar : list) {
            String string = pVar.f2621c;
            if (string == null) {
                if (pVar.a != null) {
                    StringBuilder sbF = g.a.a.a.a.F("name:");
                    sbF.append((Object) pVar.a);
                    string = sbF.toString();
                } else {
                    string = "";
                }
            }
            arrayList.add(string);
        }
        return arrayList;
    }
}
