package androidx.core.app;

import android.annotation.SuppressLint;
import android.app.Notification;
import android.app.PendingIntent;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.Icon;
import android.net.Uri;
import android.os.Bundle;
import android.widget.RemoteViews;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import androidx.core.graphics.drawable.IconCompat;
import java.util.ArrayList;

/* JADX INFO: loaded from: classes.dex */
public final class s0 {
    public boolean A;
    public String B;
    public Bundle C;
    public Notification F;
    public RemoteViews G;
    public RemoteViews H;
    public RemoteViews I;
    public String J;
    public String L;
    public g0.i M;
    public final boolean O;
    public p0 P;
    public final Notification Q;
    public final ArrayList R;

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

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

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

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public PendingIntent f1652g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public PendingIntent f1653h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public RemoteViews f1654i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public IconCompat f1655j;

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

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public int f1657l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public int f1658m;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public boolean f1660o;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    public j1 f1661p;

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

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

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public CharSequence[] f1664s;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public int f1665t;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public int f1666u;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public boolean f1667v;

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

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

    /* JADX INFO: renamed from: z, reason: collision with root package name */
    public boolean f1671z;

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

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

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

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public boolean f1659n = true;

    /* JADX INFO: renamed from: y, reason: collision with root package name */
    public boolean f1670y = false;
    public int D = 0;
    public int E = 0;
    public int K = 0;
    public int N = 0;

    public s0(Context context, String str) {
        Notification notification = new Notification();
        this.Q = notification;
        this.f1646a = context;
        this.J = str;
        notification.when = System.currentTimeMillis();
        notification.audioStreamType = -1;
        this.f1658m = 0;
        this.R = new ArrayList();
        this.O = true;
    }

    @Nullable
    private static Bundle getExtrasWithoutDuplicateData(@NonNull Notification notification, @Nullable j1 j1Var) {
        if (notification.extras == null) {
            return null;
        }
        Bundle bundle = new Bundle(notification.extras);
        bundle.remove("android.title");
        bundle.remove("android.text");
        bundle.remove("android.infoText");
        bundle.remove("android.subText");
        bundle.remove("android.intent.extra.CHANNEL_ID");
        bundle.remove("android.intent.extra.CHANNEL_GROUP_ID");
        bundle.remove("android.showWhen");
        bundle.remove("android.progress");
        bundle.remove("android.progressMax");
        bundle.remove("android.progressIndeterminate");
        bundle.remove("android.chronometerCountDown");
        bundle.remove("android.colorized");
        bundle.remove("android.people.list");
        bundle.remove("android.people");
        bundle.remove("android.support.sortKey");
        bundle.remove("android.support.groupKey");
        bundle.remove("android.support.isGroupSummary");
        bundle.remove("android.support.localOnly");
        bundle.remove("android.support.actionExtras");
        Bundle bundle2 = bundle.getBundle("android.car.EXTENSIONS");
        if (bundle2 != null) {
            Bundle bundle3 = new Bundle(bundle2);
            bundle3.remove("invisible_actions");
            bundle.putBundle("android.car.EXTENSIONS", bundle3);
        }
        if (j1Var != null) {
            j1Var.clearCompatExtraKeys(bundle);
        }
        return bundle;
    }

    @Nullable
    public static CharSequence limitCharSequenceLength(@Nullable CharSequence charSequence) {
        return (charSequence != null && charSequence.length() > 5120) ? charSequence.subSequence(0, 5120) : charSequence;
    }

    public final Notification a() {
        return new l1(this).b();
    }

    @NonNull
    public s0 addAction(int i10, @Nullable CharSequence charSequence, @Nullable PendingIntent pendingIntent) {
        this.f1647b.add(new g0(i10, charSequence, pendingIntent));
        return this;
    }

    @NonNull
    public s0 addExtras(@Nullable Bundle bundle) {
        if (bundle != null) {
            Bundle bundle2 = this.C;
            if (bundle2 == null) {
                this.C = new Bundle(bundle);
            } else {
                bundle2.putAll(bundle);
            }
        }
        return this;
    }

    @NonNull
    @RequiresApi(21)
    public s0 addInvisibleAction(int i10, @Nullable CharSequence charSequence, @Nullable PendingIntent pendingIntent) {
        this.f1649d.add(new g0(i10, charSequence, pendingIntent));
        return this;
    }

