package androidx.core.app;

import android.app.Notification;
import android.app.PendingIntent;
import android.app.Person;
import android.app.RemoteInput;
import android.content.Context;
import android.content.LocusId;
import android.graphics.drawable.Icon;
import android.media.AudioAttributes;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import android.widget.RemoteViews;
import androidx.core.app.m;
import androidx.core.graphics.drawable.IconCompat;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/* loaded from: classes.dex */
class n implements l {

    /* renamed from: a, reason: collision with root package name */
    private final Context f3622a;

    /* renamed from: b, reason: collision with root package name */
    private final Notification.Builder f3623b;

    /* renamed from: c, reason: collision with root package name */
    private final m.e f3624c;

    /* renamed from: d, reason: collision with root package name */
    private RemoteViews f3625d;

    /* renamed from: e, reason: collision with root package name */
    private RemoteViews f3626e;

    /* renamed from: f, reason: collision with root package name */
    private final List f3627f = new ArrayList();

    /* renamed from: g, reason: collision with root package name */
    private final Bundle f3628g = new Bundle();

    /* renamed from: h, reason: collision with root package name */
    private int f3629h;

    /* renamed from: i, reason: collision with root package name */
    private RemoteViews f3630i;

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public static class a {
        static Notification.Builder a(Notification.Builder builder, Notification.Action action) {
            return builder.addAction(action);
        }

        static Notification.Action.Builder b(Notification.Action.Builder builder, Bundle bundle) {
            return builder.addExtras(bundle);
        }

        static Notification.Action.Builder c(Notification.Action.Builder builder, RemoteInput remoteInput) {
            return builder.addRemoteInput(remoteInput);
        }

        static Notification.Action d(Notification.Action.Builder builder) {
            return builder.build();
        }

        static Notification.Action.Builder e(int i10, CharSequence charSequence, PendingIntent pendingIntent) {
            return new Notification.Action.Builder(i10, charSequence, pendingIntent);
        }

        static String f(Notification notification) {
            return notification.getGroup();
        }

        static Notification.Builder g(Notification.Builder builder, String str) {
            return builder.setGroup(str);
        }

        static Notification.Builder h(Notification.Builder builder, boolean z10) {
            return builder.setGroupSummary(z10);
        }

        static Notification.Builder i(Notification.Builder builder, boolean z10) {
            return builder.setLocalOnly(z10);
        }

        static Notification.Builder j(Notification.Builder builder, String str) {
            return builder.setSortKey(str);
        }
    }

    /* loaded from: classes.dex */
    static class b {
        static Notification.Builder a(Notification.Builder builder, String str) {
            return builder.addPerson(str);
        }

        static Notification.Builder b(Notification.Builder builder, String str) {
            return builder.setCategory(str);
        }

        static Notification.Builder c(Notification.Builder builder, int i10) {
            return builder.setColor(i10);
        }

        static Notification.Builder d(Notification.Builder builder, Notification notification) {
            return builder.setPublicVersion(notification);
        }

        static Notification.Builder e(Notification.Builder builder, Uri uri, Object obj) {
            return builder.setSound(uri, (AudioAttributes) obj);
        }

