导航菜单

页面标题

页面副标题

Moneyman v2.316.0.0 - FcmManagerImpl.java 源代码

正在查看: Moneyman v2.316.0.0 应用的 FcmManagerImpl.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.exponea.sdk.manager;

import S1.A;
import S1.C0322p;
import S1.C0324s;
import S1.C0325t;
import Zf.a;
import android.R;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.media.Ringtone;
import android.media.RingtoneManager;
import android.net.Uri;
import androidx.core.graphics.drawable.IconCompat;
import com.exponea.sdk.Exponea;
import com.exponea.sdk.ExponeaExtras;
import com.exponea.sdk.manager.TrackingConsentManager;
import com.exponea.sdk.models.Constants;
import com.exponea.sdk.models.ExponeaConfiguration;
import com.exponea.sdk.models.ExponeaNotificationActionType;
import com.exponea.sdk.models.NotificationAction;
import com.exponea.sdk.models.NotificationChannelImportance;
import com.exponea.sdk.models.NotificationPayload;
import com.exponea.sdk.repository.PushTokenRepository;
import com.exponea.sdk.services.ExponeaPushTrackingActivity;
import com.exponea.sdk.services.MessagingUtils;
import com.exponea.sdk.services.inappcontentblock.ContentBlockCarouselViewController;
import com.exponea.sdk.util.ExtensionsKt;
import com.exponea.sdk.util.Logger;
import hg.g;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Random;
import kotlin.Metadata;
import kotlin.jvm.internal.Ref;
import kotlin.jvm.internal.i;