    @NonNull
    @Deprecated
    public s0 addPerson(@Nullable String str) {
        if (str != null && !str.isEmpty()) {
            this.R.add(str);
        }
        return this;
    }

    public final void b(int i10, boolean z10) {
        Notification notification = this.Q;
        if (z10) {
            notification.flags = i10 | notification.flags;
        } else {
            notification.flags = (~i10) & notification.flags;
        }
    }

    @Nullable
    @SuppressLint({"BuilderSetStyle"})
    public RemoteViews createBigContentView() {
        RemoteViews remoteViewsMakeBigContentView;
        j1 j1Var;
        if (this.H != null && ((j1Var = this.f1661p) == null || !j1Var.displayCustomViewInline())) {
            return this.H;
        }
        l1 l1Var = new l1(this);
        j1 j1Var2 = this.f1661p;
        return (j1Var2 == null || (remoteViewsMakeBigContentView = j1Var2.makeBigContentView(l1Var)) == null) ? r0.a(r0.d(this.f1646a, l1Var.b())) : remoteViewsMakeBigContentView;
    }

    @Nullable
    @SuppressLint({"BuilderSetStyle"})
    public RemoteViews createContentView() {
        RemoteViews remoteViewsMakeContentView;
        j1 j1Var;
        if (this.G != null && ((j1Var = this.f1661p) == null || !j1Var.displayCustomViewInline())) {
            return this.G;
        }
        l1 l1Var = new l1(this);
        j1 j1Var2 = this.f1661p;
        return (j1Var2 == null || (remoteViewsMakeContentView = j1Var2.makeContentView(l1Var)) == null) ? r0.b(r0.d(this.f1646a, l1Var.b())) : remoteViewsMakeContentView;
    }

    @Nullable
    @SuppressLint({"BuilderSetStyle"})
    public RemoteViews createHeadsUpContentView() {
        RemoteViews remoteViewsMakeHeadsUpContentView;
        j1 j1Var;
        if (this.I != null && ((j1Var = this.f1661p) == null || !j1Var.displayCustomViewInline())) {
            return this.I;
        }
        l1 l1Var = new l1(this);
        j1 j1Var2 = this.f1661p;
        return (j1Var2 == null || (remoteViewsMakeHeadsUpContentView = j1Var2.makeHeadsUpContentView(l1Var)) == null) ? r0.c(r0.d(this.f1646a, l1Var.b())) : remoteViewsMakeHeadsUpContentView;
    }

    @Nullable
    @RestrictTo({RestrictTo.Scope.f557c})
    public p0 getBubbleMetadata() {
        return this.P;
    }

    @NonNull
    public s0 setBubbleMetadata(@Nullable p0 p0Var) {
        this.P = p0Var;
        return this;
    }

    @NonNull
    public s0 setCategory(@Nullable String str) {
        this.B = str;
        return this;
    }

    @NonNull
    public s0 setContent(@Nullable RemoteViews remoteViews) {
        this.Q.contentView = remoteViews;
        return this;
    }

    @NonNull
    public s0 setContentInfo(@Nullable CharSequence charSequence) {
        this.f1656k = limitCharSequenceLength(charSequence);
        return this;
    }

    @NonNull
    public s0 setContentIntent(@Nullable PendingIntent pendingIntent) {
        this.f1652g = pendingIntent;
        return this;
    }

    @NonNull
    public s0 setContentText(@Nullable CharSequence charSequence) {
        this.f1651f = limitCharSequenceLength(charSequence);
        return this;
    }

    @NonNull
    public s0 setContentTitle(@Nullable CharSequence charSequence) {
        this.f1650e = limitCharSequenceLength(charSequence);
        return this;
    }

    @NonNull
    public s0 setCustomBigContentView(@Nullable RemoteViews remoteViews) {
        this.H = remoteViews;
        return this;
    }

    @NonNull
    public s0 setCustomContentView(@Nullable RemoteViews remoteViews) {
        this.G = remoteViews;
        return this;
    }

    @NonNull
    public s0 setCustomHeadsUpContentView(@Nullable RemoteViews remoteViews) {
        this.I = remoteViews;
        return this;
    }

