package androidx.core.app;

import android.app.Notification;
import android.app.PendingIntent;
import android.app.RemoteInput;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import androidx.core.graphics.drawable.IconCompat;
import com.debridstream.tv.R;
import java.util.ArrayList;
import java.util.Iterator;
import n.C2579f;

/* JADX INFO: loaded from: classes.dex */
public final class G implements InterfaceC1001h {

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

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final Notification.Builder f11193b;

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

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final Bundle f11195d;

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r11v1, types: [android.os.Bundle] */
    /* JADX WARN: Type inference failed for: r15v0, types: [android.os.BaseBundle, android.os.Bundle] */
    /* JADX WARN: Type inference failed for: r2v20, types: [android.os.Bundle] */
    /* JADX WARN: Type inference failed for: r2v21, types: [android.os.Bundle] */
    /* JADX WARN: Type inference failed for: r3v35, types: [android.os.Bundle] */
    /* JADX WARN: Type inference failed for: r3v45 */
    /* JADX WARN: Type inference failed for: r3v46 */
    /* JADX WARN: Type inference failed for: r3v8, types: [android.app.Notification$Builder] */
    /* JADX WARN: Type inference failed for: r4v2, types: [java.lang.CharSequence[]] */
    /* JADX WARN: Type inference failed for: r6v43, types: [android.os.Bundle[]] */
    /* JADX WARN: Type inference failed for: r6v44, types: [android.os.Parcelable[]] */
    /* JADX WARN: Type inference failed for: r6v47 */
    /* JADX WARN: Type inference failed for: r9v2, types: [android.os.Bundle] */
    public G(C1007n c1007n) throws Throwable {
        Throwable th;
        int i6;
        ?? r6;
        ArrayList arrayList;
        C1002i c1002iC;
        new ArrayList();
        this.f11195d = new Bundle();
        this.f11194c = c1007n;
        Context context = c1007n.f11249a;
        this.f11192a = context;
        if (Build.VERSION.SDK_INT >= 26) {
            this.f11193b = D.a(context, c1007n.f11271x);
        } else {
            this.f11193b = new Notification.Builder(c1007n.f11249a);
        }
        Notification notification = c1007n.f11247B;
        Throwable th2 = null;
        int i7 = 2;
        this.f11193b.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(c1007n.f11253e).setContentText(c1007n.f11254f).setContentInfo(null).setContentIntent(c1007n.f11255g).setDeleteIntent(notification.deleteIntent).setFullScreenIntent(null, (notification.flags & 128) != 0).setNumber(0).setProgress(c1007n.f11261n, c1007n.f11262o, c1007n.f11263p);
        Notification.Builder builder = this.f11193b;
        IconCompat iconCompat = c1007n.f11256h;
        builder.setLargeIcon(iconCompat == null ? null : iconCompat.h(context));
        this.f11193b.setSubText(c1007n.f11260m).setUsesChronometer(c1007n.f11259k).setPriority(c1007n.f11257i);
        C c6 = c1007n.l;
        if (c6 instanceof C1011s) {
            C1011s c1011s = (C1011s) c6;
            PendingIntent pendingIntent = c1011s.f11277d;
            C1002i c1002iC2 = pendingIntent == null ? c1011s.c(R.drawable.ic_call_decline, R.string.call_notification_hang_up_action, c1011s.f11281h, R.color.call_notification_decline_color, c1011s.f11278e) : c1011s.c(R.drawable.ic_call_decline, R.string.call_notification_decline_action, c1011s.f11281h, R.color.call_notification_decline_color, pendingIntent);
            PendingIntent pendingIntent2 = c1011s.f11276c;
            if (pendingIntent2 == null) {
                c1002iC = null;
            } else {
                boolean z6 = c1011s.f11279f;
                c1002iC = c1011s.c(z6 ? R.drawable.ic_call_answer_video : R.drawable.ic_call_answer, z6 ? R.string.call_notification_answer_video_action : R.string.call_notification_answer_action, c1011s.f11280g, R.color.call_notification_answer_color, pendingIntent2);
            }
            ArrayList arrayList2 = new ArrayList(3);
            arrayList2.add(c1002iC2);
            ArrayList<C1002i> arrayList3 = c1011s.mBuilder.f11250b;
            if (arrayList3 != null) {
                for (C1002i c1002i : arrayList3) {
                    c1002i.getClass();
                    if (!c1002i.f11232a.getBoolean("key_action_priority") && i7 > 1) {
                        arrayList2.add(c1002i);
                        i7--;
                    }
                    if (c1002iC != null && i7 == 1) {
                        arrayList2.add(c1002iC);
                        i7--;
                    }
                }
            }
            if (c1002iC != null && i7 >= 1) {
                arrayList2.add(c1002iC);
            }
            Iterator it = arrayList2.iterator();
            while (it.hasNext()) {
                a((C1002i) it.next());
            }
        } else {
            Iterator it2 = c1007n.f11250b.iterator();
            while (it2.hasNext()) {
                a((C1002i) it2.next());
            }
        }
        Bundle bundle = c1007n.f11268u;
        if (bundle != null) {
            this.f11195d.putAll(bundle);
        }
        int i8 = Build.VERSION.SDK_INT;
        this.f11193b.setShowWhen(c1007n.f11258j);
        this.f11193b.setLocalOnly(c1007n.f11265r);
        this.f11193b.setGroup(c1007n.f11264q);
        this.f11193b.setSortKey(null);
        this.f11193b.setGroupSummary(false);
        this.f11193b.setCategory(null);
        this.f11193b.setColor(c1007n.f11269v);
        this.f11193b.setVisibility(c1007n.f11270w);
        this.f11193b.setPublicVersion(null);
        this.f11193b.setSound(notification.sound, notification.audioAttributes);
        ArrayList arrayList4 = c1007n.f11248C;
        ArrayList<O> arrayList5 = c1007n.f11251c;
        if (i8 < 28) {
            if (arrayList5 == null) {
                arrayList = null;
            } else {
                arrayList = new ArrayList(arrayList5.size());
                for (O o6 : arrayList5) {
                    String str = o6.f11219c;
                    if (str == null) {
                        CharSequence charSequence = o6.f11217a;
                        str = charSequence != null ? "name:" + ((Object) charSequence) : "";
                    }
                    arrayList.add(str);
                }
            }
            if (arrayList != null) {
                if (arrayList4 == null) {
                    arrayList4 = arrayList;
                } else {
                    C2579f c2579f = new C2579f(arrayList4.size() + arrayList.size());
                    c2579f.addAll(arrayList);
                    c2579f.addAll(arrayList4);
                    arrayList4 = new ArrayList(c2579f);
                }
            }
        }
        if (arrayList4 != null && !arrayList4.isEmpty()) {
            Iterator it3 = arrayList4.iterator();
            while (it3.hasNext()) {
                this.f11193b.addPerson((String) it3.next());
            }
        }
        ArrayList arrayList6 = c1007n.f11252d;
        if (arrayList6.size() > 0) {
            if (c1007n.f11268u == null) {
                c1007n.f11268u = new Bundle();
            }
            Bundle bundle2 = c1007n.f11268u.getBundle("android.car.EXTENSIONS");
            ?? bundle3 = bundle2 == null ? new Bundle() : bundle2;
            ?? bundle4 = new Bundle((Bundle) bundle3);
            ?? bundle5 = new Bundle();
            int i9 = 0;
            while (i9 < arrayList6.size()) {
                String string = Integer.toString(i9);
                C1002i c1002i2 = (C1002i) arrayList6.get(i9);
                ?? bundle6 = new Bundle();
                IconCompat iconCompatA = c1002i2.a();
                bundle6.putInt("icon", iconCompatA != null ? iconCompatA.e() : 0);
                bundle6.putCharSequence("title", c1002i2.f11238g);
                bundle6.putParcelable("actionIntent", c1002i2.f11239h);
                Bundle bundle7 = c1002i2.f11232a;
                Bundle bundle8 = bundle7 != null ? new Bundle(bundle7) : new Bundle();
                Throwable th3 = th2;
                bundle8.putBoolean("android.support.allowGeneratedReplies", c1002i2.f11235d);
                bundle6.putBundle("extras", bundle8);
                Q[] qArr = c1002i2.f11234c;
                if (qArr == null) {
                    r6 = th3;
                } else {
                    r6 = new Bundle[qArr.length];
                    if (qArr.length > 0) {
                        Q q6 = qArr[0];
                        new Bundle();
                        throw th3;
                    }
                }
                bundle6.putParcelableArray("remoteInputs", r6);
                bundle6.putBoolean("showsUserInterface", c1002i2.f11236e);
                bundle6.putInt("semanticAction", 0);
                bundle5.putBundle(string, bundle6);
                i9++;
                th2 = th3;
            }
            th = th2;
            bundle3.putBundle("invisible_actions", bundle5);
            bundle4.putBundle("invisible_actions", bundle5);
            if (c1007n.f11268u == null) {
                c1007n.f11268u = new Bundle();
            }
            c1007n.f11268u.putBundle("android.car.EXTENSIONS", bundle3);
            this.f11195d.putBundle("android.car.EXTENSIONS", bundle4);
        } else {
            th = null;
        }
        int i10 = Build.VERSION.SDK_INT;
        this.f11193b.setExtras(c1007n.f11268u);
        this.f11193b.setRemoteInputHistory(th);
        if (i10 >= 26) {
            D.b(this.f11193b, c1007n.f11272y);
            D.e(this.f11193b);
            D.f(this.f11193b);
            D.g(this.f11193b);
            D.d(this.f11193b);
            if (c1007n.f11267t) {
                D.c(this.f11193b, c1007n.f11266s);
            }
            if (!TextUtils.isEmpty(c1007n.f11271x)) {
                this.f11193b.setSound(null).setDefaults(0).setLights(0, 0, 0).setVibrate(null);
            }
        }
        if (i10 >= 28) {
            for (O o7 : arrayList5) {
                Notification.Builder builder2 = this.f11193b;
                o7.getClass();
                E.a(builder2, E.d(o7));
            }
        }
        int i11 = Build.VERSION.SDK_INT;
        if (i11 >= 29) {
            AbstractC0996c.b(this.f11193b, c1007n.f11246A);
            AbstractC0996c.c(this.f11193b);
        }
        if (i11 < 31 || (i6 = c1007n.f11273z) == 0) {
            return;
        }
        F.b(this.f11193b, i6);
    }

