导航菜单

页面标题

页面副标题

Biko v2.0.23 - FirebaseNotificationService.java 源代码

正在查看: Biko v2.0.23 应用的 FirebaseNotificationService.java JAVA 源代码文件

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


package app.callpe.service;

import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.media.AudioAttributes;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.SystemClock;
import android.service.notification.StatusBarNotification;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.util.Log;
import androidx.core.app.ActivityCompat;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import androidx.core.content.ContextCompat;
import androidx.lifecycle.DefaultLifecycleObserver;
import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.ProcessLifecycleOwner;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import app.callpe.App;
import app.callpe.common.utils.Constants;
import app.callpe.common.utils.GroupUtils;
import app.callpe.common.utils.Helper;
import app.callpe.common.utils.MediaPlayerSingleton;
import app.callpe.common.utils.RxBus;
import app.callpe.common.utils.TextUtils;
import app.callpe.common.utils.helper_functions.Utils;
import app.callpe.common.utils.receivers.CallBroadcastReceiver;
import app.callpe.common.utils.sharedpref.PrefKeys;
import app.callpe.common.utils.sharedpref.SharedPref;
import app.callpe.data.model.FcmModel;
import app.callpe.data.model.FcmVideoDetails;
import app.callpe.data.model.GroupModel;
import app.callpe.data.model.GroupNotificationCountModel;
import app.callpe.data.model.GroupNotificationModel;
import app.callpe.data.model.LoginCodeReceivedEvent;
import app.callpe.data.model.PaymentSuccessOrderNotification;
import app.callpe.data.model.StreamerModelKt;
import app.callpe.data.model.UserActionItem;
import app.callpe.db.LocalDB;
import app.callpe.db.dao.ChatDao;
import app.callpe.db.dao.NotificationDAO;
import app.callpe.service.FirebaseNotificationService;
import app.callpe.ui.SplashActivity;
import app.callpe.ui.call.CallActivity;
import app.callpe.ui.chat.AgentBroadcastChatActivity;
import app.callpe.ui.chat.ChatActivity;
import app.callpe.ui.chat.NotificationChatActivity;
import app.callpe.ui.chat.StreamerBroadcastChatActivity;
import app.callpe.ui.chat.SupportChatActivity;
import app.callpe.ui.home.AgentHomeActivity;
import app.callpe.ui.home.HomeActivity;
import app.callpe.ui.home.StreamerDetailActivity;
import app.callpe.ui.home.StreamerHomeActivity;
import app.callpe.ui.home.fragments.ChatListFragment;
import app.callpe.ui.home.vitok.UnblockRequestsActivity;
import app.callpe.ui.user.KycSubmitActivity;
import app.callpe.ui.user.TicketsActivity;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.FutureTarget;
import com.facebook.internal.FacebookRequestErrorClassification;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.messaging.FirebaseMessaging;
import com.google.gson.Gson;
import com.vdx.sud.service.LudoGameServiceUtil;
import dagger.hilt.android.AndroidEntryPoint;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import javax.inject.Inject;
import kotlin.Metadata;
import kotlin.Pair;
import kotlin.collections.CollectionsKt;
import kotlin.coroutines.CoroutineContext;
import kotlin.jvm.JvmStatic;
import kotlin.jvm.internal.ArrayIteratorKt;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.text.StringsKt;
import kotlinx.coroutines.BuildersKt;
import kotlinx.coroutines.CompletableJob;
import kotlinx.coroutines.CoroutineScope;
import kotlinx.coroutines.CoroutineScopeKt;
import kotlinx.coroutines.CoroutineStart;
import kotlinx.coroutines.Dispatchers;
import kotlinx.coroutines.Job;
import kotlinx.coroutines.JobKt;
import kotlinx.coroutines.flow.Flow;
import kotlinx.coroutines.flow.FlowKt;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import timber.log.Timber;

@Metadata(d1 = {"\u0000ô\u0001\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\b\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\b\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0010\t\n\u0000\n\u0002\u0010$\n\u0002\u0010\u000e\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010 \n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\t\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010%\n\u0002\b\b\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\n\n\u0002\u0010!\n\u0002\b\u0013\b\u0007\u0018\u0000 \u0097\u00012\u00020\u00012\u00020\u0002:\u0002\u0097\u0001B\u0005¢\u0006\u0002\u0010\u0003J$\u0010+\u001a\u00020,2\u0006\u0010-\u001a\u00020.2\u0012\u0010/\u001a\u000e\u0012\u0004\u0012\u000201\u0012\u0004\u0012\u00020100H\u0002J$\u00102\u001a\u00020,2\u0006\u0010-\u001a\u00020.2\u0012\u0010/\u001a\u000e\u0012\u0004\u0012\u000201\u0012\u0004\u0012\u00020100H\u0002J$\u00103\u001a\u00020,2\u0006\u0010-\u001a\u00020.2\u0012\u0010/\u001a\u000e\u0012\u0004\u0012\u000201\u0012\u0004\u0012\u00020100H\u0002J\u0010\u00104\u001a\u00020,2\u0006\u00105\u001a\u000206H\u0002J\u0018\u00107\u001a\u00020,2\u0006\u00108\u001a\u0002092\u0006\u0010:\u001a\u000201H\u0002J\u0010\u0010;\u001a\u00020<2\u0006\u0010=\u001a\u000201H\u0002J&\u0010>\u001a\b\u0012\u0004\u0012\u0002010?2\u0006\u0010@\u001a\u0002012\u0006\u0010A\u001a\u0002012\u0006\u0010B\u001a\u000201H\u0002J\u0018\u0010C\u001a\u00020,2\u0006\u0010D\u001a\u00020E2\u0006\u0010/\u001a\u000201H\u0002J\u001e\u0010F\u001a\u0004\u0018\u00010G2\b\u0010H\u001a\u0004\u0018\u00010I2\b\u0010J\u001a\u0004\u0018\u000101H\u0002J\n\u0010K\u001a\u0004\u0018\u00010LH\u0002J \u0010M\u001a\u0012\u0012\u0004\u0012\u0002010Nj\b\u0012\u0004\u0012\u000201`O2\u0006\u0010P\u001a\u000201H\u0002J(\u0010Q\u001a\u00020R2\f\u0010S\u001a\b\u0012\u0004\u0012\u00020I0T2\u0006\u0010U\u001a\u0002012\b\u0010J\u001a\u0004\u0018\u000101H\u0002J4\u0010V\u001a\u00020,2\u0006\u0010-\u001a\u00020.2\u0006\u0010=\u001a\u0002012\u0006\u0010W\u001a\u0002012\u0012\u0010/\u001a\u000e\u0012\u0004\u0012\u000201\u0012\u0004\u0012\u00020100H\u0002J\u001c\u0010X\u001a\u00020,2\u0012\u0010/\u001a\u000e\u0012\u0004\u0012\u000201\u0012\u0004\u0012\u00020100H\u0002J\u0010\u0010Y\u001a\u00020Z2\u0006\u0010[\u001a\u00020ZH\u0002J\u001c\u0010\\\u001a\u00020,2\u0012\u0010/\u001a\u000e\u0012\u0004\u0012\u000201\u0012\u0004\u0012\u00020100H\u0002J$\u0010]\u001a\u00020,2\u0012\u0010/\u001a\u000e\u0012\u0004\u0012\u000201\u0012\u0004\u0012\u000201002\u0006\u0010^\u001a\u000201H\u0003J\u001c\u0010_\u001a\u00020,2\u0012\u0010/\u001a\u000e\u0012\u0004\u0012\u000201\u0012\u0004\u0012\u00020100H\u0002J\b\u0010`\u001a\u00020,H\u0002J\b\u0010a\u001a\u00020,H\u0002J$\u0010b\u001a\u00020,2\u0006\u0010c\u001a\u00020d2\u0012\u0010/\u001a\u000e\u0012\u0004\u0012\u000201\u0012\u0004\u0012\u00020100H\u0002J\u001c\u0010e\u001a\u00020,2\u0012\u0010/\u001a\u000e\u0012\u0004\u0012\u000201\u0012\u0004\u0012\u0002010fH\u0002J\u0018\u0010g\u001a\u00020,2\u0006\u0010h\u001a\u00020\u000b2\u0006\u0010/\u001a\u000201H\u0002J\b\u0010i\u001a\u00020,H\u0002J\u001c\u0010j\u001a\u00020,2\u0012\u0010/\u001a\u000e\u0012\u0004\u0012\u000201\u0012\u0004\u0012\u00020100H\u0002J\u0010\u0010k\u001a\u00020,2\u0006\u0010l\u001a\u00020.H\u0002J\u0010\u0010m\u001a\u00020,2\u0006\u0010l\u001a\u00020.H\u0002J\u0018\u0010n\u001a\u00020,2\u0006\u0010H\u001a\u00020o2\u0006\u0010^\u001a\u000201H\u0002J\b\u0010p\u001a\u00020\u000bH\u0002J\b\u0010q\u001a\u00020,H\u0016J\b\u0010r\u001a\u00020,H\u0016J\u0010\u0010s\u001a\u00020,2\u0006\u0010t\u001a\u00020uH\u0016J\u0010\u0010v\u001a\u00020,2\u0006\u0010w\u001a\u000201H\u0016J\u0010\u0010x\u001a\u00020,2\u0006\u0010y\u001a\u00020zH\u0016J\u0010\u0010{\u001a\u00020,2\u0006\u0010y\u001a\u00020zH\u0016J\u001a\u0010|\u001a\u00020,2\b\u0010/\u001a\u0004\u0018\u0001012\u0006\u0010^\u001a\u000201H\u0002J\u0018\u0010}\u001a\u00020,2\u0006\u0010c\u001a\u0002012\u0006\u0010~\u001a\u000201H\u0002J#\u0010\u007f\u001a\u00020,2\u0006\u0010=\u001a\u0002012\u0006\u0010c\u001a\u0002012\t\b\u0002\u0010\u0080\u0001\u001a\u00020\u000bH\u0002J!\u0010\u0081\u0001\u001a\u00020,2\u0006\u0010c\u001a\u00020G2\u0006\u0010-\u001a\u00020.2\u0006\u0010U\u001a\u000201H\u0002JP\u0010\u0082\u0001\u001a\u00020,2\u0006\u0010U\u001a\u0002012\u0007\u0010\u0083\u0001\u001a\u0002012\u0012\u0010/\u001a\u000e\u0012\u0004\u0012\u000201\u0012\u0004\u0012\u000201002\u000e\u0010\u0084\u0001\u001a\t\u0012\u0004\u0012\u00020I0\u0085\u00012\u0007\u0010\u0086\u0001\u001a\u00020\u000b2\u0007\u0010\u0087\u0001\u001a\u00020*H\u0003JP\u0010\u0088\u0001\u001a\u00020,2\u0006\u0010U\u001a\u0002012\u0007\u0010\u0083\u0001\u001a\u0002012\u0012\u0010/\u001a\u000e\u0012\u0004\u0012\u000201\u0012\u0004\u0012\u000201002\u000e\u0010\u0084\u0001\u001a\t\u0012\u0004\u0012\u00020I0\u0085\u00012\u0007\u0010\u0086\u0001\u001a\u00020\u000b2\u0007\u0010\u0087\u0001\u001a\u00020*H\u0003JP\u0010\u0089\u0001\u001a\u00020,2\u0006\u0010U\u001a\u0002012\u0007\u0010\u0083\u0001\u001a\u0002012\u0012\u0010/\u001a\u000e\u0012\u0004\u0012\u000201\u0012\u0004\u0012\u000201002\u000e\u0010\u0084\u0001\u001a\t\u0012\u0004\u0012\u00020I0\u0085\u00012\u0007\u0010\u0086\u0001\u001a\u00020\u000b2\u0007\u0010\u0087\u0001\u001a\u00020*H\u0003JZ\u0010\u008a\u0001\u001a\u00020,2\u0006\u0010U\u001a\u0002012\b\u0010W\u001a\u0004\u0018\u0001012\u0007\u0010\u0083\u0001\u001a\u0002012\u0012\u0010/\u001a\u000e\u0012\u0004\u0012\u000201\u0012\u0004\u0012\u000201002\u000e\u0010\u0084\u0001\u001a\t\u0012\u0004\u0012\u00020I0\u0085\u00012\u0007\u0010\u0086\u0001\u001a\u00020\u000b2\u0007\u0010\u0087\u0001\u001a\u00020*H\u0003JP\u0010\u008b\u0001\u001a\u00020,2\u0006\u0010U\u001a\u0002012\u0007\u0010\u0083\u0001\u001a\u0002012\u0012\u0010/\u001a\u000e\u0012\u0004\u0012\u000201\u0012\u0004\u0012\u000201002\u000e\u0010\u0084\u0001\u001a\t\u0012\u0004\u0012\u00020I0\u0085\u00012\u0007\u0010\u0086\u0001\u001a\u00020\u000b2\u0007\u0010\u0087\u0001\u001a\u00020*H\u0003J+\u0010\u008c\u0001\u001a\u00020,2\u0007\u0010\u008d\u0001\u001a\u00020.2\u0006\u0010c\u001a\u0002012\u0006\u0010W\u001a\u0002012\u0007\u0010\u008e\u0001\u001a\u00020\u000bH\u0002J$\u0010\u008f\u0001\u001a\u00020,2\u0006\u0010=\u001a\u0002012\u0006\u0010c\u001a\u0002012\t\b\u0002\u0010\u0090\u0001\u001a\u00020\u000bH\u0002J\u0012\u0010\u0091\u0001\u001a\u00020,2\u0007\u0010\u0092\u0001\u001a\u00020.H\u0002J\"\u0010\u0093\u0001\u001a\u00020,2\u0007\u0010\u0094\u0001\u001a\u00020.2\u0006\u0010c\u001a\u0002012\u0006\u0010^\u001a\u000201H\u0002J\u001b\u0010\u0095\u0001\u001a\u00020,2\b\u0010H\u001a\u0004\u0018\u00010o2\u0006\u0010^\u001a\u000201H\u0002J%\u0010\u0096\u0001\u001a\u00020,2\u0006\u0010-\u001a\u00020.2\u0012\u0010/\u001a\u000e\u0012\u0004\u0012\u000201\u0012\u0004\u0012\u00020100H\u0002R\u001e\u0010\u0004\u001a\u00020\u00058\u0006@\u0006X\u0087.¢\u0006\u000e\n\u0000\u001a\u0004\b\u0006\u0010\u0007\"\u0004\b\b\u0010\tR\u000e\u0010\n\u001a\u00020\u000bX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\f\u001a\u0004\u0018\u00010\rX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u000e\u001a\u0004\u0018\u00010\rX\u0082\u000e¢\u0006\u0002\n\u0000R\u001e\u0010\u000f\u001a\u00020\u00108\u0006@\u0006X\u0087.¢\u0006\u000e\n\u0000\u001a\u0004\b\u0011\u0010\u0012\"\u0004\b\u0013\u0010\u0014R\u0010\u0010\u0015\u001a\u0004\u0018\u00010\rX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u0016\u001a\u0004\u0018\u00010\rX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0017\u001a\u00020\u000bX\u0082\u000e¢\u0006\u0002\n\u0000R\u001e\u0010\u0018\u001a\u00020\u00198\u0006@\u0006X\u0087.¢\u0006\u000e\n\u0000\u001a\u0004\b\u001a\u0010\u001b\"\u0004\b\u001c\u0010\u001dR\u001e\u0010\u001e\u001a\u00020\u001f8\u0006@\u0006X\u0087.¢\u0006\u000e\n\u0000\u001a\u0004\b \u0010!\"\u0004\b\"\u0010#R\u000e\u0010$\u001a\u00020%X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010&\u001a\u00020'X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010(\u001a\u0004\u0018\u00010\rX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010)\u001a\u00020*X\u0082\u000e¢\u0006\u0002\n\u0000¨\u0006\u0098\u0001"}, d2 = {"Lapp/callpe/service/FirebaseNotificationService;", "Lcom/google/firebase/messaging/FirebaseMessagingService;", "Landroidx/lifecycle/DefaultLifecycleObserver;", "()V", "apiService", "Lapp/callpe/service/ApiService;", "getApiService", "()Lapp/callpe/service/ApiService;", "setApiService", "(Lapp/callpe/service/ApiService;)V", "appAccess", "", "broadcastAgentSummaryNotificationBuilder", "Landroidx/core/app/NotificationCompat$Builder;", "broadcastSummaryNotificationBuilder", "groupDao", "Lapp/callpe/db/dao/ChatDao;", "getGroupDao", "()Lapp/callpe/db/dao/ChatDao;", "setGroupDao", "(Lapp/callpe/db/dao/ChatDao;)V", "groupSummaryNotificationBuilder", "importantSummaryNotificationBuilder", "isAppInForeground", "notificationDAO", "Lapp/callpe/db/dao/NotificationDAO;", "getNotificationDAO", "()Lapp/callpe/db/dao/NotificationDAO;", "setNotificationDAO", "(Lapp/callpe/db/dao/NotificationDAO;)V", "rxBus", "Lapp/callpe/common/utils/RxBus;", "getRxBus", "()Lapp/callpe/common/utils/RxBus;", "setRxBus", "(Lapp/callpe/common/utils/RxBus;)V", "serviceJob", "Lkotlinx/coroutines/CompletableJob;", "serviceScope", "Lkotlinx/coroutines/CoroutineScope;", "supportSummaryNotificationBuilder", "timeGap", "", "broadcastAgentChatNotification", "", "chatId", "", "data", "", "", "broadcastChatNotification", "chatNotification", "createHeadsUpNotification", "videoModel", "Lapp/callpe/data/model/FcmVideoDetails;", "createMissedCallNotification", "context", "Landroid/content/Context;", FacebookRequestErrorClassification.KEY_NAME, "createNotification", "Landroid/app/Notification;", "title", "downloadFile", "Lkotlinx/coroutines/flow/Flow;", "url", "dirPath", "fileName", "eventSuccess", "paymentSuccessOrderNotification", "Lapp/callpe/data/model/PaymentSuccessOrderNotification;", "getGroupMessage", "Landroid/text/Spannable;", "model", "Lapp/callpe/data/model/GroupNotificationModel;", "chatType", "getMissCallIntent", "Landroid/app/PendingIntent;", "getNotificationsByKey", "Ljava/util/ArrayList;", "Lkotlin/collections/ArrayList;", "key", "getStyleForGroupNotification", "Landroidx/core/app/NotificationCompat$InboxStyle;", "messageBody", "", "chatTitle", "groupChatNotification", "pic", "handleAgentBroadcastChatNotification", "handleAppAccessIntent", "Landroid/content/Intent;", "intent", "handleBroadcastChatNotification", "handleChatMessageNotification", "userRole", "handleChatNotification", "handleGoingOfflineNotification", "handleGoingOnlineNotification", "handleGroupNotification", "message", "Lapp/callpe/data/model/GroupModel;", "handleLoginCodeRemoteMessage", "", "handleLudoGameStatus", "started", "handlePingNotification", "handleSupportNotification", "handleUserBannedByStreamer", "livestreamId", "handleUserKickedByStreamer", "initiateCall", "Lapp/callpe/data/model/FcmModel;", "isLiveStreamRunning", "onCreate", "onDestroy", "onMessageReceived", "remoteMessage", "Lcom/google/firebase/messaging/RemoteMessage;", "onNewToken", "s", "onStart", "owner", "Landroidx/lifecycle/LifecycleOwner;", "onStop", "showCallingNotification", "showGeneralNotification", "role", "showKycStatusNotification", "kycRejected", "showMessageUnlockNotification", "showMultipleAgentBroadcastNotification", "chat_id", "chatList", "", "mute", "size", "showMultipleBroadcastNotification", "showMultipleChatNotification", "showMultipleGroupNotification", "showMultipleSupportNotification", "showStreamerOnlineNotification", "streamerId", "fromMedia", "showStreamerStatusNotification", "streamerRejected", "showTicketResolvedNotification", "ticketId", "showUnblockNotification", "id", "startRinging", "supportChatNotification", "Companion", "app_bikoRelease"}, k = 1, mv = {1, 8, 0}, xi = 48)
@AndroidEntryPoint
public final class FirebaseNotificationService extends Hilt_FirebaseNotificationService implements DefaultLifecycleObserver {