        static Notification.Builder f(Notification.Builder builder, int i10) {
            return builder.setVisibility(i10);
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public static class c {
        static Notification.Action.Builder a(Icon icon, CharSequence charSequence, PendingIntent pendingIntent) {
            return new Notification.Action.Builder(icon, charSequence, pendingIntent);
        }

        static Notification.Builder b(Notification.Builder builder, Icon icon) {
            return builder.setLargeIcon(icon);
        }

        static Notification.Builder c(Notification.Builder builder, Object obj) {
            return builder.setSmallIcon((Icon) obj);
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public static class d {
        static Notification.Action.Builder a(Notification.Action.Builder builder, boolean z10) {
            return builder.setAllowGeneratedReplies(z10);
        }

        static Notification.Builder b(Notification.Builder builder, RemoteViews remoteViews) {
            return builder.setCustomBigContentView(remoteViews);
        }

        static Notification.Builder c(Notification.Builder builder, RemoteViews remoteViews) {
            return builder.setCustomContentView(remoteViews);
        }

        static Notification.Builder d(Notification.Builder builder, RemoteViews remoteViews) {
            return builder.setCustomHeadsUpContentView(remoteViews);
        }

        static Notification.Builder e(Notification.Builder builder, CharSequence[] charSequenceArr) {
            return builder.setRemoteInputHistory(charSequenceArr);
        }
    }

    /* loaded from: classes.dex */
    static class e {
        static Notification.Builder a(Context context, String str) {
            return new Notification.Builder(context, str);
        }

        static Notification.Builder b(Notification.Builder builder, int i10) {
            return builder.setBadgeIconType(i10);
        }

        static Notification.Builder c(Notification.Builder builder, boolean z10) {
            return builder.setColorized(z10);
        }

        static Notification.Builder d(Notification.Builder builder, int i10) {
            return builder.setGroupAlertBehavior(i10);
        }

        static Notification.Builder e(Notification.Builder builder, CharSequence charSequence) {
            return builder.setSettingsText(charSequence);
        }

        static Notification.Builder f(Notification.Builder builder, String str) {
            return builder.setShortcutId(str);
        }

        static Notification.Builder g(Notification.Builder builder, long j10) {
            return builder.setTimeoutAfter(j10);
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public static class f {
        static Notification.Builder a(Notification.Builder builder, Person person) {
            return builder.addPerson(person);
        }

        static Notification.Action.Builder b(Notification.Action.Builder builder, int i10) {
            return builder.setSemanticAction(i10);
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public static class g {
        static Notification.Builder a(Notification.Builder builder, boolean z10) {
            return builder.setAllowSystemGeneratedContextualActions(z10);
        }

        static Notification.Builder b(Notification.Builder builder, Notification.BubbleMetadata bubbleMetadata) {
            return builder.setBubbleMetadata(bubbleMetadata);
        }

        static Notification.Action.Builder c(Notification.Action.Builder builder, boolean z10) {
            return builder.setContextual(z10);
        }

        static Notification.Builder d(Notification.Builder builder, Object obj) {
            return builder.setLocusId((LocusId) obj);
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public static class h {
        static Notification.Action.Builder a(Notification.Action.Builder builder, boolean z10) {
            return builder.setAuthenticationRequired(z10);
        }

        static Notification.Builder b(Notification.Builder builder, int i10) {
            return builder.setForegroundServiceBehavior(i10);
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public n(m.e eVar) {
        int i10;
        this.f3624c = eVar;
        Context context = eVar.f3592a;
        this.f3622a = context;
        Notification.Builder a10 = e.a(context, eVar.K);
        this.f3623b = a10;
        Notification notification = eVar.R;
        a10.setWhen(notification.when).setSmallIcon(notification.icon, notification.iconLevel).setContent(notification.contentView).setTicker(notification.tickerText, eVar.f3600i).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(eVar.f3596e).setContentText(eVar.f3597f).setContentInfo(eVar.f3602k).setContentIntent(eVar.f3598g).setDeleteIntent(notification.deleteIntent).setFullScreenIntent(eVar.f3599h, (notification.flags & 128) != 0).setNumber(eVar.f3603l).setProgress(eVar.f3611t, eVar.f3612u, eVar.f3613v);
        IconCompat iconCompat = eVar.f3601j;
        c.b(a10, iconCompat == null ? null : iconCompat.m(context));
        a10.setSubText(eVar.f3608q).setUsesChronometer(eVar.f3606o).setPriority(eVar.f3604m);
        Iterator it = eVar.f3593b.iterator();
        while (it.hasNext()) {
            b((m.a) it.next());
        }
        Bundle bundle = eVar.D;
        if (bundle != null) {
            this.f3628g.putAll(bundle);
        }
        this.f3625d = eVar.H;
        this.f3626e = eVar.I;
        this.f3623b.setShowWhen(eVar.f3605n);
        a.i(this.f3623b, eVar.f3617z);
        a.g(this.f3623b, eVar.f3614w);
        a.j(this.f3623b, eVar.f3616y);
        a.h(this.f3623b, eVar.f3615x);
        this.f3629h = eVar.O;
        b.b(this.f3623b, eVar.C);
        b.c(this.f3623b, eVar.E);
        b.f(this.f3623b, eVar.F);
        b.d(this.f3623b, eVar.G);
        b.e(this.f3623b, notification.sound, notification.audioAttributes);
        ArrayList arrayList = eVar.U;
        if (arrayList != null && !arrayList.isEmpty()) {
            Iterator it2 = arrayList.iterator();
            while (it2.hasNext()) {
                b.a(this.f3623b, (String) it2.next());
            }
        }
        this.f3630i = eVar.J;
        if (eVar.f3595d.size() > 0) {
            Bundle bundle2 = eVar.c().getBundle("android.car.EXTENSIONS");
            bundle2 = bundle2 == null ? new Bundle() : bundle2;
            Bundle bundle3 = new Bundle(bundle2);
            Bundle bundle4 = new Bundle();
            for (int i11 = 0; i11 < eVar.f3595d.size(); i11++) {
                bundle4.putBundle(Integer.toString(i11), o.a((m.a) eVar.f3595d.get(i11)));
            }
            bundle2.putBundle("invisible_actions", bundle4);
            bundle3.putBundle("invisible_actions", bundle4);
            eVar.c().putBundle("android.car.EXTENSIONS", bundle2);
            this.f3628g.putBundle("android.car.EXTENSIONS", bundle3);
        }
        int i12 = Build.VERSION.SDK_INT;
        Object obj = eVar.T;
        if (obj != null) {
            c.c(this.f3623b, obj);
        }
        this.f3623b.setExtras(eVar.D);
        d.e(this.f3623b, eVar.f3610s);
        RemoteViews remoteViews = eVar.H;
        if (remoteViews != null) {
            d.c(this.f3623b, remoteViews);
        }
        RemoteViews remoteViews2 = eVar.I;
        if (remoteViews2 != null) {
            d.b(this.f3623b, remoteViews2);
        }
        RemoteViews remoteViews3 = eVar.J;
        if (remoteViews3 != null) {
            d.d(this.f3623b, remoteViews3);
        }
        e.b(this.f3623b, eVar.L);
        e.e(this.f3623b, eVar.f3609r);
        e.f(this.f3623b, eVar.M);
        e.g(this.f3623b, eVar.N);
        e.d(this.f3623b, eVar.O);
        if (eVar.B) {
            e.c(this.f3623b, eVar.A);
        }
        if (!TextUtils.isEmpty(eVar.K)) {
            this.f3623b.setSound(null).setDefaults(0).setLights(0, 0, 0).setVibrate(null);
        }
        Iterator it3 = eVar.f3594c.iterator();
        if (it3.hasNext()) {
            android.support.v4.media.session.b.a(it3.next());
            throw null;
        }
        g.a(this.f3623b, eVar.Q);
        g.b(this.f3623b, m.d.a(null));
        if (i12 >= 31 && (i10 = eVar.P) != 0) {
            h.b(this.f3623b, i10);
        }
        if (eVar.S) {
            if (this.f3624c.f3615x) {
                this.f3629h = 2;
            } else {
                this.f3629h = 1;
            }
            this.f3623b.setVibrate(null);
            this.f3623b.setSound(null);
            int i13 = notification.defaults & (-2) & (-3);
            notification.defaults = i13;
            this.f3623b.setDefaults(i13);
            if (TextUtils.isEmpty(this.f3624c.f3614w)) {
                a.g(this.f3623b, "silent");
            }
            e.d(this.f3623b, this.f3629h);
        }
    }

    private void b(m.a aVar) {
        IconCompat d10 = aVar.d();
        Notification.Action.Builder a10 = c.a(d10 != null ? d10.l() : null, aVar.h(), aVar.a());
        if (aVar.e() != null) {
            for (RemoteInput remoteInput : t.b(aVar.e())) {
                a.c(a10, remoteInput);
            }
        }
        Bundle bundle = aVar.c() != null ? new Bundle(aVar.c()) : new Bundle();
        bundle.putBoolean("android.support.allowGeneratedReplies", aVar.b());
        int i10 = Build.VERSION.SDK_INT;
        d.a(a10, aVar.b());
        bundle.putInt("android.support.action.semanticAction", aVar.f());
        f.b(a10, aVar.f());
        g.c(a10, aVar.j());
        if (i10 >= 31) {
            h.a(a10, aVar.i());
        }
        bundle.putBoolean("android.support.action.showsUserInterface", aVar.g());
        a.b(a10, bundle);
        a.a(this.f3623b, a.d(a10));
    }

    @Override // androidx.core.app.l
    public Notification.Builder a() {
        return this.f3623b;
    }

    public Notification c() {
        Bundle a10;
        RemoteViews f10;
        RemoteViews d10;
        m.g gVar = this.f3624c.f3607p;
        if (gVar != null) {
            gVar.b(this);
        }
        RemoteViews e10 = gVar != null ? gVar.e(this) : null;
        Notification d11 = d();
        if (e10 != null) {
            d11.contentView = e10;
        } else {
            RemoteViews remoteViews = this.f3624c.H;
            if (remoteViews != null) {
                d11.contentView = remoteViews;
            }
        }
        if (gVar != null && (d10 = gVar.d(this)) != null) {
            d11.bigContentView = d10;
        }
        if (gVar != null && (f10 = this.f3624c.f3607p.f(this)) != null) {
            d11.headsUpContentView = f10;
        }
        if (gVar != null && (a10 = m.a(d11)) != null) {
            gVar.a(a10);
        }
        return d11;
    }

    protected Notification d() {
        return this.f3623b.build();
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public Context e() {
        return this.f3622a;
    }
}