@Metadata(d1 = {"\u0000º\u0001\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010$\n\u0002\u0010\u000e\n\u0000\n\u0002\u0010\u0006\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010\b\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\t\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u000b\n\u0002\b\b\n\u0002\u0018\u0002\n\u0002\b\b\n\u0002\u0018\u0002\n\u0002\b\u000b\n\u0002\u0018\u0002\n\u0002\b\u0005\b\u0010\u0018\u00002\u00020\u0001B/\u0012\u0006\u0010\u0003\u001a\u00020\u0002\u0012\u0006\u0010\u0005\u001a\u00020\u0004\u0012\u0006\u0010\u0007\u001a\u00020\u0006\u0012\u0006\u0010\t\u001a\u00020\b\u0012\u0006\u0010\u000b\u001a\u00020\n¢\u0006\u0004\b\f\u0010\rJ\u0017\u0010\u0011\u001a\u00020\u00102\u0006\u0010\u000f\u001a\u00020\u000eH\u0002¢\u0006\u0004\b\u0011\u0010\u0012J+\u0010\u0019\u001a\u00020\u00182\u0012\u0010\u0015\u001a\u000e\u0012\u0004\u0012\u00020\u0014\u0012\u0004\u0012\u00020\u00140\u00132\u0006\u0010\u0017\u001a\u00020\u0016H\u0002¢\u0006\u0004\b\u0019\u0010\u001aJ\u0017\u0010\u001c\u001a\u00020\u001b2\u0006\u0010\u000f\u001a\u00020\u000eH\u0002¢\u0006\u0004\b\u001c\u0010\u001dJ\u001f\u0010!\u001a\u00020\u001b2\u0006\u0010\u001f\u001a\u00020\u001e2\u0006\u0010 \u001a\u00020\u0018H\u0002¢\u0006\u0004\b!\u0010\"J\u000f\u0010$\u001a\u00020#H\u0002¢\u0006\u0004\b$\u0010%J'\u0010&\u001a\u00020\u001b2\u0006\u0010\u000f\u001a\u00020\u000e2\u0006\u0010\u001f\u001a\u00020\u001e2\u0006\u0010 \u001a\u00020\u0018H\u0002¢\u0006\u0004\b&\u0010'J\u0019\u0010*\u001a\u00020\u001b2\b\u0010)\u001a\u0004\u0018\u00010(H\u0002¢\u0006\u0004\b*\u0010+J\u001f\u0010-\u001a\u00020\u001b2\u0006\u0010\u001f\u001a\u00020\u001e2\u0006\u0010,\u001a\u00020\u0018H\u0002¢\u0006\u0004\b-\u0010\"J\u001f\u0010.\u001a\u00020\u001b2\u0006\u0010\u001f\u001a\u00020\u001e2\u0006\u0010,\u001a\u00020\u0018H\u0002¢\u0006\u0004\b.\u0010\"J\u0017\u00100\u001a\u00020/2\u0006\u0010,\u001a\u00020\u0018H\u0002¢\u0006\u0004\b0\u00101J3\u00108\u001a\u0004\u0018\u0001072\u0006\u0010,\u001a\u00020\u00182\b\u00103\u001a\u0004\u0018\u0001022\u0006\u00105\u001a\u0002042\u0006\u00106\u001a\u00020#H\u0002¢\u0006\u0004\b8\u00109J!\u0010;\u001a\u0004\u0018\u0001072\u0006\u00106\u001a\u00020#2\u0006\u0010:\u001a\u00020/H\u0002¢\u0006\u0004\b;\u0010<J)\u0010>\u001a\u0002072\u0006\u00106\u001a\u00020#2\u0006\u0010:\u001a\u00020/2\b\u0010=\u001a\u0004\u0018\u00010\u0014H\u0002¢\u0006\u0004\b>\u0010?J-\u0010E\u001a\u00020\u001b2\b\u0010@\u001a\u0004\u0018\u00010\u00142\b\u0010B\u001a\u0004\u0018\u00010A2\b\u0010D\u001a\u0004\u0018\u00010CH\u0016¢\u0006\u0004\bE\u0010FJ=\u0010J\u001a\u00020\u001b2\u0014\u0010 \u001a\u0010\u0012\u0004\u0012\u00020\u0014\u0012\u0004\u0012\u00020\u0014\u0018\u00010\u00132\u0006\u0010\u000f\u001a\u00020\u000e2\u0006\u0010H\u001a\u00020G2\u0006\u0010I\u001a\u00020\u0016H\u0016¢\u0006\u0004\bJ\u0010KJ\u000f\u0010\u0011\u001a\u00020\u0010H\u0016¢\u0006\u0004\b\u0011\u0010LJ\u000f\u0010M\u001a\u00020\u001bH\u0014¢\u0006\u0004\bM\u0010NJ/\u0010S\u001a\u00020\u001b2\u0006\u0010,\u001a\u00020\u00182\u0006\u0010O\u001a\u00020\u00162\u0006\u0010Q\u001a\u00020P2\u0006\u0010R\u001a\u00020\u0010H\u0014¢\u0006\u0004\bS\u0010TJ\u001f\u0010H\u001a\u00020\u001b2\u0006\u0010\u000f\u001a\u00020\u000e2\u0006\u0010,\u001a\u00020\u0018H\u0016¢\u0006\u0004\bH\u0010UJ\u001f\u0010X\u001a\u00020\u001b2\u0006\u0010\u0003\u001a\u00020\u00022\u0006\u0010\u000f\u001a\u00020\u000eH\u0000¢\u0006\u0004\bV\u0010WJ\u0019\u0010Z\u001a\u0004\u0018\u00010Y2\u0006\u0010=\u001a\u00020\u0014H\u0014¢\u0006\u0004\bZ\u0010[R\u0014\u0010\u0005\u001a\u00020\u00048\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u0005\u0010\\R\u0014\u0010\u0007\u001a\u00020\u00068\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\u0007\u0010]R\u0014\u0010\t\u001a\u00020\b8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\b\t\u0010^R\u001a\u0010\u000b\u001a\u00020\n8\u0000X\u0080\u0004¢\u0006\f\n\u0004\b\u000b\u0010_\u001a\u0004\b`\u0010aR\u001c\u0010c\u001a\n b*\u0004\u0018\u00010\u00020\u00028\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\bc\u0010dR\u0014\u0010f\u001a\u00020e8\u0002X\u0082\u0004¢\u0006\u0006\n\u0004\bf\u0010gR\u0018\u0010h\u001a\u0004\u0018\u00010#8\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\bh\u0010i¨\u0006j"}, d2 = {"Lcom/exponea/sdk/manager/FcmManagerImpl;", "Lcom/exponea/sdk/manager/FcmManager;", "Landroid/content/Context;", "context", "Lcom/exponea/sdk/models/ExponeaConfiguration;", "configuration", "Lcom/exponea/sdk/manager/EventManager;", "eventManager", "Lcom/exponea/sdk/repository/PushTokenRepository;", "pushTokenRepository", "Lcom/exponea/sdk/manager/TrackingConsentManager;", "trackingConsentManager", "<init>", "(Landroid/content/Context;Lcom/exponea/sdk/models/ExponeaConfiguration;Lcom/exponea/sdk/manager/EventManager;Lcom/exponea/sdk/repository/PushTokenRepository;Lcom/exponea/sdk/manager/TrackingConsentManager;)V", "Landroid/app/NotificationManager;", "manager", "Lcom/exponea/sdk/models/NotificationChannelImportance;", "findNotificationChannelImportance", "(Landroid/app/NotificationManager;)Lcom/exponea/sdk/models/NotificationChannelImportance;", ContentBlockCarouselViewController.EMPTY_PLACEHOLDER_ID, ContentBlockCarouselViewController.EMPTY_PLACEHOLDER_ID, "source", ContentBlockCarouselViewController.EMPTY_PLACEHOLDER_ID, "deviceReceivedTimestamp", "Lcom/exponea/sdk/models/NotificationPayload;", "parseNotificationPayload", "(Ljava/util/Map;D)Lcom/exponea/sdk/models/NotificationPayload;", "LVf/A;", "createNotificationChannel", "(Landroid/app/NotificationManager;)V", "LS1/A;", NotificationAction.ACTION_TYPE_NOTIFICATION, "messageData", "handlePayloadImage", "(LS1/A;Lcom/exponea/sdk/models/NotificationPayload;)V", ContentBlockCarouselViewController.EMPTY_PLACEHOLDER_ID, "getPushIconRes", "()I", "handlePayloadSound", "(Landroid/app/NotificationManager;LS1/A;Lcom/exponea/sdk/models/NotificationPayload;)V", "Landroid/net/Uri;", "soundUri", "playNotificationSound", "(Landroid/net/Uri;)V", "payload", "handlePayloadButtons", "handlePayloadNotificationAction", "Landroid/content/Intent;", "getPushReceiverIntent", "(Lcom/exponea/sdk/models/NotificationPayload;)Landroid/content/Intent;", "Lcom/exponea/sdk/models/ExponeaNotificationActionType;", "action", "Lcom/exponea/sdk/models/NotificationAction;", "actionInfo", "requestCode", "Landroid/app/PendingIntent;", "generateActionPendingIntent", "(Lcom/exponea/sdk/models/NotificationPayload;Lcom/exponea/sdk/models/ExponeaNotificationActionType;Lcom/exponea/sdk/models/NotificationAction;I)Landroid/app/PendingIntent;", "trackingIntent", "getAppIntent", "(ILandroid/content/Intent;)Landroid/app/PendingIntent;", "url", "getUrlIntent", "(ILandroid/content/Intent;Ljava/lang/String;)Landroid/app/PendingIntent;", "token", "Lcom/exponea/sdk/models/ExponeaConfiguration$TokenFrequency;", "tokenTrackFrequency", "Lcom/exponea/sdk/util/TokenType;", "tokenType", "trackToken", "(Ljava/lang/String;Lcom/exponea/sdk/models/ExponeaConfiguration$TokenFrequency;Lcom/exponea/sdk/util/TokenType;)V", ContentBlockCarouselViewController.EMPTY_PLACEHOLDER_ID, "showNotification", "timestamp", "handleRemoteMessage", "(Ljava/util/Map;Landroid/app/NotificationManager;ZD)V", "()Lcom/exponea/sdk/models/NotificationChannelImportance;", "onSelfCheckReceived", "()V", "deliveredTimestamp", "Lcom/exponea/sdk/models/Constants$PushNotifShownStatus;", "shownStatus", "notificationChannelImportance", "trackDeliveredPush", "(Lcom/exponea/sdk/models/NotificationPayload;DLcom/exponea/sdk/models/Constants$PushNotifShownStatus;Lcom/exponea/sdk/models/NotificationChannelImportance;)V", "(Landroid/app/NotificationManager;Lcom/exponea/sdk/models/NotificationPayload;)V", "ensureNotificationChannelExistence$sdk_release", "(Landroid/content/Context;Landroid/app/NotificationManager;)V", "ensureNotificationChannelExistence", "Landroid/graphics/Bitmap;", "getBitmapFromUrl", "(Ljava/lang/String;)Landroid/graphics/Bitmap;", "Lcom/exponea/sdk/models/ExponeaConfiguration;", "Lcom/exponea/sdk/manager/EventManager;", "Lcom/exponea/sdk/repository/PushTokenRepository;", "Lcom/exponea/sdk/manager/TrackingConsentManager;", "getTrackingConsentManager$sdk_release", "()Lcom/exponea/sdk/manager/TrackingConsentManager;", "kotlin.jvm.PlatformType", "application", "Landroid/content/Context;", "Ljava/util/Random;", "requestCodeGenerator", "Ljava/util/Random;", "lastPushNotificationId", "Ljava/lang/Integer;", "sdk_release"}, k = 1, mv = {1, 9, 0}, xi = 48)
public class FcmManagerImpl implements FcmManager {
    private final Context application;
    private final ExponeaConfiguration configuration;
    private final EventManager eventManager;
    private Integer lastPushNotificationId;
    private final PushTokenRepository pushTokenRepository;
    private final Random requestCodeGenerator;
    private final TrackingConsentManager trackingConsentManager;

