package androidx.core.app;

import android.app.Notification;
import android.app.RemoteInput;
import android.content.Context;
import android.content.LocusId;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.os.Build;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.ReplaceWith;
import androidx.core.graphics.drawable.IconCompat;

/* JADX INFO: loaded from: classes.dex */
public abstract class k1 {
    @Nullable
    public static g0 getAction(@NonNull Notification notification, int i10) {
        b2[] b2VarArr;
        int i11;
        Notification.Action action = notification.actions[i10];
        RemoteInput[] remoteInputs = action.getRemoteInputs();
        if (remoteInputs == null) {
            b2VarArr = null;
        } else {
            b2[] b2VarArr2 = new b2[remoteInputs.length];
            for (int i12 = 0; i12 < remoteInputs.length; i12++) {
                RemoteInput remoteInput = remoteInputs[i12];
                b2VarArr2[i12] = new b2(remoteInput.getResultKey(), remoteInput.getLabel(), remoteInput.getChoices(), remoteInput.getAllowFreeFormInput(), Build.VERSION.SDK_INT >= 29 ? b0.e(remoteInput) : 0, remoteInput.getExtras(), null);
            }
            b2VarArr = b2VarArr2;
        }
        int i13 = Build.VERSION.SDK_INT;
        boolean z10 = action.getExtras().getBoolean("android.support.allowGeneratedReplies") || action.getAllowGeneratedReplies();
        boolean z11 = action.getExtras().getBoolean("android.support.action.showsUserInterface", true);
        int iQ = i13 >= 28 ? m.d.q(action) : action.getExtras().getInt("android.support.action.semanticAction", 0);
        boolean zH = i13 >= 29 ? b0.h(action) : false;
        boolean zA = i13 >= 31 ? h0.a(action) : false;
        if (action.getIcon() != null || (i11 = action.icon) == 0) {
            return new g0(action.getIcon() != null ? IconCompat.createFromIconOrNullIfZeroResId(action.getIcon()) : null, action.title, action.actionIntent, action.getExtras(), b2VarArr, (b2[]) null, z10, iQ, z11, zH, zA);
        }
        return new g0(i11, action.title, action.actionIntent, action.getExtras(), b2VarArr, (b2[]) null, z10, iQ, z11, zH, zA);
    }

    @Nullable
    public static p0 getBubbleMetadata(@NonNull Notification notification) {
        if (Build.VERSION.SDK_INT >= 29) {
            return p0.fromPlatform(b0.d(notification));
        }
        return null;
    }

    @Nullable
    public static String getCategory(@NonNull Notification notification) {
        return notification.category;
    }

    @Nullable
    public static String getChannelId(@NonNull Notification notification) {
        if (Build.VERSION.SDK_INT >= 26) {
            return a0.f(notification);
        }
        return null;
    }

    @Nullable
    public static CharSequence getContentInfo(@NonNull Notification notification) {
        return notification.extras.getCharSequence("android.infoText");
    }

    @Nullable
    public static CharSequence getContentText(@NonNull Notification notification) {
        return notification.extras.getCharSequence("android.text");
    }

    @Nullable
    public static CharSequence getContentTitle(@NonNull Notification notification) {
        return notification.extras.getCharSequence("android.title");
    }

    @Nullable
    @ReplaceWith(expression = "notification.extras")
    @Deprecated
    public static Bundle getExtras(@NonNull Notification notification) {
        return notification.extras;
    }

    @Nullable
    public static String getGroup(@NonNull Notification notification) {
        return notification.getGroup();
    }

    @Nullable
    public static g0.i getLocusId(@NonNull Notification notification) {
        LocusId locusIdG;
        if (Build.VERSION.SDK_INT < 29 || (locusIdG = b0.g(notification)) == null) {
            return null;
        }
        p0.g.checkNotNull(locusIdG, "locusId cannot be null");
        return new g0.i((String) p0.g.checkStringNotEmpty(b0.f(locusIdG), "id cannot be empty"));
    }

    @Nullable
    public static Notification getPublicVersion(@NonNull Notification notification) {
        return notification.publicVersion;
    }

    @Nullable
    public static CharSequence getSettingsText(@NonNull Notification notification) {
        if (Build.VERSION.SDK_INT >= 26) {
            return a0.B(notification);
        }
        return null;
    }

    @Nullable
    public static String getShortcutId(@NonNull Notification notification) {
        if (Build.VERSION.SDK_INT >= 26) {
            return a0.C(notification);
        }
        return null;
    }

    @Nullable
    public static String getSortKey(@NonNull Notification notification) {
        return notification.getSortKey();
    }

    @Nullable
    public static CharSequence getSubText(@NonNull Notification notification) {
        return notification.extras.getCharSequence("android.subText");
    }

    @Nullable
    public static Bitmap reduceLargeIconSize(@NonNull Context context, @Nullable Bitmap bitmap) {
        if (bitmap == null || Build.VERSION.SDK_INT >= 27) {
            return bitmap;
        }
        Resources resources = context.getResources();
        int dimensionPixelSize = resources.getDimensionPixelSize(e0.c.compat_notification_large_icon_max_width);
        int dimensionPixelSize2 = resources.getDimensionPixelSize(e0.c.compat_notification_large_icon_max_height);
        if (bitmap.getWidth() <= dimensionPixelSize && bitmap.getHeight() <= dimensionPixelSize2) {
            return bitmap;
        }
        double dMin = Math.min(((double) dimensionPixelSize) / ((double) Math.max(1, bitmap.getWidth())), ((double) dimensionPixelSize2) / ((double) Math.max(1, bitmap.getHeight())));
        return Bitmap.createScaledBitmap(bitmap, (int) Math.ceil(((double) bitmap.getWidth()) * dMin), (int) Math.ceil(((double) bitmap.getHeight()) * dMin), true);
    }
}