    @Inject
    public ApiService apiService;
    private boolean appAccess;
    private NotificationCompat.Builder broadcastAgentSummaryNotificationBuilder;
    private NotificationCompat.Builder broadcastSummaryNotificationBuilder;

    @Inject
    public ChatDao groupDao;
    private NotificationCompat.Builder groupSummaryNotificationBuilder;
    private NotificationCompat.Builder importantSummaryNotificationBuilder;
    private boolean isAppInForeground;

    @Inject
    public NotificationDAO notificationDAO;

    @Inject
    public RxBus rxBus;
    private final CompletableJob serviceJob;
    private CoroutineScope serviceScope;
    private NotificationCompat.Builder supportSummaryNotificationBuilder;
    private int timeGap;

    public static final Companion INSTANCE = new Companion(null);
    public static String CHAT_GROUP_KEY_CHAT = "GROUP_CHAT_KEY";
    public static String CHAT_SUPPORT_KEY_CHAT = "CHAT_SUPPORT_KEY_CHAT";
    public static String CHAT_NOTIFICATION_KEY_CHAT = "CHAT_NOTIFICATION_KEY_CHAT";
    public static String CHAT_BROADCAST_KEY_CHAT = "CHAT_BROADCAST_KEY_CHAT";
    public static String AGENT_BROADCAST_KEY_CHAT = "AGENT_BROADCAST_KEY_CHAT";
    public static int groupChatNotificationId = 7001;
    public static int supportChatNotificationId = 7002;
    public static int notificationChatId = 7003;
    public static int broadcastNotificationChatId = 7004;
    public static int agentBroadcastNotificationChatId = 7006;

    @JvmStatic
    public static final void fetchFCMToken(Context context) {
        INSTANCE.fetchFCMToken(context);
    }

    @JvmStatic
    public static final int getNotificationIcon(NotificationCompat.Builder builder) {
        return INSTANCE.getNotificationIcon(builder);
    }

    @JvmStatic
    public static final int getNotificationPersonIcon(Notification.Builder builder) {
        return INSTANCE.getNotificationPersonIcon(builder);
    }

    public FirebaseNotificationService() {
        CoroutineContext Job$default = JobKt.Job$default((Job) null, 1, (Object) null);
        this.serviceJob = Job$default;
        this.serviceScope = CoroutineScopeKt.CoroutineScope(Dispatchers.getIO().plus(Job$default));
        this.appAccess = true;
        this.timeGap = 180;
    }

    public final ApiService getApiService() {
        ApiService apiService = this.apiService;
        if (apiService != null) {
            return apiService;
        }
        Intrinsics.throwUninitializedPropertyAccessException("apiService");
        return null;
    }

    public final void setApiService(ApiService apiService) {
        Intrinsics.checkNotNullParameter(apiService, "<set-?>");
        this.apiService = apiService;
    }

    public final ChatDao getGroupDao() {
        ChatDao chatDao = this.groupDao;
        if (chatDao != null) {
            return chatDao;
        }
        Intrinsics.throwUninitializedPropertyAccessException("groupDao");
        return null;
    }

    public final void setGroupDao(ChatDao chatDao) {
        Intrinsics.checkNotNullParameter(chatDao, "<set-?>");
        this.groupDao = chatDao;
    }

    public final NotificationDAO getNotificationDAO() {
        NotificationDAO notificationDAO = this.notificationDAO;
        if (notificationDAO != null) {
            return notificationDAO;
        }
        Intrinsics.throwUninitializedPropertyAccessException("notificationDAO");
        return null;
    }

    public final void setNotificationDAO(NotificationDAO notificationDAO) {
        Intrinsics.checkNotNullParameter(notificationDAO, "<set-?>");
        this.notificationDAO = notificationDAO;
    }

    public final RxBus getRxBus() {
        RxBus rxBus = this.rxBus;
        if (rxBus != null) {
            return rxBus;
        }
        Intrinsics.throwUninitializedPropertyAccessException("rxBus");
        return null;
    }

    public final void setRxBus(RxBus rxBus) {
        Intrinsics.checkNotNullParameter(rxBus, "<set-?>");
        this.rxBus = rxBus;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        ProcessLifecycleOwner.Companion.get().getLifecycle().addObserver((LifecycleObserver) this);
    }

    public void onMessageReceived(com.google.firebase.messaging.RemoteMessage r18) {
        throw new UnsupportedOperationException("Method not decompiled: app.callpe.service.FirebaseNotificationService.onMessageReceived(com.google.firebase.messaging.RemoteMessage):void");
    }

    private final void handleUserKickedByStreamer(long livestreamId) {
        getRxBus().send(new Pair(Constants.LIVESTREAM_KICK, Long.valueOf(livestreamId)));
    }

    private final void handleUserBannedByStreamer(long livestreamId) {
        getRxBus().send(new Pair(Constants.LIVESTREAM_BAN, Long.valueOf(livestreamId)));
    }