    public final void a(C1002i c1002i) {
        IconCompat iconCompatA = c1002i.a();
        Notification.Action.Builder builder = new Notification.Action.Builder(iconCompatA != null ? iconCompatA.h(null) : null, c1002i.f11238g, c1002i.f11239h);
        Q[] qArr = c1002i.f11234c;
        if (qArr != null) {
            RemoteInput[] remoteInputArr = new RemoteInput[qArr.length];
            if (qArr.length > 0) {
                Q q6 = qArr[0];
                throw null;
            }
            for (RemoteInput remoteInput : remoteInputArr) {
                builder.addRemoteInput(remoteInput);
            }
        }
        Bundle bundle = c1002i.f11232a;
        Bundle bundle2 = bundle != null ? new Bundle(bundle) : new Bundle();
        boolean z6 = c1002i.f11235d;
        bundle2.putBoolean("android.support.allowGeneratedReplies", z6);
        int i6 = Build.VERSION.SDK_INT;
        builder.setAllowGeneratedReplies(z6);
        bundle2.putInt("android.support.action.semanticAction", 0);
        if (i6 >= 28) {
            E.c(builder);
        }
        if (i6 >= 29) {
            AbstractC0996c.d(builder);
        }
        if (i6 >= 31) {
            F.a(builder);
        }
        bundle2.putBoolean("android.support.action.showsUserInterface", c1002i.f11236e);
        builder.addExtras(bundle2);
        this.f11193b.addAction(builder.build());
    }
}