    @Metadata(k = 3, mv = {1, 9, 0}, xi = 48)
    public class WhenMappings {
        public static final int[] $EnumSwitchMapping$0;
        public static final int[] $EnumSwitchMapping$1;

        static {
            int[] iArr = new int[ExponeaConfiguration.TokenFrequency.values().length];
            try {
                iArr[ExponeaConfiguration.TokenFrequency.ON_TOKEN_CHANGE.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                iArr[ExponeaConfiguration.TokenFrequency.EVERY_LAUNCH.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                iArr[ExponeaConfiguration.TokenFrequency.DAILY.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            $EnumSwitchMapping$0 = iArr;
            int[] iArr2 = new int[ExponeaNotificationActionType.values().length];
            try {
                iArr2[ExponeaNotificationActionType.BROWSER.ordinal()] = 1;
            } catch (NoSuchFieldError unused4) {
            }
            try {
                iArr2[ExponeaNotificationActionType.DEEPLINK.ordinal()] = 2;
            } catch (NoSuchFieldError unused5) {
            }
            $EnumSwitchMapping$1 = iArr2;
        }
    }

    public FcmManagerImpl(Context context, ExponeaConfiguration exponeaConfiguration, EventManager eventManager, PushTokenRepository pushTokenRepository, TrackingConsentManager trackingConsentManager) {
        i.g(context, "context");
        i.g(exponeaConfiguration, "configuration");
        i.g(eventManager, "eventManager");
        i.g(pushTokenRepository, "pushTokenRepository");
        i.g(trackingConsentManager, "trackingConsentManager");
        this.configuration = exponeaConfiguration;
        this.eventManager = eventManager;
        this.pushTokenRepository = pushTokenRepository;
        this.trackingConsentManager = trackingConsentManager;
        this.application = context.getApplicationContext();
        this.requestCodeGenerator = new Random();
    }

    private final void createNotificationChannel(NotificationManager manager) {
        String pushChannelName = this.configuration.getPushChannelName();
        String pushChannelDescription = this.configuration.getPushChannelDescription();
        NotificationChannel notificationChannel = new NotificationChannel(this.configuration.getPushChannelId(), pushChannelName, this.configuration.getPushNotificationImportance());
        notificationChannel.setDescription(pushChannelDescription);
        notificationChannel.setShowBadge(true);
        notificationChannel.setSound(null, null);
        manager.createNotificationChannel(notificationChannel);
    }

    private final PendingIntent generateActionPendingIntent(NotificationPayload payload, ExponeaNotificationActionType action, NotificationAction actionInfo, int requestCode) {
        Intent pushReceiverIntent = getPushReceiverIntent(payload);
        pushReceiverIntent.putExtra(ExponeaExtras.EXTRA_ACTION_INFO, actionInfo);
        int i5 = action == null ? -1 : WhenMappings.$EnumSwitchMapping$1[action.ordinal()];
        if (i5 == 1) {
            pushReceiverIntent.setAction(ExponeaExtras.ACTION_URL_CLICKED);
            return getUrlIntent(requestCode, pushReceiverIntent, actionInfo.getUrl());
        }
        if (i5 != 2) {
            pushReceiverIntent.setAction(ExponeaExtras.ACTION_CLICKED);
            return getAppIntent(requestCode, pushReceiverIntent);
        }
        pushReceiverIntent.setAction(ExponeaExtras.ACTION_DEEPLINK_CLICKED);
        return getUrlIntent(requestCode, pushReceiverIntent, actionInfo.getUrl());
    }

    private final PendingIntent getAppIntent(int requestCode, Intent trackingIntent) {
        MessagingUtils.Companion companion = MessagingUtils.INSTANCE;
        if (!companion.multiPendingIntentsAllowed()) {
            return PendingIntent.getActivity(this.application, requestCode, trackingIntent, companion.getPendingIntentFlags$sdk_release());
        }
        Context context = this.application;
        i.f(context, "application");
        return PendingIntent.getActivities(this.application, requestCode, new Intent[]{companion.getIntentAppOpen(context), trackingIntent}, companion.getPendingIntentFlags$sdk_release());
    }

    private final int getPushIconRes() {
        Integer pushIcon = this.configuration.getPushIcon();
        int intValue = pushIcon != null ? pushIcon.intValue() : 17301659;
        try {
            this.application.getResources().getResourceName(intValue);
            return intValue;
        } catch (Resources.NotFoundException unused) {
            Logger.INSTANCE.e(this, "Invalid icon resource: " + intValue);
            return R.drawable.ic_dialog_info;
        }
    }

    private final Intent getPushReceiverIntent(NotificationPayload payload) {
        ExponeaPushTrackingActivity.Companion companion = ExponeaPushTrackingActivity.INSTANCE;
        Context context = this.application;
        i.f(context, "application");
        return companion.getClickIntent(context, payload.getNotificationId(), payload.getNotificationData(), payload.getRawData(), payload.getDeliveredTimestamp());
    }

    private final PendingIntent getUrlIntent(int requestCode, Intent trackingIntent, String url) {
        MessagingUtils.Companion companion = MessagingUtils.INSTANCE;
        if (!companion.multiPendingIntentsAllowed()) {
            PendingIntent activity = PendingIntent.getActivity(this.application, requestCode, trackingIntent, companion.getPendingIntentFlags$sdk_release());
            i.f(activity, "getActivity(...)");
            return activity;
        }
        Intent intent = new Intent("android.intent.action.VIEW");
        intent.addFlags(270532608);
        if (url != null && url.length() != 0) {
            intent.setData(Uri.parse(url));
        }
        PendingIntent activities = PendingIntent.getActivities(this.application, requestCode, new Intent[]{intent, trackingIntent}, companion.getPendingIntentFlags$sdk_release());
        i.f(activities, "getActivities(...)");
        return activities;
    }

    private final void handlePayloadButtons(A notification, NotificationPayload payload) {
        if (payload.getButtons() != null) {
            Iterator<NotificationPayload.ActionPayload> it = payload.getButtons().iterator();
            while (it.hasNext()) {
                NotificationPayload.ActionPayload next = it.next();
                PendingIntent generateActionPendingIntent = generateActionPendingIntent(payload, next.getAction(), new NotificationAction(NotificationAction.ACTION_TYPE_BUTTON, next.getTitle(), ExtensionsKt.adjustUrl(next.getUrl())), this.requestCodeGenerator.nextInt());
                notification.f3361b.add(new C0322p(0, next.getTitle(), generateActionPendingIntent));
            }
        }
    }

    private final void handlePayloadImage(A notification, NotificationPayload messageData) {
        Bitmap bitmapFromUrl;
        if (messageData.getImage() == null || (bitmapFromUrl = getBitmapFromUrl(messageData.getImage())) == null) {
            return;
        }
        C0324s c0324s = new C0324s();
        IconCompat iconCompat = new IconCompat(1);
        iconCompat.f14158b = bitmapFromUrl;
        c0324s.f3483e = iconCompat;
        notification.e(c0324s);
    }

    private final void handlePayloadNotificationAction(A notification, NotificationPayload payload) {
        NotificationPayload.ActionPayload notificationAction = payload.getNotificationAction();
        notification.f3366g = generateActionPendingIntent(payload, notificationAction.getAction(), new NotificationAction(NotificationAction.ACTION_TYPE_NOTIFICATION, notificationAction.getTitle(), ExtensionsKt.adjustUrl(notificationAction.getUrl())), this.requestCodeGenerator.nextInt());
    }

    private final void handlePayloadSound(NotificationManager manager, A notification, NotificationPayload messageData) {
        String a02;
        Uri defaultUri = RingtoneManager.getDefaultUri(2);
        if (messageData.getSound() != null) {
            if (g.k(new File(messageData.getSound())).length() == 0) {
                a02 = messageData.getSound();
            } else {
                String name = new File(messageData.getSound()).getName();
                i.f(name, "getName(...)");
                a02 = Eh.A.a0(name, name);
            }
            if (this.application.getResources().getIdentifier(a02, "raw", this.application.getPackageName()) != 0) {
                defaultUri = Uri.parse("android.resource://" + this.application.getPackageName() + "/raw/" + a02);
            }
        }
        boolean z7 = true;
        boolean z8 = false;
        if (manager.getCurrentInterruptionFilter() != 1) {
            Logger.INSTANCE.d(this, "Won't play notification sound, DnD mode is on");
            z7 = false;
        }
        if (!manager.areNotificationsEnabled()) {
            Logger.INSTANCE.d(this, "Won't play notification sound, notifications are not allowed");
            z7 = false;
        }
        MessagingUtils.Companion companion = MessagingUtils.INSTANCE;
        Context context = this.application;
        i.f(context, "application");
        NotificationChannel notificationChannel = companion.getNotificationChannel(context, manager, this.configuration.getPushChannelId());
        if (notificationChannel == null) {
            Logger.INSTANCE.d(this, "Won't play notification sound, channel not found.");
        } else if (notificationChannel.getImportance() <= 2) {
            Logger.INSTANCE.d(this, "Won't play notification sound, channel has low importance.");
        } else {
            z8 = z7;
        }
        if (z8) {
            try {
                playNotificationSound(defaultUri);
            } catch (Throwable th) {
                Logger.INSTANCE.e(this, "Failed to play notification sound", th);
                playNotificationSound(RingtoneManager.getDefaultUri(2));
            }
        }
    }

    private final NotificationPayload parseNotificationPayload(Map<String, String> source, double deviceReceivedTimestamp) {
        NotificationPayload notificationPayload = new NotificationPayload(new HashMap(source));
        Double sentTimestamp = notificationPayload.getNotificationData().getSentTimestamp();
        if (sentTimestamp != null && deviceReceivedTimestamp <= sentTimestamp.doubleValue()) {
            deviceReceivedTimestamp = sentTimestamp.doubleValue() + 1;
        }
        notificationPayload.setDeliveredTimestamp(Double.valueOf(deviceReceivedTimestamp));
        return notificationPayload;
    }

    private final void playNotificationSound(Uri soundUri) {
        Ringtone ringtone = RingtoneManager.getRingtone(this.application, soundUri);
        if (ringtone != null) {
            ringtone.play();
        }
    }

    public final void ensureNotificationChannelExistence$sdk_release(Context context, NotificationManager manager) {
        i.g(context, "context");
        i.g(manager, "manager");
        if (MessagingUtils.INSTANCE.doesChannelExists(context, manager, this.configuration.getPushChannelId())) {
            return;
        }
        createNotificationChannel(manager);
    }

    @Override
    public NotificationChannelImportance findNotificationChannelImportance() {
        Object systemService = this.application.getSystemService(NotificationAction.ACTION_TYPE_NOTIFICATION);
        i.e(systemService, "null cannot be cast to non-null type android.app.NotificationManager");
        return findNotificationChannelImportance((NotificationManager) systemService);
    }

    public Bitmap getBitmapFromUrl(final String url) {
        i.g(url, "url");
        final Ref.ObjectRef objectRef = new Ref.ObjectRef();
        a aVar = new a(new kg.a() {
            {
                super(0);
            }

            public Object invoke() {
                m53invoke();
                return Vf.A.a;
            }

            public final void m53invoke() {
                try {
                    InputStream openStream = new URL(url).openStream();
                    objectRef.a = BitmapFactory.decodeStream(openStream);
                } catch (IOException e4) {
                    e4.printStackTrace();
                }
            }
        });
        aVar.start();
        aVar.join();
        return (Bitmap) objectRef.a;
    }

    public final TrackingConsentManager getTrackingConsentManager() {
        return this.trackingConsentManager;
    }

    @Override
    public void handleRemoteMessage(Map<String, String> messageData, NotificationManager manager, boolean showNotification, double timestamp) {
        i.g(manager, "manager");
        Logger logger = Logger.INSTANCE;
        logger.d(this, "handleRemoteMessage");
        if (!this.configuration.getAutomaticPushNotification()) {
            logger.w(this, "Notification delivery not handled, initialized SDK configuration has 'automaticPushNotification' == false");
            return;
        }
        Context context = this.application;
        i.f(context, "application");
        ensureNotificationChannelExistence$sdk_release(context, manager);
        if (messageData == null) {
            logger.w(this, "Push notification not handled because of no data");
            return;
        }
        NotificationPayload parseNotificationPayload = parseNotificationPayload(messageData, timestamp);
        if (parseNotificationPayload.getDeliveredTimestamp() == null) {
            logger.e(this, "Push notification needs info about time delivery");
            parseNotificationPayload.setDeliveredTimestamp(Double.valueOf(timestamp));
        }
        if (parseNotificationPayload.getNotificationAction().getAction() == ExponeaNotificationActionType.SELFCHECK) {
            logger.d(this, "Self-check notification received");
            onSelfCheckReceived();
            return;
        }
        NotificationChannelImportance findNotificationChannelImportance = findNotificationChannelImportance(manager);
        MessagingUtils.Companion companion = MessagingUtils.INSTANCE;
        Context context2 = this.application;
        i.f(context2, "application");
        if (companion.areNotificationsBlockedForTheApp$sdk_release(context2, manager, this.configuration.getPushChannelId())) {
            logger.w(this, "Notification delivery not handled, notifications for the app are turned off in the settings");
            Double deliveredTimestamp = parseNotificationPayload.getDeliveredTimestamp();
            i.d(deliveredTimestamp);
            trackDeliveredPush(parseNotificationPayload, deliveredTimestamp.doubleValue(), Constants.PushNotifShownStatus.NOT_SHOWN, findNotificationChannelImportance);
            return;
        }
        int notificationId = parseNotificationPayload.getNotificationId();
        Integer num = this.lastPushNotificationId;
        if (num != null && notificationId == num.intValue()) {
            logger.i(this, "Ignoring push notification with id " + parseNotificationPayload.getNotificationId() + " that was already received.");
            return;
        }
        this.lastPushNotificationId = Integer.valueOf(parseNotificationPayload.getNotificationId());
        if (!showNotification || parseNotificationPayload.getSilent() || (Eh.A.F(parseNotificationPayload.getTitle()) && Eh.A.F(parseNotificationPayload.getMessage()))) {
            Double deliveredTimestamp2 = parseNotificationPayload.getDeliveredTimestamp();
            i.d(deliveredTimestamp2);
            trackDeliveredPush(parseNotificationPayload, deliveredTimestamp2.doubleValue(), Constants.PushNotifShownStatus.NOT_SHOWN, findNotificationChannelImportance);
        } else {
            Double deliveredTimestamp3 = parseNotificationPayload.getDeliveredTimestamp();
            i.d(deliveredTimestamp3);
            trackDeliveredPush(parseNotificationPayload, deliveredTimestamp3.doubleValue(), Constants.PushNotifShownStatus.SHOWN, findNotificationChannelImportance);
            showNotification(manager, parseNotificationPayload);
        }
    }

    public void onSelfCheckReceived() {
        Exponea.INSTANCE.selfCheckPushReceived$sdk_release();
    }

    @Override
    public void showNotification(NotificationManager manager, NotificationPayload payload) {
        i.g(manager, "manager");
        i.g(payload, "payload");
        Logger.INSTANCE.d(this, "showNotification");
        Context context = this.application;
        i.f(context, "application");
        ensureNotificationChannelExistence$sdk_release(context, manager);
        A a8 = new A(this.application, this.configuration.getPushChannelId());
        a8.f3365f = A.b(payload.getMessage());
        a8.f3364e = A.b(payload.getTitle());
        a8.f3350F = this.configuration.getPushChannelId();
        a8.f3357M.icon = getPushIconRes();
        C0325t c0325t = new C0325t();
        c0325t.f3487e = A.b(payload.getMessage());
        a8.e(c0325t);
        Integer pushAccentColor = this.configuration.getPushAccentColor();
        if (pushAccentColor != null) {
            a8.f3347C = pushAccentColor.intValue();
        }
        handlePayloadImage(a8, payload);
        handlePayloadSound(manager, a8, payload);
        handlePayloadButtons(a8, payload);
        handlePayloadNotificationAction(a8, payload);
        manager.notify(payload.getNotificationId(), a8.a());
    }

    public void trackDeliveredPush(NotificationPayload payload, double deliveredTimestamp, Constants.PushNotifShownStatus shownStatus, NotificationChannelImportance notificationChannelImportance) {
        i.g(payload, "payload");
        i.g(shownStatus, "shownStatus");
        i.g(notificationChannelImportance, "notificationChannelImportance");
        if (payload.getNotificationData().getHasTrackingConsent()) {
            this.trackingConsentManager.trackDeliveredPush(payload.getNotificationData(), deliveredTimestamp, TrackingConsentManager.MODE.CONSIDER_CONSENT, shownStatus, notificationChannelImportance);
        } else {
            Logger.INSTANCE.i(this, "Event for delivered notification is not tracked because consent is not given");
        }
        Exponea.INSTANCE.notifyCallbacksForNotificationDelivery$sdk_release(payload);
    }

    @Override
    public void trackToken(java.lang.String r10, com.exponea.sdk.models.ExponeaConfiguration.TokenFrequency r11, com.exponea.sdk.util.TokenType r12) {
        throw new UnsupportedOperationException("Method not decompiled: com.exponea.sdk.manager.FcmManagerImpl.trackToken(java.lang.String, com.exponea.sdk.models.ExponeaConfiguration$TokenFrequency, com.exponea.sdk.util.TokenType):void");
    }

    private final NotificationChannelImportance findNotificationChannelImportance(NotificationManager manager) {
        MessagingUtils.Companion companion = MessagingUtils.INSTANCE;
        Context context = this.application;
        i.f(context, "application");
        return companion.getNotificationChannelImportance(context, manager, this.configuration.getPushChannelId());
    }
}