    private final void handleLoginCodeRemoteMessage(Map<String, String> data) {
        String str = data.get("data");
        Timber.e("LOGIN_DATA " + str, new Object[0]);
        Log.d("LAS", "LOGIN_DATA " + str);
        if (str != null) {
            try {
                JSONObject jSONObject = new JSONObject(str);
                String optString = jSONObject.optString("gcmCode", "");
                String optString2 = jSONObject.optString("requestId", "");
                Timber.e("FCM, gcmCode = " + optString + ", requestId = " + optString2, new Object[0]);
                RxBus rxBus = getRxBus();
                Intrinsics.checkNotNullExpressionValue(optString, "gcmCode");
                Intrinsics.checkNotNullExpressionValue(optString2, "requestId");
                rxBus.send(new LoginCodeReceivedEvent(optString, optString2));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    static void showKycStatusNotification$default(FirebaseNotificationService firebaseNotificationService, String str, String str2, boolean z, int i, Object obj) {
        if ((i & 4) != 0) {
            z = false;
        }
        firebaseNotificationService.showKycStatusNotification(str, str2, z);
    }

    private final void showKycStatusNotification(String title, String message, boolean kycRejected) {
        try {
            Uri parse = Uri.parse("android.resource://" + getApplicationContext().getPackageName() + "/2131886113");
            Intent intent = new Intent(getApplicationContext(), (Class<?>) StreamerHomeActivity.class);
            if (kycRejected) {
                intent = new Intent(getApplicationContext(), (Class<?>) KycSubmitActivity.class);
                intent.putExtra("edit", true);
            }
            Intent handleAppAccessIntent = handleAppAccessIntent(intent);
            handleAppAccessIntent.addFlags(268484608);
            handleAppAccessIntent.putExtra("notification_clicked", true);
            PendingIntent activity = PendingIntent.getActivity(getApplicationContext(), 1, handleAppAccessIntent(handleAppAccessIntent), 201326592);
            PendingIntent broadcast = PendingIntent.getBroadcast(getApplicationContext(), 1, new Intent((Context) this, (Class<?>) NotificationClickReceiver.class), 201326592);
            Object systemService = getSystemService("notification");
            Intrinsics.checkNotNull(systemService, "null cannot be cast to non-null type android.app.NotificationManager");
            NotificationManager notificationManager = (NotificationManager) systemService;
            if (Build.VERSION.SDK_INT >= 26) {
                NotificationChannel notificationChannel = new NotificationChannel("104", "General Notifications", 5);
                notificationChannel.setDescription("General Notifications");
                notificationChannel.enableLights(true);
                notificationChannel.enableVibration(false);
                notificationChannel.setSound(parse, new AudioAttributes.Builder().setContentType(4).setUsage(5).build());
                notificationManager.createNotificationChannel(notificationChannel);
            }
            NotificationCompat.Builder priority = new NotificationCompat.Builder((Context) this, "104").setContentTitle(TextUtils.makeTextBold(title)).setContentText(message).setAutoCancel(true).setSound(parse).setContentIntent(activity).setDeleteIntent(broadcast).setLights(-16776961, 300, 1000).setWhen(System.currentTimeMillis()).setWhen(System.currentTimeMillis()).setVibrate(new long[]{0}).setPriority(1);
            Intrinsics.checkNotNullExpressionValue(priority, "Builder(this, NOTIFICATI…tionCompat.PRIORITY_HIGH)");
            priority.setSmallIcon(INSTANCE.getNotificationIcon(priority));
            priority.setStyle(new NotificationCompat.BigTextStyle().bigText(message));
            notificationManager.notify(Integer.parseInt("100001"), priority.build());
        } catch (Exception unused) {
        }
    }

    static void showStreamerStatusNotification$default(FirebaseNotificationService firebaseNotificationService, String str, String str2, boolean z, int i, Object obj) {
        if ((i & 4) != 0) {
            z = false;
        }
        firebaseNotificationService.showStreamerStatusNotification(str, str2, z);
    }

    private final void showStreamerStatusNotification(String title, String message, boolean streamerRejected) {
        try {
            Uri parse = Uri.parse("android.resource://" + getApplicationContext().getPackageName() + "/2131886113");
            Intent intent = new Intent(getApplicationContext(), (Class<?>) SplashActivity.class);
            if (streamerRejected) {
                intent = new Intent(getApplicationContext(), (Class<?>) SplashActivity.class);
                intent.putExtra("edit", true);
            }
            intent.addFlags(268484608);
            intent.putExtra("notification_clicked", true);
            PendingIntent activity = PendingIntent.getActivity(getApplicationContext(), 1, intent, 201326592);
            PendingIntent broadcast = PendingIntent.getBroadcast(getApplicationContext(), 1, new Intent((Context) this, (Class<?>) NotificationClickReceiver.class), 201326592);
            Object systemService = getSystemService("notification");
            Intrinsics.checkNotNull(systemService, "null cannot be cast to non-null type android.app.NotificationManager");
            NotificationManager notificationManager = (NotificationManager) systemService;
            if (Build.VERSION.SDK_INT >= 26) {
                NotificationChannel notificationChannel = new NotificationChannel("104", "General Notifications", 5);
                notificationChannel.setDescription("General Notifications");
                notificationChannel.enableLights(true);
                notificationChannel.enableVibration(false);
                notificationChannel.setSound(parse, new AudioAttributes.Builder().setContentType(4).setUsage(5).build());
                notificationManager.createNotificationChannel(notificationChannel);
            }
            NotificationCompat.Builder priority = new NotificationCompat.Builder((Context) this, "104").setContentTitle(TextUtils.makeTextBold(title)).setContentText(message).setAutoCancel(true).setSound(parse).setContentIntent(activity).setDeleteIntent(broadcast).setLights(-16776961, 300, 1000).setWhen(System.currentTimeMillis()).setWhen(System.currentTimeMillis()).setVibrate(new long[]{0}).setPriority(1);
            Intrinsics.checkNotNullExpressionValue(priority, "Builder(this, NOTIFICATI…tionCompat.PRIORITY_HIGH)");
            priority.setSmallIcon(INSTANCE.getNotificationIcon(priority));
            priority.setStyle(new NotificationCompat.BigTextStyle().bigText(message));
            notificationManager.notify(Integer.parseInt("100001"), priority.build());
        } catch (Exception unused) {
        }
    }

    private final void showGeneralNotification(String message, String role) {
        try {
            Uri parse = Uri.parse("android.resource://" + getApplicationContext().getPackageName() + "/2131886113");
            Intent intent = new Intent(getApplicationContext(), (Class<?>) SplashActivity.class);
            int hashCode = role.hashCode();
            if (hashCode != -1721406419) {
                if (hashCode != 2614219) {
                    if (hashCode == 62212837 && role.equals("AGENT")) {
                        intent = new Intent(getApplicationContext(), (Class<?>) AgentHomeActivity.class);
                    }
                } else if (role.equals("USER")) {
                    intent = new Intent(getApplicationContext(), (Class<?>) HomeActivity.class);
                }
            } else if (role.equals("STREAMER")) {
                intent = new Intent(getApplicationContext(), (Class<?>) StreamerHomeActivity.class);
            }
            intent.addFlags(268484608);
            intent.putExtra("notification_clicked", true);
            PendingIntent activity = PendingIntent.getActivity(getApplicationContext(), 1, intent, 201326592);
            PendingIntent broadcast = PendingIntent.getBroadcast(getApplicationContext(), 1, new Intent((Context) this, (Class<?>) NotificationClickReceiver.class), 201326592);
            Object systemService = getSystemService("notification");
            Intrinsics.checkNotNull(systemService, "null cannot be cast to non-null type android.app.NotificationManager");
            NotificationManager notificationManager = (NotificationManager) systemService;
            if (Build.VERSION.SDK_INT >= 26) {
                NotificationChannel notificationChannel = new NotificationChannel("204", "General Notifications", 5);
                notificationChannel.setDescription("General Notifications");
                notificationChannel.enableLights(true);
                notificationChannel.enableVibration(false);
                notificationChannel.setSound(parse, new AudioAttributes.Builder().setContentType(4).setUsage(5).build());
                notificationManager.createNotificationChannel(notificationChannel);
            }
            NotificationCompat.Builder priority = new NotificationCompat.Builder((Context) this, "204").setContentText(message).setAutoCancel(true).setSound(parse).setContentIntent(activity).setDeleteIntent(broadcast).setLights(-16776961, 300, 1000).setWhen(System.currentTimeMillis()).setWhen(System.currentTimeMillis()).setVibrate(new long[]{0}).setPriority(1);
            Intrinsics.checkNotNullExpressionValue(priority, "Builder(this, NOTIFICATI…tionCompat.PRIORITY_HIGH)");
            priority.setSmallIcon(INSTANCE.getNotificationIcon(priority));
            priority.setStyle(new NotificationCompat.BigTextStyle().bigText(message));
            notificationManager.notify(Integer.parseInt("100008"), priority.build());
        } catch (Exception unused) {
        }
    }

    private final void showStreamerOnlineNotification(long streamerId, String message, String pic, boolean fromMedia) {
        try {
            Uri parse = Uri.parse("android.resource://" + getApplicationContext().getPackageName() + "/2131886113");
            Intent handleAppAccessIntent = handleAppAccessIntent(new Intent(getApplicationContext(), (Class<?>) StreamerDetailActivity.class));
            handleAppAccessIntent.addFlags(268435456);
            handleAppAccessIntent.putExtra("notification_clicked", true);
            Intent handleAppAccessIntent2 = handleAppAccessIntent(handleAppAccessIntent);
            handleAppAccessIntent2.putExtra("id", streamerId);
            PendingIntent activity = PendingIntent.getActivity(getApplicationContext(), 1, handleAppAccessIntent2, 201326592);
            PendingIntent broadcast = PendingIntent.getBroadcast(getApplicationContext(), 1, new Intent((Context) this, (Class<?>) NotificationClickReceiver.class), 201326592);
            Object systemService = getSystemService("notification");
            Intrinsics.checkNotNull(systemService, "null cannot be cast to non-null type android.app.NotificationManager");
            NotificationManager notificationManager = (NotificationManager) systemService;
            if (Build.VERSION.SDK_INT >= 26) {
                NotificationChannel notificationChannel = new NotificationChannel("1204", "General Notifications", 5);
                notificationChannel.setDescription("General Notifications");
                notificationChannel.enableLights(true);
                notificationChannel.enableVibration(false);
                notificationChannel.setSound(parse, new AudioAttributes.Builder().setContentType(4).setUsage(5).build());
                notificationManager.createNotificationChannel(notificationChannel);
            }
            Bitmap bitmap = null;
            try {
                FutureTarget submit = Glide.with((Context) this).asBitmap().load(pic).submit();
                Intrinsics.checkNotNullExpressionValue(submit, "with(this@FirebaseNotifi…tmap().load(pic).submit()");
                bitmap = (Bitmap) submit.get();
            } catch (Exception e) {
                Timber.e(e);
            }
            NotificationCompat.Builder priority = new NotificationCompat.Builder((Context) this, "1204").setAutoCancel(true).setSound(parse).setContentIntent(activity).setDeleteIntent(broadcast).setLights(-16776961, 300, 1000).setWhen(System.currentTimeMillis()).setWhen(System.currentTimeMillis()).setVibrate(new long[]{0}).setPriority(1);
            Intrinsics.checkNotNullExpressionValue(priority, "Builder(this, NOTIFICATI…tionCompat.PRIORITY_HIGH)");
            if (fromMedia) {
                priority.setContentTitle(message);
            } else {
                priority.setContentText(message);
            }
            priority.setSmallIcon(INSTANCE.getNotificationIcon(priority));
            if (bitmap != null) {
                priority.setLargeIcon(Helper.INSTANCE.getCircleBitmap(bitmap));
            }
            notificationManager.notify(Integer.parseInt("100001"), priority.build());
        } catch (Exception unused) {
        }
    }

    private final void showMessageUnlockNotification(Spannable message, long chatId, String chatTitle) {
        try {
            Uri parse = Uri.parse("android.resource://" + getApplicationContext().getPackageName() + "/2131886113");
            Intent handleAppAccessIntent = handleAppAccessIntent(new Intent(getApplicationContext(), (Class<?>) ChatActivity.class));
            handleAppAccessIntent.addFlags(268484608);
            handleAppAccessIntent.putExtra("notification_clicked", true);
            handleAppAccessIntent.putExtra("chatId", chatId);
            handleAppAccessIntent.putExtra("chatName", chatTitle);
            PendingIntent activity = PendingIntent.getActivity(getApplicationContext(), 122, handleAppAccessIntent(handleAppAccessIntent), 201326592);
            PendingIntent broadcast = PendingIntent.getBroadcast(getApplicationContext(), 1, new Intent((Context) this, (Class<?>) NotificationClickReceiver.class), 201326592);
            Object systemService = getSystemService("notification");
            Intrinsics.checkNotNull(systemService, "null cannot be cast to non-null type android.app.NotificationManager");
            NotificationManager notificationManager = (NotificationManager) systemService;
            if (Build.VERSION.SDK_INT >= 26) {
                NotificationChannel notificationChannel = new NotificationChannel("1204", "General Notifications", 5);
                notificationChannel.setDescription("General Notifications");
                notificationChannel.enableLights(true);
                notificationChannel.enableVibration(false);
                notificationChannel.setSound(parse, new AudioAttributes.Builder().setContentType(4).setUsage(5).build());
                notificationManager.createNotificationChannel(notificationChannel);
            }
            NotificationCompat.Builder priority = new NotificationCompat.Builder((Context) this, "1204").setContentText(message).setContentTitle("Photo unlocked").setAutoCancel(true).setSound(parse).setContentIntent(activity).setDeleteIntent(broadcast).setLights(-16776961, 300, 1000).setWhen(System.currentTimeMillis()).setWhen(System.currentTimeMillis()).setVibrate(new long[]{0}).setPriority(1);
            Intrinsics.checkNotNullExpressionValue(priority, "Builder(this, NOTIFICATI…tionCompat.PRIORITY_HIGH)");
            priority.setSmallIcon(INSTANCE.getNotificationIcon(priority));
            notificationManager.notify(Integer.parseInt("100002"), priority.build());
        } catch (Exception unused) {
        }
    }

    private final void showUnblockNotification(long id, String message, String userRole) {
        try {
            Uri parse = Uri.parse("android.resource://" + getApplicationContext().getPackageName() + "/2131886113");
            Intent intent = new Intent(getApplicationContext(), (Class<?>) StreamerDetailActivity.class);
            if (Intrinsics.areEqual(userRole, "STREAMER")) {
                intent = new Intent(getApplicationContext(), (Class<?>) UnblockRequestsActivity.class);
            }
            Intent handleAppAccessIntent = handleAppAccessIntent(intent);
            handleAppAccessIntent.addFlags(268435456);
            handleAppAccessIntent.putExtra("notification_clicked", true);
            Intent handleAppAccessIntent2 = handleAppAccessIntent(handleAppAccessIntent);
            handleAppAccessIntent2.putExtra("id", id);
            PendingIntent activity = PendingIntent.getActivity(getApplicationContext(), 1, handleAppAccessIntent2, 201326592);
            PendingIntent broadcast = PendingIntent.getBroadcast(getApplicationContext(), 1, new Intent((Context) this, (Class<?>) NotificationClickReceiver.class), 201326592);
            Object systemService = getSystemService("notification");
            Intrinsics.checkNotNull(systemService, "null cannot be cast to non-null type android.app.NotificationManager");
            NotificationManager notificationManager = (NotificationManager) systemService;
            if (Build.VERSION.SDK_INT >= 26) {
                NotificationChannel notificationChannel = new NotificationChannel("1204", "General Notifications", 5);
                notificationChannel.setDescription("General Notifications");
                notificationChannel.enableLights(true);
                notificationChannel.enableVibration(false);
                notificationChannel.setSound(parse, new AudioAttributes.Builder().setContentType(4).setUsage(5).build());
                notificationManager.createNotificationChannel(notificationChannel);
            }
            NotificationCompat.Builder priority = new NotificationCompat.Builder((Context) this, "1204").setContentText(message).setAutoCancel(true).setSound(parse).setContentIntent(activity).setDeleteIntent(broadcast).setLights(-16776961, 300, 1000).setWhen(System.currentTimeMillis()).setWhen(System.currentTimeMillis()).setVibrate(new long[]{0}).setPriority(1);
            Intrinsics.checkNotNullExpressionValue(priority, "Builder(this, NOTIFICATI…tionCompat.PRIORITY_HIGH)");
            priority.setSmallIcon(INSTANCE.getNotificationIcon(priority));
            notificationManager.notify(Integer.parseInt("100004"), priority.build());
        } catch (Exception unused) {
        }
    }

    private final void showTicketResolvedNotification(long ticketId) {
        try {
            Uri parse = Uri.parse("android.resource://" + getApplicationContext().getPackageName() + "/2131886113");
            Intent handleAppAccessIntent = handleAppAccessIntent(new Intent(getApplicationContext(), (Class<?>) TicketsActivity.class));
            handleAppAccessIntent.addFlags(268435456);
            handleAppAccessIntent.putExtra("notification_clicked", true);
            handleAppAccessIntent.putExtra("ticketId", ticketId);
            PendingIntent activity = PendingIntent.getActivity(getApplicationContext(), 122, handleAppAccessIntent(handleAppAccessIntent), 201326592);
            PendingIntent broadcast = PendingIntent.getBroadcast(getApplicationContext(), 1, new Intent((Context) this, (Class<?>) NotificationClickReceiver.class), 201326592);
            Object systemService = getSystemService("notification");
            Intrinsics.checkNotNull(systemService, "null cannot be cast to non-null type android.app.NotificationManager");
            NotificationManager notificationManager = (NotificationManager) systemService;
            if (Build.VERSION.SDK_INT >= 26) {
                NotificationChannel notificationChannel = new NotificationChannel("1204", "General Notifications", 5);
                notificationChannel.setDescription("General Notifications");
                notificationChannel.enableLights(true);
                notificationChannel.enableVibration(false);
                notificationChannel.setSound(parse, new AudioAttributes.Builder().setContentType(4).setUsage(5).build());
                notificationManager.createNotificationChannel(notificationChannel);
            }
            NotificationCompat.Builder priority = new NotificationCompat.Builder((Context) this, "1204").setContentText("Your problem has been resolved, click to check details").setStyle(new NotificationCompat.BigTextStyle().bigText("Your problem has been resolved, click to check details")).setAutoCancel(true).setSound(parse).setContentIntent(activity).setDeleteIntent(broadcast).setLights(-16776961, 300, 1000).setWhen(System.currentTimeMillis()).setWhen(System.currentTimeMillis()).setVibrate(new long[]{0}).setPriority(1);
            Intrinsics.checkNotNullExpressionValue(priority, "Builder(this, NOTIFICATI…tionCompat.PRIORITY_HIGH)");
            priority.setSmallIcon(INSTANCE.getNotificationIcon(priority));
            notificationManager.notify(Integer.parseInt("100003"), priority.build());
        } catch (Exception unused) {
        }
    }

    private final void handleChatMessageNotification(Map<String, String> data, String userRole) {
        GroupModel groupModel;
        String str = data.get("data");
        Timber.e("message %s", new Object[]{str});
        if (str == null || (groupModel = (GroupModel) new Gson().fromJson(str, GroupModel.class)) == null || groupModel.isFlagged()) {
            return;
        }
        if (Intrinsics.areEqual(groupModel.getMessageType(), Constants.VIDEO_CALL) || Intrinsics.areEqual(groupModel.getMessageType(), "AUDIO_CALL")) {
            if (groupModel.getFailureReason() != null && Intrinsics.areEqual(groupModel.getFailureReason(), "UNANSWERED")) {
                String senderName = groupModel.getSenderName();
                Intrinsics.checkNotNullExpressionValue(senderName, "message.senderName");
                createMissedCallNotification((Context) this, senderName);
                return;
            } else {
                if (Intrinsics.areEqual(userRole, "USER") && groupModel.getFailureReason() != null && Intrinsics.areEqual(groupModel.getFailureReason(), "CANCELLED")) {
                    Context context = (Context) this;
                    Helper.cancelNotification(context, 9999);
                    stopService(new Intent(context, (Class<?>) HeadsUpNotificationService.class));
                    MediaPlayerSingleton companion = MediaPlayerSingleton.INSTANCE.getInstance();
                    if (companion != null) {
                        companion.stop();
                        return;
                    }
                    return;
                }
                return;
            }
        }
        if (App.Companion.isHome()) {
            if (Intrinsics.areEqual(userRole, "USER")) {
                Intent intent = new Intent(Constants.NOTIFY);
                intent.putExtra("img", groupModel.getProfile());
                intent.putExtra(FacebookRequestErrorClassification.KEY_NAME, groupModel.getSenderName().toString());
                intent.putExtra("message_type", groupModel.getMessageType().toString());
                String str2 = groupModel.getMessage() != null ? groupModel.getMessage().toString() : "";
                intent.putExtra("message", str2);
                Timber.e("Sending data: img=" + groupModel.getSenderPic() + ", name=" + groupModel.getSenderName() + ", message_type=" + groupModel.getMessageType() + ", message=" + str2, new Object[0]);
                Context context2 = (Context) this;
                LocalBroadcastManager.getInstance(context2).sendBroadcast(intent);
                LocalBroadcastManager.getInstance(context2).sendBroadcast(new Intent(Constants.GROUP_CHAT_NOTIFICATION_REFRESH));
                return;
            }
            handleGroupNotification(groupModel, data);
            return;
        }
        if (App.Companion.isVideoCallScreen()) {
            Intent intent2 = new Intent(Constants.MESSAGE_RECEIVED);
            intent2.putExtra("chat", str);
            LocalBroadcastManager.getInstance((Context) this).sendBroadcast(intent2);
            return;
        }
        handleGroupNotification(groupModel, data);
    }

    private final void showCallingNotification(java.lang.String r9, java.lang.String r10) {
        throw new UnsupportedOperationException("Method not decompiled: app.callpe.service.FirebaseNotificationService.showCallingNotification(java.lang.String, java.lang.String):void");
    }

    private final void startRinging(FcmModel model, String userRole) {
        try {
            if (Intrinsics.areEqual(userRole, "STREAMER")) {
                if ((model != null ? Long.valueOf(model.getVideoId()) : null) == null) {
                    return;
                }
                BuildersKt.launch$default(CoroutineScopeKt.CoroutineScope(Dispatchers.getIO()), (CoroutineContext) null, (CoroutineStart) null, new FirebaseNotificationService$startRinging$1(this, model, null), 3, (Object) null);
            }
        } catch (Exception e) {
            Timber.e(e);
        }
    }

    public final void initiateCall(FcmModel model, String userRole) {
        FcmVideoDetails fcmVideoDetails = new FcmVideoDetails();
        fcmVideoDetails.fillValues(model, userRole);
        if (fcmVideoDetails.isPriorityCall() && !VideoCallService.INSTANCE.isPriorityVideoCallServiceRunning()) {
            createHeadsUpNotification(fcmVideoDetails);
            return;
        }
        if (this.isAppInForeground && !isLiveStreamRunning()) {
            if (App.Companion.isVideoCallScreen() || App.Companion.isCallScreen()) {
                Long id = fcmVideoDetails.getId();
                Intrinsics.checkNotNullExpressionValue(id, "videoModel.id");
                SharedPref.setLong((Context) this, PrefKeys.LATEST_CALL_ID, id.longValue());
                return;
            } else {
                if (App.isChatScreen || App.isSupportChatScreen) {
                    LocalBroadcastManager.getInstance((Context) this).sendBroadcast(new Intent(Constants.CALL_INITIALIZED));
                }
                Intent intent = new Intent(getApplication(), (Class<?>) CallBroadcastReceiver.class);
                intent.putExtra(Constants.FCM_DATA, new Gson().toJson(fcmVideoDetails));
                sendBroadcast(intent);
                return;
            }
        }
        if (HeadsUpNotificationService.INSTANCE.isServiceRunning()) {
            Timber.e("HeadsUpNotificationService is already running", new Object[0]);
        } else {
            createHeadsUpNotification(fcmVideoDetails);
        }
    }

    private final void createHeadsUpNotification(FcmVideoDetails videoModel) {
        if (Build.VERSION.SDK_INT >= 29) {
            try {
                Context applicationContext = getApplicationContext();
                Intent intent = new Intent(getApplicationContext(), (Class<?>) HeadsUpNotificationService.class);
                intent.putExtra(Constants.FCM_DATA, new Gson().toJson(videoModel));
                ContextCompat.startForegroundService(applicationContext, intent);
                return;
            } catch (Exception e) {
                Timber.e("call notification error " + e, new Object[0]);
                return;
            }
        }
        Intent intent2 = new Intent(getApplicationContext(), (Class<?>) CallActivity.class);
        intent2.setFlags(268435456);
        intent2.putExtra(Constants.FCM_DATA, new Gson().toJson(videoModel));
        intent2.setAction("android.intent.action.MAIN");
        intent2.addCategory("android.intent.category.LAUNCHER");
        getApplication().startActivity(intent2);
    }

    private final boolean isLiveStreamRunning() {
        return LiveStreamingService.INSTANCE.isLiveStreamingRunning();
    }

    private final void createMissedCallNotification(Context context, String name) {
        Uri parse = Uri.parse("android.resource://" + getApplicationContext().getPackageName() + "/2131886113");
        ArrayList<Notification> arrayList = new ArrayList();
        Iterator<T> it = getNotificationsByKey("missed_calls").iterator();
        while (it.hasNext()) {
            arrayList.add(createNotification((String) it.next()));
        }
        String str = "missed_call_channel";
        if (Build.VERSION.SDK_INT >= 26) {
            NotificationChannel notificationChannel = new NotificationChannel("missed_call_channel_group", "Missed Call Group", 4);
            notificationChannel.setDescription("Miss call channel");
            notificationChannel.enableLights(true);
            notificationChannel.enableVibration(false);
            notificationChannel.setSound(parse, new AudioAttributes.Builder().setContentType(4).setUsage(5).build());
            NotificationChannel notificationChannel2 = new NotificationChannel("missed_call_channel", "Missed Call", 4);
            if (arrayList.size() > 1) {
                str = "missed_call_channel_low";
                notificationChannel2 = new NotificationChannel("missed_call_channel_low", "Missed Call", 2);
            }
            NotificationManager notificationManager = (NotificationManager) context.getSystemService(NotificationManager.class);
            notificationManager.createNotificationChannel(notificationChannel2);
            notificationManager.createNotificationChannel(notificationChannel);
        }
        NotificationCompat.Builder autoCancel = new NotificationCompat.Builder(context, str).setSmallIcon(2131231674).setContentTitle("Missed Call").setContentText("You have a missed call from " + name).setSound(parse).setPriority(2).setGroup("missed_calls").setGroupSummary(false).setAutoCancel(true);
        Intrinsics.checkNotNullExpressionValue(autoCancel, "Builder(context, NOTIFIC…alse).setAutoCancel(true)");
        autoCancel.setContentIntent(getMissCallIntent());
        NotificationCompat.Builder groupSummary = new NotificationCompat.Builder(context, "missed_call_channel_group").setSmallIcon(2131231674).setContentTitle("Missed Calls").setPriority(1).setAutoCancel(true).setGroup("missed_calls").setGroupSummary(true);
        Intrinsics.checkNotNullExpressionValue(groupSummary, "Builder(context, \"missed…s\").setGroupSummary(true)");
        Context context2 = (Context) this;
        if (ActivityCompat.checkSelfPermission(context2, "android.permission.POST_NOTIFICATIONS") != 0) {
            return;
        }
        NotificationManagerCompat from = NotificationManagerCompat.from(context2);
        if (arrayList.size() > 1) {
            from.cancelAll();
            for (Notification notification : arrayList) {
                from.notify(notification.hashCode(), notification);
            }
            from.notify(autoCancel.hashCode(), autoCancel.build());
            from.notify(2001, groupSummary.build());
            return;
        }
        from.notify(autoCancel.hashCode(), autoCancel.build());
    }

    private final ArrayList<String> getNotificationsByKey(String key) {
        ArrayList<String> arrayList = new ArrayList<>();
        Object systemService = getSystemService("notification");
        Intrinsics.checkNotNull(systemService, "null cannot be cast to non-null type android.app.NotificationManager");
        StatusBarNotification[] activeNotifications = ((NotificationManager) systemService).getActiveNotifications();
        ArrayList arrayList2 = new ArrayList();
        if (activeNotifications != null) {
            Iterator it = ArrayIteratorKt.iterator(activeNotifications);
            while (it.hasNext()) {
                StatusBarNotification statusBarNotification = (StatusBarNotification) it.next();
                if (statusBarNotification.getGroupKey() != null) {
                    String groupKey = statusBarNotification.getGroupKey();
                    Intrinsics.checkNotNullExpressionValue(groupKey, "notification.groupKey");
                    if (StringsKt.contains$default(groupKey, key, false, 2, (Object) null)) {
                        arrayList2.add(statusBarNotification);
                    }
                }
            }
        }
        Timber.e("Miss call size " + arrayList2.size(), new Object[0]);
        Iterator it2 = arrayList2.iterator();
        while (it2.hasNext()) {
            Bundle bundle = ((StatusBarNotification) it2.next()).getNotification().extras;
            Intrinsics.checkNotNullExpressionValue(bundle, "notification.notification.extras");
            CharSequence charSequence = bundle.getCharSequence("android.text");
            Timber.tag("Notification Text").e(String.valueOf(charSequence), new Object[0]);
            if (charSequence != null) {
                arrayList.add(charSequence.toString());
            }
        }
        return arrayList;
    }

    private final Notification createNotification(String title) {
        Notification build = new NotificationCompat.Builder(getApplicationContext(), "missed_call_channel_low").setSmallIcon(2131231672).setContentTitle("Missed Call").setContentText(title).setPriority(2).setGroup("missed_calls").setGroupSummary(false).setAutoCancel(true).build();
        Intrinsics.checkNotNullExpressionValue(build, "Builder(applicationConte…tAutoCancel(true).build()");
        return build;
    }

    private final PendingIntent getMissCallIntent() {
        try {
            Intent intent = new Intent((Context) this, (Class<?>) SplashActivity.class);
            intent.putExtra("notification_miss_call_group", true);
            intent.setFlags(603979776);
            return PendingIntent.getActivity((Context) this, 2001, intent, 201326592);
        } catch (Exception e) {
            Timber.e(e);
            return null;
        }
    }

    private final void handlePingNotification() {
        BuildersKt.launch$default(this.serviceScope, (CoroutineContext) null, (CoroutineStart) null, new FirebaseNotificationService$handlePingNotification$1(this, null), 3, (Object) null);
    }

    private final void handleGoingOnlineNotification() {
        try {
            PingService pingService = new PingService();
            Intent intent = new Intent((Context) this, pingService.getClass());
            if (!Utils.isMyServiceRunning(pingService.getClass(), (Context) this)) {
                startService(intent);
                Timber.d("Service started successfully", new Object[0]);
            } else {
                Timber.d("Service is already running", new Object[0]);
            }
            if (App.Companion.isHome()) {
                LocalBroadcastManager.getInstance((Context) this).sendBroadcast(new Intent(Constants.MAKE_ONLINE));
            } else {
                StreamerHomeActivity.INSTANCE.setUserOnline(true);
            }
        } catch (Exception e) {
            Timber.e(e);
        }
    }

    private final void handleGoingOfflineNotification() {
        try {
            PingService pingService = new PingService();
            Intent intent = new Intent((Context) this, pingService.getClass());
            if (Utils.isMyServiceRunning(pingService.getClass(), (Context) this)) {
                stopService(intent);
                Timber.d("Service stopped successfully", new Object[0]);
            } else {
                Timber.d("Service is already stopped", new Object[0]);
            }
            if (App.Companion.isHome()) {
                LocalBroadcastManager.getInstance((Context) this).sendBroadcast(new Intent(Constants.MAKE_OFFLINE));
            } else {
                StreamerHomeActivity.INSTANCE.setUserOffline(true);
            }
        } catch (Exception e) {
            Timber.e(e);
        }
    }

    public void onNewToken(String s) {
        Intrinsics.checkNotNullParameter(s, "s");
        super.onNewToken(s);
        Timber.d("onNewToken: %s", new Object[]{s});
        getSharedPreferences("vitok_perf_fcm", 0).edit().putString("fcm", s).apply();
    }

    private final void handleSupportNotification(Map<String, String> data) {
        GroupModel groupModel;
        String str = data.get("data");
        Timber.e("message %s", new Object[]{str});
        if (str == null || (groupModel = (GroupModel) new Gson().fromJson(str, GroupModel.class)) == null) {
            return;
        }
        Timber.e("App.isSupportChatScreen " + App.isSupportChatScreen, new Object[0]);
        if (App.isSupportChatScreen) {
            Intent intent = new Intent(Constants.NOTIFICATION_REFRESH);
            intent.putExtra("chat_id", groupModel.getChatId().longValue());
            intent.putExtra("chat_message", str);
            LocalBroadcastManager.getInstance((Context) this).sendBroadcast(intent);
            return;
        }
        if (App.Companion.isHome()) {
            App.Companion companion = App.Companion;
            App.notificationAvailable = true;
            Long chatId = groupModel.getChatId();
            Intrinsics.checkNotNullExpressionValue(chatId, "message.chatId");
            supportChatNotification(chatId.longValue(), data);
            LocalBroadcastManager.getInstance((Context) this).sendBroadcast(new Intent(Constants.GROUP_CHAT_NOTIFICATION_REFRESH));
            return;
        }
        if (!this.isAppInForeground) {
            Long chatId2 = groupModel.getChatId();
            Intrinsics.checkNotNullExpressionValue(chatId2, "message.chatId");
            supportChatNotification(chatId2.longValue(), data);
        } else {
            Long chatId3 = groupModel.getChatId();
            Intrinsics.checkNotNullExpressionValue(chatId3, "message.chatId");
            supportChatNotification(chatId3.longValue(), data);
        }
    }

    private final void supportChatNotification(final long chatId, final Map<String, String> data) {
        LocalDB.databaseWriteExecutor.execute(new Runnable() {
            @Override
            public final void run() {
                FirebaseNotificationService.supportChatNotification$lambda$13(data, this, chatId);
            }
        });
    }

    public static final void supportChatNotification$lambda$13(Map map, FirebaseNotificationService firebaseNotificationService, long j) {
        Intrinsics.checkNotNullParameter(map, "$data");
        Intrinsics.checkNotNullParameter(firebaseNotificationService, "this$0");
        App.Companion companion = App.Companion;
        App.notificationAvailable = true;
        Object fromJson = new Gson().fromJson((String) map.get("data"), GroupModel.class);
        Intrinsics.checkNotNullExpressionValue(fromJson, "Gson().fromJson(data[\"da…, GroupModel::class.java)");
        firebaseNotificationService.getGroupDao().insertSupportNotificationChat(GroupUtils.mapToSupportNotificationModel((GroupModel) fromJson));
        SystemClock.sleep(50L);
        List<GroupNotificationModel> supportChatNotificationList = firebaseNotificationService.getGroupDao().getSupportChatNotificationList(Long.valueOf(j));
        Intrinsics.checkNotNull(supportChatNotificationList, "null cannot be cast to non-null type java.util.ArrayList<app.callpe.data.model.GroupNotificationModel>{ kotlin.collections.TypeAliasesKt.ArrayList<app.callpe.data.model.GroupNotificationModel> }");
        ArrayList arrayList = (ArrayList) supportChatNotificationList;
        if (arrayList.size() > 1) {
            arrayList.remove(arrayList.size() - 1);
        } else if (arrayList.size() == 1) {
            arrayList = new ArrayList();
        }
        String string = firebaseNotificationService.getString(2131952938);
        Intrinsics.checkNotNullExpressionValue(string, "getString(R.string.support_service)");
        firebaseNotificationService.showMultipleSupportNotification(string, String.valueOf(j), map, arrayList, false, 1);
    }

    private final void showMultipleSupportNotification(String chatTitle, String chat_id, Map<String, String> data, List<GroupNotificationModel> chatList, boolean mute, int size) {
        NotificationChannel notificationChannel;
        try {
            Intent intent = new Intent((Context) this, (Class<?>) SplashActivity.class);
            intent.putExtra("notification_group", true);
            intent.setFlags(603979776);
            PendingIntent activity = PendingIntent.getActivity((Context) this, supportChatNotificationId, intent, 201326592);
            Intrinsics.checkNotNullExpressionValue(activity, "getActivity(\n           …G_IMMUTABLE\n            )");
            Uri parse = Uri.parse("android.resource://" + getApplicationContext().getPackageName() + "/2131886113");
            Intent handleAppAccessIntent = handleAppAccessIntent(new Intent(getApplicationContext(), (Class<?>) SupportChatActivity.class));
            handleAppAccessIntent.setFlags(603979776);
            handleAppAccessIntent.putExtra("notification_clicked", true);
            Timber.e("chat id  %s", new Object[]{chat_id});
            Long valueOf = Long.valueOf(chat_id);
            Intrinsics.checkNotNullExpressionValue(valueOf, "valueOf(chat_id)");
            handleAppAccessIntent.putExtra("chatId", valueOf.longValue());
            handleAppAccessIntent.putExtra("chatName", chatTitle);
            PendingIntent activity2 = PendingIntent.getActivity((Context) this, Integer.parseInt(chat_id), handleAppAccessIntent, 1140850688);
            Intrinsics.checkNotNullExpressionValue(activity2, "getActivity(\n           …G_IMMUTABLE\n            )");
            Intent intent2 = new Intent((Context) this, (Class<?>) NotificationClickReceiver.class);
            intent2.putExtra("chatId", chat_id);
            intent2.setAction(Constants.NotificationChatDeleteAction);
            PendingIntent activity3 = PendingIntent.getActivity((Context) this, 0, intent2, 1140850688);
            Intrinsics.checkNotNullExpressionValue(activity3, "getActivity(\n           …G_IMMUTABLE\n            )");
            Object systemService = getSystemService("notification");
            Intrinsics.checkNotNull(systemService, "null cannot be cast to non-null type android.app.NotificationManager");
            NotificationManager notificationManager = (NotificationManager) systemService;
            String str = "315";
            if (Build.VERSION.SDK_INT >= 26) {
                Timber.e("showTransactionNotification: mute %s", new Object[]{Boolean.valueOf(mute)});
                NotificationChannel notificationChannel2 = new NotificationChannel("3501", "Support Chat", 4);
                notificationChannel2.setDescription("Message Notifications");
                notificationChannel2.enableLights(true);
                notificationChannel2.enableVibration(false);
                notificationChannel2.setSound(parse, new AudioAttributes.Builder().setContentType(4).setUsage(5).build());
                notificationManager.createNotificationChannel(notificationChannel2);
                if (!mute) {
                    String str2 = "316";
                    if (size > 1) {
                        notificationChannel = new NotificationChannel("316", "Notification_Group_Multi", 2);
                    } else {
                        str2 = "317";
                        NotificationChannel notificationChannel3 = new NotificationChannel("317", "Notification_Support_Channel", 5);
                        notificationChannel3.setDescription("Support Notifications");
                        notificationChannel3.enableLights(true);
                        notificationChannel3.enableVibration(false);
                        notificationChannel3.setSound(parse, new AudioAttributes.Builder().setContentType(4).setUsage(5).build());
                        notificationChannel = notificationChannel3;
                    }
                    notificationManager.createNotificationChannel(notificationChannel);
                    str = str2;
                } else {
                    NotificationChannel notificationChannel4 = new NotificationChannel("318", "Notification_Support_NoS", 5);
                    notificationChannel4.setDescription("Support Notifications");
                    notificationChannel4.enableLights(true);
                    notificationChannel4.enableVibration(false);
                    notificationChannel4.setSound(parse, new AudioAttributes.Builder().setContentType(4).setUsage(5).build());
                    notificationManager.createNotificationChannel(notificationChannel4);
                    str = "318";
                }
            }
            NotificationCompat.Builder priority = new NotificationCompat.Builder((Context) this, str).setAutoCancel(true).setSound(parse).setContentIntent(activity2).setDeleteIntent(activity3).setLights(-16776961, 300, 1000).setWhen(System.currentTimeMillis()).setVibrate(new long[]{0}).setGroupSummary(false).setGroup(CHAT_SUPPORT_KEY_CHAT).setPriority(2);
            Intrinsics.checkNotNullExpressionValue(priority, "Builder(\n               …ationCompat.PRIORITY_MAX)");
            priority.setSmallIcon(INSTANCE.getNotificationIcon(priority));
            Object fromJson = new Gson().fromJson(data.get("data"), GroupModel.class);
            Intrinsics.checkNotNullExpressionValue(fromJson, "Gson().fromJson(data[\"da…, GroupModel::class.java)");
            GroupModel groupModel = (GroupModel) fromJson;
            priority.setContentTitle(TextUtils.makeTextBold(chatTitle));
            GroupNotificationModel mapToGroupNotificationModel = GroupUtils.mapToGroupNotificationModel(groupModel);
            Intrinsics.checkNotNullExpressionValue(mapToGroupNotificationModel, "mapToGroupNotificationModel(chatModel)");
            chatList.add(mapToGroupNotificationModel);
            priority.setContentText(getGroupMessage(GroupUtils.mapToGroupNotificationModel(groupModel), ""));
            priority.setStyle(getStyleForGroupNotification(chatList, chatTitle, ""));
            this.supportSummaryNotificationBuilder = new NotificationCompat.Builder((Context) this, "3501").setGroup(CHAT_SUPPORT_KEY_CHAT).setGroupSummary(true).setContentTitle(chatTitle).setSmallIcon(2131230881).setAutoCancel(true).setContentIntent(activity);
            if (mute) {
                return;
            }
            notificationManager.notify(Integer.parseInt(chat_id), priority.build());
            if (size > 1) {
                int i = supportChatNotificationId;
                NotificationCompat.Builder builder = this.supportSummaryNotificationBuilder;
                notificationManager.notify(i, builder != null ? builder.build() : null);
            }
        } catch (Exception e) {
            Timber.e(e);
        }
    }

    private final void handleChatNotification(Map<String, String> data) {
        GroupModel groupModel;
        String str = data.get("data");
        Timber.e("message %s", new Object[]{str});
        if (str == null || (groupModel = (GroupModel) new Gson().fromJson(str, GroupModel.class)) == null) {
            return;
        }
        Timber.e("App.isNotificationScreen " + App.isNotificationScreen, new Object[0]);
        if (App.isNotificationScreen) {
            Intent intent = new Intent(Constants.NOTIFICATION_REFRESH);
            intent.putExtra("chat_id", groupModel.getChatId().longValue());
            intent.putExtra("chat_message", str);
            LocalBroadcastManager.getInstance((Context) this).sendBroadcast(intent);
            return;
        }
        if (App.Companion.isHome()) {
            App.Companion companion = App.Companion;
            App.notificationAvailable = true;
            Long chatId = groupModel.getChatId();
            Intrinsics.checkNotNullExpressionValue(chatId, "message.chatId");
            chatNotification(chatId.longValue(), data);
            LocalBroadcastManager.getInstance((Context) this).sendBroadcast(new Intent(Constants.GROUP_CHAT_NOTIFICATION_REFRESH));
            return;
        }
        if (!this.isAppInForeground) {
            Long chatId2 = groupModel.getChatId();
            Intrinsics.checkNotNullExpressionValue(chatId2, "message.chatId");
            chatNotification(chatId2.longValue(), data);
        } else {
            Long chatId3 = groupModel.getChatId();
            Intrinsics.checkNotNullExpressionValue(chatId3, "message.chatId");
            chatNotification(chatId3.longValue(), data);
        }
    }

    private final void chatNotification(final long chatId, final Map<String, String> data) {
        LocalDB.databaseWriteExecutor.execute(new Runnable() {
            @Override
            public final void run() {
                FirebaseNotificationService.chatNotification$lambda$14(data, this, chatId);
            }
        });
    }

    public static final void chatNotification$lambda$14(Map map, FirebaseNotificationService firebaseNotificationService, long j) {
        Intrinsics.checkNotNullParameter(map, "$data");
        Intrinsics.checkNotNullParameter(firebaseNotificationService, "this$0");
        App.Companion companion = App.Companion;
        App.notificationAvailable = true;
        Object fromJson = new Gson().fromJson((String) map.get("data"), GroupModel.class);
        Intrinsics.checkNotNullExpressionValue(fromJson, "Gson().fromJson(data[\"da…, GroupModel::class.java)");
        firebaseNotificationService.getGroupDao().insertNotificationHelpChat(GroupUtils.mapToNotificationHelptModel((GroupModel) fromJson));
        SystemClock.sleep(50L);
        List<GroupNotificationModel> chatNotificationSupportList = firebaseNotificationService.getGroupDao().getChatNotificationSupportList(Long.valueOf(j));
        Intrinsics.checkNotNull(chatNotificationSupportList, "null cannot be cast to non-null type java.util.ArrayList<app.callpe.data.model.GroupNotificationModel>{ kotlin.collections.TypeAliasesKt.ArrayList<app.callpe.data.model.GroupNotificationModel> }");
        ArrayList arrayList = (ArrayList) chatNotificationSupportList;
        if (arrayList.size() > 1) {
            arrayList.remove(arrayList.size() - 1);
        } else if (arrayList.size() == 1) {
            arrayList = new ArrayList();
        }
        String string = firebaseNotificationService.getString(2131952144);
        Intrinsics.checkNotNullExpressionValue(string, "getString(R.string.important_notifications)");
        firebaseNotificationService.showMultipleChatNotification(string, String.valueOf(j), map, arrayList, false, 1);
    }

    private final void showMultipleChatNotification(String chatTitle, String chat_id, Map<String, String> data, List<GroupNotificationModel> chatList, boolean mute, int size) {
        String str;
        NotificationChannel notificationChannel;
        try {
            Intent intent = new Intent((Context) this, (Class<?>) SplashActivity.class);
            intent.putExtra("notification_group", true);
            intent.setFlags(603979776);
            PendingIntent activity = PendingIntent.getActivity((Context) this, notificationChatId, intent, 201326592);
            Intrinsics.checkNotNullExpressionValue(activity, "getActivity(\n           …G_IMMUTABLE\n            )");
            Uri parse = Uri.parse("android.resource://" + getApplicationContext().getPackageName() + "/2131886113");
            Intent handleAppAccessIntent = handleAppAccessIntent(new Intent(getApplicationContext(), (Class<?>) NotificationChatActivity.class));
            handleAppAccessIntent.setFlags(603979776);
            handleAppAccessIntent.putExtra("notification_clicked", true);
            Timber.e("chat id  %s", new Object[]{chat_id});
            Long valueOf = Long.valueOf(chat_id);
            Intrinsics.checkNotNullExpressionValue(valueOf, "valueOf(chat_id)");
            handleAppAccessIntent.putExtra("chatId", valueOf.longValue());
            handleAppAccessIntent.putExtra("chatName", chatTitle);
            PendingIntent activity2 = PendingIntent.getActivity((Context) this, Integer.parseInt(chat_id), handleAppAccessIntent, 1140850688);
            Intrinsics.checkNotNullExpressionValue(activity2, "getActivity(\n           …G_IMMUTABLE\n            )");
            Intent intent2 = new Intent((Context) this, (Class<?>) NotificationClickReceiver.class);
            intent2.putExtra("chatId", chat_id);
            intent2.setAction(Constants.NotificationChatDeleteAction);
            PendingIntent activity3 = PendingIntent.getActivity((Context) this, 0, intent2, 1140850688);
            Intrinsics.checkNotNullExpressionValue(activity3, "getActivity(\n           …G_IMMUTABLE\n            )");
            Object systemService = getSystemService("notification");
            Intrinsics.checkNotNull(systemService, "null cannot be cast to non-null type android.app.NotificationManager");
            NotificationManager notificationManager = (NotificationManager) systemService;
            String str2 = "615";
            if (Build.VERSION.SDK_INT >= 26) {
                Timber.e("showTransactionNotification: mute %s", new Object[]{Boolean.valueOf(mute)});
                NotificationChannel notificationChannel2 = new NotificationChannel("6700", "Group Chat", 4);
                notificationChannel2.setDescription("Message Notifications");
                notificationChannel2.enableLights(true);
                notificationChannel2.enableVibration(false);
                notificationChannel2.setSound(parse, new AudioAttributes.Builder().setContentType(4).setUsage(5).build());
                notificationManager.createNotificationChannel(notificationChannel2);
                if (!mute) {
                    str = "616";
                    if (size > 1) {
                        notificationChannel = new NotificationChannel("616", "Important_Notification_Multi", 2);
                    } else {
                        str = "617";
                        NotificationChannel notificationChannel3 = new NotificationChannel("617", "Important_Notification_Channel", 4);
                        notificationChannel3.setDescription("Notifications");
                        notificationChannel3.enableLights(true);
                        notificationChannel3.enableVibration(false);
                        notificationChannel3.setSound(parse, new AudioAttributes.Builder().setContentType(4).setUsage(5).build());
                        notificationChannel = notificationChannel3;
                    }
                    notificationManager.createNotificationChannel(notificationChannel);
                } else {
                    str = "618";
                    NotificationChannel notificationChannel4 = new NotificationChannel("618", "Notification_Support_NoS", 5);
                    notificationChannel4.setDescription("Notifications");
                    notificationChannel4.enableLights(true);
                    notificationChannel4.enableVibration(false);
                    notificationChannel4.setSound(parse, new AudioAttributes.Builder().setContentType(4).setUsage(5).build());
                    notificationManager.createNotificationChannel(notificationChannel4);
                }
                str2 = str;
            }
            NotificationCompat.Builder priority = new NotificationCompat.Builder((Context) this, str2).setAutoCancel(true).setSound(parse).setContentIntent(activity2).setDeleteIntent(activity3).setLights(-16776961, 300, 1000).setWhen(System.currentTimeMillis()).setVibrate(new long[]{0}).setGroupSummary(false).setGroup(CHAT_NOTIFICATION_KEY_CHAT).setPriority(2);
            Intrinsics.checkNotNullExpressionValue(priority, "Builder(\n               …ationCompat.PRIORITY_MAX)");
            priority.setSmallIcon(INSTANCE.getNotificationIcon(priority));
            Object fromJson = new Gson().fromJson(data.get("data"), GroupModel.class);
            Intrinsics.checkNotNullExpressionValue(fromJson, "Gson().fromJson(data[\"da…, GroupModel::class.java)");
            GroupModel groupModel = (GroupModel) fromJson;
            priority.setContentTitle(TextUtils.makeTextBold(chatTitle));
            GroupNotificationModel mapToGroupNotificationModel = GroupUtils.mapToGroupNotificationModel(groupModel);
            Intrinsics.checkNotNullExpressionValue(mapToGroupNotificationModel, "mapToGroupNotificationModel(chatModel)");
            chatList.add(mapToGroupNotificationModel);
            priority.setContentText(getGroupMessage(GroupUtils.mapToGroupNotificationModel(groupModel), ""));
            priority.setStyle(getStyleForGroupNotification(chatList, chatTitle, ""));
            this.importantSummaryNotificationBuilder = new NotificationCompat.Builder((Context) this, "6700").setGroup(CHAT_NOTIFICATION_KEY_CHAT).setGroupSummary(true).setContentTitle(chatTitle).setSmallIcon(2131230881).setAutoCancel(true).setContentIntent(activity);
            if (mute) {
                return;
            }
            notificationManager.notify(Integer.parseInt(chat_id), priority.build());
            if (size > 1) {
                int i = notificationChatId;
                NotificationCompat.Builder builder = this.importantSummaryNotificationBuilder;
                notificationManager.notify(i, builder != null ? builder.build() : null);
            }
        } catch (Exception e) {
            Timber.e(e);
        }
    }

    private final void handleBroadcastChatNotification(Map<String, String> data) {
        GroupModel groupModel;
        String str = data.get("data");
        Timber.e("message %s", new Object[]{str});
        if (str == null || (groupModel = (GroupModel) new Gson().fromJson(str, GroupModel.class)) == null) {
            return;
        }
        Timber.e("App.isBroadcastScreen " + App.isBroadcastScreen, new Object[0]);
        if (App.isBroadcastScreen) {
            Intent intent = new Intent(Constants.NOTIFICATION_REFRESH);
            intent.putExtra("chat_id", groupModel.getChatId().longValue());
            intent.putExtra("chat_message", str);
            LocalBroadcastManager.getInstance((Context) this).sendBroadcast(intent);
            return;
        }
        if (App.Companion.isHome()) {
            App.Companion companion = App.Companion;
            App.notificationAvailable = true;
            Long chatId = groupModel.getChatId();
            Intrinsics.checkNotNullExpressionValue(chatId, "message.chatId");
            broadcastChatNotification(chatId.longValue(), data);
            LocalBroadcastManager.getInstance((Context) this).sendBroadcast(new Intent(Constants.GROUP_CHAT_NOTIFICATION_REFRESH));
            return;
        }
        if (!this.isAppInForeground) {
            Long chatId2 = groupModel.getChatId();
            Intrinsics.checkNotNullExpressionValue(chatId2, "message.chatId");
            broadcastChatNotification(chatId2.longValue(), data);
        } else {
            Long chatId3 = groupModel.getChatId();
            Intrinsics.checkNotNullExpressionValue(chatId3, "message.chatId");
            broadcastChatNotification(chatId3.longValue(), data);
        }
    }

    private final void broadcastChatNotification(final long chatId, final Map<String, String> data) {
        LocalDB.databaseWriteExecutor.execute(new Runnable() {
            @Override
            public final void run() {
                FirebaseNotificationService.broadcastChatNotification$lambda$15(data, this, chatId);
            }
        });
    }

    public static final void broadcastChatNotification$lambda$15(Map map, FirebaseNotificationService firebaseNotificationService, long j) {
        Intrinsics.checkNotNullParameter(map, "$data");
        Intrinsics.checkNotNullParameter(firebaseNotificationService, "this$0");
        App.Companion companion = App.Companion;
        App.notificationAvailable = true;
        Object fromJson = new Gson().fromJson((String) map.get("data"), GroupModel.class);
        Intrinsics.checkNotNullExpressionValue(fromJson, "Gson().fromJson(data[\"da…, GroupModel::class.java)");
        firebaseNotificationService.getGroupDao().insertBroadcastChat(GroupUtils.mapToBroadcastNotificationModel((GroupModel) fromJson));
        SystemClock.sleep(50L);
        List<GroupNotificationModel> broadcastChatNotificationList = firebaseNotificationService.getGroupDao().getBroadcastChatNotificationList();
        Intrinsics.checkNotNull(broadcastChatNotificationList, "null cannot be cast to non-null type java.util.ArrayList<app.callpe.data.model.GroupNotificationModel>{ kotlin.collections.TypeAliasesKt.ArrayList<app.callpe.data.model.GroupNotificationModel> }");
        ArrayList arrayList = (ArrayList) broadcastChatNotificationList;
        if (arrayList.size() > 1) {
            arrayList.remove(arrayList.size() - 1);
        } else if (arrayList.size() == 1) {
            arrayList = new ArrayList();
        }
        String string = firebaseNotificationService.getString(2131952608);
        Intrinsics.checkNotNullExpressionValue(string, "getString(R.string.streamer_broadcast)");
        firebaseNotificationService.showMultipleBroadcastNotification(string, String.valueOf(j), map, arrayList, false, 1);
    }

    private final void showMultipleBroadcastNotification(String chatTitle, String chat_id, Map<String, String> data, List<GroupNotificationModel> chatList, boolean mute, int size) {
        Uri uri;
        NotificationChannel notificationChannel;
        try {
            Intent intent = new Intent((Context) this, (Class<?>) SplashActivity.class);
            intent.putExtra("notification_group", true);
            intent.setFlags(603979776);
            PendingIntent activity = PendingIntent.getActivity((Context) this, broadcastNotificationChatId, intent, 201326592);
            Intrinsics.checkNotNullExpressionValue(activity, "getActivity(\n           …G_IMMUTABLE\n            )");
            Uri parse = Uri.parse("android.resource://" + getApplicationContext().getPackageName() + "/2131886113");
            Intent handleAppAccessIntent = handleAppAccessIntent(new Intent(getApplicationContext(), (Class<?>) StreamerBroadcastChatActivity.class));
            handleAppAccessIntent.setFlags(603979776);
            handleAppAccessIntent.putExtra("notification_clicked", true);
            Timber.e("chat id  %s", new Object[]{chat_id});
            Long valueOf = Long.valueOf(chat_id);
            Intrinsics.checkNotNullExpressionValue(valueOf, "valueOf(chat_id)");
            handleAppAccessIntent.putExtra("chatId", valueOf.longValue());
            handleAppAccessIntent.putExtra("chatName", chatTitle);
            PendingIntent activity2 = PendingIntent.getActivity((Context) this, Integer.parseInt(chat_id), handleAppAccessIntent, 1140850688);
            Intrinsics.checkNotNullExpressionValue(activity2, "getActivity(\n           …G_IMMUTABLE\n            )");
            Intent intent2 = new Intent((Context) this, (Class<?>) NotificationClickReceiver.class);
            intent2.putExtra("chatId", chat_id);
            intent2.setAction(Constants.NotificationChatDeleteAction);
            PendingIntent activity3 = PendingIntent.getActivity((Context) this, 0, intent2, 1140850688);
            Intrinsics.checkNotNullExpressionValue(activity3, "getActivity(\n           …G_IMMUTABLE\n            )");
            Object systemService = getSystemService("notification");
            Intrinsics.checkNotNull(systemService, "null cannot be cast to non-null type android.app.NotificationManager");
            NotificationManager notificationManager = (NotificationManager) systemService;
            String str = "515";
            if (Build.VERSION.SDK_INT >= 26) {
                Timber.e("showTransactionNotification: mute %s", new Object[]{Boolean.valueOf(mute)});
                NotificationChannel notificationChannel2 = new NotificationChannel("3701", "Broadcast Chat", 4);
                notificationChannel2.setDescription("Broadcast Notifications");
                notificationChannel2.enableLights(true);
                notificationChannel2.enableVibration(false);
                uri = parse;
                notificationChannel2.setSound(uri, new AudioAttributes.Builder().setContentType(4).setUsage(5).build());
                notificationManager.createNotificationChannel(notificationChannel2);
                if (!mute) {
                    str = "516";
                    if (size > 1) {
                        notificationChannel = new NotificationChannel("516", "Notification_Multi", 2);
                    } else {
                        str = "517";
                        NotificationChannel notificationChannel3 = new NotificationChannel("517", "Broadcast_Channel", 4);
                        notificationChannel3.setDescription("Broadcast Notifications");
                        notificationChannel3.enableLights(true);
                        notificationChannel3.enableVibration(false);
                        notificationChannel3.setSound(uri, new AudioAttributes.Builder().setContentType(4).setUsage(5).build());
                        notificationChannel = notificationChannel3;
                    }
                    notificationManager.createNotificationChannel(notificationChannel);
                } else {
                    str = "518";
                    NotificationChannel notificationChannel4 = new NotificationChannel("518", "Broadcast_NoS", 5);
                    notificationChannel4.setDescription("Broadcast Notifications");
                    notificationChannel4.enableLights(true);
                    notificationChannel4.enableVibration(false);
                    notificationChannel4.setSound(uri, new AudioAttributes.Builder().setContentType(4).setUsage(5).build());
                    notificationManager.createNotificationChannel(notificationChannel4);
                }
            } else {
                uri = parse;
            }
            NotificationCompat.Builder priority = new NotificationCompat.Builder((Context) this, str).setAutoCancel(true).setSound(uri).setContentIntent(activity2).setDeleteIntent(activity3).setLights(-16776961, 300, 1000).setWhen(System.currentTimeMillis()).setVibrate(new long[]{0}).setGroupSummary(false).setGroup(CHAT_BROADCAST_KEY_CHAT).setPriority(2);
            Intrinsics.checkNotNullExpressionValue(priority, "Builder(\n               …ationCompat.PRIORITY_MAX)");
            priority.setSmallIcon(INSTANCE.getNotificationIcon(priority));
            Object fromJson = new Gson().fromJson(data.get("data"), GroupModel.class);
            Intrinsics.checkNotNullExpressionValue(fromJson, "Gson().fromJson(data[\"da…, GroupModel::class.java)");
            GroupModel groupModel = (GroupModel) fromJson;
            priority.setContentTitle(TextUtils.makeTextBold(chatTitle));
            GroupNotificationModel mapToGroupNotificationModel = GroupUtils.mapToGroupNotificationModel(groupModel);
            Intrinsics.checkNotNullExpressionValue(mapToGroupNotificationModel, "mapToGroupNotificationModel(chatModel)");
            chatList.add(mapToGroupNotificationModel);
            priority.setContentText(getGroupMessage(GroupUtils.mapToGroupNotificationModel(groupModel), ""));
            priority.setStyle(getStyleForGroupNotification(chatList, chatTitle, ""));
            this.broadcastSummaryNotificationBuilder = new NotificationCompat.Builder((Context) this, "3701").setGroup(CHAT_BROADCAST_KEY_CHAT).setGroupSummary(true).setContentTitle(chatTitle).setSmallIcon(2131230881).setAutoCancel(true).setContentIntent(activity);
            if (mute) {
                return;
            }
            notificationManager.notify(Integer.parseInt(chat_id), priority.build());
            if (size > 1) {
                int i = broadcastNotificationChatId;
                NotificationCompat.Builder builder = this.broadcastSummaryNotificationBuilder;
                notificationManager.notify(i, builder != null ? builder.build() : null);
            }
        } catch (Exception e) {
            Timber.e(e);
        }
    }

    private final void handleAgentBroadcastChatNotification(Map<String, String> data) {
        GroupModel groupModel;
        String str = data.get("data");
        Timber.e("message %s", new Object[]{str});
        if (str == null || (groupModel = (GroupModel) new Gson().fromJson(str, GroupModel.class)) == null) {
            return;
        }
        Timber.e("App.isAgentBroadcastScreen " + App.isAgentBroadcastScreen, new Object[0]);
        if (App.isAgentBroadcastScreen) {
            Intent intent = new Intent(Constants.NOTIFICATION_REFRESH);
            intent.putExtra("chat_id", groupModel.getChatId().longValue());
            intent.putExtra("chat_message", str);
            LocalBroadcastManager.getInstance((Context) this).sendBroadcast(intent);
            return;
        }
        if (App.Companion.isHome()) {
            App.Companion companion = App.Companion;
            App.notificationAvailable = true;
            Long chatId = groupModel.getChatId();
            Intrinsics.checkNotNullExpressionValue(chatId, "message.chatId");
            broadcastAgentChatNotification(chatId.longValue(), data);
            LocalBroadcastManager.getInstance((Context) this).sendBroadcast(new Intent(Constants.GROUP_CHAT_NOTIFICATION_REFRESH));
            return;
        }
        if (!this.isAppInForeground) {
            Long chatId2 = groupModel.getChatId();
            Intrinsics.checkNotNullExpressionValue(chatId2, "message.chatId");
            broadcastAgentChatNotification(chatId2.longValue(), data);
        } else {
            Long chatId3 = groupModel.getChatId();
            Intrinsics.checkNotNullExpressionValue(chatId3, "message.chatId");
            broadcastAgentChatNotification(chatId3.longValue(), data);
        }
    }

    private final void broadcastAgentChatNotification(final long chatId, final Map<String, String> data) {
        LocalDB.databaseWriteExecutor.execute(new Runnable() {
            @Override
            public final void run() {
                FirebaseNotificationService.broadcastAgentChatNotification$lambda$16(data, this, chatId);
            }
        });
    }

    public static final void broadcastAgentChatNotification$lambda$16(Map map, FirebaseNotificationService firebaseNotificationService, long j) {
        Intrinsics.checkNotNullParameter(map, "$data");
        Intrinsics.checkNotNullParameter(firebaseNotificationService, "this$0");
        App.Companion companion = App.Companion;
        App.notificationAvailable = true;
        Object fromJson = new Gson().fromJson((String) map.get("data"), GroupModel.class);
        Intrinsics.checkNotNullExpressionValue(fromJson, "Gson().fromJson(data[\"da…, GroupModel::class.java)");
        firebaseNotificationService.getGroupDao().insertAgentBroadcastChat(GroupUtils.mapToAgentBroadcastNotificationModel((GroupModel) fromJson));
        SystemClock.sleep(50L);
        List<GroupNotificationModel> broadcastChatNotificationList = firebaseNotificationService.getGroupDao().getBroadcastChatNotificationList();
        Intrinsics.checkNotNull(broadcastChatNotificationList, "null cannot be cast to non-null type java.util.ArrayList<app.callpe.data.model.GroupNotificationModel>{ kotlin.collections.TypeAliasesKt.ArrayList<app.callpe.data.model.GroupNotificationModel> }");
        ArrayList arrayList = (ArrayList) broadcastChatNotificationList;
        if (arrayList.size() > 1) {
            arrayList.remove(arrayList.size() - 1);
        } else if (arrayList.size() == 1) {
            arrayList = new ArrayList();
        }
        String string = firebaseNotificationService.getString(2131951662);
        Intrinsics.checkNotNullExpressionValue(string, "getString(R.string.agent_broadcast)");
        firebaseNotificationService.showMultipleAgentBroadcastNotification(string, String.valueOf(j), map, arrayList, false, 1);
    }

    private final void showMultipleAgentBroadcastNotification(String chatTitle, String chat_id, Map<String, String> data, List<GroupNotificationModel> chatList, boolean mute, int size) {
        Uri uri;
        NotificationChannel notificationChannel;
        try {
            Intent intent = new Intent((Context) this, (Class<?>) SplashActivity.class);
            intent.putExtra("notification_group", true);
            intent.setFlags(603979776);
            PendingIntent activity = PendingIntent.getActivity((Context) this, agentBroadcastNotificationChatId, intent, 201326592);
            Intrinsics.checkNotNullExpressionValue(activity, "getActivity(\n           …G_IMMUTABLE\n            )");
            Uri parse = Uri.parse("android.resource://" + getApplicationContext().getPackageName() + "/2131886113");
            Intent handleAppAccessIntent = handleAppAccessIntent(new Intent(getApplicationContext(), (Class<?>) AgentBroadcastChatActivity.class));
            handleAppAccessIntent.setFlags(603979776);
            handleAppAccessIntent.putExtra("notification_clicked", true);
            Timber.e("chat id  %s", new Object[]{chat_id});
            Long valueOf = Long.valueOf(chat_id);
            Intrinsics.checkNotNullExpressionValue(valueOf, "valueOf(chat_id)");
            handleAppAccessIntent.putExtra("chatId", valueOf.longValue());
            handleAppAccessIntent.putExtra("chatName", chatTitle);
            PendingIntent activity2 = PendingIntent.getActivity((Context) this, Integer.parseInt(chat_id), handleAppAccessIntent, 1140850688);
            Intrinsics.checkNotNullExpressionValue(activity2, "getActivity(\n           …G_IMMUTABLE\n            )");
            Intent intent2 = new Intent((Context) this, (Class<?>) NotificationClickReceiver.class);
            intent2.putExtra("chatId", chat_id);
            intent2.setAction(Constants.NotificationChatDeleteAction);
            PendingIntent activity3 = PendingIntent.getActivity((Context) this, 0, intent2, 1140850688);
            Intrinsics.checkNotNullExpressionValue(activity3, "getActivity(\n           …G_IMMUTABLE\n            )");
            Object systemService = getSystemService("notification");
            Intrinsics.checkNotNull(systemService, "null cannot be cast to non-null type android.app.NotificationManager");
            NotificationManager notificationManager = (NotificationManager) systemService;
            String str = "515";
            if (Build.VERSION.SDK_INT >= 26) {
                Timber.e("showTransactionNotification: mute %s", new Object[]{Boolean.valueOf(mute)});
                NotificationChannel notificationChannel2 = new NotificationChannel("3702", "Agent Broadcast Chat", 4);
                notificationChannel2.setDescription("Agent Broadcast Notifications");
                notificationChannel2.enableLights(true);
                notificationChannel2.enableVibration(false);
                uri = parse;
                notificationChannel2.setSound(uri, new AudioAttributes.Builder().setContentType(4).setUsage(5).build());
                notificationManager.createNotificationChannel(notificationChannel2);
                if (!mute) {
                    str = "916";
                    if (size > 1) {
                        notificationChannel = new NotificationChannel("916", "Agent Notification Multi", 2);
                    } else {
                        str = "917";
                        NotificationChannel notificationChannel3 = new NotificationChannel("917", "Agent Broadcast Channel", 4);
                        notificationChannel3.setDescription("Agent Broadcast Notifications");
                        notificationChannel3.enableLights(true);
                        notificationChannel3.enableVibration(false);
                        notificationChannel3.setSound(uri, new AudioAttributes.Builder().setContentType(4).setUsage(5).build());
                        notificationChannel = notificationChannel3;
                    }
                    notificationManager.createNotificationChannel(notificationChannel);
                } else {
                    str = "918";
                    NotificationChannel notificationChannel4 = new NotificationChannel("918", "Agent Broadcast NoS", 5);
                    notificationChannel4.setDescription("Agent Broadcast Notifications");
                    notificationChannel4.enableLights(true);
                    notificationChannel4.enableVibration(false);
                    notificationChannel4.setSound(uri, new AudioAttributes.Builder().setContentType(4).setUsage(5).build());
                    notificationManager.createNotificationChannel(notificationChannel4);
                }
            } else {
                uri = parse;
            }
            NotificationCompat.Builder priority = new NotificationCompat.Builder((Context) this, str).setAutoCancel(true).setSound(uri).setContentIntent(activity2).setDeleteIntent(activity3).setLights(-16776961, 300, 1000).setWhen(System.currentTimeMillis()).setVibrate(new long[]{0}).setGroupSummary(false).setGroup(AGENT_BROADCAST_KEY_CHAT).setPriority(2);
            Intrinsics.checkNotNullExpressionValue(priority, "Builder(\n               …ationCompat.PRIORITY_MAX)");
            priority.setSmallIcon(INSTANCE.getNotificationIcon(priority));
            Object fromJson = new Gson().fromJson(data.get("data"), GroupModel.class);
            Intrinsics.checkNotNullExpressionValue(fromJson, "Gson().fromJson(data[\"da…, GroupModel::class.java)");
            GroupModel groupModel = (GroupModel) fromJson;
            priority.setContentTitle(TextUtils.makeTextBold(chatTitle));
            GroupNotificationModel mapToGroupNotificationModel = GroupUtils.mapToGroupNotificationModel(groupModel);
            Intrinsics.checkNotNullExpressionValue(mapToGroupNotificationModel, "mapToGroupNotificationModel(chatModel)");
            chatList.add(mapToGroupNotificationModel);
            priority.setContentText(getGroupMessage(GroupUtils.mapToGroupNotificationModel(groupModel), ""));
            priority.setStyle(getStyleForGroupNotification(chatList, chatTitle, ""));
            this.broadcastAgentSummaryNotificationBuilder = new NotificationCompat.Builder((Context) this, "3702").setGroup(AGENT_BROADCAST_KEY_CHAT).setGroupSummary(true).setContentTitle(chatTitle).setSmallIcon(2131230881).setAutoCancel(true).setContentIntent(activity);
            if (mute) {
                return;
            }
            notificationManager.notify(Integer.parseInt(chat_id), priority.build());
            if (size > 1) {
                int i = agentBroadcastNotificationChatId;
                NotificationCompat.Builder builder = this.broadcastAgentSummaryNotificationBuilder;
                notificationManager.notify(i, builder != null ? builder.build() : null);
            }
        } catch (Exception e) {
            Timber.e(e);
        }
    }

    private final void handleGroupNotification(GroupModel message, Map<String, String> data) {
        String str = data.get("data");
        if (Intrinsics.areEqual(message.getMessageType(), Constants.VIDEO_CALL) || Intrinsics.areEqual(message.getMessageType(), "AUDIO_CALL")) {
            return;
        }
        Timber.e("App.isChatScreen " + App.isChatScreen, new Object[0]);
        Timber.e("App.isHome " + App.Companion.isHome(), new Object[0]);
        if (App.isChatScreen) {
            StringBuilder sb = new StringBuilder();
            sb.append("message.chatId.toLong() == App.chatId ");
            sb.append(message.getChatId().longValue() == App.chatId);
            Timber.e(sb.toString(), new Object[0]);
            if (message.getChatId().longValue() == App.chatId) {
                Intent intent = new Intent(Constants.NOTIFICATION_REFRESH);
                intent.putExtra("chat_id", message.getChatId().longValue());
                intent.putExtra("chat_message", str);
                LocalBroadcastManager.getInstance((Context) this).sendBroadcast(intent);
                return;
            }
            ChatListFragment.appOpen = true;
            if (message.isNotify()) {
                Long chatId = message.getChatId();
                Intrinsics.checkNotNullExpressionValue(chatId, "message.chatId");
                long longValue = chatId.longValue();
                String senderName = message.getSenderName();
                Intrinsics.checkNotNullExpressionValue(senderName, "message.senderName");
                groupChatNotification(longValue, senderName, StreamerModelKt.getProfile(message.getSenderPic()), data);
                return;
            }
            return;
        }
        if (App.Companion.isHome()) {
            if (message.isNotify()) {
                Long chatId2 = message.getChatId();
                Intrinsics.checkNotNullExpressionValue(chatId2, "message.chatId");
                long longValue2 = chatId2.longValue();
                String senderName2 = message.getSenderName();
                Intrinsics.checkNotNullExpressionValue(senderName2, "message.senderName");
                groupChatNotification(longValue2, senderName2, StreamerModelKt.getProfile(message.getSenderPic()), data);
            }
            Intent intent2 = new Intent(Constants.GROUP_CHAT_NOTIFICATION_REFRESH);
            intent2.putExtra("message", str);
            LocalBroadcastManager.getInstance((Context) this).sendBroadcast(intent2);
            return;
        }
        if (!this.isAppInForeground) {
            if (message.isNotify()) {
                Long chatId3 = message.getChatId();
                Intrinsics.checkNotNullExpressionValue(chatId3, "message.chatId");
                long longValue3 = chatId3.longValue();
                String senderName3 = message.getSenderName();
                Intrinsics.checkNotNullExpressionValue(senderName3, "message.senderName");
                groupChatNotification(longValue3, senderName3, StreamerModelKt.getProfile(message.getSenderPic()), data);
                return;
            }
            return;
        }
        if (message.isNotify()) {
            Long chatId4 = message.getChatId();
            Intrinsics.checkNotNullExpressionValue(chatId4, "message.chatId");
            long longValue4 = chatId4.longValue();
            String senderName4 = message.getSenderName();
            Intrinsics.checkNotNullExpressionValue(senderName4, "message.senderName");
            groupChatNotification(longValue4, senderName4, StreamerModelKt.getProfile(message.getSenderPic()), data);
        }
    }

    private final void groupChatNotification(final long chatId, final String title, final String pic, final Map<String, String> data) {
        LocalDB.databaseWriteExecutor.execute(new Runnable() {
            @Override
            public final void run() {
                FirebaseNotificationService.groupChatNotification$lambda$17(FirebaseNotificationService.this, chatId, title, data, pic);
            }
        });
    }

    public static final void groupChatNotification$lambda$17(FirebaseNotificationService firebaseNotificationService, long j, String str, Map map, String str2) {
        List<Long> list;
        Intrinsics.checkNotNullParameter(firebaseNotificationService, "this$0");
        Intrinsics.checkNotNullParameter(str, "$title");
        Intrinsics.checkNotNullParameter(map, "$data");
        Intrinsics.checkNotNullParameter(str2, "$pic");
        int notificationCount = firebaseNotificationService.getNotificationDAO().getNotificationCount(Long.valueOf(j)) + 1;
        int messageCount = firebaseNotificationService.getNotificationDAO().getMessageCount(Long.valueOf(j)) + 1;
        Timber.d("assignNotification: multi tn  %s", new Object[]{Integer.valueOf(notificationCount)});
        Timber.d("assignNotification: multi cid %s", new Object[]{Long.valueOf(j)});
        Timber.e("chatTitle title %s", new Object[]{str});
        Timber.e("is mute %s", new Object[]{false});
        GroupNotificationCountModel groupNotificationCountModel = new GroupNotificationCountModel();
        groupNotificationCountModel.setId(Long.valueOf(j));
        groupNotificationCountModel.setNotificationCount(notificationCount);
        groupNotificationCountModel.setMessageCount(messageCount);
        firebaseNotificationService.getNotificationDAO().insert(groupNotificationCountModel);
        App.Companion companion = App.Companion;
        App.notificationAvailable = true;
        Object fromJson = new Gson().fromJson((String) map.get("data"), GroupModel.class);
        Intrinsics.checkNotNullExpressionValue(fromJson, "Gson().fromJson(data[\"da…, GroupModel::class.java)");
        firebaseNotificationService.getGroupDao().insertNotificationChat(GroupUtils.mapToGroupNotificationModel((GroupModel) fromJson));
        SystemClock.sleep(50L);
        List<Long> distinctNotificationList = firebaseNotificationService.getGroupDao().getDistinctNotificationList();
        Intrinsics.checkNotNullExpressionValue(distinctNotificationList, "groupDao.distinctNotificationList");
        LinkedHashMap linkedHashMap = new LinkedHashMap();
        Iterator<Long> it = distinctNotificationList.iterator();
        while (it.hasNext()) {
            long longValue = it.next().longValue();
            List<GroupNotificationModel> chatNotificationList = firebaseNotificationService.getGroupDao().getChatNotificationList(Long.valueOf(longValue));
            Intrinsics.checkNotNullExpressionValue(chatNotificationList, "groupDao.getChatNotificationList(id)");
            linkedHashMap.put(Long.valueOf(longValue), chatNotificationList);
        }
        for (Map.Entry entry : linkedHashMap.entrySet()) {
            if (Intrinsics.areEqual(entry.getKey(), Long.valueOf(j))) {
                ArrayList chatNotificationList2 = firebaseNotificationService.getGroupDao().getChatNotificationList(Long.valueOf(j));
                Intrinsics.checkNotNullExpressionValue(chatNotificationList2, "groupDao.getChatNotifica…ang.Long.valueOf(chatId))");
                if (chatNotificationList2.size() > 1) {
                    chatNotificationList2.remove(chatNotificationList2.size() - 1);
                } else if (chatNotificationList2.size() == 1) {
                    chatNotificationList2 = new ArrayList();
                }
                list = distinctNotificationList;
                firebaseNotificationService.showMultipleGroupNotification(str, str2, String.valueOf(j), map, chatNotificationList2, false, distinctNotificationList.size());
            } else {
                list = distinctNotificationList;
                ChatDao groupDao = firebaseNotificationService.getGroupDao();
                Object key = entry.getKey();
                Intrinsics.checkNotNullExpressionValue(key, "map.key");
                String title = groupDao.getTitle(((Number) key).longValue());
                String str3 = title == null ? "" : title;
                ChatDao groupDao2 = firebaseNotificationService.getGroupDao();
                Object key2 = entry.getKey();
                Intrinsics.checkNotNullExpressionValue(key2, "map.key");
                String pic = groupDao2.getPic(((Number) key2).longValue());
                String str4 = pic == null ? "" : pic;
                HashMap hashMap = new HashMap();
                Object value = entry.getValue();
                Intrinsics.checkNotNullExpressionValue(value, "map.value");
                ArrayList mutableList = CollectionsKt.toMutableList((Collection) value);
                if (mutableList.size() > 1) {
                    mutableList.remove(mutableList.size() - 1);
                } else if (mutableList.size() == 1) {
                    mutableList = new ArrayList();
                }
                List<GroupNotificationModel> list2 = mutableList;
                try {
                    String json = new Gson().toJson(GroupUtils.mapToGroupNotificationModel(firebaseNotificationService.getGroupDao().getChatNotificationLatValue((Long) entry.getKey())));
                    Intrinsics.checkNotNullExpressionValue(json, "Gson().toJson(\n         …                        )");
                    hashMap.put("data", json);
                    firebaseNotificationService.showMultipleGroupNotification(str3, str4, String.valueOf(((Number) entry.getKey()).longValue()), hashMap, list2, false, list.size());
                } catch (Exception e) {
                    Timber.e(e, "Map error", new Object[0]);
                }
            }
            distinctNotificationList = list;
        }
    }

    private final void showMultipleGroupNotification(String chatTitle, String pic, String chat_id, Map<String, String> data, List<GroupNotificationModel> chatList, boolean mute, int size) {
        String str;
        NotificationChannel notificationChannel;
        try {
            Intent intent = new Intent((Context) this, (Class<?>) SplashActivity.class);
            intent.putExtra("notification_group", true);
            intent.setFlags(603979776);
            PendingIntent activity = PendingIntent.getActivity((Context) this, groupChatNotificationId, intent, 201326592);
            Intrinsics.checkNotNullExpressionValue(activity, "getActivity(\n           …G_IMMUTABLE\n            )");
            Uri parse = Uri.parse("android.resource://" + getApplicationContext().getPackageName() + "/2131886113");
            Intent handleAppAccessIntent = handleAppAccessIntent(new Intent(getApplicationContext(), (Class<?>) ChatActivity.class));
            handleAppAccessIntent.setFlags(603979776);
            handleAppAccessIntent.putExtra("notification_clicked", true);
            Timber.e("chat id  %s", new Object[]{chat_id});
            if (Long.parseLong(chat_id) == -1) {
                App.Companion companion = App.Companion;
                App.chatId = Long.parseLong(chat_id);
                App.Companion companion2 = App.Companion;
                App.chatTitle = chatTitle;
                App.Companion companion3 = App.Companion;
                App.profile = pic;
            }
            Long valueOf = Long.valueOf(chat_id);
            Intrinsics.checkNotNullExpressionValue(valueOf, "valueOf(chat_id)");
            handleAppAccessIntent.putExtra("chatId", valueOf.longValue());
            handleAppAccessIntent.putExtra("chatName", chatTitle);
            handleAppAccessIntent.putExtra("profilePic", pic);
            PendingIntent activity2 = PendingIntent.getActivity((Context) this, Integer.parseInt(chat_id), handleAppAccessIntent, 1140850688);
            Intrinsics.checkNotNullExpressionValue(activity2, "getActivity(\n           …G_IMMUTABLE\n            )");
            Intent intent2 = new Intent((Context) this, (Class<?>) NotificationClickReceiver.class);
            intent2.putExtra("chatId", chat_id);
            intent2.setAction(Constants.NotificationChatDeleteAction);
            PendingIntent activity3 = PendingIntent.getActivity((Context) this, 0, intent2, 1140850688);
            Intrinsics.checkNotNullExpressionValue(activity3, "getActivity(\n           …G_IMMUTABLE\n            )");
            Object systemService = getSystemService("notification");
            Intrinsics.checkNotNull(systemService, "null cannot be cast to non-null type android.app.NotificationManager");
            NotificationManager notificationManager = (NotificationManager) systemService;
            String str2 = "220";
            if (Build.VERSION.SDK_INT >= 26) {
                str = "3710";
                Timber.e("showTransactionNotification: mute %s", new Object[]{Boolean.valueOf(mute)});
                NotificationChannel notificationChannel2 = new NotificationChannel(str, "Messages", 4);
                notificationChannel2.setDescription("Message Notifications");
                notificationChannel2.enableLights(true);
                notificationChannel2.enableVibration(false);
                notificationChannel2.setSound(parse, new AudioAttributes.Builder().setContentType(4).setUsage(5).build());
                notificationManager.createNotificationChannel(notificationChannel2);
                if (!mute) {
                    String str3 = "221";
                    if (size > 1) {
                        notificationChannel = new NotificationChannel("221", "Notification Group Multi", 2);
                    } else {
                        str3 = "222";
                        NotificationChannel notificationChannel3 = new NotificationChannel("222", "Notification  Message  Channel", 4);
                        notificationChannel3.setDescription("Group Notifications");
                        notificationChannel3.enableLights(true);
                        notificationChannel3.enableVibration(false);
                        notificationChannel3.setSound(parse, new AudioAttributes.Builder().setContentType(4).setUsage(5).build());
                        notificationChannel = notificationChannel3;
                    }
                    notificationManager.createNotificationChannel(notificationChannel);
                    str2 = str3;
                } else {
                    NotificationChannel notificationChannel4 = new NotificationChannel("218", "Notification NoS", 5);
                    notificationChannel4.setDescription("Group Notifications");
                    notificationChannel4.enableLights(true);
                    notificationChannel4.enableVibration(false);
                    notificationChannel4.setSound(parse, new AudioAttributes.Builder().setContentType(4).setUsage(5).build());
                    notificationManager.createNotificationChannel(notificationChannel4);
                    str2 = "218";
                }
            } else {
                str = "3710";
            }
            NotificationCompat.Builder builder = new NotificationCompat.Builder((Context) this, str2);
            String str4 = pic;
            if (!(str4 == null || str4.length() == 0)) {
                try {
                    FutureTarget submit = Glide.with((Context) this).asBitmap().load(pic).submit();
                    Intrinsics.checkNotNullExpressionValue(submit, "with(this@FirebaseNotifi…tmap().load(pic).submit()");
                    Bitmap bitmap = (Bitmap) submit.get();
                    Helper helper = Helper.INSTANCE;
                    Intrinsics.checkNotNullExpressionValue(bitmap, "profileBitmap");
                    builder.setLargeIcon(helper.getCircleBitmap(bitmap));
                } catch (Exception e) {
                    Timber.e(e);
                }
            }
            builder.setAutoCancel(true).setSound(parse).setContentIntent(activity2).setDeleteIntent(activity3).setLights(-16776961, 300, 1000).setWhen(System.currentTimeMillis()).setVibrate(new long[]{0}).setGroupSummary(false).setGroup(CHAT_GROUP_KEY_CHAT).setPriority(1);
            builder.setSmallIcon(INSTANCE.getNotificationIcon(builder));
            Object fromJson = new Gson().fromJson(data.get("data"), GroupModel.class);
            Intrinsics.checkNotNullExpressionValue(fromJson, "Gson().fromJson(data[\"da…, GroupModel::class.java)");
            GroupModel groupModel = (GroupModel) fromJson;
            builder.setContentTitle(TextUtils.makeTextBold(chatTitle));
            GroupNotificationModel mapToGroupNotificationModel = GroupUtils.mapToGroupNotificationModel(groupModel);
            Intrinsics.checkNotNullExpressionValue(mapToGroupNotificationModel, "mapToGroupNotificationModel(chatModel)");
            chatList.add(mapToGroupNotificationModel);
            builder.setContentText(getGroupMessage(GroupUtils.mapToGroupNotificationModel(groupModel), pic));
            builder.setStyle(getStyleForGroupNotification(chatList, chatTitle, pic));
            this.groupSummaryNotificationBuilder = new NotificationCompat.Builder((Context) this, str).setGroup(CHAT_GROUP_KEY_CHAT).setGroupSummary(true).setContentTitle(chatTitle).setSmallIcon(2131230881).setAutoCancel(true).setContentIntent(activity);
            if (mute) {
                return;
            }
            notificationManager.notify(Integer.parseInt(chat_id), builder.build());
            if (size > 1) {
                int i = groupChatNotificationId;
                NotificationCompat.Builder builder2 = this.groupSummaryNotificationBuilder;
                notificationManager.notify(i, builder2 != null ? builder2.build() : null);
            }
        } catch (Exception e2) {
            Timber.e(e2);
        }
    }

    private final Spannable getGroupMessage(GroupNotificationModel model, String chatType) {
        String str;
        UserActionItem userActionItem;
        if (model == null) {
            return SpannableStringBuilder.valueOf("");
        }
        if (model.getType().equals(Constants.TEXT)) {
            return SpannableStringBuilder.valueOf("").append((CharSequence) TextUtils.getFormattedText(model.getMessage()));
        }
        if (model.getType().equals(Constants.IMAGE)) {
            return SpannableStringBuilder.valueOf("" + getResources().getString(2131952969));
        }
        if (model.getType().equals(Constants.LOCKED_IMAGE)) {
            return SpannableStringBuilder.valueOf("" + getResources().getString(2131952971));
        }
        if (model.getType().equals(Constants.VIDEO)) {
            return SpannableStringBuilder.valueOf("" + getResources().getString(2131952979));
        }
        if (model.getType().equals(Constants.DOCUMENT)) {
            return SpannableStringBuilder.valueOf("" + getResources().getString(2131952965));
        }
        if (model.getType().equals("LOCATION")) {
            return SpannableStringBuilder.valueOf("" + getResources().getString(2131952970));
        }
        if (model.getType().equals("AUDIO")) {
            return SpannableStringBuilder.valueOf("" + getResources().getString(2131952959));
        }
        if (model.getType().equals("CONTACT")) {
            return SpannableStringBuilder.valueOf("" + getResources().getString(2131951910));
        }
        if (model.getType().equals(Constants.GIFT_REQUEST)) {
            return SpannableStringBuilder.valueOf(model.getSenderName() + " has requested a gift");
        }
        if (model.getType().equals("GIFT_SENT")) {
            return SpannableStringBuilder.valueOf(model.getSenderName() + " has sent a gift");
        }
        if (model.getType().equals("USER_ACTION")) {
            String message = model.getMessage();
            Intrinsics.checkNotNullExpressionValue(message, "model.message");
            Timber.e("Message " + message, new Object[0]);
            if (!StringUtils.isEmpty(message) && (userActionItem = (UserActionItem) new Gson().fromJson(message, UserActionItem.class)) != null) {
                String userAction = userActionItem.getUserAction();
                if (Intrinsics.areEqual("PROFILE_PIC_UPLOAD", userAction)) {
                    str = "Please submit your profile photo again.\n\nकृपया अपनी प्रोफ़ाइल फोटो फिर से सबमिट करें।";
                } else if (Intrinsics.areEqual("AGE_PROOF_UPLOAD", userAction)) {
                    str = "Please submit your age proof again.\n\nकृपया अपना ऐज प्रूफ फिर से सबमिट करे।";
                } else if (Intrinsics.areEqual("AUDITION_VIDEO_UPLOAD", userAction)) {
                    str = "Please submit your audition video again.\n\nकृपया अपना ऑडिशन वीडियो फिर से सबमिट करे।";
                }
                return SpannableStringBuilder.valueOf(str);
            }
            str = "Please submit your document again.";
            return SpannableStringBuilder.valueOf(str);
        }
        return SpannableStringBuilder.valueOf("");
    }

    private final NotificationCompat.InboxStyle getStyleForGroupNotification(List<? extends GroupNotificationModel> messageBody, String chatTitle, String chatType) {
        NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
        Iterator<? extends GroupNotificationModel> it = messageBody.iterator();
        while (it.hasNext()) {
            inboxStyle.addLine(getGroupMessage(it.next(), chatType));
        }
        inboxStyle.setSummaryText("Tap to open");
        return inboxStyle;
    }

    private final void eventSuccess(PaymentSuccessOrderNotification paymentSuccessOrderNotification, String data) {
        Context context = (Context) this;
        try {
            BuildersKt.launch$default(CoroutineScopeKt.CoroutineScope(Dispatchers.getIO()), (CoroutineContext) null, (CoroutineStart) null, new FirebaseNotificationService$eventSuccess$1(this, paymentSuccessOrderNotification, SharedPref.getString(context, PrefKeys.INSTALL_SOURCE), data, SharedPref.getString(context, PrefKeys.USER_CREATED_AT), null), 3, (Object) null);
        } catch (Exception e) {
            Timber.e(e);
        }
    }

    private final Intent handleAppAccessIntent(Intent intent) {
        return this.appAccess ? intent : new Intent(getApplicationContext(), (Class<?>) SplashActivity.class);
    }

    @Metadata(d1 = {"\u00008\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0002\b\u0005\n\u0002\u0010\b\n\u0002\b\u0005\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\b\u0086\u0003\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J\u0010\u0010\u000f\u001a\u00020\u00102\u0006\u0010\u0011\u001a\u00020\u0012H\u0007J\u0010\u0010\u0013\u001a\u00020\n2\u0006\u0010\u0014\u001a\u00020\u0015H\u0007J\u0010\u0010\u0016\u001a\u00020\n2\u0006\u0010\u0014\u001a\u00020\u0017H\u0007J\u000e\u0010\u0018\u001a\u00020\u00042\u0006\u0010\u0011\u001a\u00020\u0012R\u0012\u0010\u0003\u001a\u00020\u00048\u0006@\u0006X\u0087\u000e¢\u0006\u0002\n\u0000R\u0012\u0010\u0005\u001a\u00020\u00048\u0006@\u0006X\u0087\u000e¢\u0006\u0002\n\u0000R\u0012\u0010\u0006\u001a\u00020\u00048\u0006@\u0006X\u0087\u000e¢\u0006\u0002\n\u0000R\u0012\u0010\u0007\u001a\u00020\u00048\u0006@\u0006X\u0087\u000e¢\u0006\u0002\n\u0000R\u0012\u0010\b\u001a\u00020\u00048\u0006@\u0006X\u0087\u000e¢\u0006\u0002\n\u0000R\u0012\u0010\t\u001a\u00020\n8\u0006@\u0006X\u0087\u000e¢\u0006\u0002\n\u0000R\u0012\u0010\u000b\u001a\u00020\n8\u0006@\u0006X\u0087\u000e¢\u0006\u0002\n\u0000R\u0012\u0010\f\u001a\u00020\n8\u0006@\u0006X\u0087\u000e¢\u0006\u0002\n\u0000R\u0012\u0010\r\u001a\u00020\n8\u0006@\u0006X\u0087\u000e¢\u0006\u0002\n\u0000R\u0012\u0010\u000e\u001a\u00020\n8\u0006@\u0006X\u0087\u000e¢\u0006\u0002\n\u0000¨\u0006\u0019"}, d2 = {"Lapp/callpe/service/FirebaseNotificationService$Companion;", "", "()V", "AGENT_BROADCAST_KEY_CHAT", "", "CHAT_BROADCAST_KEY_CHAT", "CHAT_GROUP_KEY_CHAT", "CHAT_NOTIFICATION_KEY_CHAT", "CHAT_SUPPORT_KEY_CHAT", "agentBroadcastNotificationChatId", "", "broadcastNotificationChatId", "groupChatNotificationId", "notificationChatId", "supportChatNotificationId", "fetchFCMToken", "", "context", "Landroid/content/Context;", "getNotificationIcon", "notificationBuilder", "Landroidx/core/app/NotificationCompat$Builder;", "getNotificationPersonIcon", "Landroid/app/Notification$Builder;", "getToken", "app_bikoRelease"}, k = 1, mv = {1, 8, 0}, xi = 48)
    public static final class Companion {
        public Companion(DefaultConstructorMarker defaultConstructorMarker) {
            this();
        }

        private Companion() {
        }

        @JvmStatic
        public final int getNotificationIcon(NotificationCompat.Builder notificationBuilder) {
            Intrinsics.checkNotNullParameter(notificationBuilder, "notificationBuilder");
            notificationBuilder.setColor(32768);
            return 2131231663;
        }

        @JvmStatic
        public final int getNotificationPersonIcon(Notification.Builder notificationBuilder) {
            Intrinsics.checkNotNullParameter(notificationBuilder, "notificationBuilder");
            notificationBuilder.setColor(32768);
            return 2131231663;
        }

        @JvmStatic
        public final void fetchFCMToken(final Context context) {
            Intrinsics.checkNotNullParameter(context, "context");
            FirebaseMessaging.getInstance().getToken().addOnCompleteListener(new OnCompleteListener() {
                public final void onComplete(Task task) {
                    FirebaseNotificationService.Companion.fetchFCMToken$lambda$1(context, task);
                }
            });
        }

        public static final void fetchFCMToken$lambda$1(Context context, Task task) {
            String str;
            Intrinsics.checkNotNullParameter(context, "$context");
            Intrinsics.checkNotNullParameter(task, "task");
            if (!task.isSuccessful() || (str = (String) task.getResult()) == null) {
                return;
            }
            Timber.d("FCM Token " + str, new Object[0]);
            SharedPreferences.Editor edit = context.getSharedPreferences("vitok_perf_fcm", 0).edit();
            edit.putString("fcm", str).apply();
            edit.apply();
        }

        public final String getToken(Context context) {
            Intrinsics.checkNotNullParameter(context, "context");
            String string = context.getSharedPreferences("vitok_perf_fcm", 0).getString("fcm", "");
            return string == null ? "" : string;
        }
    }

    public void onStart(LifecycleOwner owner) {
        Intrinsics.checkNotNullParameter(owner, "owner");
        this.isAppInForeground = true;
        Timber.d("onForegroundStart: %s", new Object[]{true});
    }

    public void onStop(LifecycleOwner owner) {
        Intrinsics.checkNotNullParameter(owner, "owner");
        this.isAppInForeground = false;
        Timber.d("onForegroundStart: %s", new Object[]{false});
    }

    public void onDestroy() {
        super.onDestroy();
        ProcessLifecycleOwner.Companion.get().getLifecycle().removeObserver((LifecycleObserver) this);
    }

    public final Flow<String> downloadFile(String url, String dirPath, String fileName) {
        return FlowKt.flowOn(FlowKt.callbackFlow(new FirebaseNotificationService$downloadFile$1(url, dirPath, fileName, null)), Dispatchers.getIO());
    }

    private final void handleLudoGameStatus(boolean started, String data) {
        FcmModel fcmModel;
        String roomId;
        FcmModel fcmModel2;
        if (started) {
            if ((data.length() == 0) || (fcmModel2 = (FcmModel) new Gson().fromJson(data, FcmModel.class)) == null || fcmModel2.getRoomId() == null) {
                return;
            }
            Context context = (Context) this;
            String string = SharedPref.getString(context, PrefKeys.ACCOUNT_ID);
            String string2 = SharedPref.getString(context, PrefKeys.AUTH_TOKEN);
            LudoGameServiceUtil ludoGameServiceUtil = LudoGameServiceUtil.INSTANCE;
            String roomId2 = fcmModel2.getRoomId();
            Intrinsics.checkNotNullExpressionValue(string, "userId");
            Intrinsics.checkNotNullExpressionValue(string2, "sessionToken");
            ludoGameServiceUtil.createOrUpdateLudoService(context, roomId2, string, string2);
            return;
        }
        if (App.Companion.isSudScreen()) {
            Intent intent = new Intent(Constants.LUDO_GAME_ENDED);
            if ((data.length() == 0) || (fcmModel = (FcmModel) new Gson().fromJson(data, FcmModel.class)) == null || (roomId = fcmModel.getRoomId()) == null) {
                return;
            }
            intent.putExtra("roomId", roomId);
            LocalBroadcastManager.getInstance((Context) this).sendBroadcast(intent);
            return;
        }
        LudoGameServiceUtil.INSTANCE.stopLudoService((Context) this);
    }
}