    @NonNull
    public s0 setDeleteIntent(@Nullable PendingIntent pendingIntent) {
        this.Q.deleteIntent = pendingIntent;
        return this;
    }

    @NonNull
    public s0 setExtras(@Nullable Bundle bundle) {
        this.C = bundle;
        return this;
    }

    @NonNull
    public s0 setFullScreenIntent(@Nullable PendingIntent pendingIntent, boolean z10) {
        this.f1653h = pendingIntent;
        b(128, z10);
        return this;
    }

    @NonNull
    public s0 setGroup(@Nullable String str) {
        this.f1668w = str;
        return this;
    }

    @NonNull
    public s0 setLargeIcon(@Nullable Bitmap bitmap) {
        this.f1655j = bitmap == null ? null : IconCompat.c(k1.reduceLargeIconSize(this.f1646a, bitmap));
        return this;
    }

    @NonNull
    public s0 setLocusId(@Nullable g0.i iVar) {
        this.M = iVar;
        return this;
    }

    @NonNull
    public s0 setPublicVersion(@Nullable Notification notification) {
        this.F = notification;
        return this;
    }

    @NonNull
    public s0 setRemoteInputHistory(@Nullable CharSequence[] charSequenceArr) {
        this.f1664s = charSequenceArr;
        return this;
    }

    @NonNull
    public s0 setSettingsText(@Nullable CharSequence charSequence) {
        this.f1663r = limitCharSequenceLength(charSequence);
        return this;
    }

    @NonNull
    public s0 setShortcutId(@Nullable String str) {
        this.L = str;
        return this;
    }

    @NonNull
    public s0 setShortcutInfo(@Nullable h0.b bVar) {
        return this;
    }

    @NonNull
    public s0 setSortKey(@Nullable String str) {
        this.f1669x = str;
        return this;
    }

    @NonNull
    public s0 setSound(@Nullable Uri uri) {
        Notification notification = this.Q;
        notification.sound = uri;
        notification.audioStreamType = -1;
        notification.audioAttributes = q0.a(q0.e(q0.c(q0.b(), 4), 5));
        return this;
    }

    @NonNull
    public s0 setStyle(@Nullable j1 j1Var) {
        if (this.f1661p != j1Var) {
            this.f1661p = j1Var;
            if (j1Var != null) {
                j1Var.setBuilder(this);
            }
        }
        return this;
    }

    @NonNull
    public s0 setSubText(@Nullable CharSequence charSequence) {
        this.f1662q = limitCharSequenceLength(charSequence);
        return this;
    }

    @NonNull
    public s0 setTicker(@Nullable CharSequence charSequence) {
        this.Q.tickerText = limitCharSequenceLength(charSequence);
        return this;
    }

    @NonNull
    public s0 setVibrate(@Nullable long[] jArr) {
        this.Q.vibrate = jArr;
        return this;
    }

    @NonNull
    public s0 addAction(@Nullable g0 g0Var) {
        if (g0Var != null) {
            this.f1647b.add(g0Var);
        }
        return this;
    }

    @NonNull
    @RequiresApi(21)
    public s0 addInvisibleAction(@Nullable g0 g0Var) {
        if (g0Var != null) {
            this.f1649d.add(g0Var);
        }
        return this;
    }

    @NonNull
    @Deprecated
    public s0 setTicker(@Nullable CharSequence charSequence, @Nullable RemoteViews remoteViews) {
        this.Q.tickerText = limitCharSequenceLength(charSequence);
        this.f1654i = remoteViews;
        return this;
    }

    @NonNull
    public s0 addPerson(@Nullable z1 z1Var) {
        if (z1Var != null) {
            this.f1648c.add(z1Var);
        }
        return this;
    }

    @NonNull
    @RequiresApi(23)
    public s0 setLargeIcon(@Nullable Icon icon) {
        this.f1655j = icon == null ? null : IconCompat.createFromIcon(icon);
        return this;
    }

    @NonNull
    public s0 setSound(@Nullable Uri uri, int i10) {
        Notification notification = this.Q;
        notification.sound = uri;
        notification.audioStreamType = i10;
        notification.audioAttributes = q0.a(q0.d(q0.c(q0.b(), 4), i10));
        return this;
    }
}
