APK反编译源代码展示 - 南明离火平台提供

应用版本信息
应用名称:国中资本
版本号:1.0.0
包名称:com.byhhd.oxojy

MD5 校验值:1036132062d4d223cd1a714f5bbea98b

反编译源代码说明

NotificationsController.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。


package im.skmzhmurqt.messenger;

import android.app.ActivityManager;
import android.app.AlarmManager;
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.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.ImageDecoder;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Point;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.PostProcessor;
import android.graphics.drawable.BitmapDrawable;
import android.media.AudioAttributes;
import android.media.AudioManager;
import android.media.SoundPool;
import android.net.Uri;
import android.os.Build;
import android.os.PowerManager;
import android.os.SystemClock;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.LongSparseArray;
import android.util.SparseArray;
import android.util.SparseIntArray;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import androidx.core.app.Person;
import androidx.core.app.RemoteInput;
import androidx.core.content.FileProvider;
import androidx.core.graphics.drawable.IconCompat;
import com.google.android.exoplayer2.text.ttml.TtmlNode;
import com.google.android.exoplayer2.upstream.cache.ContentMetadata;
import com.google.android.exoplayer2.util.MimeTypes;
import com.zhy.http.okhttp.OkHttpUtils;
import im.skmzhmurqt.messenger.support.SparseLongArray;
import im.skmzhmurqt.tgnet.ConnectionsManager;
import im.skmzhmurqt.tgnet.RequestDelegate;
import im.skmzhmurqt.tgnet.TLApiModel;
import im.skmzhmurqt.tgnet.TLJsonResolve;
import im.skmzhmurqt.tgnet.TLObject;
import im.skmzhmurqt.tgnet.TLRPC;
import im.skmzhmurqt.tgnet.TLRPCRedpacket;
import im.skmzhmurqt.ui.LaunchActivity;
import im.skmzhmurqt.ui.PopupNotificationActivity;
import im.skmzhmurqt.ui.hui.packet.bean.RedpacketBean;
import im.skmzhmurqt.ui.hui.packet.bean.RedpacketResponse;
import im.skmzhmurqt.ui.hui.transfer.bean.TransferResponse;
import java.io.File;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class NotificationsController extends BaseController {
    public static final String EXTRA_VOICE_REPLY = "extra_voice_reply";
    private static volatile NotificationsController[] Instance = null;
    public static final int SETTING_MUTE_2_DAYS = 2;
    public static final int SETTING_MUTE_8_HOURS = 1;
    public static final int SETTING_MUTE_FOREVER = 3;
    public static final int SETTING_MUTE_HOUR = 0;
    public static final int SETTING_MUTE_UNMUTE = 4;
    public static final int TYPE_CHANNEL = 2;
    public static final int TYPE_GROUP = 0;
    public static final int TYPE_PRIVATE = 1;
    protected static AudioManager audioManager;
    private static NotificationManagerCompat notificationManager;
    private static NotificationManager systemNotificationManager;
    private AlarmManager alarmManager;
    private ArrayList<MessageObject> delayedPushMessages;
    private LongSparseArray<MessageObject> fcmRandomMessagesDict;
    private boolean inChatSoundEnabled;
    private int lastBadgeCount;
    private int lastButtonId;
    private int lastOnlineFromOtherDevice;
    private long lastSoundOutPlay;
    private long lastSoundPlay;
    private LongSparseArray<Integer> lastWearNotifiedMessageId;
    private String launcherClassName;
    private Runnable notificationDelayRunnable;
    private PowerManager.WakeLock notificationDelayWakelock;
    private String notificationGroup;
    private int notificationId;
    private boolean notifyCheck;
    private long opened_dialog_id;
    private int personal_count;
    public ArrayList<MessageObject> popupMessages;
    public ArrayList<MessageObject> popupReplyMessages;
    private LongSparseArray<Integer> pushDialogs;
    private LongSparseArray<Integer> pushDialogsOverrideMention;
    private ArrayList<MessageObject> pushMessages;
    private LongSparseArray<MessageObject> pushMessagesDict;
    public boolean showBadgeMessages;
    public boolean showBadgeMuted;
    public boolean showBadgeNumber;
    private LongSparseArray<Point> smartNotificationsDialogs;
    private int soundIn;
    private boolean soundInLoaded;
    private int soundOut;
    private boolean soundOutLoaded;
    private SoundPool soundPool;
    private int soundRecord;
    private boolean soundRecordLoaded;
    private int total_unread_count;
    private LongSparseArray<Integer> wearNotificationsIds;
    public static String OTHER_NOTIFICATIONS_CHANNEL = null;
    private static DispatchQueue notificationsQueue = new DispatchQueue("notificationsQueue");
    public static long globalSecretChatId = -4294967296L;

    static {
        notificationManager = null;
        systemNotificationManager = null;
        if (Build.VERSION.SDK_INT >= 26 && ApplicationLoader.applicationContext != null) {
            notificationManager = NotificationManagerCompat.from(ApplicationLoader.applicationContext);
            systemNotificationManager = (NotificationManager) ApplicationLoader.applicationContext.getSystemService("notification");
            checkOtherNotificationsChannel();
        }
        audioManager = (AudioManager) ApplicationLoader.applicationContext.getSystemService(MimeTypes.BASE_TYPE_AUDIO);
        Instance = new NotificationsController[3];
    }

    public static NotificationsController getInstance(int num) {
        NotificationsController localInstance = Instance[num];
        if (localInstance == null) {
            synchronized (NotificationsController.class) {
                localInstance = Instance[num];
                if (localInstance == null) {
                    NotificationsController[] notificationsControllerArr = Instance;
                    NotificationsController notificationsController = new NotificationsController(num);
                    localInstance = notificationsController;
                    notificationsControllerArr[num] = notificationsController;
                }
            }
        }
        return localInstance;
    }

    public NotificationManagerCompat getNotificationManager() {
        return notificationManager;
    }

    public NotificationsController(int instance) {
        super(instance);
        this.pushMessages = new ArrayList<>();
        this.delayedPushMessages = new ArrayList<>();
        this.pushMessagesDict = new LongSparseArray<>();
        this.fcmRandomMessagesDict = new LongSparseArray<>();
        this.smartNotificationsDialogs = new LongSparseArray<>();
        this.pushDialogs = new LongSparseArray<>();
        this.wearNotificationsIds = new LongSparseArray<>();
        this.lastWearNotifiedMessageId = new LongSparseArray<>();
        this.pushDialogsOverrideMention = new LongSparseArray<>();
        this.popupMessages = new ArrayList<>();
        this.popupReplyMessages = new ArrayList<>();
        this.opened_dialog_id = 0L;
        this.lastButtonId = 5000;
        this.total_unread_count = 0;
        this.personal_count = 0;
        this.notifyCheck = false;
        this.lastOnlineFromOtherDevice = 0;
        this.lastBadgeCount = -1;
        this.notificationId = this.currentAccount + 1;
        StringBuilder sb = new StringBuilder();
        sb.append("messages");
        sb.append(this.currentAccount == 0 ? "" : Integer.valueOf(this.currentAccount));
        this.notificationGroup = sb.toString();
        SharedPreferences preferences = getAccountInstance().getNotificationsSettings();
        this.inChatSoundEnabled = preferences.getBoolean("EnableInChatSound", true);
        this.showBadgeNumber = preferences.getBoolean("badgeNumber", true);
        this.showBadgeMuted = preferences.getBoolean("badgeNumberMuted", false);
        this.showBadgeMessages = preferences.getBoolean("badgeNumberMessages", true);
        notificationManager = NotificationManagerCompat.from(ApplicationLoader.applicationContext);
        systemNotificationManager = (NotificationManager) ApplicationLoader.applicationContext.getSystemService("notification");
        try {
            audioManager = (AudioManager) ApplicationLoader.applicationContext.getSystemService(MimeTypes.BASE_TYPE_AUDIO);
        } catch (Exception e) {
            FileLog.e(e);
        }
        try {
            this.alarmManager = (AlarmManager) ApplicationLoader.applicationContext.getSystemService(NotificationCompat.CATEGORY_ALARM);
        } catch (Exception e2) {
            FileLog.e(e2);
        }
        try {
            PowerManager pm = (PowerManager) ApplicationLoader.applicationContext.getSystemService("power");
            PowerManager.WakeLock newWakeLock = pm.newWakeLock(1, "hchat:notification_delay_lock");
            this.notificationDelayWakelock = newWakeLock;
            newWakeLock.setReferenceCounted(false);
        } catch (Exception e3) {
            FileLog.e(e3);
        }
        this.notificationDelayRunnable = new Runnable() {
            @Override
            public final void run() {
                NotificationsController.this.lambda$new$0$NotificationsController();
            }
        };
    }

    public void lambda$new$0$NotificationsController() {
        if (BuildVars.LOGS_ENABLED) {
            FileLog.d("delay reached");
        }
        if (!this.delayedPushMessages.isEmpty()) {
            showOrUpdateNotification(true);
            this.delayedPushMessages.clear();
        }
        try {
            if (this.notificationDelayWakelock.isHeld()) {
                this.notificationDelayWakelock.release();
            }
        } catch (Exception e) {
            FileLog.e(e);
        }
    }

    public static void checkOtherNotificationsChannel() {
        if (Build.VERSION.SDK_INT < 26) {
            return;
        }
        SharedPreferences preferences = null;
        if (OTHER_NOTIFICATIONS_CHANNEL == null) {
            preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", 0);
            OTHER_NOTIFICATIONS_CHANNEL = preferences.getString("OtherKey", "Other3");
        }
        NotificationChannel notificationChannel = systemNotificationManager.getNotificationChannel(OTHER_NOTIFICATIONS_CHANNEL);
        if (notificationChannel != null && notificationChannel.getImportance() == 0) {
            systemNotificationManager.deleteNotificationChannel(OTHER_NOTIFICATIONS_CHANNEL);
            OTHER_NOTIFICATIONS_CHANNEL = null;
            notificationChannel = null;
        }
        if (OTHER_NOTIFICATIONS_CHANNEL == null) {
            if (preferences == null) {
                preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", 0);
            }
            OTHER_NOTIFICATIONS_CHANNEL = "Other" + Utilities.random.nextLong();
            preferences.edit().putString("OtherKey", OTHER_NOTIFICATIONS_CHANNEL).commit();
        }
        if (notificationChannel == null) {
            NotificationChannel notificationChannel2 = new NotificationChannel(OTHER_NOTIFICATIONS_CHANNEL, "Other", 2);
            notificationChannel2.enableLights(false);
            notificationChannel2.enableVibration(false);
            AudioAttributes.Builder builder = new AudioAttributes.Builder();
            builder.setContentType(4);
            builder.setUsage(5);
            notificationChannel2.setSound(Settings.System.DEFAULT_NOTIFICATION_URI, builder.build());
            try {
                systemNotificationManager.createNotificationChannel(notificationChannel2);
            } catch (Exception e) {
                FileLog.e(e);
            }
        }
    }

    public void cleanup() {
        this.popupMessages.clear();
        this.popupReplyMessages.clear();
        notificationsQueue.postRunnable(new Runnable() {
            @Override
            public final void run() {
                NotificationsController.this.lambda$cleanup$1$NotificationsController();
            }
        });
    }

    public void lambda$cleanup$1$NotificationsController() {
        this.opened_dialog_id = 0L;
        this.total_unread_count = 0;
        this.personal_count = 0;
        this.pushMessages.clear();
        this.pushMessagesDict.clear();
        this.fcmRandomMessagesDict.clear();
        this.pushDialogs.clear();
        this.wearNotificationsIds.clear();
        this.lastWearNotifiedMessageId.clear();
        this.delayedPushMessages.clear();
        this.notifyCheck = false;
        this.lastBadgeCount = 0;
        try {
            if (this.notificationDelayWakelock.isHeld()) {
                this.notificationDelayWakelock.release();
            }
        } catch (Exception e) {
            FileLog.e(e);
        }
        dismissNotification();
        setBadge(getTotalAllUnreadCount());
        SharedPreferences preferences = getAccountInstance().getNotificationsSettings();
        SharedPreferences.Editor editor = preferences.edit();
        editor.clear();
        editor.commit();
        if (Build.VERSION.SDK_INT >= 26) {
            try {
                String keyStart = this.currentAccount + "channel";
                List<NotificationChannel> list = systemNotificationManager.getNotificationChannels();
                int count = list.size();
                for (int a = 0; a < count; a++) {
                    NotificationChannel channel = list.get(a);
                    String id = channel.getId();
                    if (id.startsWith(keyStart)) {
                        systemNotificationManager.deleteNotificationChannel(id);
                    }
                }
            } catch (Throwable e2) {
                FileLog.e(e2);
            }
        }
    }

    public void setInChatSoundEnabled(boolean value) {
        this.inChatSoundEnabled = value;
    }

    public void lambda$setOpenedDialogId$2$NotificationsController(long dialog_id) {
        this.opened_dialog_id = dialog_id;
    }

    public void setOpenedDialogId(final long dialog_id) {
        notificationsQueue.postRunnable(new Runnable() {
            @Override
            public final void run() {
                NotificationsController.this.lambda$setOpenedDialogId$2$NotificationsController(dialog_id);
            }
        });
    }

    public void setLastOnlineFromOtherDevice(final int time) {
        notificationsQueue.postRunnable(new Runnable() {
            @Override
            public final void run() {
                NotificationsController.this.lambda$setLastOnlineFromOtherDevice$3$NotificationsController(time);
            }
        });
    }

    public void lambda$setLastOnlineFromOtherDevice$3$NotificationsController(int time) {
        if (BuildVars.LOGS_ENABLED) {
            FileLog.d("set last online from other device = " + time);
        }
        this.lastOnlineFromOtherDevice = time;
    }

    public void removeNotificationsForDialog(long did) {
        processReadMessages(null, did, 0, Integer.MAX_VALUE, false);
        LongSparseArray<Integer> dialogsToUpdate = new LongSparseArray<>();
        dialogsToUpdate.put(did, 0);
        processDialogsUpdateRead(dialogsToUpdate);
    }

    public boolean hasMessagesToReply() {
        for (int a = 0; a < this.pushMessages.size(); a++) {
            MessageObject messageObject = this.pushMessages.get(a);
            long dialog_id = messageObject.getDialogId();
            if ((!messageObject.messageOwner.mentioned || !(messageObject.messageOwner.action instanceof TLRPC.TL_messageActionPinMessage)) && ((int) dialog_id) != 0 && (messageObject.messageOwner.to_id.channel_id == 0 || messageObject.isMegagroup())) {
                return true;
            }
        }
        return false;
    }

    public void forceShowPopupForReply() {
        notificationsQueue.postRunnable(new Runnable() {
            @Override
            public final void run() {
                NotificationsController.this.lambda$forceShowPopupForReply$5$NotificationsController();
            }
        });
    }

    public void lambda$forceShowPopupForReply$5$NotificationsController() {
        final ArrayList<MessageObject> popupArray = new ArrayList<>();
        for (int a = 0; a < this.pushMessages.size(); a++) {
            MessageObject messageObject = this.pushMessages.get(a);
            long dialog_id = messageObject.getDialogId();
            if ((!messageObject.messageOwner.mentioned || !(messageObject.messageOwner.action instanceof TLRPC.TL_messageActionPinMessage)) && ((int) dialog_id) != 0 && (messageObject.messageOwner.to_id.channel_id == 0 || messageObject.isMegagroup())) {
                popupArray.add(0, messageObject);
            }
        }
        if (!popupArray.isEmpty() && !AndroidUtilities.needShowPasscode(false)) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    NotificationsController.this.lambda$null$4$NotificationsController(popupArray);
                }
            });
        }
    }

    public void lambda$null$4$NotificationsController(ArrayList popupArray) {
        this.popupReplyMessages = popupArray;
        Intent popupIntent = new Intent(ApplicationLoader.applicationContext, (Class<?>) PopupNotificationActivity.class);
        popupIntent.putExtra("force", true);
        popupIntent.putExtra("currentAccount", this.currentAccount);
        popupIntent.setFlags(268763140);
        ApplicationLoader.applicationContext.startActivity(popupIntent);
        Intent it = new Intent("android.intent.action.CLOSE_SYSTEM_DIALOGS");
        ApplicationLoader.applicationContext.sendBroadcast(it);
    }

    public void removeDeletedMessagesFromNotifications(final SparseArray<ArrayList<Integer>> deletedMessages) {
        final ArrayList<MessageObject> popupArrayRemove = new ArrayList<>(0);
        notificationsQueue.postRunnable(new Runnable() {
            @Override
            public final void run() {
                NotificationsController.this.lambda$removeDeletedMessagesFromNotifications$8$NotificationsController(deletedMessages, popupArrayRemove);
            }
        });
    }

    public void lambda$removeDeletedMessagesFromNotifications$8$NotificationsController(SparseArray deletedMessages, final ArrayList popupArrayRemove) {
        int old_unread_count = this.total_unread_count;
        SharedPreferences preferences = getAccountInstance().getNotificationsSettings();
        int a = 0;
        while (a < deletedMessages.size()) {
            int key = deletedMessages.keyAt(a);
            long dialog_id = -key;
            ArrayList<Integer> mids = (ArrayList) deletedMessages.get(key);
            Integer currentCount = this.pushDialogs.get(dialog_id);
            if (currentCount == null) {
                currentCount = 0;
            }
            Integer newCount = currentCount;
            int b = 0;
            while (b < mids.size()) {
                int old_unread_count2 = old_unread_count;
                SharedPreferences preferences2 = preferences;
                long mid = (key << 32) | mids.get(b).intValue();
                MessageObject messageObject = this.pushMessagesDict.get(mid);
                if (messageObject != null) {
                    this.pushMessagesDict.remove(mid);
                    this.delayedPushMessages.remove(messageObject);
                    this.pushMessages.remove(messageObject);
                    if (isPersonalMessage(messageObject)) {
                        this.personal_count--;
                    }
                    popupArrayRemove.add(messageObject);
                    newCount = Integer.valueOf(newCount.intValue() - 1);
                }
                b++;
                old_unread_count = old_unread_count2;
                preferences = preferences2;
            }
            int old_unread_count3 = old_unread_count;
            SharedPreferences preferences3 = preferences;
            int old_unread_count4 = newCount.intValue();
            if (old_unread_count4 <= 0) {
                newCount = 0;
                this.smartNotificationsDialogs.remove(dialog_id);
            }
            if (!newCount.equals(currentCount)) {
                int intValue = this.total_unread_count - currentCount.intValue();
                this.total_unread_count = intValue;
                this.total_unread_count = intValue + newCount.intValue();
                this.pushDialogs.put(dialog_id, newCount);
            }
            if (newCount.intValue() == 0) {
                this.pushDialogs.remove(dialog_id);
                this.pushDialogsOverrideMention.remove(dialog_id);
            }
            a++;
            old_unread_count = old_unread_count3;
            preferences = preferences3;
        }
        int old_unread_count5 = old_unread_count;
        if (!popupArrayRemove.isEmpty()) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    NotificationsController.this.lambda$null$6$NotificationsController(popupArrayRemove);
                }
            });
        }
        if (old_unread_count5 != this.total_unread_count) {
            if (this.notifyCheck) {
                scheduleNotificationDelay(this.lastOnlineFromOtherDevice > getConnectionsManager().getCurrentTime());
            } else {
                this.delayedPushMessages.clear();
                showOrUpdateNotification(this.notifyCheck);
            }
            final int pushDialogsCount = this.pushDialogs.size();
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    NotificationsController.this.lambda$null$7$NotificationsController(pushDialogsCount);
                }
            });
        }
        this.notifyCheck = false;
        if (this.showBadgeNumber) {
            setBadge(getTotalAllUnreadCount());
        }
    }

    public void lambda$null$6$NotificationsController(ArrayList popupArrayRemove) {
        int size = popupArrayRemove.size();
        for (int a = 0; a < size; a++) {
            this.popupMessages.remove(popupArrayRemove.get(a));
        }
    }

    public void lambda$null$7$NotificationsController(int pushDialogsCount) {
        NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.notificationsCountUpdated, Integer.valueOf(this.currentAccount));
        getNotificationCenter().postNotificationName(NotificationCenter.dialogsUnreadCounterChanged, Integer.valueOf(pushDialogsCount));
    }

    public void removeDeletedHisoryFromNotifications(final SparseIntArray deletedMessages) {
        final ArrayList<MessageObject> popupArrayRemove = new ArrayList<>(0);
        notificationsQueue.postRunnable(new Runnable() {
            @Override
            public final void run() {
                NotificationsController.this.lambda$removeDeletedHisoryFromNotifications$11$NotificationsController(deletedMessages, popupArrayRemove);
            }
        });
    }

    public void lambda$removeDeletedHisoryFromNotifications$11$NotificationsController(SparseIntArray deletedMessages, final ArrayList popupArrayRemove) {
        long dialog_id;
        long dialog_id2;
        int i;
        int old_unread_count = this.total_unread_count;
        getAccountInstance().getNotificationsSettings();
        for (int a = 0; a < deletedMessages.size(); a++) {
            int key = deletedMessages.keyAt(a);
            long dialog_id3 = -key;
            int id = deletedMessages.get(key);
            Integer currentCount = this.pushDialogs.get(dialog_id3);
            if (currentCount == null) {
                currentCount = 0;
            }
            Integer newCount = currentCount;
            int c = 0;
            while (c < this.pushMessages.size()) {
                MessageObject messageObject = this.pushMessages.get(c);
                if (messageObject.getDialogId() != dialog_id3 || messageObject.getId() > id) {
                    dialog_id2 = dialog_id3;
                    i = 1;
                } else {
                    dialog_id2 = dialog_id3;
                    this.pushMessagesDict.remove(messageObject.getIdWithChannel());
                    this.delayedPushMessages.remove(messageObject);
                    this.pushMessages.remove(messageObject);
                    c--;
                    if (isPersonalMessage(messageObject)) {
                        i = 1;
                        this.personal_count--;
                    } else {
                        i = 1;
                    }
                    popupArrayRemove.add(messageObject);
                    newCount = Integer.valueOf(newCount.intValue() - i);
                }
                c += i;
                dialog_id3 = dialog_id2;
            }
            long dialog_id4 = dialog_id3;
            if (newCount.intValue() > 0) {
                dialog_id = dialog_id4;
            } else {
                newCount = 0;
                dialog_id = dialog_id4;
                this.smartNotificationsDialogs.remove(dialog_id);
            }
            if (!newCount.equals(currentCount)) {
                int intValue = this.total_unread_count - currentCount.intValue();
                this.total_unread_count = intValue;
                this.total_unread_count = intValue + newCount.intValue();
                this.pushDialogs.put(dialog_id, newCount);
            }
            if (newCount.intValue() == 0) {
                this.pushDialogs.remove(dialog_id);
                this.pushDialogsOverrideMention.remove(dialog_id);
            }
        }
        if (popupArrayRemove.isEmpty()) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    NotificationsController.this.lambda$null$9$NotificationsController(popupArrayRemove);
                }
            });
        }
        if (old_unread_count != this.total_unread_count) {
            if (this.notifyCheck) {
                scheduleNotificationDelay(this.lastOnlineFromOtherDevice > getConnectionsManager().getCurrentTime());
            } else {
                this.delayedPushMessages.clear();
                showOrUpdateNotification(this.notifyCheck);
            }
            final int pushDialogsCount = this.pushDialogs.size();
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    NotificationsController.this.lambda$null$10$NotificationsController(pushDialogsCount);
                }
            });
        }
        this.notifyCheck = false;
        if (this.showBadgeNumber) {
            setBadge(getTotalAllUnreadCount());
        }
    }

    public void lambda$null$9$NotificationsController(ArrayList popupArrayRemove) {
        int size = popupArrayRemove.size();
        for (int a = 0; a < size; a++) {
            this.popupMessages.remove(popupArrayRemove.get(a));
        }
    }

    public void lambda$null$10$NotificationsController(int pushDialogsCount) {
        NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.notificationsCountUpdated, Integer.valueOf(this.currentAccount));
        getNotificationCenter().postNotificationName(NotificationCenter.dialogsUnreadCounterChanged, Integer.valueOf(pushDialogsCount));
    }

    public void processReadMessages(final SparseLongArray inbox, final long dialog_id, final int max_date, final int max_id, final boolean isPopup) {
        final ArrayList<MessageObject> popupArrayRemove = new ArrayList<>(0);
        notificationsQueue.postRunnable(new Runnable() {
            @Override
            public final void run() {
                NotificationsController.this.lambda$processReadMessages$13$NotificationsController(inbox, popupArrayRemove, dialog_id, max_id, max_date, isPopup);
            }
        });
    }

    public void lambda$processReadMessages$13$NotificationsController(SparseLongArray inbox, final ArrayList popupArrayRemove, long dialog_id, int max_id, int max_date, boolean isPopup) {
        if (inbox != null) {
            for (int b = 0; b < inbox.size(); b++) {
                int key = inbox.keyAt(b);
                long messageId = inbox.get(key);
                int a = 0;
                while (a < this.pushMessages.size()) {
                    MessageObject messageObject = this.pushMessages.get(a);
                    if (!messageObject.messageOwner.from_scheduled && messageObject.getDialogId() == key && messageObject.getId() <= ((int) messageId)) {
                        if (isPersonalMessage(messageObject)) {
                            this.personal_count--;
                        }
                        popupArrayRemove.add(messageObject);
                        long mid = messageObject.getId();
                        if (messageObject.messageOwner.to_id.channel_id != 0) {
                            mid |= messageObject.messageOwner.to_id.channel_id << 32;
                        }
                        this.pushMessagesDict.remove(mid);
                        this.delayedPushMessages.remove(messageObject);
                        this.pushMessages.remove(a);
                        a--;
                    }
                    a++;
                }
            }
        }
        if (dialog_id != 0 && (max_id != 0 || max_date != 0)) {
            int a2 = 0;
            while (a2 < this.pushMessages.size()) {
                MessageObject messageObject2 = this.pushMessages.get(a2);
                if (messageObject2.getDialogId() == dialog_id) {
                    boolean remove = false;
                    if (max_date != 0) {
                        if (messageObject2.messageOwner.date <= max_date) {
                            remove = true;
                        }
                    } else if (!isPopup) {
                        if (messageObject2.getId() <= max_id || max_id < 0) {
                            remove = true;
                        }
                    } else if (messageObject2.getId() == max_id || max_id < 0) {
                        remove = true;
                    }
                    if (remove) {
                        if (isPersonalMessage(messageObject2)) {
                            this.personal_count--;
                        }
                        this.pushMessages.remove(a2);
                        this.delayedPushMessages.remove(messageObject2);
                        popupArrayRemove.add(messageObject2);
                        long mid2 = messageObject2.getId();
                        if (messageObject2.messageOwner.to_id.channel_id != 0) {
                            mid2 |= messageObject2.messageOwner.to_id.channel_id << 32;
                        }
                        this.pushMessagesDict.remove(mid2);
                        a2--;
                    }
                }
                a2++;
            }
        }
        if (!popupArrayRemove.isEmpty()) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    NotificationsController.this.lambda$null$12$NotificationsController(popupArrayRemove);
                }
            });
        }
    }

    public void lambda$null$12$NotificationsController(ArrayList popupArrayRemove) {
        int size = popupArrayRemove.size();
        for (int a = 0; a < size; a++) {
            this.popupMessages.remove(popupArrayRemove.get(a));
        }
        NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.pushMessagesUpdated, new Object[0]);
    }

    private int addToPopupMessages(ArrayList<MessageObject> popupArrayAdd, MessageObject messageObject, int lower_id, long dialog_id, boolean isChannel, SharedPreferences preferences) {
        int popup = 0;
        if (lower_id != 0) {
            if (preferences.getBoolean(ContentMetadata.KEY_CUSTOM_PREFIX + dialog_id, false)) {
                popup = preferences.getInt("popup_" + dialog_id, 0);
            } else {
                popup = 0;
            }
            if (popup == 0) {
                if (isChannel) {
                    popup = preferences.getInt("popupChannel", 0);
                } else {
                    popup = preferences.getInt(((int) dialog_id) < 0 ? "popupGroup" : "popupAll", 0);
                }
            } else if (popup == 1) {
                popup = 3;
            } else if (popup == 2) {
                popup = 0;
            }
        }
        if (popup != 0 && messageObject.messageOwner.to_id.channel_id != 0 && !messageObject.isMegagroup()) {
            popup = 0;
        }
        if (popup != 0) {
            popupArrayAdd.add(0, messageObject);
        }
        return popup;
    }

    public void processNewMessages(final ArrayList<MessageObject> messageObjects, final boolean isLast, final boolean isFcm, final CountDownLatch countDownLatch) {
        if (messageObjects.isEmpty()) {
            if (countDownLatch != null) {
                countDownLatch.countDown();
            }
        } else {
            final ArrayList<MessageObject> popupArrayAdd = new ArrayList<>(0);
            notificationsQueue.postRunnable(new Runnable() {
                @Override
                public final void run() {
                    NotificationsController.this.lambda$processNewMessages$16$NotificationsController(messageObjects, popupArrayAdd, isFcm, isLast, countDownLatch);
                }
            });
        }
    }

    public void lambda$processNewMessages$16$NotificationsController(ArrayList messageObjects, final ArrayList popupArrayAdd, boolean isFcm, boolean isLast, CountDownLatch countDownLatch) {
        Integer override;
        int a;
        boolean allowPinned;
        long mid;
        boolean isChannel;
        int lower_id;
        long random_id;
        boolean value;
        LongSparseArray<Boolean> settingsCache;
        boolean added;
        boolean edited;
        int i;
        long original_dialog_id;
        MessageObject messageObject;
        ArrayList arrayList = messageObjects;
        LongSparseArray<Boolean> settingsCache2 = new LongSparseArray<>();
        SharedPreferences preferences = getAccountInstance().getNotificationsSettings();
        boolean allowPinned2 = preferences.getBoolean("PinnedMessages", true);
        boolean added2 = false;
        boolean edited2 = false;
        int popup = 0;
        boolean hasScheduled = false;
        int a2 = 0;
        while (a2 < messageObjects.size()) {
            MessageObject messageObject2 = (MessageObject) arrayList.get(a2);
            if (messageObject2.messageOwner != null && messageObject2.messageOwner.silent) {
                if (messageObject2.messageOwner.action instanceof TLRPC.TL_messageActionContactSignUp) {
                    a = a2;
                    allowPinned = allowPinned2;
                } else if (messageObject2.messageOwner.action instanceof TLRPC.TL_messageActionUserJoined) {
                    a = a2;
                    allowPinned = allowPinned2;
                }
                settingsCache = settingsCache2;
                a2 = a + 1;
                arrayList = messageObjects;
                allowPinned2 = allowPinned;
                settingsCache2 = settingsCache;
            }
            a = a2;
            long mid2 = messageObject2.getId();
            long random_id2 = messageObject2.isFcmMessage() ? messageObject2.messageOwner.random_id : 0L;
            allowPinned = allowPinned2;
            long dialog_id = messageObject2.getDialogId();
            int lower_id2 = (int) dialog_id;
            if (messageObject2.messageOwner.to_id.channel_id != 0) {
                mid = mid2 | (messageObject2.messageOwner.to_id.channel_id << 32);
                isChannel = true;
            } else {
                mid = mid2;
                isChannel = false;
            }
            MessageObject oldMessageObject = this.pushMessagesDict.get(mid);
            if (oldMessageObject == null) {
                random_id = random_id2;
                if (messageObject2.messageOwner.random_id != 0) {
                    lower_id = lower_id2;
                    oldMessageObject = this.fcmRandomMessagesDict.get(messageObject2.messageOwner.random_id);
                    if (oldMessageObject != null) {
                        this.fcmRandomMessagesDict.remove(messageObject2.messageOwner.random_id);
                    }
                } else {
                    lower_id = lower_id2;
                }
            } else {
                lower_id = lower_id2;
                random_id = random_id2;
            }
            if (oldMessageObject == null) {
                long mid3 = mid;
                int lower_id3 = lower_id;
                long random_id3 = random_id;
                if (!edited2) {
                    if (isFcm) {
                        getMessagesStorage().putPushMessage(messageObject2);
                    }
                    if (dialog_id != this.opened_dialog_id || !ApplicationLoader.isScreenOn) {
                        if (messageObject2.messageOwner.mentioned) {
                            if (allowPinned || !(messageObject2.messageOwner.action instanceof TLRPC.TL_messageActionPinMessage)) {
                                dialog_id = messageObject2.messageOwner.from_id;
                            }
                        }
                        if (isPersonalMessage(messageObject2)) {
                            this.personal_count++;
                        }
                        boolean z = lower_id3 < 0;
                        int index = settingsCache2.indexOfKey(dialog_id);
                        if (index >= 0) {
                            value = settingsCache2.valueAt(index).booleanValue();
                        } else {
                            int notifyOverride = getNotifyOverride(preferences, dialog_id);
                            boolean value2 = notifyOverride == -1 ? isGlobalNotificationsEnabled(dialog_id) : notifyOverride != 2;
                            settingsCache2.put(dialog_id, Boolean.valueOf(value2));
                            value = value2;
                        }
                        if (value) {
                            if (isFcm) {
                                settingsCache = settingsCache2;
                                added = true;
                                edited = edited2;
                                i = 0;
                                original_dialog_id = dialog_id;
                            } else {
                                added = true;
                                edited = edited2;
                                original_dialog_id = dialog_id;
                                settingsCache = settingsCache2;
                                i = 0;
                                popup = addToPopupMessages(popupArrayAdd, messageObject2, lower_id3, dialog_id, isChannel, preferences);
                            }
                            if (!hasScheduled) {
                                hasScheduled = messageObject2.messageOwner.from_scheduled;
                            }
                            this.delayedPushMessages.add(messageObject2);
                            this.pushMessages.add(i, messageObject2);
                            if (mid3 != 0) {
                                this.pushMessagesDict.put(mid3, messageObject2);
                            } else if (random_id3 != 0) {
                                this.fcmRandomMessagesDict.put(random_id3, messageObject2);
                            }
                            if (original_dialog_id != dialog_id) {
                                Integer current = this.pushDialogsOverrideMention.get(original_dialog_id);
                                this.pushDialogsOverrideMention.put(original_dialog_id, Integer.valueOf(current == null ? 1 : current.intValue() + 1));
                            }
                            edited2 = edited;
                            added2 = added;
                        } else {
                            settingsCache = settingsCache2;
                            edited2 = edited2;
                            added2 = true;
                        }
                        a2 = a + 1;
                        arrayList = messageObjects;
                        allowPinned2 = allowPinned;
                        settingsCache2 = settingsCache;
                    } else if (!isFcm) {
                        playInChatSound();
                    }
                }
                settingsCache = settingsCache2;
                a2 = a + 1;
                arrayList = messageObjects;
                allowPinned2 = allowPinned;
                settingsCache2 = settingsCache;
            } else if (oldMessageObject.isFcmMessage()) {
                this.pushMessagesDict.put(mid, messageObject2);
                int idxOld = this.pushMessages.indexOf(oldMessageObject);
                if (idxOld >= 0) {
                    this.pushMessages.set(idxOld, messageObject2);
                    messageObject = messageObject2;
                    popup = addToPopupMessages(popupArrayAdd, messageObject2, lower_id, dialog_id, isChannel, preferences);
                } else {
                    messageObject = messageObject2;
                }
                if (isFcm) {
                    boolean z2 = messageObject.localEdit;
                    edited2 = z2;
                    if (z2) {
                        getMessagesStorage().putPushMessage(messageObject);
                    }
                }
                settingsCache = settingsCache2;
                a2 = a + 1;
                arrayList = messageObjects;
                allowPinned2 = allowPinned;
                settingsCache2 = settingsCache;
            } else {
                settingsCache = settingsCache2;
                a2 = a + 1;
                arrayList = messageObjects;
                allowPinned2 = allowPinned;
                settingsCache2 = settingsCache;
            }
        }
        boolean edited3 = edited2;
        if (added2) {
            this.notifyCheck = isLast;
        }
        if (!popupArrayAdd.isEmpty() && !AndroidUtilities.needShowPasscode(false)) {
            final int popupFinal = popup;
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    NotificationsController.this.lambda$null$14$NotificationsController(popupArrayAdd, popupFinal);
                }
            });
        }
        if (isFcm || hasScheduled) {
            if (edited3) {
                this.delayedPushMessages.clear();
                showOrUpdateNotification(this.notifyCheck);
            } else if (added2) {
                long dialog_id2 = ((MessageObject) messageObjects.get(0)).getDialogId();
                int old_unread_count = this.total_unread_count;
                int notifyOverride2 = getNotifyOverride(preferences, dialog_id2);
                boolean canAddValue = notifyOverride2 == -1 ? isGlobalNotificationsEnabled(dialog_id2) : notifyOverride2 != 2;
                Integer currentCount = this.pushDialogs.get(dialog_id2);
                Integer newCount = Integer.valueOf(currentCount != null ? currentCount.intValue() + 1 : 1);
                if (this.notifyCheck && !canAddValue && (override = this.pushDialogsOverrideMention.get(dialog_id2)) != null && override.intValue() != 0) {
                    canAddValue = true;
                    newCount = override;
                }
                if (canAddValue) {
                    if (currentCount != null) {
                        this.total_unread_count -= currentCount.intValue();
                    }
                    this.total_unread_count += newCount.intValue();
                    this.pushDialogs.put(dialog_id2, newCount);
                }
                if (old_unread_count != this.total_unread_count) {
                    this.delayedPushMessages.clear();
                    showOrUpdateNotification(this.notifyCheck);
                    final int pushDialogsCount = this.pushDialogs.size();
                    AndroidUtilities.runOnUIThread(new Runnable() {
                        @Override
                        public final void run() {
                            NotificationsController.this.lambda$null$15$NotificationsController(pushDialogsCount);
                        }
                    });
                }
                this.notifyCheck = false;
                if (this.showBadgeNumber) {
                    setBadge(getTotalAllUnreadCount());
                }
            }
        }
        if (countDownLatch != null) {
            countDownLatch.countDown();
        }
    }

    public void lambda$null$14$NotificationsController(ArrayList popupArrayAdd, int popupFinal) {
        this.popupMessages.addAll(0, popupArrayAdd);
        if (ApplicationLoader.mainInterfacePaused || (!ApplicationLoader.isScreenOn && !SharedConfig.isWaitingForPasscodeEnter)) {
            if (popupFinal == 3 || ((popupFinal == 1 && ApplicationLoader.isScreenOn) || (popupFinal == 2 && !ApplicationLoader.isScreenOn))) {
                Intent popupIntent = new Intent(ApplicationLoader.applicationContext, (Class<?>) PopupNotificationActivity.class);
                popupIntent.setFlags(268763140);
                try {
                    ApplicationLoader.applicationContext.startActivity(popupIntent);
                } catch (Throwable th) {
                }
            }
        }
    }

    public void lambda$null$15$NotificationsController(int pushDialogsCount) {
        NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.notificationsCountUpdated, Integer.valueOf(this.currentAccount));
        getNotificationCenter().postNotificationName(NotificationCenter.dialogsUnreadCounterChanged, Integer.valueOf(pushDialogsCount));
    }

    public int getTotalUnreadCount() {
        return this.total_unread_count;
    }

    public void processDialogsUpdateRead(final LongSparseArray<Integer> dialogsToUpdate) {
        final ArrayList<MessageObject> popupArrayToRemove = new ArrayList<>();
        notificationsQueue.postRunnable(new Runnable() {
            @Override
            public final void run() {
                NotificationsController.this.lambda$processDialogsUpdateRead$19$NotificationsController(dialogsToUpdate, popupArrayToRemove);
            }
        });
    }

    public void lambda$processDialogsUpdateRead$19$NotificationsController(LongSparseArray longSparseArray, final ArrayList arrayList) {
        long j;
        Integer num;
        Integer num2;
        int i = this.total_unread_count;
        SharedPreferences notificationsSettings = getAccountInstance().getNotificationsSettings();
        int i2 = 0;
        while (true) {
            boolean z = false;
            int i3 = 1;
            if (i2 >= longSparseArray.size()) {
                break;
            }
            long keyAt = longSparseArray.keyAt(i2);
            int notifyOverride = getNotifyOverride(notificationsSettings, keyAt);
            if (notifyOverride == -1) {
                z = isGlobalNotificationsEnabled(keyAt);
            } else if (notifyOverride != 2) {
                z = true;
            }
            Integer num3 = this.pushDialogs.get(keyAt);
            Integer num4 = (Integer) longSparseArray.get(keyAt);
            if (this.notifyCheck && !z && (num2 = this.pushDialogsOverrideMention.get(keyAt)) != null && num2.intValue() != 0) {
                z = true;
                num4 = num2;
            }
            if (num4.intValue() == 0) {
                this.smartNotificationsDialogs.remove(keyAt);
            }
            if (num4.intValue() < 0) {
                if (num3 == null) {
                    i2++;
                } else {
                    num4 = Integer.valueOf(num3.intValue() + num4.intValue());
                }
            }
            if ((z || num4.intValue() == 0) && num3 != null) {
                this.total_unread_count -= num3.intValue();
            }
            if (num4.intValue() == 0) {
                this.pushDialogs.remove(keyAt);
                this.pushDialogsOverrideMention.remove(keyAt);
                int i4 = 0;
                while (i4 < this.pushMessages.size()) {
                    MessageObject messageObject = this.pushMessages.get(i4);
                    if (messageObject.messageOwner.from_scheduled || messageObject.getDialogId() != keyAt) {
                        j = keyAt;
                        num = num3;
                    } else {
                        if (isPersonalMessage(messageObject)) {
                            this.personal_count -= i3;
                        }
                        this.pushMessages.remove(i4);
                        i4--;
                        this.delayedPushMessages.remove(messageObject);
                        j = keyAt;
                        long id = messageObject.getId();
                        if (messageObject.messageOwner.to_id.channel_id == 0) {
                            num = num3;
                        } else {
                            num = num3;
                            id |= messageObject.messageOwner.to_id.channel_id << 32;
                        }
                        this.pushMessagesDict.remove(id);
                        arrayList.add(messageObject);
                    }
                    i3 = 1;
                    i4++;
                    num3 = num;
                    keyAt = j;
                }
            } else if (z) {
                this.total_unread_count += num4.intValue();
                this.pushDialogs.put(keyAt, num4);
            }
            i2++;
        }
        if (!arrayList.isEmpty()) {
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    NotificationsController.this.lambda$null$17$NotificationsController(arrayList);
                }
            });
        }
        if (i != this.total_unread_count) {
            if (this.notifyCheck) {
                scheduleNotificationDelay(this.lastOnlineFromOtherDevice > getConnectionsManager().getCurrentTime());
            } else {
                this.delayedPushMessages.clear();
                showOrUpdateNotification(this.notifyCheck);
            }
            final int size = this.pushDialogs.size();
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    NotificationsController.this.lambda$null$18$NotificationsController(size);
                }
            });
        }
        this.notifyCheck = false;
        if (this.showBadgeNumber) {
            setBadge(getTotalAllUnreadCount());
        }
    }

    public void lambda$null$17$NotificationsController(ArrayList popupArrayToRemove) {
        int size = popupArrayToRemove.size();
        for (int a = 0; a < size; a++) {
            this.popupMessages.remove(popupArrayToRemove.get(a));
        }
    }

    public void lambda$null$18$NotificationsController(int pushDialogsCount) {
        NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.notificationsCountUpdated, Integer.valueOf(this.currentAccount));
        getNotificationCenter().postNotificationName(NotificationCenter.dialogsUnreadCounterChanged, Integer.valueOf(pushDialogsCount));
    }

    public void processLoadedUnreadMessages(final LongSparseArray<Integer> dialogs, final ArrayList<TLRPC.Message> messages, final ArrayList<MessageObject> push, ArrayList<TLRPC.User> users, ArrayList<TLRPC.Chat> chats, ArrayList<TLRPC.EncryptedChat> encryptedChats) {
        getMessagesController().putUsers(users, true);
        getMessagesController().putChats(chats, true);
        getMessagesController().putEncryptedChats(encryptedChats, true);
        notificationsQueue.postRunnable(new Runnable() {
            @Override
            public final void run() {
                NotificationsController.this.lambda$processLoadedUnreadMessages$21$NotificationsController(messages, dialogs, push);
            }
        });
    }

    public void lambda$processLoadedUnreadMessages$21$NotificationsController(ArrayList messages, LongSparseArray dialogs, ArrayList push) {
        boolean value;
        boolean value2;
        int a;
        long original_dialog_id;
        boolean value3;
        boolean value4;
        int a2;
        long dialog_id;
        boolean value5;
        ArrayList arrayList = messages;
        this.pushDialogs.clear();
        this.pushMessages.clear();
        this.pushMessagesDict.clear();
        boolean z = false;
        this.total_unread_count = 0;
        this.personal_count = 0;
        SharedPreferences preferences = getAccountInstance().getNotificationsSettings();
        LongSparseArray<Boolean> settingsCache = new LongSparseArray<>();
        char c = ' ';
        int i = 1;
        if (arrayList != null) {
            int a3 = 0;
            while (a3 < messages.size()) {
                TLRPC.Message message = (TLRPC.Message) arrayList.get(a3);
                if (message != null && message.silent) {
                    if (message.action instanceof TLRPC.TL_messageActionContactSignUp) {
                        a2 = a3;
                    } else if (message.action instanceof TLRPC.TL_messageActionUserJoined) {
                        a2 = a3;
                    }
                    a3 = a2 + 1;
                    arrayList = messages;
                    z = false;
                    c = ' ';
                    i = 1;
                }
                long mid = message.id;
                if (message.to_id.channel_id != 0) {
                    mid |= message.to_id.channel_id << c;
                }
                if (this.pushMessagesDict.indexOfKey(mid) >= 0) {
                    a2 = a3;
                } else {
                    MessageObject messageObject = new MessageObject(this.currentAccount, message, z);
                    if (isPersonalMessage(messageObject)) {
                        this.personal_count += i;
                    }
                    long dialog_id2 = messageObject.getDialogId();
                    if (!messageObject.messageOwner.mentioned) {
                        a2 = a3;
                        dialog_id = dialog_id2;
                    } else {
                        a2 = a3;
                        dialog_id = messageObject.messageOwner.from_id;
                    }
                    int index = settingsCache.indexOfKey(dialog_id);
                    if (index >= 0) {
                        value5 = settingsCache.valueAt(index).booleanValue();
                    } else {
                        int notifyOverride = getNotifyOverride(preferences, dialog_id);
                        if (notifyOverride == -1) {
                            value5 = isGlobalNotificationsEnabled(dialog_id);
                        } else {
                            value5 = notifyOverride != 2;
                        }
                        settingsCache.put(dialog_id, Boolean.valueOf(value5));
                    }
                    if (value5 && (dialog_id != this.opened_dialog_id || !ApplicationLoader.isScreenOn)) {
                        this.pushMessagesDict.put(mid, messageObject);
                        this.pushMessages.add(0, messageObject);
                        if (dialog_id2 != dialog_id) {
                            Integer current = this.pushDialogsOverrideMention.get(dialog_id2);
                            this.pushDialogsOverrideMention.put(dialog_id2, Integer.valueOf(current == null ? 1 : current.intValue() + 1));
                        }
                    }
                }
                a3 = a2 + 1;
                arrayList = messages;
                z = false;
                c = ' ';
                i = 1;
            }
        }
        for (int a4 = 0; a4 < dialogs.size(); a4++) {
            long dialog_id3 = dialogs.keyAt(a4);
            int index2 = settingsCache.indexOfKey(dialog_id3);
            if (index2 >= 0) {
                value4 = settingsCache.valueAt(index2).booleanValue();
            } else {
                int notifyOverride2 = getNotifyOverride(preferences, dialog_id3);
                if (notifyOverride2 == -1) {
                    value3 = isGlobalNotificationsEnabled(dialog_id3);
                } else {
                    value3 = notifyOverride2 != 2;
                }
                settingsCache.put(dialog_id3, Boolean.valueOf(value3));
                value4 = value3;
            }
            if (value4) {
                int count = ((Integer) dialogs.valueAt(a4)).intValue();
                this.pushDialogs.put(dialog_id3, Integer.valueOf(count));
                this.total_unread_count += count;
            }
        }
        ArrayList arrayList2 = push;
        if (arrayList2 != null) {
            int a5 = 0;
            while (a5 < push.size()) {
                MessageObject messageObject2 = (MessageObject) arrayList2.get(a5);
                long mid2 = messageObject2.getId();
                if (messageObject2.messageOwner.to_id.channel_id != 0) {
                    mid2 |= messageObject2.messageOwner.to_id.channel_id << 32;
                }
                if (this.pushMessagesDict.indexOfKey(mid2) >= 0) {
                    a = a5;
                } else {
                    if (isPersonalMessage(messageObject2)) {
                        this.personal_count++;
                    }
                    long dialog_id4 = messageObject2.getDialogId();
                    long random_id = messageObject2.messageOwner.random_id;
                    if (messageObject2.messageOwner.mentioned) {
                        dialog_id4 = messageObject2.messageOwner.from_id;
                    }
                    int index3 = settingsCache.indexOfKey(dialog_id4);
                    if (index3 >= 0) {
                        value2 = settingsCache.valueAt(index3).booleanValue();
                    } else {
                        int notifyOverride3 = getNotifyOverride(preferences, dialog_id4);
                        if (notifyOverride3 == -1) {
                            value = isGlobalNotificationsEnabled(dialog_id4);
                        } else {
                            value = notifyOverride3 != 2;
                        }
                        settingsCache.put(dialog_id4, Boolean.valueOf(value));
                        value2 = value;
                    }
                    if (!value2) {
                        a = a5;
                    } else if (dialog_id4 == this.opened_dialog_id && ApplicationLoader.isScreenOn) {
                        a = a5;
                    } else {
                        if (mid2 != 0) {
                            this.pushMessagesDict.put(mid2, messageObject2);
                        } else if (random_id != 0) {
                            this.fcmRandomMessagesDict.put(random_id, messageObject2);
                        }
                        this.pushMessages.add(0, messageObject2);
                        if (dialog_id4 != dialog_id4) {
                            a = a5;
                            original_dialog_id = dialog_id4;
                            Integer current2 = this.pushDialogsOverrideMention.get(original_dialog_id);
                            this.pushDialogsOverrideMention.put(original_dialog_id, Integer.valueOf(current2 == null ? 1 : current2.intValue() + 1));
                        } else {
                            a = a5;
                            original_dialog_id = dialog_id4;
                        }
                        Integer currentCount = this.pushDialogs.get(dialog_id4);
                        Integer newCount = Integer.valueOf(currentCount != null ? currentCount.intValue() + 1 : 1);
                        if (currentCount != null) {
                            this.total_unread_count -= currentCount.intValue();
                        }
                        this.total_unread_count += newCount.intValue();
                        this.pushDialogs.put(dialog_id4, newCount);
                    }
                }
                a5 = a + 1;
                arrayList2 = push;
            }
        }
        final int pushDialogsCount = this.pushDialogs.size();
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                NotificationsController.this.lambda$null$20$NotificationsController(pushDialogsCount);
            }
        });
        showOrUpdateNotification(SystemClock.elapsedRealtime() / 1000 < 60);
        if (this.showBadgeNumber) {
            setBadge(getTotalAllUnreadCount());
        }
    }

    public void lambda$null$20$NotificationsController(int pushDialogsCount) {
        if (this.total_unread_count == 0) {
            this.popupMessages.clear();
            NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.pushMessagesUpdated, new Object[0]);
        }
        NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.notificationsCountUpdated, Integer.valueOf(this.currentAccount));
        getNotificationCenter().postNotificationName(NotificationCenter.dialogsUnreadCounterChanged, Integer.valueOf(pushDialogsCount));
    }

    private int getTotalAllUnreadCount() {
        int count = 0;
        for (int a = 0; a < 3; a++) {
            if (UserConfig.getInstance(a).isClientActivated()) {
                NotificationsController controller = getInstance(a);
                if (controller.showBadgeNumber) {
                    if (controller.showBadgeMessages) {
                        if (controller.showBadgeMuted) {
                            try {
                                int N = MessagesController.getInstance(a).allDialogs.size();
                                for (int i = 0; i < N; i++) {
                                    TLRPC.Dialog dialog = MessagesController.getInstance(a).allDialogs.get(i);
                                    if (dialog.unread_count != 0) {
                                        count += dialog.unread_count;
                                    }
                                }
                            } catch (Exception e) {
                                FileLog.e(e);
                            }
                        } else {
                            count += controller.total_unread_count;
                        }
                    } else if (controller.showBadgeMuted) {
                        try {
                            int N2 = MessagesController.getInstance(a).allDialogs.size();
                            for (int i2 = 0; i2 < N2; i2++) {
                                if (MessagesController.getInstance(a).allDialogs.get(i2).unread_count != 0) {
                                    count++;
                                }
                            }
                        } catch (Exception e2) {
                            FileLog.e(e2);
                        }
                    } else {
                        count += controller.pushDialogs.size();
                    }
                }
            }
        }
        return count;
    }

    public void lambda$updateBadge$22$NotificationsController() {
        setBadge(getTotalAllUnreadCount());
    }

    public void updateBadge() {
        notificationsQueue.postRunnable(new Runnable() {
            @Override
            public final void run() {
                NotificationsController.this.lambda$updateBadge$22$NotificationsController();
            }
        });
    }

    private void setBadge(int count) {
        if (this.lastBadgeCount == count) {
            return;
        }
        this.lastBadgeCount = count;
        NotificationBadge.applyCount(count);
    }

    private String getShortStringForMessage(MessageObject messageObject, String[] userName, boolean[] preview) {
        int i;
        int i2;
        char c;
        char c2;
        char c3;
        char c4;
        int i3;
        char c5;
        if (AndroidUtilities.needShowPasscode(false) || SharedConfig.isWaitingForPasscodeEnter) {
            return LocaleController.getString("YouHaveNewMessage", R.string.YouHaveNewMessage);
        }
        long dialog_id = messageObject.messageOwner.dialog_id;
        int chat_id = messageObject.messageOwner.to_id.chat_id != 0 ? messageObject.messageOwner.to_id.chat_id : messageObject.messageOwner.to_id.channel_id;
        int from_id = messageObject.messageOwner.to_id.user_id;
        if (preview != null) {
            preview[0] = true;
        }
        SharedPreferences preferences = getAccountInstance().getNotificationsSettings();
        boolean dialogPreviewEnabled = preferences.getBoolean("content_preview_" + dialog_id, true);
        if (messageObject.isFcmMessage()) {
            if (chat_id == 0 && from_id != 0) {
                if (Build.VERSION.SDK_INT > 27) {
                    userName[0] = messageObject.localName;
                }
                if (!dialogPreviewEnabled || !preferences.getBoolean("EnablePreviewAll", true)) {
                    if (preview != null) {
                        preview[0] = false;
                    }
                    return LocaleController.getString("Message", R.string.Message);
                }
            } else if (chat_id != 0) {
                if (messageObject.messageOwner.to_id.channel_id == 0 || messageObject.isMegagroup()) {
                    userName[0] = messageObject.localUserName;
                } else if (Build.VERSION.SDK_INT > 27) {
                    userName[0] = messageObject.localName;
                }
                if (!dialogPreviewEnabled || ((!messageObject.localChannel && !preferences.getBoolean("EnablePreviewGroup", true)) || (messageObject.localChannel && !preferences.getBoolean("EnablePreviewChannel", true)))) {
                    if (preview != null) {
                        preview[0] = false;
                    }
                    if (!messageObject.isMegagroup() && messageObject.messageOwner.to_id.channel_id != 0) {
                        return LocaleController.formatString("ChannelMessageNoText", R.string.ChannelMessageNoText, messageObject.localName);
                    }
                    return LocaleController.formatString("NotificationMessageGroupNoText", R.string.NotificationMessageGroupNoText, messageObject.localUserName, messageObject.localName);
                }
            }
            return messageObject.messageOwner.message;
        }
        if (from_id == 0) {
            if (messageObject.isFromUser() || messageObject.getId() < 0) {
                from_id = messageObject.messageOwner.from_id;
            } else {
                from_id = -chat_id;
            }
        } else if (from_id == getUserConfig().getClientUserId()) {
            from_id = messageObject.messageOwner.from_id;
        }
        if (dialog_id == 0) {
            if (chat_id != 0) {
                dialog_id = -chat_id;
            } else if (from_id != 0) {
                dialog_id = from_id;
            }
        }
        String name = null;
        if (from_id > 0) {
            TLRPC.User user = getMessagesController().getUser(Integer.valueOf(from_id));
            if (user != null) {
                name = UserObject.getName(user);
                if (chat_id != 0) {
                    userName[0] = name;
                } else if (Build.VERSION.SDK_INT <= 27) {
                    userName[0] = null;
                } else {
                    userName[0] = name;
                }
            }
        } else {
            TLRPC.Chat chat = getMessagesController().getChat(Integer.valueOf(-from_id));
            if (chat != null) {
                name = chat.title;
                userName[0] = name;
            }
        }
        if (name == null) {
            return null;
        }
        TLRPC.Chat chat2 = null;
        if (chat_id != 0) {
            chat2 = getMessagesController().getChat(Integer.valueOf(chat_id));
            if (chat2 == null) {
                return null;
            }
            if (ChatObject.isChannel(chat2) && !chat2.megagroup && Build.VERSION.SDK_INT <= 27) {
                userName[0] = null;
            }
        }
        if (((int) dialog_id) == 0) {
            userName[0] = null;
            return LocaleController.getString("YouHaveNewMessage", R.string.YouHaveNewMessage);
        }
        boolean isChannel = ChatObject.isChannel(chat2) && !chat2.megagroup;
        if (dialogPreviewEnabled && ((chat_id == 0 && from_id != 0 && preferences.getBoolean("EnablePreviewAll", true)) || (chat_id != 0 && ((!isChannel && preferences.getBoolean("EnablePreviewGroup", true)) || (isChannel && preferences.getBoolean("EnablePreviewChannel", true)))))) {
            if (messageObject.messageOwner instanceof TLRPC.TL_messageService) {
                userName[0] = null;
                if ((messageObject.messageOwner.action instanceof TLRPC.TL_messageActionUserJoined) || (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionContactSignUp)) {
                    return LocaleController.formatString("NotificationContactJoined", R.string.NotificationContactJoined, name);
                }
                if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionUserUpdatedPhoto) {
                    return LocaleController.formatString("NotificationContactNewPhoto", R.string.NotificationContactNewPhoto, name);
                }
                if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionLoginUnknownLocation) {
                    String date = LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, LocaleController.getInstance().formatterYear.format(messageObject.messageOwner.date * 1000), LocaleController.getInstance().formatterDay.format(messageObject.messageOwner.date * 1000));
                    return LocaleController.formatString("NotificationUnrecognizedDevice", R.string.NotificationUnrecognizedDevice, getUserConfig().getCurrentUser().first_name, date, messageObject.messageOwner.action.title, messageObject.messageOwner.action.address);
                }
                if ((messageObject.messageOwner.action instanceof TLRPC.TL_messageActionGameScore) || (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionPaymentSent)) {
                    return messageObject.messageText.toString();
                }
                if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionPhoneCall) {
                    TLRPC.PhoneCallDiscardReason reason = messageObject.messageOwner.action.reason;
                    if (!messageObject.isOut() && (reason instanceof TLRPC.TL_phoneCallDiscardReasonMissed)) {
                        return LocaleController.getString("CallMessageIncomingMissed", R.string.CallMessageIncomingMissed);
                    }
                } else {
                    if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionChatAddUser) {
                        int singleUserId = messageObject.messageOwner.action.user_id;
                        if (singleUserId == 0 && messageObject.messageOwner.action.users.size() == 1) {
                            singleUserId = messageObject.messageOwner.action.users.get(0).intValue();
                        }
                        if (singleUserId != 0) {
                            if (messageObject.messageOwner.to_id.channel_id != 0 && !chat2.megagroup) {
                                return LocaleController.formatString("ChannelAddedByNotification", R.string.ChannelAddedByNotification, name, chat2.title);
                            }
                            if (singleUserId == getUserConfig().getClientUserId()) {
                                return LocaleController.formatString("NotificationInvitedToGroup", R.string.NotificationInvitedToGroup, name, chat2.title);
                            }
                            TLRPC.User u2 = getMessagesController().getUser(Integer.valueOf(singleUserId));
                            if (u2 == null) {
                                return null;
                            }
                            return from_id == u2.id ? chat2.megagroup ? LocaleController.formatString("NotificationGroupAddSelfMega", R.string.NotificationGroupAddSelfMega, name, chat2.title) : LocaleController.formatString("NotificationGroupAddSelf", R.string.NotificationGroupAddSelf, name, chat2.title) : LocaleController.formatString("NotificationGroupAddMember", R.string.NotificationGroupAddMember, name, chat2.title, UserObject.getName(u2));
                        }
                        StringBuilder names = new StringBuilder();
                        for (int a = 0; a < messageObject.messageOwner.action.users.size(); a++) {
                            TLRPC.User user2 = getMessagesController().getUser(messageObject.messageOwner.action.users.get(a));
                            if (user2 != null) {
                                String name2 = UserObject.getName(user2);
                                if (names.length() != 0) {
                                    names.append(", ");
                                }
                                names.append(name2);
                            }
                        }
                        return LocaleController.formatString("NotificationGroupAddMember", R.string.NotificationGroupAddMember, name, chat2.title, names.toString());
                    }
                    if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionChatJoinedByLink) {
                        return LocaleController.formatString("NotificationInvitedToGroupByLink", R.string.NotificationInvitedToGroupByLink, name, chat2.title);
                    }
                    if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionChatEditTitle) {
                        return LocaleController.formatString("NotificationEditedGroupName", R.string.NotificationEditedGroupName, name, messageObject.messageOwner.action.title);
                    }
                    if ((messageObject.messageOwner.action instanceof TLRPC.TL_messageActionChatEditPhoto) || (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionChatDeletePhoto)) {
                        if (messageObject.messageOwner.to_id.channel_id != 0 && !chat2.megagroup) {
                            return LocaleController.formatString("ChannelPhotoEditNotification", R.string.ChannelPhotoEditNotification, chat2.title);
                        }
                        return LocaleController.formatString("NotificationEditedGroupPhoto", R.string.NotificationEditedGroupPhoto, name, chat2.title);
                    }
                    if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionChatDeleteUser) {
                        if (messageObject.messageOwner.action.user_id == getUserConfig().getClientUserId()) {
                            return LocaleController.formatString("NotificationGroupKickYou", R.string.NotificationGroupKickYou, name, chat2.title);
                        }
                        if (messageObject.messageOwner.action.user_id == from_id) {
                            return LocaleController.formatString("NotificationGroupLeftMember", R.string.NotificationGroupLeftMember, name, chat2.title);
                        }
                        TLRPC.User u22 = getMessagesController().getUser(Integer.valueOf(messageObject.messageOwner.action.user_id));
                        if (u22 == null) {
                            return null;
                        }
                        return LocaleController.formatString("NotificationGroupKickMember", R.string.NotificationGroupKickMember, name, chat2.title, UserObject.getName(u22));
                    }
                    if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionChatCreate) {
                        return messageObject.messageText.toString();
                    }
                    if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionChannelCreate) {
                        return messageObject.messageText.toString();
                    }
                    if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionChatMigrateTo) {
                        return LocaleController.formatString("ActionMigrateFromGroupNotify", R.string.ActionMigrateFromGroupNotify, chat2.title);
                    }
                    if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionChannelMigrateFrom) {
                        return LocaleController.formatString("ActionMigrateFromGroupNotify", R.string.ActionMigrateFromGroupNotify, messageObject.messageOwner.action.title);
                    }
                    if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionScreenshotTaken) {
                        return messageObject.messageText.toString();
                    }
                    if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionPinMessage) {
                        if (chat2 == null) {
                            i = 1;
                        } else {
                            if (!ChatObject.isChannel(chat2) || chat2.megagroup) {
                                if (messageObject.replyMessageObject == null) {
                                    return LocaleController.formatString("NotificationActionPinnedNoText", R.string.NotificationActionPinnedNoText, name, chat2.title);
                                }
                                MessageObject object = messageObject.replyMessageObject;
                                if (object.isMusic()) {
                                    return LocaleController.formatString("NotificationActionPinnedMusic", R.string.NotificationActionPinnedMusic, name, chat2.title);
                                }
                                if (object.isVideo()) {
                                    if (Build.VERSION.SDK_INT >= 19 && !TextUtils.isEmpty(object.messageOwner.message)) {
                                        return LocaleController.formatString("NotificationActionPinnedText", R.string.NotificationActionPinnedText, name, "📹 " + object.messageOwner.message, chat2.title);
                                    }
                                    return LocaleController.formatString("NotificationActionPinnedVideo", R.string.NotificationActionPinnedVideo, name, chat2.title);
                                }
                                if (object.isGif()) {
                                    if (Build.VERSION.SDK_INT >= 19 && !TextUtils.isEmpty(object.messageOwner.message)) {
                                        return LocaleController.formatString("NotificationActionPinnedText", R.string.NotificationActionPinnedText, name, "🎬 " + object.messageOwner.message, chat2.title);
                                    }
                                    return LocaleController.formatString("NotificationActionPinnedGif", R.string.NotificationActionPinnedGif, name, chat2.title);
                                }
                                if (object.isVoice()) {
                                    return LocaleController.formatString("NotificationActionPinnedVoice", R.string.NotificationActionPinnedVoice, name, chat2.title);
                                }
                                if (object.isRoundVideo()) {
                                    return LocaleController.formatString("NotificationActionPinnedRound", R.string.NotificationActionPinnedRound, name, chat2.title);
                                }
                                if (object.isSticker() || object.isAnimatedSticker()) {
                                    String emoji = object.getStickerEmoji();
                                    return emoji != null ? LocaleController.formatString("NotificationActionPinnedStickerEmoji", R.string.NotificationActionPinnedStickerEmoji, name, chat2.title, emoji) : LocaleController.formatString("NotificationActionPinnedSticker", R.string.NotificationActionPinnedSticker, name, chat2.title);
                                }
                                if (object.messageOwner.media instanceof TLRPC.TL_messageMediaDocument) {
                                    if (Build.VERSION.SDK_INT >= 19 && !TextUtils.isEmpty(object.messageOwner.message)) {
                                        return LocaleController.formatString("NotificationActionPinnedText", R.string.NotificationActionPinnedText, name, "📎 " + object.messageOwner.message, chat2.title);
                                    }
                                    return LocaleController.formatString("NotificationActionPinnedFile", R.string.NotificationActionPinnedFile, name, chat2.title);
                                }
                                if (object.messageOwner.media instanceof TLRPC.TL_messageMediaGeo) {
                                    c3 = 0;
                                    c4 = 1;
                                    i3 = 2;
                                } else {
                                    if (!(object.messageOwner.media instanceof TLRPC.TL_messageMediaVenue)) {
                                        if (object.messageOwner.media instanceof TLRPC.TL_messageMediaGeoLive) {
                                            return LocaleController.formatString("NotificationActionPinnedGeoLive", R.string.NotificationActionPinnedGeoLive, name, chat2.title);
                                        }
                                        if (object.messageOwner.media instanceof TLRPC.TL_messageMediaContact) {
                                            TLRPC.TL_messageMediaContact mediaContact = (TLRPC.TL_messageMediaContact) object.messageOwner.media;
                                            return LocaleController.formatString("NotificationActionPinnedContact2", R.string.NotificationActionPinnedContact2, name, chat2.title, ContactsController.formatName(mediaContact.first_name, mediaContact.last_name));
                                        }
                                        if (object.messageOwner.media instanceof TLRPC.TL_messageMediaPoll) {
                                            TLRPC.TL_messageMediaPoll mediaPoll = (TLRPC.TL_messageMediaPoll) object.messageOwner.media;
                                            return LocaleController.formatString("NotificationActionPinnedPoll2", R.string.NotificationActionPinnedPoll2, name, chat2.title, mediaPoll.poll.question);
                                        }
                                        if (object.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto) {
                                            if (Build.VERSION.SDK_INT >= 19 && !TextUtils.isEmpty(object.messageOwner.message)) {
                                                return LocaleController.formatString("NotificationActionPinnedText", R.string.NotificationActionPinnedText, name, "🖼 " + object.messageOwner.message, chat2.title);
                                            }
                                            return LocaleController.formatString("NotificationActionPinnedPhoto", R.string.NotificationActionPinnedPhoto, name, chat2.title);
                                        }
                                        if (object.messageOwner.media instanceof TLRPC.TL_messageMediaGame) {
                                            return LocaleController.formatString("NotificationActionPinnedGame", R.string.NotificationActionPinnedGame, name, chat2.title);
                                        }
                                        if (object.messageText != null && object.messageText.length() > 0) {
                                            CharSequence message = object.messageText;
                                            if (message.length() <= 20) {
                                                c5 = 0;
                                            } else {
                                                StringBuilder sb = new StringBuilder();
                                                c5 = 0;
                                                sb.append((Object) message.subSequence(0, 20));
                                                sb.append("...");
                                                message = sb.toString();
                                            }
                                            Object[] objArr = new Object[3];
                                            objArr[c5] = name;
                                            objArr[1] = message;
                                            objArr[2] = chat2.title;
                                            return LocaleController.formatString("NotificationActionPinnedText", R.string.NotificationActionPinnedText, objArr);
                                        }
                                        return LocaleController.formatString("NotificationActionPinnedNoText", R.string.NotificationActionPinnedNoText, name, chat2.title);
                                    }
                                    c3 = 0;
                                    c4 = 1;
                                    i3 = 2;
                                }
                                Object[] objArr2 = new Object[i3];
                                objArr2[c3] = name;
                                objArr2[c4] = chat2.title;
                                return LocaleController.formatString("NotificationActionPinnedGeo", R.string.NotificationActionPinnedGeo, objArr2);
                            }
                            i = 1;
                        }
                        if (messageObject.replyMessageObject == null) {
                            Object[] objArr3 = new Object[i];
                            objArr3[0] = chat2.title;
                            return LocaleController.formatString("NotificationActionPinnedNoTextChannel", R.string.NotificationActionPinnedNoTextChannel, objArr3);
                        }
                        MessageObject object2 = messageObject.replyMessageObject;
                        if (object2.isMusic()) {
                            return LocaleController.formatString("NotificationActionPinnedMusicChannel", R.string.NotificationActionPinnedMusicChannel, chat2.title);
                        }
                        if (object2.isVideo()) {
                            if (Build.VERSION.SDK_INT >= 19 && !TextUtils.isEmpty(object2.messageOwner.message)) {
                                return LocaleController.formatString("NotificationActionPinnedTextChannel", R.string.NotificationActionPinnedTextChannel, chat2.title, "📹 " + object2.messageOwner.message);
                            }
                            return LocaleController.formatString("NotificationActionPinnedVideoChannel", R.string.NotificationActionPinnedVideoChannel, chat2.title);
                        }
                        if (object2.isGif()) {
                            if (Build.VERSION.SDK_INT >= 19 && !TextUtils.isEmpty(object2.messageOwner.message)) {
                                return LocaleController.formatString("NotificationActionPinnedTextChannel", R.string.NotificationActionPinnedTextChannel, chat2.title, "🎬 " + object2.messageOwner.message);
                            }
                            return LocaleController.formatString("NotificationActionPinnedGifChannel", R.string.NotificationActionPinnedGifChannel, chat2.title);
                        }
                        if (object2.isVoice()) {
                            return LocaleController.formatString("NotificationActionPinnedVoiceChannel", R.string.NotificationActionPinnedVoiceChannel, chat2.title);
                        }
                        if (object2.isRoundVideo()) {
                            return LocaleController.formatString("NotificationActionPinnedRoundChannel", R.string.NotificationActionPinnedRoundChannel, chat2.title);
                        }
                        if (object2.isSticker() || object2.isAnimatedSticker()) {
                            String emoji2 = object2.getStickerEmoji();
                            return emoji2 != null ? LocaleController.formatString("NotificationActionPinnedStickerEmojiChannel", R.string.NotificationActionPinnedStickerEmojiChannel, chat2.title, emoji2) : LocaleController.formatString("NotificationActionPinnedStickerChannel", R.string.NotificationActionPinnedStickerChannel, chat2.title);
                        }
                        if (object2.messageOwner.media instanceof TLRPC.TL_messageMediaDocument) {
                            if (Build.VERSION.SDK_INT >= 19 && !TextUtils.isEmpty(object2.messageOwner.message)) {
                                return LocaleController.formatString("NotificationActionPinnedTextChannel", R.string.NotificationActionPinnedTextChannel, chat2.title, "📎 " + object2.messageOwner.message);
                            }
                            return LocaleController.formatString("NotificationActionPinnedFileChannel", R.string.NotificationActionPinnedFileChannel, chat2.title);
                        }
                        if (object2.messageOwner.media instanceof TLRPC.TL_messageMediaGeo) {
                            i2 = 1;
                            c = 0;
                        } else {
                            if (!(object2.messageOwner.media instanceof TLRPC.TL_messageMediaVenue)) {
                                if (object2.messageOwner.media instanceof TLRPC.TL_messageMediaGeoLive) {
                                    return LocaleController.formatString("NotificationActionPinnedGeoLiveChannel", R.string.NotificationActionPinnedGeoLiveChannel, chat2.title);
                                }
                                if (object2.messageOwner.media instanceof TLRPC.TL_messageMediaContact) {
                                    TLRPC.TL_messageMediaContact mediaContact2 = (TLRPC.TL_messageMediaContact) object2.messageOwner.media;
                                    return LocaleController.formatString("NotificationActionPinnedContactChannel2", R.string.NotificationActionPinnedContactChannel2, chat2.title, ContactsController.formatName(mediaContact2.first_name, mediaContact2.last_name));
                                }
                                if (object2.messageOwner.media instanceof TLRPC.TL_messageMediaPoll) {
                                    TLRPC.TL_messageMediaPoll mediaPoll2 = (TLRPC.TL_messageMediaPoll) object2.messageOwner.media;
                                    return LocaleController.formatString("NotificationActionPinnedPollChannel2", R.string.NotificationActionPinnedPollChannel2, chat2.title, mediaPoll2.poll.question);
                                }
                                if (object2.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto) {
                                    if (Build.VERSION.SDK_INT >= 19 && !TextUtils.isEmpty(object2.messageOwner.message)) {
                                        return LocaleController.formatString("NotificationActionPinnedTextChannel", R.string.NotificationActionPinnedTextChannel, chat2.title, "🖼 " + object2.messageOwner.message);
                                    }
                                    return LocaleController.formatString("NotificationActionPinnedPhotoChannel", R.string.NotificationActionPinnedPhotoChannel, chat2.title);
                                }
                                if (object2.messageOwner.media instanceof TLRPC.TL_messageMediaGame) {
                                    return LocaleController.formatString("NotificationActionPinnedGameChannel", R.string.NotificationActionPinnedGameChannel, chat2.title);
                                }
                                if (object2.messageText != null && object2.messageText.length() > 0) {
                                    CharSequence message2 = object2.messageText;
                                    if (message2.length() <= 20) {
                                        c2 = 0;
                                    } else {
                                        StringBuilder sb2 = new StringBuilder();
                                        c2 = 0;
                                        sb2.append((Object) message2.subSequence(0, 20));
                                        sb2.append("...");
                                        message2 = sb2.toString();
                                    }
                                    Object[] objArr4 = new Object[2];
                                    objArr4[c2] = chat2.title;
                                    objArr4[1] = message2;
                                    return LocaleController.formatString("NotificationActionPinnedTextChannel", R.string.NotificationActionPinnedTextChannel, objArr4);
                                }
                                return LocaleController.formatString("NotificationActionPinnedNoTextChannel", R.string.NotificationActionPinnedNoTextChannel, chat2.title);
                            }
                            i2 = 1;
                            c = 0;
                        }
                        Object[] objArr5 = new Object[i2];
                        objArr5[c] = chat2.title;
                        return LocaleController.formatString("NotificationActionPinnedGeoChannel", R.string.NotificationActionPinnedGeoChannel, objArr5);
                    }
                    if (messageObject.messageOwner.action instanceof TLRPCRedpacket.CL_messagesActionReceivedRpkTransfer) {
                        TLRPCRedpacket.CL_messagesActionReceivedRpkTransfer action = (TLRPCRedpacket.CL_messagesActionReceivedRpkTransfer) messageObject.messageOwner.action;
                        if (action.trans == 0) {
                            TLRPC.User receiver = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(action.receiver.user_id));
                            TLRPC.User sender = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(action.sender.user_id));
                            TLApiModel<RedpacketResponse> parse = TLJsonResolve.parse(action.data, (Class<?>) RedpacketResponse.class);
                            RedpacketResponse bean = parse.model;
                            StringBuilder builder = new StringBuilder();
                            if (bean != null) {
                                if (messageObject.isOut()) {
                                    if (getUserConfig().clientUserId == action.sender.user_id) {
                                        builder.append(LocaleController.getString(R.string.YouReceivedYourPacket));
                                    } else {
                                        builder.append(String.format(LocaleController.getString(R.string.YouReceivePacketFrom), UserObject.getName(sender)));
                                    }
                                } else if (getUserConfig().clientUserId == action.sender.user_id) {
                                    builder.append(UserObject.getName(receiver));
                                    builder.append(" ");
                                    builder.append(LocaleController.getString(R.string.ReceivedYourPacket));
                                } else {
                                    builder.append(String.format(LocaleController.getString(R.string.WhoReceivePacketFrom), UserObject.getName(receiver), UserObject.getName(sender)));
                                }
                            }
                            return builder.toString();
                        }
                    }
                }
            } else {
                if (messageObject.isMediaEmpty()) {
                    if (!TextUtils.isEmpty(messageObject.messageText)) {
                        return messageObject.messageText.toString();
                    }
                    if (!TextUtils.isEmpty(messageObject.messageOwner.message)) {
                        return messageObject.messageOwner.message;
                    }
                    return LocaleController.getString("Message", R.string.Message);
                }
                if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto) {
                    if (Build.VERSION.SDK_INT >= 19 && !TextUtils.isEmpty(messageObject.messageOwner.message)) {
                        return "🖼 " + messageObject.messageOwner.message;
                    }
                    if (messageObject.messageOwner.media.ttl_seconds != 0) {
                        return LocaleController.getString("AttachDestructingPhoto", R.string.AttachDestructingPhoto);
                    }
                    return LocaleController.getString("AttachPhoto", R.string.AttachPhoto);
                }
                if (messageObject.messageOwner.media instanceof TLRPCRedpacket.CL_messagesRpkTransferMedia) {
                    TLRPCRedpacket.CL_messagesRpkTransferMedia media = (TLRPCRedpacket.CL_messagesRpkTransferMedia) messageObject.messageOwner.media;
                    if (media.trans == 0) {
                        RedpacketResponse bean2 = null;
                        if (media.data != null) {
                            TLApiModel<RedpacketResponse> parse2 = TLJsonResolve.parse(media.data, (Class<?>) RedpacketResponse.class);
                            RedpacketResponse bean3 = parse2.model;
                            bean2 = bean3;
                        }
                        if (bean2 != null) {
                            RedpacketBean red = bean2.getRed();
                            TLRPC.User sender2 = getMessagesController().getUser(Integer.valueOf(red.getInitiatorUserIdInt()));
                            return String.format(LocaleController.getString(R.string.ReceiveRedPackFrom), UserObject.getName(sender2));
                        }
                        return LocaleController.getString(R.string.ReceivePacketMessage);
                    }
                    if (media.trans == 1 || media.trans == 2) {
                        TransferResponse bean4 = null;
                        if (media.data != null) {
                            TLApiModel<TransferResponse> parse3 = TLJsonResolve.parse(media.data, (Class<?>) TransferResponse.class);
                            TransferResponse bean5 = parse3.model;
                            bean4 = bean5;
                        }
                        if (bean4 != null) {
                            TransferResponse.Status state = bean4.getState();
                            if (messageObject.isOutOwner()) {
                                if (state == TransferResponse.Status.WAITING) {
                                    return LocaleController.getString(R.string.TransferWaitingOtherCollect);
                                }
                                if (state == TransferResponse.Status.RECEIVED) {
                                    if (bean4.getInitiatorUserIdInt() == UserConfig.getInstance(UserConfig.selectedAccount).clientUserId) {
                                        return LocaleController.getString(R.string.TransferOtherHasCollected);
                                    }
                                    return LocaleController.getString(R.string.YouHaveConfirmedReceipt);
                                }
                                if (state == TransferResponse.Status.REFUSED) {
                                    if (bean4.getInitiatorUserIdInt() == UserConfig.getInstance(UserConfig.selectedAccount).clientUserId) {
                                        return LocaleController.getString(R.string.TransferHasBeenReturned);
                                    }
                                    return LocaleController.getString(R.string.YouHaveReturned);
                                }
                                if (state == TransferResponse.Status.TIMEOUT) {
                                    return LocaleController.getString(R.string.TransferHasReturned);
                                }
                            } else {
                                int sender_id = bean4.getInitiatorUserIdInt();
                                int receiver_id = Integer.parseInt(bean4.getRecipientUserId());
                                TLRPC.User sender3 = getMessagesController().getUser(Integer.valueOf(sender_id));
                                TLRPC.User receiver2 = getMessagesController().getUser(Integer.valueOf(receiver_id));
                                if (state == TransferResponse.Status.WAITING) {
                                    return String.format(LocaleController.getString(R.string.TransferReceivedFromSomebody), UserObject.getName(sender3));
                                }
                                if (state == TransferResponse.Status.RECEIVED) {
                                    return sender_id == UserConfig.getInstance(UserConfig.selectedAccount).clientUserId ? String.format(LocaleController.getString(R.string.TransferReceivedBySomebody), UserObject.getName(receiver2)) : LocaleController.getString(R.string.YouHaveConfirmedReceipt);
                                }
                                if (state == TransferResponse.Status.REFUSED) {
                                    return sender_id == UserConfig.getInstance(UserConfig.selectedAccount).clientUserId ? String.format(LocaleController.getString(R.string.TransferReturnedBySomebody), UserObject.getName(receiver2)) : LocaleController.getString(R.string.YouHaveReturned);
                                }
                                if (state == TransferResponse.Status.TIMEOUT) {
                                    return String.format(LocaleController.getString(R.string.TransferSendToSomebodyExpired), UserObject.getName(receiver2));
                                }
                            }
                        } else {
                            return LocaleController.getString(R.string.TransferMessages);
                        }
                    }
                } else {
                    if (messageObject.isVideo()) {
                        if (Build.VERSION.SDK_INT >= 19 && !TextUtils.isEmpty(messageObject.messageOwner.message)) {
                            return "📹 " + messageObject.messageOwner.message;
                        }
                        if (messageObject.messageOwner.media.ttl_seconds != 0) {
                            return LocaleController.getString("AttachDestructingVideo", R.string.AttachDestructingVideo);
                        }
                        return LocaleController.getString("AttachVideo", R.string.AttachVideo);
                    }
                    if (messageObject.isGame()) {
                        return LocaleController.getString("AttachGame", R.string.AttachGame);
                    }
                    if (messageObject.isVoice()) {
                        return LocaleController.getString("AttachAudio", R.string.AttachAudio);
                    }
                    if (messageObject.isRoundVideo()) {
                        return LocaleController.getString("AttachRound", R.string.AttachRound);
                    }
                    if (messageObject.isMusic()) {
                        return LocaleController.getString("AttachMusic", R.string.AttachMusic);
                    }
                    if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaContact) {
                        return LocaleController.getString("AttachContact", R.string.AttachContact);
                    }
                    if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaPoll) {
                        return LocaleController.getString("Poll", R.string.Poll);
                    }
                    if ((messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaGeo) || (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaVenue)) {
                        return LocaleController.getString("AttachLocation", R.string.AttachLocation);
                    }
                    if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaGeoLive) {
                        return LocaleController.getString("AttachLiveLocation", R.string.AttachLiveLocation);
                    }
                    if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaDocument) {
                        if (messageObject.isSticker() || messageObject.isAnimatedSticker()) {
                            String emoji3 = messageObject.getStickerEmoji();
                            if (emoji3 != null) {
                                return emoji3 + " " + LocaleController.getString("AttachSticker", R.string.AttachSticker);
                            }
                            return LocaleController.getString("AttachSticker", R.string.AttachSticker);
                        }
                        if (messageObject.isGif()) {
                            if (Build.VERSION.SDK_INT >= 19 && !TextUtils.isEmpty(messageObject.messageOwner.message)) {
                                return "🎬 " + messageObject.messageOwner.message;
                            }
                            return LocaleController.getString("AttachGif", R.string.AttachGif);
                        }
                        if (Build.VERSION.SDK_INT >= 19 && !TextUtils.isEmpty(messageObject.messageOwner.message)) {
                            return "📎 " + messageObject.messageOwner.message;
                        }
                        return LocaleController.getString("AttachDocument", R.string.AttachDocument);
                    }
                }
            }
            return null;
        }
        if (preview != null) {
            preview[0] = false;
        }
        return LocaleController.getString("Message", R.string.Message);
    }

    private String getStringForMessage(MessageObject messageObject, boolean z, boolean[] zArr, boolean[] zArr2) {
        String str;
        String str2;
        TLRPC.Chat chat;
        boolean z2;
        String str3;
        boolean z3;
        TLRPC.Chat chat2;
        TLRPC.Chat chat3;
        if (AndroidUtilities.needShowPasscode(false) || SharedConfig.isWaitingForPasscodeEnter) {
            return LocaleController.getString("YouHaveNewMessage", R.string.YouHaveNewMessage);
        }
        long j = messageObject.messageOwner.dialog_id;
        int i = messageObject.messageOwner.to_id.chat_id != 0 ? messageObject.messageOwner.to_id.chat_id : messageObject.messageOwner.to_id.channel_id;
        int i2 = messageObject.messageOwner.to_id.user_id;
        if (zArr2 != null) {
            zArr2[0] = true;
        }
        SharedPreferences notificationsSettings = getAccountInstance().getNotificationsSettings();
        boolean z4 = notificationsSettings.getBoolean("content_preview_" + j, true);
        if (messageObject.isFcmMessage()) {
            if (i == 0 && i2 != 0) {
                if (!z4 || !notificationsSettings.getBoolean("EnablePreviewAll", true)) {
                    if (zArr2 != null) {
                        zArr2[0] = false;
                    }
                    return LocaleController.formatString("NotificationMessageNoText", R.string.NotificationMessageNoText, messageObject.localName);
                }
            } else if (i != 0 && (!z4 || ((!messageObject.localChannel && !notificationsSettings.getBoolean("EnablePreviewGroup", true)) || (messageObject.localChannel && !notificationsSettings.getBoolean("EnablePreviewChannel", true))))) {
                if (zArr2 != null) {
                    zArr2[0] = false;
                }
                if (!messageObject.isMegagroup() && messageObject.messageOwner.to_id.channel_id != 0) {
                    return LocaleController.formatString("ChannelMessageNoText", R.string.ChannelMessageNoText, messageObject.localName);
                }
                return LocaleController.formatString("NotificationMessageGroupNoText", R.string.NotificationMessageGroupNoText, messageObject.localUserName, messageObject.localName);
            }
            zArr[0] = true;
            return (String) messageObject.messageText;
        }
        int clientUserId = getUserConfig().getClientUserId();
        if (i2 == 0) {
            if (messageObject.isFromUser() || messageObject.getId() < 0) {
                i2 = messageObject.messageOwner.from_id;
            } else {
                i2 = -i;
            }
        } else if (i2 == clientUserId) {
            i2 = messageObject.messageOwner.from_id;
        }
        if (j == 0) {
            if (i != 0) {
                j = -i;
            } else if (i2 != 0) {
                j = i2;
            }
        }
        String str4 = null;
        if (i2 > 0) {
            if (messageObject.messageOwner.from_scheduled) {
                str = "NotificationMessageNoText";
                str4 = j == ((long) clientUserId) ? LocaleController.getString("MessageScheduledReminderNotification", R.string.MessageScheduledReminderNotification) : LocaleController.getString("NotificationMessageScheduledName", R.string.NotificationMessageScheduledName);
            } else {
                str = "NotificationMessageNoText";
                TLRPC.User user = getMessagesController().getUser(Integer.valueOf(i2));
                if (user != null) {
                    str4 = UserObject.getName(user);
                }
            }
        } else {
            str = "NotificationMessageNoText";
            TLRPC.Chat chat4 = getMessagesController().getChat(Integer.valueOf(-i2));
            if (chat4 != null) {
                str4 = chat4.title;
            }
        }
        if (str4 == null) {
            return null;
        }
        TLRPC.Chat chat5 = null;
        if (i != 0 && (chat5 = getMessagesController().getChat(Integer.valueOf(i))) == null) {
            return null;
        }
        if (((int) j) == 0) {
            return LocaleController.getString("YouHaveNewMessage", R.string.YouHaveNewMessage);
        }
        if (i != 0 || i2 == 0) {
            str2 = null;
            TLRPC.Chat chat6 = chat5;
            if (i != 0) {
                if (ChatObject.isChannel(chat6)) {
                    chat = chat6;
                    if (!chat.megagroup) {
                        z2 = true;
                        if (z4) {
                            if (z2) {
                            }
                            if (z2) {
                            }
                        }
                        if (zArr2 != null) {
                            zArr2[0] = false;
                        }
                        if (!ChatObject.isChannel(chat) && !chat.megagroup) {
                            return LocaleController.formatString("ChannelMessageNoText", R.string.ChannelMessageNoText, str4);
                        }
                        return LocaleController.formatString("NotificationMessageGroupNoText", R.string.NotificationMessageGroupNoText, str4, chat.title);
                    }
                } else {
                    chat = chat6;
                }
                z2 = false;
                if (z4) {
                }
                if (zArr2 != null) {
                }
                if (!ChatObject.isChannel(chat)) {
                }
                return LocaleController.formatString("NotificationMessageGroupNoText", R.string.NotificationMessageGroupNoText, str4, chat.title);
            }
        } else {
            if (z4) {
                str2 = null;
                if (!notificationsSettings.getBoolean("EnablePreviewAll", true)) {
                    chat2 = chat5;
                    str3 = str;
                    z3 = false;
                } else {
                    if (messageObject.messageOwner instanceof TLRPC.TL_messageService) {
                        if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionUserJoined) {
                            chat3 = chat5;
                        } else if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionContactSignUp) {
                            chat3 = chat5;
                        } else {
                            if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionUserUpdatedPhoto) {
                                return LocaleController.formatString("NotificationContactNewPhoto", R.string.NotificationContactNewPhoto, str4);
                            }
                            if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionLoginUnknownLocation) {
                                return LocaleController.formatString("NotificationUnrecognizedDevice", R.string.NotificationUnrecognizedDevice, getUserConfig().getCurrentUser().first_name, LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, LocaleController.getInstance().formatterYear.format(messageObject.messageOwner.date * 1000), LocaleController.getInstance().formatterDay.format(messageObject.messageOwner.date * 1000)), messageObject.messageOwner.action.title, messageObject.messageOwner.action.address);
                            }
                            if ((messageObject.messageOwner.action instanceof TLRPC.TL_messageActionGameScore) || (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionPaymentSent)) {
                                return messageObject.messageText.toString();
                            }
                            if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionPhoneCall) {
                                TLRPC.PhoneCallDiscardReason phoneCallDiscardReason = messageObject.messageOwner.action.reason;
                                if (!messageObject.isOut() && (phoneCallDiscardReason instanceof TLRPC.TL_phoneCallDiscardReasonMissed)) {
                                    str2 = LocaleController.getString("CallMessageIncomingMissed", R.string.CallMessageIncomingMissed);
                                }
                                return str2;
                            }
                            if (messageObject.messageOwner.action instanceof TLRPCRedpacket.CL_messagesActionReceivedRpkTransfer) {
                                TLRPCRedpacket.CL_messagesActionReceivedRpkTransfer cL_messagesActionReceivedRpkTransfer = (TLRPCRedpacket.CL_messagesActionReceivedRpkTransfer) messageObject.messageOwner.action;
                                if (cL_messagesActionReceivedRpkTransfer.trans == 0) {
                                    TLRPC.User user2 = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(cL_messagesActionReceivedRpkTransfer.receiver.user_id));
                                    TLRPC.User user3 = MessagesController.getInstance(this.currentAccount).getUser(Integer.valueOf(cL_messagesActionReceivedRpkTransfer.sender.user_id));
                                    RedpacketResponse redpacketResponse = (RedpacketResponse) TLJsonResolve.parse(cL_messagesActionReceivedRpkTransfer.data, (Class<?>) RedpacketResponse.class).model;
                                    StringBuilder sb = new StringBuilder();
                                    if (redpacketResponse != null) {
                                        if (messageObject.isOut()) {
                                            if (getUserConfig().clientUserId == cL_messagesActionReceivedRpkTransfer.sender.user_id) {
                                                sb.append(LocaleController.getString(R.string.YouReceivedYourPacket));
                                            } else {
                                                sb.append(String.format(LocaleController.getString(R.string.YouReceivePacketFrom), UserObject.getName(user3)));
                                            }
                                        } else if (getUserConfig().clientUserId == cL_messagesActionReceivedRpkTransfer.sender.user_id) {
                                            sb.append(UserObject.getName(user2));
                                            sb.append(" ");
                                            sb.append(LocaleController.getString(R.string.ReceivedYourPacket));
                                        } else {
                                            sb.append(String.format(LocaleController.getString(R.string.WhoReceivePacketFrom), UserObject.getName(user2), UserObject.getName(user3)));
                                        }
                                    }
                                    return sb.toString();
                                }
                            }
                        }
                        return LocaleController.formatString("NotificationContactJoined", R.string.NotificationContactJoined, str4);
                    }
                    if (messageObject.isMediaEmpty()) {
                        if (!z) {
                            if (TextUtils.isEmpty(messageObject.messageOwner.message)) {
                                return LocaleController.formatString(str, R.string.NotificationMessageNoText, str4);
                            }
                            String formatString = LocaleController.formatString("NotificationMessageText", R.string.NotificationMessageText, str4, messageObject.messageOwner.message);
                            zArr[0] = true;
                            return formatString;
                        }
                        return LocaleController.formatString(str, R.string.NotificationMessageNoText, str4);
                    }
                    if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto) {
                        if (z || Build.VERSION.SDK_INT < 19 || TextUtils.isEmpty(messageObject.messageOwner.message)) {
                            return messageObject.messageOwner.media.ttl_seconds != 0 ? LocaleController.formatString("NotificationMessageSDPhoto", R.string.NotificationMessageSDPhoto, str4) : LocaleController.formatString("NotificationMessagePhoto", R.string.NotificationMessagePhoto, str4);
                        }
                        String formatString2 = LocaleController.formatString("NotificationMessageText", R.string.NotificationMessageText, str4, "🖼 " + messageObject.messageOwner.message);
                        zArr[0] = true;
                        return formatString2;
                    }
                    if (messageObject.isVideo()) {
                        if (z || Build.VERSION.SDK_INT < 19 || TextUtils.isEmpty(messageObject.messageOwner.message)) {
                            return messageObject.messageOwner.media.ttl_seconds != 0 ? LocaleController.formatString("NotificationMessageSDVideo", R.string.NotificationMessageSDVideo, str4) : LocaleController.formatString("NotificationMessageVideo", R.string.NotificationMessageVideo, str4);
                        }
                        String formatString3 = LocaleController.formatString("NotificationMessageText", R.string.NotificationMessageText, str4, "📹 " + messageObject.messageOwner.message);
                        zArr[0] = true;
                        return formatString3;
                    }
                    if (messageObject.isGame()) {
                        return LocaleController.formatString("NotificationMessageGame", R.string.NotificationMessageGame, str4, messageObject.messageOwner.media.game.title);
                    }
                    if (messageObject.isVoice()) {
                        return LocaleController.formatString("NotificationMessageAudio", R.string.NotificationMessageAudio, str4);
                    }
                    if (messageObject.isRoundVideo()) {
                        return LocaleController.formatString("NotificationMessageRound", R.string.NotificationMessageRound, str4);
                    }
                    if (messageObject.isMusic()) {
                        return LocaleController.formatString("NotificationMessageMusic", R.string.NotificationMessageMusic, str4);
                    }
                    if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaContact) {
                        TLRPC.TL_messageMediaContact tL_messageMediaContact = (TLRPC.TL_messageMediaContact) messageObject.messageOwner.media;
                        return LocaleController.formatString("NotificationMessageContact2", R.string.NotificationMessageContact2, str4, ContactsController.formatName(tL_messageMediaContact.first_name, tL_messageMediaContact.last_name));
                    }
                    if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaPoll) {
                        return LocaleController.formatString("NotificationMessagePoll2", R.string.NotificationMessagePoll2, str4, ((TLRPC.TL_messageMediaPoll) messageObject.messageOwner.media).poll.question);
                    }
                    if ((messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaGeo) || (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaVenue)) {
                        return LocaleController.formatString("NotificationMessageMap", R.string.NotificationMessageMap, str4);
                    }
                    if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaGeoLive) {
                        return LocaleController.formatString("NotificationMessageLiveLocation", R.string.NotificationMessageLiveLocation, str4);
                    }
                    if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaDocument) {
                        if (messageObject.isSticker() || messageObject.isAnimatedSticker()) {
                            String stickerEmoji = messageObject.getStickerEmoji();
                            return stickerEmoji != null ? LocaleController.formatString("NotificationMessageStickerEmoji", R.string.NotificationMessageStickerEmoji, str4, stickerEmoji) : LocaleController.formatString("NotificationMessageSticker", R.string.NotificationMessageSticker, str4);
                        }
                        if (messageObject.isGif()) {
                            if (!z && Build.VERSION.SDK_INT >= 19 && !TextUtils.isEmpty(messageObject.messageOwner.message)) {
                                String formatString4 = LocaleController.formatString("NotificationMessageText", R.string.NotificationMessageText, str4, "🎬 " + messageObject.messageOwner.message);
                                zArr[0] = true;
                                return formatString4;
                            }
                            return LocaleController.formatString("NotificationMessageGif", R.string.NotificationMessageGif, str4);
                        }
                        if (!z && Build.VERSION.SDK_INT >= 19 && !TextUtils.isEmpty(messageObject.messageOwner.message)) {
                            String formatString5 = LocaleController.formatString("NotificationMessageText", R.string.NotificationMessageText, str4, "📎 " + messageObject.messageOwner.message);
                            zArr[0] = true;
                            return formatString5;
                        }
                        return LocaleController.formatString("NotificationMessageDocument", R.string.NotificationMessageDocument, str4);
                    }
                    if (messageObject.messageOwner.media instanceof TLRPCRedpacket.CL_messagesRpkTransferMedia) {
                        TLRPCRedpacket.CL_messagesRpkTransferMedia cL_messagesRpkTransferMedia = (TLRPCRedpacket.CL_messagesRpkTransferMedia) messageObject.messageOwner.media;
                        if (cL_messagesRpkTransferMedia.trans == 0) {
                            RedpacketResponse redpacketResponse2 = null;
                            if (cL_messagesRpkTransferMedia.data != null) {
                                redpacketResponse2 = (RedpacketResponse) TLJsonResolve.parse(cL_messagesRpkTransferMedia.data, (Class<?>) RedpacketResponse.class).model;
                            }
                            return redpacketResponse2 != null ? String.format(LocaleController.getString(R.string.ReceiveRedPackFrom), UserObject.getName(getMessagesController().getUser(Integer.valueOf(redpacketResponse2.getRed().getInitiatorUserIdInt())))) : LocaleController.getString(R.string.ReceivePacketMessage);
                        }
                        if (cL_messagesRpkTransferMedia.trans == 1 || cL_messagesRpkTransferMedia.trans == 2) {
                            TransferResponse transferResponse = null;
                            if (cL_messagesRpkTransferMedia.data != null) {
                                transferResponse = (TransferResponse) TLJsonResolve.parse(cL_messagesRpkTransferMedia.data, (Class<?>) TransferResponse.class).model;
                            }
                            if (transferResponse == null) {
                                return LocaleController.getString(R.string.TransferMessages);
                            }
                            TransferResponse.Status state = transferResponse.getState();
                            if (messageObject.isOutOwner()) {
                                if (state == TransferResponse.Status.WAITING) {
                                    return LocaleController.getString(R.string.TransferWaitingOtherCollect);
                                }
                                if (state == TransferResponse.Status.RECEIVED) {
                                    if (transferResponse.getInitiatorUserIdInt() == UserConfig.getInstance(UserConfig.selectedAccount).clientUserId) {
                                        return LocaleController.getString(R.string.TransferOtherHasCollected);
                                    }
                                    return LocaleController.getString(R.string.YouHaveConfirmedReceipt);
                                }
                                if (state == TransferResponse.Status.REFUSED) {
                                    if (transferResponse.getInitiatorUserIdInt() == UserConfig.getInstance(UserConfig.selectedAccount).clientUserId) {
                                        return LocaleController.getString(R.string.TransferHasBeenReturned);
                                    }
                                    return LocaleController.getString(R.string.YouHaveReturned);
                                }
                                if (state == TransferResponse.Status.TIMEOUT) {
                                    return LocaleController.getString(R.string.TransferHasReturned);
                                }
                            } else {
                                int initiatorUserIdInt = transferResponse.getInitiatorUserIdInt();
                                int parseInt = Integer.parseInt(transferResponse.getRecipientUserId());
                                TLRPC.User user4 = getMessagesController().getUser(Integer.valueOf(initiatorUserIdInt));
                                TLRPC.User user5 = getMessagesController().getUser(Integer.valueOf(parseInt));
                                if (state == TransferResponse.Status.WAITING) {
                                    return String.format(LocaleController.getString(R.string.TransferReceivedFromSomebody), UserObject.getName(user4));
                                }
                                if (state == TransferResponse.Status.RECEIVED) {
                                    return initiatorUserIdInt == UserConfig.getInstance(UserConfig.selectedAccount).clientUserId ? String.format(LocaleController.getString(R.string.TransferReceivedBySomebody), UserObject.getName(user5)) : LocaleController.getString(R.string.YouHaveConfirmedReceipt);
                                }
                                if (state == TransferResponse.Status.REFUSED) {
                                    return initiatorUserIdInt == UserConfig.getInstance(UserConfig.selectedAccount).clientUserId ? String.format(LocaleController.getString(R.string.TransferReturnedBySomebody), UserObject.getName(user5)) : LocaleController.getString(R.string.YouHaveReturned);
                                }
                                if (state == TransferResponse.Status.TIMEOUT) {
                                    return String.format(LocaleController.getString(R.string.TransferSendToSomebodyExpired), UserObject.getName(user5));
                                }
                            }
                        }
                    }
                }
            } else {
                str3 = str;
                z3 = false;
                chat2 = chat5;
            }
            if (zArr2 != null) {
                zArr2[z3 ? 1 : 0] = z3;
            }
            Object[] objArr = new Object[1];
            objArr[z3 ? 1 : 0] = str4;
            return LocaleController.formatString(str3, R.string.NotificationMessageNoText, objArr);
        }
        return str2;
    }

    private void scheduleNotificationRepeat() {
        try {
            Intent intent = new Intent(ApplicationLoader.applicationContext, (Class<?>) NotificationRepeat.class);
            intent.putExtra("currentAccount", this.currentAccount);
            PendingIntent pintent = PendingIntent.getService(ApplicationLoader.applicationContext, 0, intent, 0);
            SharedPreferences preferences = getAccountInstance().getNotificationsSettings();
            int minutes = preferences.getInt("repeat_messages", 60);
            if (minutes > 0 && this.personal_count > 0) {
                this.alarmManager.set(2, SystemClock.elapsedRealtime() + (minutes * 60 * 1000), pintent);
            } else {
                this.alarmManager.cancel(pintent);
            }
        } catch (Exception e) {
            FileLog.e(e);
        }
    }

    private boolean isPersonalMessage(MessageObject messageObject) {
        return messageObject.messageOwner.to_id != null && messageObject.messageOwner.to_id.chat_id == 0 && messageObject.messageOwner.to_id.channel_id == 0 && (messageObject.messageOwner.action == null || (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionEmpty));
    }

    private int getNotifyOverride(SharedPreferences preferences, long dialog_id) {
        int notifyOverride = preferences.getInt("notify2_" + dialog_id, -1);
        if (notifyOverride == 3) {
            int muteUntil = preferences.getInt("notifyuntil_" + dialog_id, 0);
            if (muteUntil >= getConnectionsManager().getCurrentTime()) {
                return 2;
            }
            return notifyOverride;
        }
        return notifyOverride;
    }

    public void lambda$showNotifications$23$NotificationsController() {
        showOrUpdateNotification(false);
    }

    public void showNotifications() {
        notificationsQueue.postRunnable(new Runnable() {
            @Override
            public final void run() {
                NotificationsController.this.lambda$showNotifications$23$NotificationsController();
            }
        });
    }

    public void hideNotifications() {
        notificationsQueue.postRunnable(new Runnable() {
            @Override
            public final void run() {
                NotificationsController.this.lambda$hideNotifications$24$NotificationsController();
            }
        });
    }

    public void lambda$hideNotifications$24$NotificationsController() {
        notificationManager.cancel(this.notificationId);
        this.lastWearNotifiedMessageId.clear();
        for (int a = 0; a < this.wearNotificationsIds.size(); a++) {
            notificationManager.cancel(this.wearNotificationsIds.valueAt(a).intValue());
        }
        this.wearNotificationsIds.clear();
    }

    private void dismissNotification() {
        try {
            notificationManager.cancel(this.notificationId);
            this.pushMessages.clear();
            this.pushMessagesDict.clear();
            this.lastWearNotifiedMessageId.clear();
            for (int a = 0; a < this.wearNotificationsIds.size(); a++) {
                notificationManager.cancel(this.wearNotificationsIds.valueAt(a).intValue());
            }
            this.wearNotificationsIds.clear();
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.pushMessagesUpdated, new Object[0]);
                }
            });
            if (WearDataLayerListenerService.isWatchConnected()) {
                try {
                    JSONObject o = new JSONObject();
                    o.put(TtmlNode.ATTR_ID, getUserConfig().getClientUserId());
                    o.put("cancel_all", true);
                    WearDataLayerListenerService.sendMessageToWatch("/notify", o.toString().getBytes(), "remote_notifications");
                } catch (JSONException e) {
                }
            }
        } catch (Exception e2) {
            FileLog.e(e2);
        }
    }

    private void playInChatSound() {
        if (!this.inChatSoundEnabled || MediaController.getInstance().isRecordingAudio()) {
            return;
        }
        try {
            if (audioManager.getRingerMode() == 0) {
                return;
            }
        } catch (Exception e) {
            FileLog.e(e);
        }
        try {
            SharedPreferences preferences = getAccountInstance().getNotificationsSettings();
            int notifyOverride = getNotifyOverride(preferences, this.opened_dialog_id);
            if (notifyOverride == 2) {
                return;
            }
            notificationsQueue.postRunnable(new Runnable() {
                @Override
                public final void run() {
                    NotificationsController.this.lambda$playInChatSound$27$NotificationsController();
                }
            });
        } catch (Exception e2) {
            FileLog.e(e2);
        }
    }

    public void lambda$playInChatSound$27$NotificationsController() {
        if (Math.abs(System.currentTimeMillis() - this.lastSoundPlay) <= 500) {
            return;
        }
        try {
            if (this.soundPool == null) {
                SoundPool soundPool = new SoundPool(3, 1, 0);
                this.soundPool = soundPool;
                soundPool.setOnLoadCompleteListener(new SoundPool.OnLoadCompleteListener() {
                    @Override
                    public final void onLoadComplete(SoundPool soundPool2, int i, int i2) {
                        NotificationsController.lambda$null$26(soundPool2, i, i2);
                    }
                });
            }
            if (this.soundIn == 0 && !this.soundInLoaded) {
                this.soundInLoaded = true;
                this.soundIn = this.soundPool.load(ApplicationLoader.applicationContext, R.raw.sound_in, 1);
            }
            if (this.soundIn != 0) {
                try {
                    this.soundPool.play(this.soundIn, 1.0f, 1.0f, 1, 0, 1.0f);
                } catch (Exception e) {
                    FileLog.e(e);
                }
            }
        } catch (Exception e2) {
            FileLog.e(e2);
        }
    }

    public static void lambda$null$26(SoundPool soundPool, int sampleId, int status) {
        if (status == 0) {
            try {
                soundPool.play(sampleId, 1.0f, 1.0f, 1, 0, 1.0f);
            } catch (Exception e) {
                FileLog.e(e);
            }
        }
    }

    private void scheduleNotificationDelay(boolean onlineReason) {
        try {
            if (BuildVars.LOGS_ENABLED) {
                FileLog.d("delay notification start, onlineReason = " + onlineReason);
            }
            this.notificationDelayWakelock.acquire(OkHttpUtils.DEFAULT_MILLISECONDS);
            notificationsQueue.cancelRunnable(this.notificationDelayRunnable);
            notificationsQueue.postRunnable(this.notificationDelayRunnable, onlineReason ? 3000 : 1000);
        } catch (Exception e) {
            FileLog.e(e);
            showOrUpdateNotification(this.notifyCheck);
        }
    }

    public void repeatNotificationMaybe() {
        notificationsQueue.postRunnable(new Runnable() {
            @Override
            public final void run() {
                NotificationsController.this.lambda$repeatNotificationMaybe$28$NotificationsController();
            }
        });
    }

    public void lambda$repeatNotificationMaybe$28$NotificationsController() {
        int hour = Calendar.getInstance().get(11);
        if (hour >= 11 && hour <= 22) {
            notificationManager.cancel(this.notificationId);
            showOrUpdateNotification(true);
        } else {
            scheduleNotificationRepeat();
        }
    }

    private boolean isEmptyVibration(long[] pattern) {
        if (pattern == null || pattern.length == 0) {
            return false;
        }
        for (long j : pattern) {
            if (j != 0) {
                return false;
            }
        }
        return true;
    }

    public void deleteNotificationChannel(final long dialogId) {
        notificationsQueue.postRunnable(new Runnable() {
            @Override
            public final void run() {
                NotificationsController.this.lambda$deleteNotificationChannel$29$NotificationsController(dialogId);
            }
        });
    }

    public void lambda$deleteNotificationChannel$29$NotificationsController(long dialogId) {
        if (Build.VERSION.SDK_INT < 26) {
            return;
        }
        try {
            SharedPreferences preferences = getAccountInstance().getNotificationsSettings();
            String key = "im.skmzhmurqt.key" + dialogId;
            String channelId = preferences.getString(key, null);
            if (channelId != null) {
                preferences.edit().remove(key).remove(key + "_s").commit();
                systemNotificationManager.deleteNotificationChannel(channelId);
            }
        } catch (Exception e) {
            FileLog.e(e);
        }
    }

    public void deleteAllNotificationChannels() {
        notificationsQueue.postRunnable(new Runnable() {
            @Override
            public final void run() {
                NotificationsController.this.lambda$deleteAllNotificationChannels$30$NotificationsController();
            }
        });
    }

    public void lambda$deleteAllNotificationChannels$30$NotificationsController() {
        if (Build.VERSION.SDK_INT < 26) {
            return;
        }
        try {
            SharedPreferences preferences = getAccountInstance().getNotificationsSettings();
            Map<String, ?> values = preferences.getAll();
            SharedPreferences.Editor editor = preferences.edit();
            for (Map.Entry<String, ?> entry : values.entrySet()) {
                String key = entry.getKey();
                if (key.startsWith("im.skmzhmurqt.key")) {
                    if (!key.endsWith("_s")) {
                        systemNotificationManager.deleteNotificationChannel((String) entry.getValue());
                    }
                    editor.remove(key);
                }
            }
            editor.commit();
        } catch (Exception e) {
            FileLog.e(e);
        }
    }

    private String validateChannelId(long dialogId, String name, long[] vibrationPattern, int ledColor, Uri sound, int importance, long[] configVibrationPattern, Uri configSound, int configImportance) {
        SharedPreferences preferences = getAccountInstance().getNotificationsSettings();
        String key = "im.skmzhmurqt.key" + dialogId;
        String channelId = preferences.getString(key, null);
        String settings = preferences.getString(key + "_s", null);
        StringBuilder newSettings = new StringBuilder();
        for (long j : vibrationPattern) {
            newSettings.append(j);
        }
        newSettings.append(ledColor);
        if (sound != null) {
            newSettings.append(sound.toString());
        }
        newSettings.append(importance);
        String newSettingsHash = Utilities.MD5(newSettings.toString());
        if (channelId != null && !settings.equals(newSettingsHash)) {
            if (0 != 0) {
                preferences.edit().putString(key, channelId).putString(key + "_s", newSettingsHash).commit();
            } else {
                systemNotificationManager.deleteNotificationChannel(channelId);
                channelId = null;
            }
        }
        if (channelId == null) {
            channelId = this.currentAccount + "channel" + dialogId + "_" + Utilities.random.nextLong();
            NotificationChannel notificationChannel = new NotificationChannel(channelId, name, importance);
            if (ledColor != 0) {
                notificationChannel.enableLights(true);
                notificationChannel.setLightColor(ledColor);
            }
            if (!isEmptyVibration(vibrationPattern)) {
                notificationChannel.enableVibration(true);
                if (vibrationPattern != null && vibrationPattern.length > 0) {
                    notificationChannel.setVibrationPattern(vibrationPattern);
                }
            } else {
                notificationChannel.enableVibration(false);
            }
            AudioAttributes.Builder builder = new AudioAttributes.Builder();
            builder.setContentType(4);
            builder.setUsage(5);
            if (sound != null) {
                notificationChannel.setSound(sound, builder.build());
            } else {
                notificationChannel.setSound(null, builder.build());
            }
            systemNotificationManager.createNotificationChannel(notificationChannel);
            preferences.edit().putString(key, channelId).putString(key + "_s", newSettingsHash).commit();
        }
        return channelId;
    }

    private void showOrUpdateNotification(boolean z) {
        Exception exc;
        long j;
        int i;
        TLRPC.Chat chat;
        boolean z2;
        String str;
        String str2;
        int i2;
        String str3;
        int i3;
        boolean z3;
        int i4;
        String str4;
        int i5;
        boolean z4;
        int i6;
        int i7;
        String str5;
        int i8;
        int i9;
        int i10;
        int i11;
        int i12;
        String str6;
        int i13;
        TLRPC.User user;
        TLRPC.FileLocation fileLocation;
        MessageObject messageObject;
        String name;
        boolean z5;
        int i14;
        ?? r27;
        String string;
        String str7;
        String str8;
        String sb;
        PendingIntent pendingIntent;
        TLRPC.User user2;
        int i15;
        Uri uri;
        String str9;
        String str10;
        TLRPC.FileLocation fileLocation2;
        boolean z6;
        String str11;
        String str12;
        TLRPC.FileLocation fileLocation3;
        int i16;
        int i17;
        String str13;
        TLRPC.FileLocation fileLocation4;
        int i18;
        int i19;
        String str14;
        String str15;
        String str16;
        MessageObject messageObject2;
        int i20;
        int i21;
        long j2;
        long[] jArr;
        boolean z7;
        MessageObject messageObject3;
        ArrayList<TLRPC.TL_keyboardButtonRow> arrayList;
        int i22;
        Intent intent;
        boolean z8;
        long j3;
        Uri uri2;
        boolean z9;
        Uri uri3;
        int ringerMode;
        int i23;
        String str17;
        int i24;
        int i25;
        if (getUserConfig().isClientActivated() && !this.pushMessages.isEmpty()) {
            if (SharedConfig.showNotificationsForAllAccounts || this.currentAccount == UserConfig.selectedAccount) {
                try {
                    getConnectionsManager().resumeNetworkMaybe();
                    MessageObject messageObject4 = this.pushMessages.get(0);
                    SharedPreferences notificationsSettings = getAccountInstance().getNotificationsSettings();
                    int i26 = notificationsSettings.getInt("dismissDate", 0);
                    try {
                        if (messageObject4.messageOwner.date <= i26) {
                            dismissNotification();
                            return;
                        }
                        long dialogId = messageObject4.getDialogId();
                        if (!messageObject4.messageOwner.mentioned) {
                            j = dialogId;
                        } else {
                            j = messageObject4.messageOwner.from_id;
                        }
                        messageObject4.getId();
                        int i27 = messageObject4.messageOwner.to_id.chat_id != 0 ? messageObject4.messageOwner.to_id.chat_id : messageObject4.messageOwner.to_id.channel_id;
                        int i28 = messageObject4.messageOwner.to_id.user_id;
                        if (i28 == 0) {
                            i28 = messageObject4.messageOwner.from_id;
                        } else if (i28 == getUserConfig().getClientUserId()) {
                            i28 = messageObject4.messageOwner.from_id;
                        }
                        boolean z10 = false;
                        TLRPC.User user3 = getMessagesController().getUser(Integer.valueOf(i28));
                        if (i27 == 0) {
                            i = i26;
                            chat = null;
                        } else {
                            i = i26;
                            TLRPC.Chat chat2 = getMessagesController().getChat(Integer.valueOf(i27));
                            z10 = ChatObject.isChannel(chat2) && !chat2.megagroup;
                            chat = chat2;
                        }
                        boolean z11 = false;
                        int i29 = -16776961;
                        int i30 = 0;
                        int notifyOverride = getNotifyOverride(notificationsSettings, j);
                        if (notifyOverride == -1) {
                            z2 = isGlobalNotificationsEnabled(dialogId);
                        } else {
                            z2 = notifyOverride != 2;
                        }
                        if (!z || !z2) {
                            z11 = true;
                        }
                        if (z11 || dialogId != j || chat == null) {
                            str = "color_";
                            str2 = "currentAccount";
                        } else {
                            try {
                                if (notificationsSettings.getBoolean(ContentMetadata.KEY_CUSTOM_PREFIX + dialogId, false)) {
                                    int i31 = notificationsSettings.getInt("smart_max_count_" + dialogId, 2);
                                    i25 = notificationsSettings.getInt("smart_delay_" + dialogId, 180);
                                    i24 = i31;
                                } else {
                                    i24 = 2;
                                    i25 = 180;
                                }
                                if (i24 != 0) {
                                    Point point = this.smartNotificationsDialogs.get(dialogId);
                                    if (point == null) {
                                        str = "color_";
                                        str2 = "currentAccount";
                                        this.smartNotificationsDialogs.put(dialogId, new Point(1, (int) (System.currentTimeMillis() / 1000)));
                                    } else {
                                        str = "color_";
                                        str2 = "currentAccount";
                                        if (point.y + i25 < System.currentTimeMillis() / 1000) {
                                            point.set(1, (int) (System.currentTimeMillis() / 1000));
                                        } else {
                                            int i32 = point.x;
                                            if (i32 < i24) {
                                                point.set(i32 + 1, (int) (System.currentTimeMillis() / 1000));
                                            } else {
                                                z11 = true;
                                            }
                                        }
                                    }
                                } else {
                                    str = "color_";
                                    str2 = "currentAccount";
                                }
                            } catch (Exception e) {
                                e = e;
                                exc = e;
                                FileLog.e(exc);
                                return;
                            }
                        }
                        String path = Settings.System.DEFAULT_NOTIFICATION_URI.getPath();
                        boolean z12 = notificationsSettings.getBoolean("EnableInAppSounds", true);
                        boolean z13 = notificationsSettings.getBoolean("EnableInAppVibrate", true);
                        boolean z14 = notificationsSettings.getBoolean("EnableInAppPreview", true);
                        boolean z15 = notificationsSettings.getBoolean(ContentMetadata.KEY_CUSTOM_PREFIX + dialogId, false);
                        if (z15) {
                            int i33 = notificationsSettings.getInt("vibrate_" + dialogId, 0);
                            i2 = notificationsSettings.getInt("priority_" + dialogId, 3);
                            str3 = notificationsSettings.getString("sound_path_" + dialogId, null);
                            i3 = i33;
                        } else {
                            i2 = 3;
                            str3 = null;
                            i3 = 0;
                        }
                        if (i27 != 0) {
                            if (z10) {
                                if (str3 != null && str3.equals(path)) {
                                    str3 = null;
                                } else if (str3 == null) {
                                    str3 = notificationsSettings.getString("ChannelSoundPath", path);
                                }
                                z3 = false;
                                int i34 = notificationsSettings.getInt("vibrate_channel", 0);
                                i30 = notificationsSettings.getInt("priority_channel", 1);
                                i29 = notificationsSettings.getInt("ChannelLed", -16776961);
                                i4 = i34;
                            } else {
                                z3 = false;
                                if (str3 != null && str3.equals(path)) {
                                    str3 = null;
                                } else if (str3 == null) {
                                    str3 = notificationsSettings.getString("GroupSoundPath", path);
                                }
                                int i35 = notificationsSettings.getInt("vibrate_group", 0);
                                i30 = notificationsSettings.getInt("priority_group", 1);
                                i29 = notificationsSettings.getInt("GroupLed", -16776961);
                                i4 = i35;
                            }
                        } else {
                            z3 = false;
                            if (i28 == 0) {
                                i4 = 0;
                            } else {
                                if (str3 != null && str3.equals(path)) {
                                    str3 = null;
                                } else if (str3 == null) {
                                    str3 = notificationsSettings.getString("GlobalSoundPath", path);
                                }
                                int i36 = notificationsSettings.getInt("vibrate_messages", 0);
                                i30 = notificationsSettings.getInt("priority_messages", 1);
                                i29 = notificationsSettings.getInt("MessagesLed", -16776961);
                                i4 = i36;
                            }
                        }
                        if (!z15) {
                            str4 = str3;
                        } else {
                            StringBuilder sb2 = new StringBuilder();
                            str4 = str3;
                            String str18 = str;
                            sb2.append(str18);
                            sb2.append(dialogId);
                            if (notificationsSettings.contains(sb2.toString())) {
                                i29 = notificationsSettings.getInt(str18 + dialogId, 0);
                            }
                        }
                        if (i2 == 3) {
                            i5 = i30;
                        } else {
                            i5 = i2;
                        }
                        if (i4 != 4) {
                            z4 = z3;
                        } else {
                            z4 = true;
                            i4 = 0;
                        }
                        if ((i4 == 2 && (i3 == 1 || i3 == 3)) || ((i4 != 2 && i3 == 2) || (i3 != 0 && i3 != 4))) {
                            i4 = i3;
                        }
                        if (ApplicationLoader.mainInterfacePaused) {
                            i6 = i4;
                            i7 = 2;
                            str5 = str4;
                        } else {
                            if (z12) {
                                str17 = str4;
                            } else {
                                str17 = null;
                            }
                            if (!z13) {
                                i4 = 2;
                            }
                            if (1 == 0) {
                                i5 = 0;
                                str5 = str17;
                                i6 = i4;
                                i7 = 2;
                            } else {
                                int i37 = i4;
                                i7 = 2;
                                if (i5 != 2) {
                                    str5 = str17;
                                    i6 = i37;
                                } else {
                                    i5 = 1;
                                    str5 = str17;
                                    i6 = i37;
                                }
                            }
                        }
                        if (!z4 || i6 == i7) {
                            i8 = i6;
                        } else {
                            try {
                                ringerMode = audioManager.getRingerMode();
                            } catch (Exception e2) {
                                i8 = i6;
                                FileLog.e(e2);
                            }
                            if (ringerMode != 0) {
                                i23 = i6;
                                if (ringerMode != 1) {
                                    i9 = 2;
                                    long[] jArr2 = null;
                                    int i38 = 0;
                                    Uri uri4 = null;
                                    if (Build.VERSION.SDK_INT >= 26) {
                                        if (i9 == 2) {
                                            jArr2 = new long[]{0, 0};
                                        } else if (i9 == 1) {
                                            jArr2 = new long[]{0, 100, 0, 100};
                                        } else {
                                            if (i9 != 0 && i9 != 4) {
                                                if (i9 == 3) {
                                                    jArr2 = new long[]{0, 1000};
                                                }
                                            }
                                            jArr2 = new long[0];
                                        }
                                        String str19 = str5;
                                        if (str19 != null && !str19.equals("NoSound")) {
                                            if (str19.equals(path)) {
                                                uri3 = Settings.System.DEFAULT_NOTIFICATION_URI;
                                            } else {
                                                uri3 = Uri.parse(str19);
                                            }
                                        } else {
                                            uri3 = null;
                                        }
                                        if (i5 == 0) {
                                            i38 = 3;
                                            str5 = str19;
                                            uri4 = uri3;
                                        } else {
                                            str5 = str19;
                                            if (i5 != 1 && i5 != 2) {
                                                if (i5 == 4) {
                                                    i38 = 1;
                                                    uri4 = uri3;
                                                } else if (i5 != 5) {
                                                    uri4 = uri3;
                                                } else {
                                                    i38 = 2;
                                                    uri4 = uri3;
                                                }
                                            }
                                            i38 = 4;
                                            uri4 = uri3;
                                        }
                                    }
                                    if (!z11) {
                                        i10 = i5;
                                        i11 = i9;
                                        i12 = i29;
                                        str6 = str5;
                                    } else {
                                        i10 = 0;
                                        i11 = 0;
                                        i12 = 0;
                                        str6 = null;
                                    }
                                    int i39 = i11;
                                    Intent intent2 = new Intent(ApplicationLoader.applicationContext, (Class<?>) LaunchActivity.class);
                                    StringBuilder sb3 = new StringBuilder();
                                    sb3.append("com.tmessages.openchat");
                                    int i40 = i10;
                                    sb3.append(Math.random());
                                    sb3.append(Integer.MAX_VALUE);
                                    intent2.setAction(sb3.toString());
                                    if (((int) dialogId) != 0) {
                                        if (this.pushDialogs.size() == 1) {
                                            if (i27 != 0) {
                                                intent2.putExtra("chatId", i27);
                                            } else if (i28 != 0) {
                                                intent2.putExtra("userId", i28);
                                            }
                                        }
                                        if (!AndroidUtilities.needShowPasscode(false) && !SharedConfig.isWaitingForPasscodeEnter) {
                                            if (this.pushDialogs.size() != 1 || Build.VERSION.SDK_INT >= 28) {
                                                i13 = i12;
                                                user = user3;
                                            } else if (chat != null) {
                                                if (chat.photo == null || chat.photo.photo_small == null || chat.photo.photo_small.volume_id == 0 || chat.photo.photo_small.local_id == 0) {
                                                    i13 = i12;
                                                    user = user3;
                                                } else {
                                                    fileLocation = chat.photo.photo_small;
                                                    i13 = i12;
                                                    user = user3;
                                                    String str20 = str2;
                                                    intent2.putExtra(str20, this.currentAccount);
                                                    PendingIntent activity = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent2, 1073741824);
                                                    if (((i27 != 0 || chat != null) && user != null) || !messageObject4.isFcmMessage()) {
                                                        messageObject = messageObject4;
                                                        boolean z16 = true;
                                                        if (chat == null) {
                                                            name = chat.title;
                                                            z5 = z16;
                                                        } else {
                                                            name = UserObject.getName(user);
                                                            z5 = z16;
                                                        }
                                                    } else {
                                                        messageObject = messageObject4;
                                                        z5 = true;
                                                        name = messageObject.localName;
                                                    }
                                                    if (((int) dialogId) == 0) {
                                                        i14 = i27;
                                                        if (this.pushDialogs.size() <= 1 && !AndroidUtilities.needShowPasscode(false) && !SharedConfig.isWaitingForPasscodeEnter) {
                                                            string = name;
                                                            r27 = z5;
                                                            if (UserConfig.getActivatedAccountsCount() > 1) {
                                                                if (this.pushDialogs.size() == 1) {
                                                                    str7 = UserObject.getFirstName(getUserConfig().getCurrentUser());
                                                                } else {
                                                                    str7 = UserObject.getFirstName(getUserConfig().getCurrentUser()) + "・";
                                                                }
                                                            } else {
                                                                str7 = "";
                                                            }
                                                            long j4 = dialogId;
                                                            if (this.pushDialogs.size() == 1 && Build.VERSION.SDK_INT >= 23) {
                                                                str8 = path;
                                                                sb = str7;
                                                                ?? color = new NotificationCompat.Builder(ApplicationLoader.applicationContext).setContentTitle(string).setSmallIcon(R.mipmap.notification).setAutoCancel(true).setNumber(this.total_unread_count).setContentIntent(activity).setGroup(this.notificationGroup).setGroupSummary(true).setShowWhen(true).setWhen(messageObject.messageOwner.date * 1000).setColor(-15618822);
                                                                long[] jArr3 = null;
                                                                color.setCategory(NotificationCompat.CATEGORY_MESSAGE);
                                                                if (chat == null || user == null || user.phone == null || user.phone.length() <= 0) {
                                                                    pendingIntent = activity;
                                                                } else {
                                                                    StringBuilder sb4 = new StringBuilder();
                                                                    pendingIntent = activity;
                                                                    sb4.append("tel:+");
                                                                    sb4.append(user.phone);
                                                                    color.addPerson(sb4.toString());
                                                                }
                                                                String str21 = null;
                                                                if (this.pushMessages.size() == 1) {
                                                                    MessageObject messageObject5 = this.pushMessages.get(0);
                                                                    user2 = user;
                                                                    boolean[] zArr = new boolean[1];
                                                                    i15 = 0;
                                                                    String stringForMessage = getStringForMessage(messageObject5, false, zArr, null);
                                                                    String str22 = stringForMessage;
                                                                    boolean z17 = messageObject5.messageOwner.silent;
                                                                    if (str22 == null) {
                                                                        return;
                                                                    }
                                                                    if (r27 == null) {
                                                                        z9 = z17;
                                                                    } else if (chat != null) {
                                                                        StringBuilder sb5 = new StringBuilder();
                                                                        z9 = z17;
                                                                        sb5.append(" @ ");
                                                                        sb5.append(string);
                                                                        str22 = str22.replace(sb5.toString(), "");
                                                                    } else {
                                                                        z9 = z17;
                                                                        if (zArr[0]) {
                                                                            str22 = str22.replace(string + ": ", "");
                                                                        } else {
                                                                            str22 = str22.replace(string + " ", "");
                                                                        }
                                                                    }
                                                                    color.setContentText(str22);
                                                                    color.setStyle(new NotificationCompat.BigTextStyle().bigText(str22));
                                                                    str9 = str6;
                                                                    str10 = str20;
                                                                    fileLocation2 = fileLocation;
                                                                    str11 = stringForMessage;
                                                                    boolean z18 = z9;
                                                                    uri = null;
                                                                    z6 = z18;
                                                                } else {
                                                                    user2 = user;
                                                                    i15 = 0;
                                                                    color.setContentText(sb);
                                                                    NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
                                                                    inboxStyle.setBigContentTitle(string);
                                                                    int min = Math.min(10, this.pushMessages.size());
                                                                    boolean[] zArr2 = new boolean[1];
                                                                    int i41 = 0;
                                                                    ?? r9 = 2;
                                                                    uri = null;
                                                                    while (i41 < min) {
                                                                        int i42 = min;
                                                                        MessageObject messageObject6 = this.pushMessages.get(i41);
                                                                        String str23 = str6;
                                                                        TLRPC.FileLocation fileLocation5 = fileLocation;
                                                                        String stringForMessage2 = getStringForMessage(messageObject6, false, zArr2, null);
                                                                        if (stringForMessage2 != null) {
                                                                            str12 = str20;
                                                                            int i43 = i;
                                                                            if (messageObject6.messageOwner.date <= i43) {
                                                                                i = i43;
                                                                            } else {
                                                                                r9 = r9;
                                                                                if (r9 == 2) {
                                                                                    str21 = stringForMessage2;
                                                                                    r9 = messageObject6.messageOwner.silent;
                                                                                }
                                                                                i = i43;
                                                                                if (this.pushDialogs.size() == 1 && r27 != null) {
                                                                                    if (chat != null) {
                                                                                        stringForMessage2 = stringForMessage2.replace(" @ " + string, "");
                                                                                    } else if (zArr2[0]) {
                                                                                        stringForMessage2 = stringForMessage2.replace(string + ": ", "");
                                                                                    } else {
                                                                                        stringForMessage2 = stringForMessage2.replace(string + " ", "");
                                                                                    }
                                                                                }
                                                                                inboxStyle.addLine(stringForMessage2);
                                                                            }
                                                                        } else {
                                                                            str12 = str20;
                                                                        }
                                                                        i41++;
                                                                        min = i42;
                                                                        str6 = str23;
                                                                        fileLocation = fileLocation5;
                                                                        str20 = str12;
                                                                        r9 = r9;
                                                                    }
                                                                    str9 = str6;
                                                                    str10 = str20;
                                                                    fileLocation2 = fileLocation;
                                                                    inboxStyle.setSummaryText(sb);
                                                                    color.setStyle(inboxStyle);
                                                                    z6 = r9 == true ? 1 : 0;
                                                                    str11 = str21;
                                                                }
                                                                Intent intent3 = new Intent(ApplicationLoader.applicationContext, (Class<?>) NotificationDismissReceiver.class);
                                                                intent3.putExtra("messageDate", messageObject.messageOwner.date);
                                                                String str24 = str10;
                                                                intent3.putExtra(str24, this.currentAccount);
                                                                color.setDeleteIntent(PendingIntent.getBroadcast(ApplicationLoader.applicationContext, 1, intent3, 134217728));
                                                                if (fileLocation2 == null) {
                                                                    fileLocation3 = fileLocation2;
                                                                } else {
                                                                    fileLocation3 = fileLocation2;
                                                                    BitmapDrawable imageFromMemory = ImageLoader.getInstance().getImageFromMemory(fileLocation3, null, "50_50");
                                                                    if (imageFromMemory != null) {
                                                                        color.setLargeIcon(imageFromMemory.getBitmap());
                                                                    } else {
                                                                        try {
                                                                            File pathToAttach = FileLoader.getPathToAttach(fileLocation3, true);
                                                                            if (pathToAttach.exists()) {
                                                                                float dp = 160.0f / AndroidUtilities.dp(50.0f);
                                                                                BitmapFactory.Options options = new BitmapFactory.Options();
                                                                                try {
                                                                                    options.inSampleSize = dp < 1.0f ? 1 : (int) dp;
                                                                                    Bitmap decodeFile = BitmapFactory.decodeFile(pathToAttach.getAbsolutePath(), options);
                                                                                    if (decodeFile != null) {
                                                                                        color.setLargeIcon(decodeFile);
                                                                                    }
                                                                                } catch (Throwable th) {
                                                                                }
                                                                            }
                                                                        } catch (Throwable th2) {
                                                                        }
                                                                    }
                                                                }
                                                                if (!z) {
                                                                    i16 = i40;
                                                                } else {
                                                                    if (!z6) {
                                                                        if (i40 == 0) {
                                                                            try {
                                                                                color.setPriority(0);
                                                                                if (Build.VERSION.SDK_INT < 26) {
                                                                                    i16 = i40;
                                                                                } else {
                                                                                    i15 = 3;
                                                                                    i16 = i40;
                                                                                }
                                                                            } catch (Exception e3) {
                                                                                exc = e3;
                                                                                FileLog.e(exc);
                                                                                return;
                                                                            }
                                                                        } else {
                                                                            i16 = i40;
                                                                            if (i16 == 1 || i16 == 2) {
                                                                                color.setPriority(1);
                                                                                if (Build.VERSION.SDK_INT >= 26) {
                                                                                    i15 = 4;
                                                                                }
                                                                            } else if (i16 == 4) {
                                                                                color.setPriority(-2);
                                                                                if (Build.VERSION.SDK_INT >= 26) {
                                                                                    i15 = 1;
                                                                                }
                                                                            } else if (i16 == 5) {
                                                                                color.setPriority(-1);
                                                                                if (Build.VERSION.SDK_INT >= 26) {
                                                                                    i15 = 2;
                                                                                }
                                                                            }
                                                                        }
                                                                        if (!z6 || z11) {
                                                                            i17 = i16;
                                                                            str13 = string;
                                                                            fileLocation4 = fileLocation3;
                                                                            i18 = i39;
                                                                            i19 = i13;
                                                                            str14 = str9;
                                                                            long[] jArr4 = {0, 0};
                                                                            color.setVibrate(jArr4);
                                                                            jArr3 = jArr4;
                                                                            str15 = str11;
                                                                        } else {
                                                                            if (!ApplicationLoader.mainInterfacePaused && !z14) {
                                                                                i17 = i16;
                                                                                str13 = string;
                                                                                if (!MediaController.getInstance().isRecordingAudio()) {
                                                                                    fileLocation4 = fileLocation3;
                                                                                    str14 = str9;
                                                                                } else if (str9 != null) {
                                                                                    str14 = str9;
                                                                                    if (str14.equals("NoSound")) {
                                                                                        fileLocation4 = fileLocation3;
                                                                                    } else if (Build.VERSION.SDK_INT >= 26) {
                                                                                        String str25 = str8;
                                                                                        if (str14.equals(str25)) {
                                                                                            uri2 = Settings.System.DEFAULT_NOTIFICATION_URI;
                                                                                            str8 = str25;
                                                                                            fileLocation4 = fileLocation3;
                                                                                        } else {
                                                                                            uri2 = Uri.parse(str14);
                                                                                            str8 = str25;
                                                                                            fileLocation4 = fileLocation3;
                                                                                        }
                                                                                        if (i13 != 0) {
                                                                                            i19 = i13;
                                                                                        } else {
                                                                                            i19 = i13;
                                                                                            color.setLights(i19, 1000, 1000);
                                                                                        }
                                                                                        i18 = i39;
                                                                                        if (i18 != 2 && !MediaController.getInstance().isRecordingAudio()) {
                                                                                            if (i18 != 1) {
                                                                                                long[] jArr5 = {0, 100, 0, 100};
                                                                                                color.setVibrate(jArr5);
                                                                                                uri = uri2;
                                                                                                jArr3 = jArr5;
                                                                                                str15 = str11;
                                                                                            } else {
                                                                                                if (i18 != 0 && i18 != 4) {
                                                                                                    if (i18 != 3) {
                                                                                                        uri = uri2;
                                                                                                        str15 = str11;
                                                                                                    } else {
                                                                                                        long[] jArr6 = {0, 1000};
                                                                                                        color.setVibrate(jArr6);
                                                                                                        uri = uri2;
                                                                                                        jArr3 = jArr6;
                                                                                                        str15 = str11;
                                                                                                    }
                                                                                                }
                                                                                                color.setDefaults(2);
                                                                                                uri = uri2;
                                                                                                jArr3 = new long[0];
                                                                                                str15 = str11;
                                                                                            }
                                                                                        }
                                                                                        long[] jArr7 = {0, 0};
                                                                                        color.setVibrate(jArr7);
                                                                                        uri = uri2;
                                                                                        jArr3 = jArr7;
                                                                                        str15 = str11;
                                                                                    } else {
                                                                                        String str26 = str8;
                                                                                        if (str14.equals(str26)) {
                                                                                            color.setSound(Settings.System.DEFAULT_NOTIFICATION_URI, 5);
                                                                                            str8 = str26;
                                                                                            fileLocation4 = fileLocation3;
                                                                                        } else if (Build.VERSION.SDK_INT < 24 || !str14.startsWith("file://") || AndroidUtilities.isInternalUri(Uri.parse(str14))) {
                                                                                            str8 = str26;
                                                                                            fileLocation4 = fileLocation3;
                                                                                            color.setSound(Uri.parse(str14), 5);
                                                                                        } else {
                                                                                            try {
                                                                                                str8 = str26;
                                                                                                try {
                                                                                                    fileLocation4 = fileLocation3;
                                                                                                } catch (Exception e4) {
                                                                                                    fileLocation4 = fileLocation3;
                                                                                                }
                                                                                                try {
                                                                                                    Uri uriForFile = FileProvider.getUriForFile(ApplicationLoader.applicationContext, "im.skmzhmurqt.messenger.provider", new File(str14.replace("file://", "")));
                                                                                                    ApplicationLoader.applicationContext.grantUriPermission("com.android.systemui", uriForFile, 1);
                                                                                                    color.setSound(uriForFile, 5);
                                                                                                } catch (Exception e5) {
                                                                                                    color.setSound(Uri.parse(str14), 5);
                                                                                                    uri2 = uri;
                                                                                                    if (i13 != 0) {
                                                                                                    }
                                                                                                    i18 = i39;
                                                                                                    if (i18 != 2) {
                                                                                                    }
                                                                                                    long[] jArr72 = {0, 0};
                                                                                                    color.setVibrate(jArr72);
                                                                                                    uri = uri2;
                                                                                                    jArr3 = jArr72;
                                                                                                    str15 = str11;
                                                                                                    long[] jArr8 = null;
                                                                                                    if (!AndroidUtilities.needShowPasscode(false)) {
                                                                                                    }
                                                                                                    str16 = str14;
                                                                                                    messageObject2 = messageObject;
                                                                                                    i20 = i18;
                                                                                                    i21 = i19;
                                                                                                    j2 = j4;
                                                                                                    jArr = null;
                                                                                                    if (jArr == null) {
                                                                                                    }
                                                                                                    if (Build.VERSION.SDK_INT < 26) {
                                                                                                    }
                                                                                                    showExtraNotifications(color, z7, sb);
                                                                                                    scheduleNotificationRepeat();
                                                                                                    return;
                                                                                                }
                                                                                            } catch (Exception e6) {
                                                                                                str8 = str26;
                                                                                                fileLocation4 = fileLocation3;
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                } else {
                                                                                    fileLocation4 = fileLocation3;
                                                                                    str14 = str9;
                                                                                }
                                                                                uri2 = uri;
                                                                                if (i13 != 0) {
                                                                                }
                                                                                i18 = i39;
                                                                                if (i18 != 2) {
                                                                                    if (i18 != 1) {
                                                                                    }
                                                                                }
                                                                                long[] jArr722 = {0, 0};
                                                                                color.setVibrate(jArr722);
                                                                                uri = uri2;
                                                                                jArr3 = jArr722;
                                                                                str15 = str11;
                                                                            }
                                                                            i17 = i16;
                                                                            str13 = string;
                                                                            color.setTicker(str11);
                                                                            if (!MediaController.getInstance().isRecordingAudio()) {
                                                                            }
                                                                            uri2 = uri;
                                                                            if (i13 != 0) {
                                                                            }
                                                                            i18 = i39;
                                                                            if (i18 != 2) {
                                                                            }
                                                                            long[] jArr7222 = {0, 0};
                                                                            color.setVibrate(jArr7222);
                                                                            uri = uri2;
                                                                            jArr3 = jArr7222;
                                                                            str15 = str11;
                                                                        }
                                                                        long[] jArr82 = null;
                                                                        if (!AndroidUtilities.needShowPasscode(false) || SharedConfig.isWaitingForPasscodeEnter || messageObject.getDialogId() != 777000) {
                                                                            str16 = str14;
                                                                            messageObject2 = messageObject;
                                                                            i20 = i18;
                                                                            i21 = i19;
                                                                            j2 = j4;
                                                                        } else if (messageObject.messageOwner.reply_markup == null) {
                                                                            str16 = str14;
                                                                            messageObject2 = messageObject;
                                                                            i20 = i18;
                                                                            i21 = i19;
                                                                            j2 = j4;
                                                                        } else {
                                                                            ArrayList<TLRPC.TL_keyboardButtonRow> arrayList2 = messageObject.messageOwner.reply_markup.rows;
                                                                            int i44 = 0;
                                                                            int size = arrayList2.size();
                                                                            while (true) {
                                                                                str16 = str14;
                                                                                int i45 = size;
                                                                                if (i44 >= i45) {
                                                                                    break;
                                                                                }
                                                                                TLRPC.TL_keyboardButtonRow tL_keyboardButtonRow = arrayList2.get(i44);
                                                                                long[] jArr9 = jArr82;
                                                                                int size2 = tL_keyboardButtonRow.buttons.size();
                                                                                int i46 = i18;
                                                                                int i47 = 0;
                                                                                while (i47 < size2) {
                                                                                    int i48 = size2;
                                                                                    TLRPC.KeyboardButton keyboardButton = tL_keyboardButtonRow.buttons.get(i47);
                                                                                    TLRPC.TL_keyboardButtonRow tL_keyboardButtonRow2 = tL_keyboardButtonRow;
                                                                                    if (keyboardButton instanceof TLRPC.TL_keyboardButtonCallback) {
                                                                                        arrayList = arrayList2;
                                                                                        i22 = i19;
                                                                                        Intent intent4 = new Intent(ApplicationLoader.applicationContext, (Class<?>) NotificationCallbackReceiver.class);
                                                                                        intent4.putExtra(str24, this.currentAccount);
                                                                                        intent = intent3;
                                                                                        z8 = z6;
                                                                                        j3 = j4;
                                                                                        intent4.putExtra("did", j3);
                                                                                        if (keyboardButton.data != null) {
                                                                                            intent4.putExtra("data", keyboardButton.data);
                                                                                        }
                                                                                        intent4.putExtra("mid", messageObject.getId());
                                                                                        String str27 = keyboardButton.text;
                                                                                        Context context = ApplicationLoader.applicationContext;
                                                                                        int i49 = this.lastButtonId;
                                                                                        messageObject3 = messageObject;
                                                                                        this.lastButtonId = i49 + 1;
                                                                                        color.addAction(0, str27, PendingIntent.getBroadcast(context, i49, intent4, 134217728));
                                                                                        jArr9 = 1;
                                                                                    } else {
                                                                                        messageObject3 = messageObject;
                                                                                        arrayList = arrayList2;
                                                                                        i22 = i19;
                                                                                        intent = intent3;
                                                                                        z8 = z6;
                                                                                        j3 = j4;
                                                                                    }
                                                                                    i47++;
                                                                                    j4 = j3;
                                                                                    size2 = i48;
                                                                                    tL_keyboardButtonRow = tL_keyboardButtonRow2;
                                                                                    arrayList2 = arrayList;
                                                                                    z6 = z8;
                                                                                    intent3 = intent;
                                                                                    messageObject = messageObject3;
                                                                                    i19 = i22;
                                                                                }
                                                                                i44++;
                                                                                jArr82 = jArr9;
                                                                                size = i45;
                                                                                z6 = z6;
                                                                                intent3 = intent3;
                                                                                messageObject = messageObject;
                                                                                i18 = i46;
                                                                                str14 = str16;
                                                                            }
                                                                            jArr = jArr82;
                                                                            messageObject2 = messageObject;
                                                                            i20 = i18;
                                                                            i21 = i19;
                                                                            j2 = j4;
                                                                            if (jArr == null && Build.VERSION.SDK_INT < 24 && SharedConfig.passcodeHash.length() == 0 && hasMessagesToReply()) {
                                                                                Intent intent5 = new Intent(ApplicationLoader.applicationContext, (Class<?>) PopupReplyReceiver.class);
                                                                                intent5.putExtra(str24, this.currentAccount);
                                                                                if (Build.VERSION.SDK_INT > 19) {
                                                                                    color.addAction(R.drawable.ic_ab_reply2, LocaleController.getString("Reply", R.string.Reply), PendingIntent.getBroadcast(ApplicationLoader.applicationContext, 2, intent5, 134217728));
                                                                                } else {
                                                                                    color.addAction(R.drawable.ic_ab_reply, LocaleController.getString("Reply", R.string.Reply), PendingIntent.getBroadcast(ApplicationLoader.applicationContext, 2, intent5, 134217728));
                                                                                }
                                                                            }
                                                                            if (Build.VERSION.SDK_INT < 26) {
                                                                                z7 = z;
                                                                                try {
                                                                                    color.setChannelId(validateChannelId(j2, name, jArr3, i21, uri, i15, jArr2, uri4, i38));
                                                                                } catch (Exception e7) {
                                                                                    e = e7;
                                                                                    exc = e;
                                                                                    FileLog.e(exc);
                                                                                    return;
                                                                                }
                                                                            } else {
                                                                                z7 = z;
                                                                            }
                                                                            showExtraNotifications(color, z7, sb);
                                                                            scheduleNotificationRepeat();
                                                                            return;
                                                                        }
                                                                        jArr = null;
                                                                        if (jArr == null) {
                                                                            Intent intent52 = new Intent(ApplicationLoader.applicationContext, (Class<?>) PopupReplyReceiver.class);
                                                                            intent52.putExtra(str24, this.currentAccount);
                                                                            if (Build.VERSION.SDK_INT > 19) {
                                                                            }
                                                                        }
                                                                        if (Build.VERSION.SDK_INT < 26) {
                                                                        }
                                                                        showExtraNotifications(color, z7, sb);
                                                                        scheduleNotificationRepeat();
                                                                        return;
                                                                    }
                                                                    i16 = i40;
                                                                }
                                                                color.setPriority(-1);
                                                                if (Build.VERSION.SDK_INT >= 26) {
                                                                    i15 = 2;
                                                                }
                                                                if (!z6) {
                                                                }
                                                                i17 = i16;
                                                                str13 = string;
                                                                fileLocation4 = fileLocation3;
                                                                i18 = i39;
                                                                i19 = i13;
                                                                str14 = str9;
                                                                long[] jArr42 = {0, 0};
                                                                color.setVibrate(jArr42);
                                                                jArr3 = jArr42;
                                                                str15 = str11;
                                                                long[] jArr822 = null;
                                                                if (!AndroidUtilities.needShowPasscode(false)) {
                                                                }
                                                                str16 = str14;
                                                                messageObject2 = messageObject;
                                                                i20 = i18;
                                                                i21 = i19;
                                                                j2 = j4;
                                                                jArr = null;
                                                                if (jArr == null) {
                                                                }
                                                                if (Build.VERSION.SDK_INT < 26) {
                                                                }
                                                                showExtraNotifications(color, z7, sb);
                                                                scheduleNotificationRepeat();
                                                                return;
                                                            }
                                                            if (this.pushDialogs.size() == 1) {
                                                                str8 = path;
                                                                sb = str7 + LocaleController.formatPluralString("NewMessages", this.total_unread_count);
                                                            } else {
                                                                StringBuilder sb6 = new StringBuilder();
                                                                sb6.append(str7);
                                                                str8 = path;
                                                                sb6.append(LocaleController.formatString("NotificationMessagesPeopleDisplayOrder", R.string.NotificationMessagesPeopleDisplayOrder, LocaleController.formatPluralString("NewMessages", this.total_unread_count), LocaleController.formatPluralString("FromChats", this.pushDialogs.size())));
                                                                sb = sb6.toString();
                                                            }
                                                            ?? color2 = new NotificationCompat.Builder(ApplicationLoader.applicationContext).setContentTitle(string).setSmallIcon(R.mipmap.notification).setAutoCancel(true).setNumber(this.total_unread_count).setContentIntent(activity).setGroup(this.notificationGroup).setGroupSummary(true).setShowWhen(true).setWhen(messageObject.messageOwner.date * 1000).setColor(-15618822);
                                                            long[] jArr32 = null;
                                                            color2.setCategory(NotificationCompat.CATEGORY_MESSAGE);
                                                            if (chat == null) {
                                                            }
                                                            pendingIntent = activity;
                                                            String str212 = null;
                                                            if (this.pushMessages.size() == 1) {
                                                            }
                                                            Intent intent32 = new Intent(ApplicationLoader.applicationContext, (Class<?>) NotificationDismissReceiver.class);
                                                            intent32.putExtra("messageDate", messageObject.messageOwner.date);
                                                            String str242 = str10;
                                                            intent32.putExtra(str242, this.currentAccount);
                                                            color2.setDeleteIntent(PendingIntent.getBroadcast(ApplicationLoader.applicationContext, 1, intent32, 134217728));
                                                            if (fileLocation2 == null) {
                                                            }
                                                            if (!z) {
                                                            }
                                                            color2.setPriority(-1);
                                                            if (Build.VERSION.SDK_INT >= 26) {
                                                            }
                                                            if (!z6) {
                                                            }
                                                            i17 = i16;
                                                            str13 = string;
                                                            fileLocation4 = fileLocation3;
                                                            i18 = i39;
                                                            i19 = i13;
                                                            str14 = str9;
                                                            long[] jArr422 = {0, 0};
                                                            color2.setVibrate(jArr422);
                                                            jArr32 = jArr422;
                                                            str15 = str11;
                                                            long[] jArr8222 = null;
                                                            if (!AndroidUtilities.needShowPasscode(false)) {
                                                            }
                                                            str16 = str14;
                                                            messageObject2 = messageObject;
                                                            i20 = i18;
                                                            i21 = i19;
                                                            j2 = j4;
                                                            jArr = null;
                                                            if (jArr == null) {
                                                            }
                                                            if (Build.VERSION.SDK_INT < 26) {
                                                            }
                                                            showExtraNotifications(color2, z7, sb);
                                                            scheduleNotificationRepeat();
                                                            return;
                                                        }
                                                    } else {
                                                        i14 = i27;
                                                    }
                                                    r27 = null;
                                                    string = LocaleController.getString("AppName", R.string.AppName);
                                                    if (UserConfig.getActivatedAccountsCount() > 1) {
                                                    }
                                                    long j42 = dialogId;
                                                    if (this.pushDialogs.size() == 1) {
                                                        str8 = path;
                                                        sb = str7;
                                                        ?? color22 = new NotificationCompat.Builder(ApplicationLoader.applicationContext).setContentTitle(string).setSmallIcon(R.mipmap.notification).setAutoCancel(true).setNumber(this.total_unread_count).setContentIntent(activity).setGroup(this.notificationGroup).setGroupSummary(true).setShowWhen(true).setWhen(messageObject.messageOwner.date * 1000).setColor(-15618822);
                                                        long[] jArr322 = null;
                                                        color22.setCategory(NotificationCompat.CATEGORY_MESSAGE);
                                                        if (chat == null) {
                                                        }
                                                        pendingIntent = activity;
                                                        String str2122 = null;
                                                        if (this.pushMessages.size() == 1) {
                                                        }
                                                        Intent intent322 = new Intent(ApplicationLoader.applicationContext, (Class<?>) NotificationDismissReceiver.class);
                                                        intent322.putExtra("messageDate", messageObject.messageOwner.date);
                                                        String str2422 = str10;
                                                        intent322.putExtra(str2422, this.currentAccount);
                                                        color22.setDeleteIntent(PendingIntent.getBroadcast(ApplicationLoader.applicationContext, 1, intent322, 134217728));
                                                        if (fileLocation2 == null) {
                                                        }
                                                        if (!z) {
                                                        }
                                                        color22.setPriority(-1);
                                                        if (Build.VERSION.SDK_INT >= 26) {
                                                        }
                                                        if (!z6) {
                                                        }
                                                        i17 = i16;
                                                        str13 = string;
                                                        fileLocation4 = fileLocation3;
                                                        i18 = i39;
                                                        i19 = i13;
                                                        str14 = str9;
                                                        long[] jArr4222 = {0, 0};
                                                        color22.setVibrate(jArr4222);
                                                        jArr322 = jArr4222;
                                                        str15 = str11;
                                                        long[] jArr82222 = null;
                                                        if (!AndroidUtilities.needShowPasscode(false)) {
                                                        }
                                                        str16 = str14;
                                                        messageObject2 = messageObject;
                                                        i20 = i18;
                                                        i21 = i19;
                                                        j2 = j42;
                                                        jArr = null;
                                                        if (jArr == null) {
                                                        }
                                                        if (Build.VERSION.SDK_INT < 26) {
                                                        }
                                                        showExtraNotifications(color22, z7, sb);
                                                        scheduleNotificationRepeat();
                                                        return;
                                                    }
                                                    if (this.pushDialogs.size() == 1) {
                                                    }
                                                    ?? color222 = new NotificationCompat.Builder(ApplicationLoader.applicationContext).setContentTitle(string).setSmallIcon(R.mipmap.notification).setAutoCancel(true).setNumber(this.total_unread_count).setContentIntent(activity).setGroup(this.notificationGroup).setGroupSummary(true).setShowWhen(true).setWhen(messageObject.messageOwner.date * 1000).setColor(-15618822);
                                                    long[] jArr3222 = null;
                                                    color222.setCategory(NotificationCompat.CATEGORY_MESSAGE);
                                                    if (chat == null) {
                                                    }
                                                    pendingIntent = activity;
                                                    String str21222 = null;
                                                    if (this.pushMessages.size() == 1) {
                                                    }
                                                    Intent intent3222 = new Intent(ApplicationLoader.applicationContext, (Class<?>) NotificationDismissReceiver.class);
                                                    intent3222.putExtra("messageDate", messageObject.messageOwner.date);
                                                    String str24222 = str10;
                                                    intent3222.putExtra(str24222, this.currentAccount);
                                                    color222.setDeleteIntent(PendingIntent.getBroadcast(ApplicationLoader.applicationContext, 1, intent3222, 134217728));
                                                    if (fileLocation2 == null) {
                                                    }
                                                    if (!z) {
                                                    }
                                                    color222.setPriority(-1);
                                                    if (Build.VERSION.SDK_INT >= 26) {
                                                    }
                                                    if (!z6) {
                                                    }
                                                    i17 = i16;
                                                    str13 = string;
                                                    fileLocation4 = fileLocation3;
                                                    i18 = i39;
                                                    i19 = i13;
                                                    str14 = str9;
                                                    long[] jArr42222 = {0, 0};
                                                    color222.setVibrate(jArr42222);
                                                    jArr3222 = jArr42222;
                                                    str15 = str11;
                                                    long[] jArr822222 = null;
                                                    if (!AndroidUtilities.needShowPasscode(false)) {
                                                    }
                                                    str16 = str14;
                                                    messageObject2 = messageObject;
                                                    i20 = i18;
                                                    i21 = i19;
                                                    j2 = j42;
                                                    jArr = null;
                                                    if (jArr == null) {
                                                    }
                                                    if (Build.VERSION.SDK_INT < 26) {
                                                    }
                                                    showExtraNotifications(color222, z7, sb);
                                                    scheduleNotificationRepeat();
                                                    return;
                                                }
                                            } else if (user3 == null) {
                                                i13 = i12;
                                                user = user3;
                                            } else if (user3.photo == null || user3.photo.photo_small == null || user3.photo.photo_small.volume_id == 0 || user3.photo.photo_small.local_id == 0) {
                                                i13 = i12;
                                                user = user3;
                                            } else {
                                                fileLocation = user3.photo.photo_small;
                                                i13 = i12;
                                                user = user3;
                                                String str202 = str2;
                                                intent2.putExtra(str202, this.currentAccount);
                                                PendingIntent activity2 = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent2, 1073741824);
                                                if (i27 != 0) {
                                                }
                                                messageObject = messageObject4;
                                                boolean z162 = true;
                                                if (chat == null) {
                                                }
                                                if (((int) dialogId) == 0) {
                                                }
                                                r27 = null;
                                                string = LocaleController.getString("AppName", R.string.AppName);
                                                if (UserConfig.getActivatedAccountsCount() > 1) {
                                                }
                                                long j422 = dialogId;
                                                if (this.pushDialogs.size() == 1) {
                                                }
                                                if (this.pushDialogs.size() == 1) {
                                                }
                                                ?? color2222 = new NotificationCompat.Builder(ApplicationLoader.applicationContext).setContentTitle(string).setSmallIcon(R.mipmap.notification).setAutoCancel(true).setNumber(this.total_unread_count).setContentIntent(activity2).setGroup(this.notificationGroup).setGroupSummary(true).setShowWhen(true).setWhen(messageObject.messageOwner.date * 1000).setColor(-15618822);
                                                long[] jArr32222 = null;
                                                color2222.setCategory(NotificationCompat.CATEGORY_MESSAGE);
                                                if (chat == null) {
                                                }
                                                pendingIntent = activity2;
                                                String str212222 = null;
                                                if (this.pushMessages.size() == 1) {
                                                }
                                                Intent intent32222 = new Intent(ApplicationLoader.applicationContext, (Class<?>) NotificationDismissReceiver.class);
                                                intent32222.putExtra("messageDate", messageObject.messageOwner.date);
                                                String str242222 = str10;
                                                intent32222.putExtra(str242222, this.currentAccount);
                                                color2222.setDeleteIntent(PendingIntent.getBroadcast(ApplicationLoader.applicationContext, 1, intent32222, 134217728));
                                                if (fileLocation2 == null) {
                                                }
                                                if (!z) {
                                                }
                                                color2222.setPriority(-1);
                                                if (Build.VERSION.SDK_INT >= 26) {
                                                }
                                                if (!z6) {
                                                }
                                                i17 = i16;
                                                str13 = string;
                                                fileLocation4 = fileLocation3;
                                                i18 = i39;
                                                i19 = i13;
                                                str14 = str9;
                                                long[] jArr422222 = {0, 0};
                                                color2222.setVibrate(jArr422222);
                                                jArr32222 = jArr422222;
                                                str15 = str11;
                                                long[] jArr8222222 = null;
                                                if (!AndroidUtilities.needShowPasscode(false)) {
                                                }
                                                str16 = str14;
                                                messageObject2 = messageObject;
                                                i20 = i18;
                                                i21 = i19;
                                                j2 = j422;
                                                jArr = null;
                                                if (jArr == null) {
                                                }
                                                if (Build.VERSION.SDK_INT < 26) {
                                                }
                                                showExtraNotifications(color2222, z7, sb);
                                                scheduleNotificationRepeat();
                                                return;
                                            }
                                        }
                                        fileLocation = null;
                                        i13 = i12;
                                        user = user3;
                                        String str2022 = str2;
                                        intent2.putExtra(str2022, this.currentAccount);
                                        PendingIntent activity22 = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent2, 1073741824);
                                        if (i27 != 0) {
                                        }
                                        messageObject = messageObject4;
                                        boolean z1622 = true;
                                        if (chat == null) {
                                        }
                                        if (((int) dialogId) == 0) {
                                        }
                                        r27 = null;
                                        string = LocaleController.getString("AppName", R.string.AppName);
                                        if (UserConfig.getActivatedAccountsCount() > 1) {
                                        }
                                        long j4222 = dialogId;
                                        if (this.pushDialogs.size() == 1) {
                                        }
                                        if (this.pushDialogs.size() == 1) {
                                        }
                                        ?? color22222 = new NotificationCompat.Builder(ApplicationLoader.applicationContext).setContentTitle(string).setSmallIcon(R.mipmap.notification).setAutoCancel(true).setNumber(this.total_unread_count).setContentIntent(activity22).setGroup(this.notificationGroup).setGroupSummary(true).setShowWhen(true).setWhen(messageObject.messageOwner.date * 1000).setColor(-15618822);
                                        long[] jArr322222 = null;
                                        color22222.setCategory(NotificationCompat.CATEGORY_MESSAGE);
                                        if (chat == null) {
                                        }
                                        pendingIntent = activity22;
                                        String str2122222 = null;
                                        if (this.pushMessages.size() == 1) {
                                        }
                                        Intent intent322222 = new Intent(ApplicationLoader.applicationContext, (Class<?>) NotificationDismissReceiver.class);
                                        intent322222.putExtra("messageDate", messageObject.messageOwner.date);
                                        String str2422222 = str10;
                                        intent322222.putExtra(str2422222, this.currentAccount);
                                        color22222.setDeleteIntent(PendingIntent.getBroadcast(ApplicationLoader.applicationContext, 1, intent322222, 134217728));
                                        if (fileLocation2 == null) {
                                        }
                                        if (!z) {
                                        }
                                        color22222.setPriority(-1);
                                        if (Build.VERSION.SDK_INT >= 26) {
                                        }
                                        if (!z6) {
                                        }
                                        i17 = i16;
                                        str13 = string;
                                        fileLocation4 = fileLocation3;
                                        i18 = i39;
                                        i19 = i13;
                                        str14 = str9;
                                        long[] jArr4222222 = {0, 0};
                                        color22222.setVibrate(jArr4222222);
                                        jArr322222 = jArr4222222;
                                        str15 = str11;
                                        long[] jArr82222222 = null;
                                        if (!AndroidUtilities.needShowPasscode(false)) {
                                        }
                                        str16 = str14;
                                        messageObject2 = messageObject;
                                        i20 = i18;
                                        i21 = i19;
                                        j2 = j4222;
                                        jArr = null;
                                        if (jArr == null) {
                                        }
                                        if (Build.VERSION.SDK_INT < 26) {
                                        }
                                        showExtraNotifications(color22222, z7, sb);
                                        scheduleNotificationRepeat();
                                        return;
                                    }
                                    if (this.pushDialogs.size() != 1 || dialogId == globalSecretChatId) {
                                        i13 = i12;
                                        user = user3;
                                    } else {
                                        i13 = i12;
                                        user = user3;
                                        intent2.putExtra("encId", (int) (dialogId >> 32));
                                    }
                                    fileLocation = null;
                                    String str20222 = str2;
                                    intent2.putExtra(str20222, this.currentAccount);
                                    PendingIntent activity222 = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent2, 1073741824);
                                    if (i27 != 0) {
                                    }
                                    messageObject = messageObject4;
                                    boolean z16222 = true;
                                    if (chat == null) {
                                    }
                                    if (((int) dialogId) == 0) {
                                    }
                                    r27 = null;
                                    string = LocaleController.getString("AppName", R.string.AppName);
                                    if (UserConfig.getActivatedAccountsCount() > 1) {
                                    }
                                    long j42222 = dialogId;
                                    if (this.pushDialogs.size() == 1) {
                                    }
                                    if (this.pushDialogs.size() == 1) {
                                    }
                                    ?? color222222 = new NotificationCompat.Builder(ApplicationLoader.applicationContext).setContentTitle(string).setSmallIcon(R.mipmap.notification).setAutoCancel(true).setNumber(this.total_unread_count).setContentIntent(activity222).setGroup(this.notificationGroup).setGroupSummary(true).setShowWhen(true).setWhen(messageObject.messageOwner.date * 1000).setColor(-15618822);
                                    long[] jArr3222222 = null;
                                    color222222.setCategory(NotificationCompat.CATEGORY_MESSAGE);
                                    if (chat == null) {
                                    }
                                    pendingIntent = activity222;
                                    String str21222222 = null;
                                    if (this.pushMessages.size() == 1) {
                                    }
                                    Intent intent3222222 = new Intent(ApplicationLoader.applicationContext, (Class<?>) NotificationDismissReceiver.class);
                                    intent3222222.putExtra("messageDate", messageObject.messageOwner.date);
                                    String str24222222 = str10;
                                    intent3222222.putExtra(str24222222, this.currentAccount);
                                    color222222.setDeleteIntent(PendingIntent.getBroadcast(ApplicationLoader.applicationContext, 1, intent3222222, 134217728));
                                    if (fileLocation2 == null) {
                                    }
                                    if (!z) {
                                    }
                                    color222222.setPriority(-1);
                                    if (Build.VERSION.SDK_INT >= 26) {
                                    }
                                    if (!z6) {
                                    }
                                    i17 = i16;
                                    str13 = string;
                                    fileLocation4 = fileLocation3;
                                    i18 = i39;
                                    i19 = i13;
                                    str14 = str9;
                                    long[] jArr42222222 = {0, 0};
                                    color222222.setVibrate(jArr42222222);
                                    jArr3222222 = jArr42222222;
                                    str15 = str11;
                                    long[] jArr822222222 = null;
                                    if (!AndroidUtilities.needShowPasscode(false)) {
                                    }
                                    str16 = str14;
                                    messageObject2 = messageObject;
                                    i20 = i18;
                                    i21 = i19;
                                    j2 = j42222;
                                    jArr = null;
                                    if (jArr == null) {
                                    }
                                    if (Build.VERSION.SDK_INT < 26) {
                                    }
                                    showExtraNotifications(color222222, z7, sb);
                                    scheduleNotificationRepeat();
                                    return;
                                }
                            } else {
                                i23 = i6;
                            }
                            i9 = i23;
                            long[] jArr22 = null;
                            int i382 = 0;
                            Uri uri42 = null;
                            if (Build.VERSION.SDK_INT >= 26) {
                            }
                            if (!z11) {
                            }
                            int i392 = i11;
                            Intent intent22 = new Intent(ApplicationLoader.applicationContext, (Class<?>) LaunchActivity.class);
                            StringBuilder sb32 = new StringBuilder();
                            sb32.append("com.tmessages.openchat");
                            int i402 = i10;
                            sb32.append(Math.random());
                            sb32.append(Integer.MAX_VALUE);
                            intent22.setAction(sb32.toString());
                            if (((int) dialogId) != 0) {
                            }
                            fileLocation = null;
                            String str202222 = str2;
                            intent22.putExtra(str202222, this.currentAccount);
                            PendingIntent activity2222 = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent22, 1073741824);
                            if (i27 != 0) {
                            }
                            messageObject = messageObject4;
                            boolean z162222 = true;
                            if (chat == null) {
                            }
                            if (((int) dialogId) == 0) {
                            }
                            r27 = null;
                            string = LocaleController.getString("AppName", R.string.AppName);
                            if (UserConfig.getActivatedAccountsCount() > 1) {
                            }
                            long j422222 = dialogId;
                            if (this.pushDialogs.size() == 1) {
                            }
                            if (this.pushDialogs.size() == 1) {
                            }
                            ?? color2222222 = new NotificationCompat.Builder(ApplicationLoader.applicationContext).setContentTitle(string).setSmallIcon(R.mipmap.notification).setAutoCancel(true).setNumber(this.total_unread_count).setContentIntent(activity2222).setGroup(this.notificationGroup).setGroupSummary(true).setShowWhen(true).setWhen(messageObject.messageOwner.date * 1000).setColor(-15618822);
                            long[] jArr32222222 = null;
                            color2222222.setCategory(NotificationCompat.CATEGORY_MESSAGE);
                            if (chat == null) {
                            }
                            pendingIntent = activity2222;
                            String str212222222 = null;
                            if (this.pushMessages.size() == 1) {
                            }
                            Intent intent32222222 = new Intent(ApplicationLoader.applicationContext, (Class<?>) NotificationDismissReceiver.class);
                            intent32222222.putExtra("messageDate", messageObject.messageOwner.date);
                            String str242222222 = str10;
                            intent32222222.putExtra(str242222222, this.currentAccount);
                            color2222222.setDeleteIntent(PendingIntent.getBroadcast(ApplicationLoader.applicationContext, 1, intent32222222, 134217728));
                            if (fileLocation2 == null) {
                            }
                            if (!z) {
                            }
                            color2222222.setPriority(-1);
                            if (Build.VERSION.SDK_INT >= 26) {
                            }
                            if (!z6) {
                            }
                            i17 = i16;
                            str13 = string;
                            fileLocation4 = fileLocation3;
                            i18 = i392;
                            i19 = i13;
                            str14 = str9;
                            long[] jArr422222222 = {0, 0};
                            color2222222.setVibrate(jArr422222222);
                            jArr32222222 = jArr422222222;
                            str15 = str11;
                            long[] jArr8222222222 = null;
                            if (!AndroidUtilities.needShowPasscode(false)) {
                            }
                            str16 = str14;
                            messageObject2 = messageObject;
                            i20 = i18;
                            i21 = i19;
                            j2 = j422222;
                            jArr = null;
                            if (jArr == null) {
                            }
                            if (Build.VERSION.SDK_INT < 26) {
                            }
                            showExtraNotifications(color2222222, z7, sb);
                            scheduleNotificationRepeat();
                            return;
                        }
                        i9 = i8;
                        long[] jArr222 = null;
                        int i3822 = 0;
                        Uri uri422 = null;
                        if (Build.VERSION.SDK_INT >= 26) {
                        }
                        if (!z11) {
                        }
                        int i3922 = i11;
                        Intent intent222 = new Intent(ApplicationLoader.applicationContext, (Class<?>) LaunchActivity.class);
                        StringBuilder sb322 = new StringBuilder();
                        sb322.append("com.tmessages.openchat");
                        int i4022 = i10;
                        sb322.append(Math.random());
                        sb322.append(Integer.MAX_VALUE);
                        intent222.setAction(sb322.toString());
                        if (((int) dialogId) != 0) {
                        }
                        fileLocation = null;
                        String str2022222 = str2;
                        intent222.putExtra(str2022222, this.currentAccount);
                        PendingIntent activity22222 = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent222, 1073741824);
                        if (i27 != 0) {
                        }
                        messageObject = messageObject4;
                        boolean z1622222 = true;
                        if (chat == null) {
                        }
                        if (((int) dialogId) == 0) {
                        }
                        r27 = null;
                        string = LocaleController.getString("AppName", R.string.AppName);
                        if (UserConfig.getActivatedAccountsCount() > 1) {
                        }
                        long j4222222 = dialogId;
                        if (this.pushDialogs.size() == 1) {
                        }
                        if (this.pushDialogs.size() == 1) {
                        }
                        ?? color22222222 = new NotificationCompat.Builder(ApplicationLoader.applicationContext).setContentTitle(string).setSmallIcon(R.mipmap.notification).setAutoCancel(true).setNumber(this.total_unread_count).setContentIntent(activity22222).setGroup(this.notificationGroup).setGroupSummary(true).setShowWhen(true).setWhen(messageObject.messageOwner.date * 1000).setColor(-15618822);
                        long[] jArr322222222 = null;
                        color22222222.setCategory(NotificationCompat.CATEGORY_MESSAGE);
                        if (chat == null) {
                        }
                        pendingIntent = activity22222;
                        String str2122222222 = null;
                        if (this.pushMessages.size() == 1) {
                        }
                        Intent intent322222222 = new Intent(ApplicationLoader.applicationContext, (Class<?>) NotificationDismissReceiver.class);
                        intent322222222.putExtra("messageDate", messageObject.messageOwner.date);
                        String str2422222222 = str10;
                        intent322222222.putExtra(str2422222222, this.currentAccount);
                        color22222222.setDeleteIntent(PendingIntent.getBroadcast(ApplicationLoader.applicationContext, 1, intent322222222, 134217728));
                        if (fileLocation2 == null) {
                        }
                        if (!z) {
                        }
                        color22222222.setPriority(-1);
                        if (Build.VERSION.SDK_INT >= 26) {
                        }
                        if (!z6) {
                        }
                        i17 = i16;
                        str13 = string;
                        fileLocation4 = fileLocation3;
                        i18 = i3922;
                        i19 = i13;
                        str14 = str9;
                        long[] jArr4222222222 = {0, 0};
                        color22222222.setVibrate(jArr4222222222);
                        jArr322222222 = jArr4222222222;
                        str15 = str11;
                        long[] jArr82222222222 = null;
                        if (!AndroidUtilities.needShowPasscode(false)) {
                        }
                        str16 = str14;
                        messageObject2 = messageObject;
                        i20 = i18;
                        i21 = i19;
                        j2 = j4222222;
                        jArr = null;
                        if (jArr == null) {
                        }
                        if (Build.VERSION.SDK_INT < 26) {
                        }
                        showExtraNotifications(color22222222, z7, sb);
                        scheduleNotificationRepeat();
                        return;
                    } catch (Exception e8) {
                        exc = e8;
                    }
                } catch (Exception e9) {
                    e = e9;
                }
            }
        }
        dismissNotification();
    }

    private void showExtraNotifications(NotificationCompat.Builder notificationBuilder, boolean notifyAboutLast, String summary) {
        int i;
        JSONArray serializedNotifications;
        Integer internalId;
        TLRPC.Chat chat;
        ArrayList arrayList;
        JSONArray serializedNotifications2;
        boolean canReply;
        String name;
        JSONObject serializedChat;
        TLRPC.User user;
        Notification mainNotification;
        boolean useSummaryNotification;
        int selfUserId;
        JSONArray serializedNotifications3;
        ArrayList arrayList2;
        TLRPC.User user2;
        String name2;
        TLRPC.FileLocation photoPath;
        boolean canReply2;
        int max_date;
        Bitmap avatarBitmap;
        NotificationCompat.Action wearReplyAction;
        int max_id;
        boolean canReply3;
        Integer internalId2;
        int highId;
        String replyToString;
        NotificationCompat.Action wearReplyAction2;
        Integer count;
        Integer count2;
        int n;
        String conversationName;
        NotificationCompat.MessagingStyle messagingStyle;
        NotificationCompat.MessagingStyle messagingStyle2;
        NotificationCompat.Action wearReplyAction3;
        int rowsMid;
        JSONArray serializedMsgs;
        int a;
        int highId2;
        NotificationCompat.Action wearReplyAction4;
        String dismissalID;
        String str;
        Bitmap avatarBitmap2;
        TLRPC.User user3;
        String str2;
        Intent dismissIntent;
        NotificationCompat.MessagingStyle messagingStyle3;
        int rowsMid2;
        String name3;
        String message;
        long uid;
        String[] senderName;
        boolean[] preview;
        StringBuilder text;
        Person person;
        int selfUserId2;
        String str3;
        JSONArray serializedMsgs2;
        Uri uri;
        final Uri uri2;
        String str4;
        File avatar;
        File avatar2;
        String name4;
        String name5;
        Notification mainNotification2 = notificationBuilder.build();
        if (Build.VERSION.SDK_INT < 18) {
            notificationManager.notify(this.notificationId, mainNotification2);
            if (BuildVars.LOGS_ENABLED) {
                FileLog.d("show summary notification by SDK check");
                return;
            }
            return;
        }
        SharedPreferences preferences = getAccountInstance().getNotificationsSettings();
        ArrayList<Long> sortedDialogs = new ArrayList<>();
        LongSparseArray<ArrayList<MessageObject>> messagesByDialogs = new LongSparseArray<>();
        int a2 = 0;
        while (true) {
            i = 0;
            if (a2 >= this.pushMessages.size()) {
                break;
            }
            MessageObject messageObject = this.pushMessages.get(a2);
            long dialog_id = messageObject.getDialogId();
            int dismissDate = preferences.getInt("dismissDate" + dialog_id, 0);
            if (messageObject.messageOwner.date > dismissDate) {
                ArrayList<MessageObject> arrayList3 = messagesByDialogs.get(dialog_id);
                if (arrayList3 == null) {
                    arrayList3 = new ArrayList<>();
                    messagesByDialogs.put(dialog_id, arrayList3);
                    sortedDialogs.add(0, Long.valueOf(dialog_id));
                }
                arrayList3.add(messageObject);
            }
            a2++;
        }
        LongSparseArray<Integer> oldIdsWear = this.wearNotificationsIds.clone();
        this.wearNotificationsIds.clear();
        ArrayList arrayList4 = new ArrayList();
        if (!WearDataLayerListenerService.isWatchConnected()) {
            serializedNotifications = null;
        } else {
            serializedNotifications = new JSONArray();
        }
        boolean useSummaryNotification2 = Build.VERSION.SDK_INT <= 27 || (Build.VERSION.SDK_INT > 27 && sortedDialogs.size() > 1);
        if (useSummaryNotification2 && Build.VERSION.SDK_INT >= 26) {
            checkOtherNotificationsChannel();
        }
        int selfUserId3 = getUserConfig().getClientUserId();
        int size = sortedDialogs.size();
        int b = 0;
        while (b < size) {
            long dialog_id2 = sortedDialogs.get(b).longValue();
            SharedPreferences preferences2 = preferences;
            ArrayList<MessageObject> messageObjects = messagesByDialogs.get(dialog_id2);
            int max_id2 = messageObjects.get(i).getId();
            ArrayList<Long> sortedDialogs2 = sortedDialogs;
            int lowerId = (int) dialog_id2;
            LongSparseArray<ArrayList<MessageObject>> messagesByDialogs2 = messagesByDialogs;
            int size2 = size;
            int b2 = b;
            int highId3 = (int) (dialog_id2 >> 32);
            Integer internalId3 = oldIdsWear.get(dialog_id2);
            if (internalId3 == null) {
                if (lowerId != 0) {
                    internalId = Integer.valueOf(lowerId);
                } else {
                    internalId = Integer.valueOf(highId3);
                }
            } else {
                oldIdsWear.remove(dialog_id2);
                internalId = internalId3;
            }
            JSONObject serializedChat2 = null;
            if (serializedNotifications != null) {
                serializedChat2 = new JSONObject();
            }
            MessageObject lastMessageObject = messageObjects.get(0);
            JSONObject serializedChat3 = serializedChat2;
            LongSparseArray<Integer> oldIdsWear2 = oldIdsWear;
            int max_date2 = lastMessageObject.messageOwner.date;
            TLRPC.User user4 = null;
            boolean isChannel = false;
            boolean isSupergroup = false;
            TLRPC.FileLocation photoPath2 = null;
            Bitmap avatarBitmap3 = null;
            File avatalFile = null;
            LongSparseArray<Person> personCache = new LongSparseArray<>();
            if (lowerId != 0) {
                chat = null;
                boolean canReply4 = lowerId != 777000;
                if (lowerId > 0) {
                    boolean canReply5 = canReply4;
                    serializedNotifications2 = serializedNotifications;
                    TLRPC.User user5 = getMessagesController().getUser(Integer.valueOf(lowerId));
                    if (user5 == null) {
                        if (lastMessageObject.isFcmMessage()) {
                            name = lastMessageObject.localName;
                            arrayList = arrayList4;
                        } else {
                            if (BuildVars.LOGS_ENABLED) {
                                FileLog.w("not found user to show dialog notification " + lowerId);
                                mainNotification = mainNotification2;
                                useSummaryNotification = useSummaryNotification2;
                                selfUserId = selfUserId3;
                                serializedNotifications3 = serializedNotifications2;
                                arrayList2 = arrayList4;
                            } else {
                                mainNotification = mainNotification2;
                                useSummaryNotification = useSummaryNotification2;
                                selfUserId = selfUserId3;
                                serializedNotifications3 = serializedNotifications2;
                                arrayList2 = arrayList4;
                            }
                            b = b2 + 1;
                            arrayList4 = arrayList2;
                            serializedNotifications = serializedNotifications3;
                            preferences = preferences2;
                            sortedDialogs = sortedDialogs2;
                            messagesByDialogs = messagesByDialogs2;
                            size = size2;
                            mainNotification2 = mainNotification;
                            oldIdsWear = oldIdsWear2;
                            useSummaryNotification2 = useSummaryNotification;
                            selfUserId3 = selfUserId;
                            i = 0;
                        }
                    } else {
                        arrayList = arrayList4;
                        String name6 = UserObject.getName(user5);
                        if (user5.photo == null || user5.photo.photo_small == null) {
                            name5 = name6;
                        } else {
                            name5 = name6;
                            if (user5.photo.photo_small.volume_id != 0 && user5.photo.photo_small.local_id != 0) {
                                photoPath2 = user5.photo.photo_small;
                                name = name5;
                            }
                        }
                        name = name5;
                    }
                    if (lowerId != selfUserId3) {
                        serializedChat = serializedChat3;
                        user = user5;
                        canReply = canReply5;
                    } else {
                        name = LocaleController.getString("MessageScheduledReminderNotification", R.string.MessageScheduledReminderNotification);
                        serializedChat = serializedChat3;
                        user = user5;
                        canReply = canReply5;
                    }
                } else {
                    boolean canReply6 = canReply4;
                    arrayList = arrayList4;
                    serializedNotifications2 = serializedNotifications;
                    TLRPC.Chat chat2 = getMessagesController().getChat(Integer.valueOf(-lowerId));
                    if (chat2 == null) {
                        if (lastMessageObject.isFcmMessage()) {
                            isSupergroup = lastMessageObject.isMegagroup();
                            name = lastMessageObject.localName;
                            chat = chat2;
                            isChannel = lastMessageObject.localChannel;
                            serializedChat = serializedChat3;
                            user = null;
                            canReply = canReply6;
                        } else {
                            if (BuildVars.LOGS_ENABLED) {
                                FileLog.w("not found chat to show dialog notification " + lowerId);
                                mainNotification = mainNotification2;
                                useSummaryNotification = useSummaryNotification2;
                                selfUserId = selfUserId3;
                                serializedNotifications3 = serializedNotifications2;
                                arrayList2 = arrayList;
                            } else {
                                mainNotification = mainNotification2;
                                useSummaryNotification = useSummaryNotification2;
                                selfUserId = selfUserId3;
                                serializedNotifications3 = serializedNotifications2;
                                arrayList2 = arrayList;
                            }
                            b = b2 + 1;
                            arrayList4 = arrayList2;
                            serializedNotifications = serializedNotifications3;
                            preferences = preferences2;
                            sortedDialogs = sortedDialogs2;
                            messagesByDialogs = messagesByDialogs2;
                            size = size2;
                            mainNotification2 = mainNotification;
                            oldIdsWear = oldIdsWear2;
                            useSummaryNotification2 = useSummaryNotification;
                            selfUserId3 = selfUserId;
                            i = 0;
                        }
                    } else {
                        boolean isSupergroup2 = chat2.megagroup;
                        isChannel = ChatObject.isChannel(chat2) && !chat2.megagroup;
                        String name7 = chat2.title;
                        if (chat2.photo == null || chat2.photo.photo_small == null) {
                            isSupergroup = isSupergroup2;
                            name4 = name7;
                        } else {
                            isSupergroup = isSupergroup2;
                            name4 = name7;
                            if (chat2.photo.photo_small.volume_id != 0 && chat2.photo.photo_small.local_id != 0) {
                                photoPath2 = chat2.photo.photo_small;
                                serializedChat = serializedChat3;
                                user = null;
                                name = name4;
                                chat = chat2;
                                canReply = canReply6;
                            }
                        }
                        serializedChat = serializedChat3;
                        user = null;
                        name = name4;
                        chat = chat2;
                        canReply = canReply6;
                    }
                }
            } else {
                chat = null;
                arrayList = arrayList4;
                serializedNotifications2 = serializedNotifications;
                canReply = false;
                if (dialog_id2 != globalSecretChatId) {
                    TLRPC.EncryptedChat encryptedChat = getMessagesController().getEncryptedChat(Integer.valueOf(highId3));
                    if (encryptedChat == null) {
                        if (BuildVars.LOGS_ENABLED) {
                            FileLog.w("not found secret chat to show dialog notification " + highId3);
                            mainNotification = mainNotification2;
                            useSummaryNotification = useSummaryNotification2;
                            selfUserId = selfUserId3;
                            serializedNotifications3 = serializedNotifications2;
                            arrayList2 = arrayList;
                        } else {
                            mainNotification = mainNotification2;
                            useSummaryNotification = useSummaryNotification2;
                            selfUserId = selfUserId3;
                            serializedNotifications3 = serializedNotifications2;
                            arrayList2 = arrayList;
                        }
                    } else {
                        user4 = getMessagesController().getUser(Integer.valueOf(encryptedChat.user_id));
                        if (user4 == null) {
                            if (BuildVars.LOGS_ENABLED) {
                                FileLog.w("not found secret chat user to show dialog notification " + encryptedChat.user_id);
                                mainNotification = mainNotification2;
                                useSummaryNotification = useSummaryNotification2;
                                selfUserId = selfUserId3;
                                serializedNotifications3 = serializedNotifications2;
                                arrayList2 = arrayList;
                            } else {
                                mainNotification = mainNotification2;
                                useSummaryNotification = useSummaryNotification2;
                                selfUserId = selfUserId3;
                                serializedNotifications3 = serializedNotifications2;
                                arrayList2 = arrayList;
                            }
                        }
                    }
                    b = b2 + 1;
                    arrayList4 = arrayList2;
                    serializedNotifications = serializedNotifications3;
                    preferences = preferences2;
                    sortedDialogs = sortedDialogs2;
                    messagesByDialogs = messagesByDialogs2;
                    size = size2;
                    mainNotification2 = mainNotification;
                    oldIdsWear = oldIdsWear2;
                    useSummaryNotification2 = useSummaryNotification;
                    selfUserId3 = selfUserId;
                    i = 0;
                }
                name = LocaleController.getString("SecretChatName", R.string.SecretChatName);
                photoPath2 = null;
                serializedChat = null;
                user = user4;
            }
            if (AndroidUtilities.needShowPasscode(false) || SharedConfig.isWaitingForPasscodeEnter) {
                String name8 = LocaleController.getString("AppName", R.string.AppName);
                mainNotification = mainNotification2;
                user2 = user;
                name2 = name8;
                photoPath = null;
                canReply2 = false;
            } else {
                mainNotification = mainNotification2;
                user2 = user;
                name2 = name;
                photoPath = photoPath2;
                canReply2 = canReply;
            }
            useSummaryNotification = useSummaryNotification2;
            if (photoPath == null) {
                max_date = max_date2;
                avatarBitmap = null;
            } else {
                avatalFile = FileLoader.getPathToAttach(photoPath, true);
                if (Build.VERSION.SDK_INT >= 28) {
                    max_date = max_date2;
                } else {
                    max_date = max_date2;
                    BitmapDrawable img = ImageLoader.getInstance().getImageFromMemory(photoPath, null, "50_50");
                    if (img != null) {
                        Bitmap avatarBitmap4 = img.getBitmap();
                        avatarBitmap = avatarBitmap4;
                    } else {
                        try {
                            if (avatalFile.exists()) {
                                float scaleFactor = 160.0f / AndroidUtilities.dp(50.0f);
                                BitmapFactory.Options options = new BitmapFactory.Options();
                                try {
                                    options.inSampleSize = scaleFactor < 1.0f ? 1 : (int) scaleFactor;
                                    avatarBitmap3 = BitmapFactory.decodeFile(avatalFile.getAbsolutePath(), options);
                                } catch (Throwable th) {
                                }
                            }
                            avatarBitmap = avatarBitmap3;
                        } catch (Throwable th2) {
                        }
                    }
                }
                avatarBitmap = null;
            }
            TLRPC.FileLocation photoPath3 = photoPath;
            Bitmap avatarBitmap5 = avatarBitmap;
            String str5 = "currentAccount";
            if (isChannel && !isSupergroup) {
                wearReplyAction = null;
                max_id = max_id2;
                canReply3 = canReply2;
                internalId2 = internalId;
                highId = highId3;
            } else if (!canReply2 || SharedConfig.isWaitingForPasscodeEnter || selfUserId3 == lowerId) {
                wearReplyAction = null;
                max_id = max_id2;
                canReply3 = canReply2;
                internalId2 = internalId;
                highId = highId3;
            } else {
                canReply3 = canReply2;
                highId = highId3;
                Intent replyIntent = new Intent(ApplicationLoader.applicationContext, (Class<?>) WearReplyReceiver.class);
                replyIntent.putExtra("dialog_id", dialog_id2);
                replyIntent.putExtra("max_id", max_id2);
                replyIntent.putExtra("currentAccount", this.currentAccount);
                internalId2 = internalId;
                PendingIntent replyPendingIntent = PendingIntent.getBroadcast(ApplicationLoader.applicationContext, internalId.intValue(), replyIntent, 134217728);
                RemoteInput remoteInputWear = new RemoteInput.Builder(EXTRA_VOICE_REPLY).setLabel(LocaleController.getString("Reply", R.string.Reply)).build();
                if (lowerId < 0) {
                    max_id = max_id2;
                    replyToString = LocaleController.formatString("ReplyToGroup", R.string.ReplyToGroup, name2);
                } else {
                    max_id = max_id2;
                    replyToString = LocaleController.formatString("ReplyToUser", R.string.ReplyToUser, name2);
                }
                wearReplyAction2 = new NotificationCompat.Action.Builder(R.drawable.ic_reply_icon, replyToString, replyPendingIntent).setAllowGeneratedReplies(true).setSemanticAction(1).addRemoteInput(remoteInputWear).setShowsUserInterface(false).build();
                count = this.pushDialogs.get(dialog_id2);
                if (count == null) {
                    count2 = count;
                } else {
                    count2 = 0;
                }
                n = Math.max(count2.intValue(), messageObjects.size());
                if (n > 1 || Build.VERSION.SDK_INT >= 28) {
                    String conversationName2 = name2;
                    conversationName = conversationName2;
                } else {
                    conversationName = String.format("%1$s (%2$d)", name2, Integer.valueOf(n));
                }
                String str6 = "";
                messagingStyle = new NotificationCompat.MessagingStyle("");
                if (Build.VERSION.SDK_INT >= 28 || (lowerId < 0 && !isChannel)) {
                    messagingStyle2 = messagingStyle;
                    messagingStyle2.setConversationTitle(conversationName);
                } else {
                    messagingStyle2 = messagingStyle;
                }
                messagingStyle2.setGroupConversation(Build.VERSION.SDK_INT >= 28 || (!isChannel && lowerId < 0));
                StringBuilder text2 = new StringBuilder();
                String[] senderName2 = new String[1];
                wearReplyAction3 = wearReplyAction2;
                boolean[] preview2 = new boolean[1];
                if (serializedChat != null) {
                    rowsMid = 0;
                    serializedMsgs = null;
                } else {
                    JSONArray serializedMsgs3 = new JSONArray();
                    rowsMid = 0;
                    serializedMsgs = serializedMsgs3;
                }
                JSONObject serializedChat4 = serializedChat;
                a = messageObjects.size() - 1;
                int rowsMid3 = rowsMid;
                ArrayList<TLRPC.TL_keyboardButtonRow> rows = null;
                while (a >= 0) {
                    ArrayList<MessageObject> messageObjects2 = messageObjects;
                    MessageObject messageObject2 = messageObjects.get(a);
                    String message2 = getShortStringForMessage(messageObject2, senderName2, preview2);
                    int a3 = a;
                    String str7 = str5;
                    JSONArray serializedMsgs4 = serializedMsgs;
                    if (dialog_id2 == selfUserId3) {
                        senderName2[0] = name2;
                    } else if (lowerId < 0 && messageObject2.messageOwner.from_scheduled) {
                        senderName2[0] = LocaleController.getString("NotificationMessageScheduledName", R.string.NotificationMessageScheduledName);
                    }
                    if (message2 == null) {
                        if (BuildVars.LOGS_ENABLED) {
                            FileLog.w("message text is null for " + messageObject2.getId() + " did = " + messageObject2.getDialogId());
                            name3 = name2;
                            messagingStyle2 = messagingStyle2;
                            str3 = str6;
                            senderName = senderName2;
                            selfUserId2 = selfUserId3;
                            preview = preview2;
                            text = text2;
                            serializedMsgs2 = serializedMsgs4;
                        } else {
                            name3 = name2;
                            str3 = str6;
                            senderName = senderName2;
                            selfUserId2 = selfUserId3;
                            preview = preview2;
                            text = text2;
                            serializedMsgs2 = serializedMsgs4;
                        }
                    } else {
                        NotificationCompat.MessagingStyle messagingStyle4 = messagingStyle2;
                        if (text2.length() > 0) {
                            text2.append("\n\n");
                        }
                        messagingStyle2 = messagingStyle4;
                        name3 = name2;
                        if (dialog_id2 != selfUserId3 && messageObject2.messageOwner.from_scheduled && lowerId > 0) {
                            String message3 = String.format("%1$s: %2$s", LocaleController.getString("NotificationMessageScheduledName", R.string.NotificationMessageScheduledName), message2);
                            text2.append(message3);
                            message = message3;
                        } else {
                            if (senderName2[0] != null) {
                                text2.append(String.format("%1$s: %2$s", senderName2[0], message2));
                            } else {
                                text2.append(message2);
                            }
                            message = message2;
                        }
                        if (lowerId > 0) {
                            uid = lowerId;
                        } else if (isChannel) {
                            uid = -lowerId;
                        } else if (lowerId < 0) {
                            uid = messageObject2.getFromId();
                        } else {
                            uid = dialog_id2;
                        }
                        LongSparseArray<Person> personCache2 = personCache;
                        Person person2 = personCache2.get(uid);
                        if (person2 != null) {
                            senderName = senderName2;
                            preview = preview2;
                            text = text2;
                            person = person2;
                        } else {
                            Person.Builder builder = new Person.Builder();
                            if (senderName2[0] == null) {
                                senderName = senderName2;
                                str4 = str6;
                            } else {
                                senderName = senderName2;
                                str4 = senderName2[0];
                            }
                            Person.Builder personBuilder = builder.setName(str4);
                            if (!preview2[0] || lowerId == 0) {
                                preview = preview2;
                                text = text2;
                            } else {
                                preview = preview2;
                                if (Build.VERSION.SDK_INT < 28) {
                                    text = text2;
                                } else {
                                    if (lowerId > 0) {
                                        text = text2;
                                    } else if (isChannel) {
                                        text = text2;
                                    } else {
                                        if (lowerId >= 0) {
                                            avatar2 = null;
                                            text = text2;
                                        } else {
                                            int fromId = messageObject2.getFromId();
                                            avatar2 = null;
                                            text = text2;
                                            TLRPC.User sender = getMessagesController().getUser(Integer.valueOf(fromId));
                                            if (sender == null && (sender = getMessagesStorage().getUserSync(fromId)) != null) {
                                                getMessagesController().putUser(sender, true);
                                            }
                                            if (sender != null && sender.photo != null && sender.photo.photo_small != null && sender.photo.photo_small.volume_id != 0 && sender.photo.photo_small.local_id != 0) {
                                                avatar = FileLoader.getPathToAttach(sender.photo.photo_small, true);
                                                loadRoundAvatar(avatar, personBuilder);
                                            }
                                        }
                                        avatar = avatar2;
                                        loadRoundAvatar(avatar, personBuilder);
                                    }
                                    avatar = avatalFile;
                                    loadRoundAvatar(avatar, personBuilder);
                                }
                            }
                            person = personBuilder.build();
                            personCache2.put(uid, person);
                        }
                        if (lowerId != 0) {
                            if (Build.VERSION.SDK_INT >= 28 && !((ActivityManager) ApplicationLoader.applicationContext.getSystemService("activity")).isLowRamDevice()) {
                                if (messageObject2.isSecretMedia()) {
                                    personCache = personCache2;
                                    selfUserId2 = selfUserId3;
                                    str3 = str6;
                                } else if (messageObject2.type == 1 || messageObject2.isSticker()) {
                                    File attach = FileLoader.getPathToMessage(messageObject2.messageOwner);
                                    NotificationCompat.MessagingStyle.Message msg = new NotificationCompat.MessagingStyle.Message(message, messageObject2.messageOwner.date * 1000, person);
                                    String mimeType = messageObject2.isSticker() ? "image/webp" : "image/jpeg";
                                    if (attach.exists()) {
                                        uri2 = FileProvider.getUriForFile(ApplicationLoader.applicationContext, "im.skmzhmurqt.messenger.provider", attach);
                                        personCache = personCache2;
                                        selfUserId2 = selfUserId3;
                                    } else {
                                        personCache = personCache2;
                                        if (getFileLoader().isLoadingFile(attach.getName())) {
                                            Uri.Builder appendPath = new Uri.Builder().scheme("content").authority(NotificationImageProvider.AUTHORITY).appendPath("msg_media_raw");
                                            StringBuilder sb = new StringBuilder();
                                            selfUserId2 = selfUserId3;
                                            int selfUserId4 = this.currentAccount;
                                            sb.append(selfUserId4);
                                            sb.append(str6);
                                            Uri.Builder _uri = appendPath.appendPath(sb.toString()).appendPath(attach.getName()).appendQueryParameter("final_path", attach.getAbsolutePath());
                                            uri2 = _uri.build();
                                        } else {
                                            selfUserId2 = selfUserId3;
                                            uri2 = null;
                                        }
                                    }
                                    if (uri2 != null) {
                                        msg.setData(mimeType, uri2);
                                        messagingStyle2.addMessage(msg);
                                        ApplicationLoader.applicationContext.grantUriPermission("com.android.systemui", uri2, 1);
                                        str3 = str6;
                                        AndroidUtilities.runOnUIThread(new Runnable() {
                                            @Override
                                            public final void run() {
                                                ApplicationLoader.applicationContext.revokeUriPermission(uri2, 1);
                                            }
                                        }, 20000L);
                                        if (!TextUtils.isEmpty(messageObject2.caption)) {
                                            messagingStyle2.addMessage(messageObject2.caption, messageObject2.messageOwner.date * 1000, person);
                                        }
                                    } else {
                                        str3 = str6;
                                        messagingStyle2.addMessage(message, messageObject2.messageOwner.date * 1000, person);
                                    }
                                } else {
                                    personCache = personCache2;
                                    selfUserId2 = selfUserId3;
                                    str3 = str6;
                                }
                                messagingStyle2.addMessage(message, messageObject2.messageOwner.date * 1000, person);
                            } else {
                                personCache = personCache2;
                                selfUserId2 = selfUserId3;
                                str3 = str6;
                                messagingStyle2.addMessage(message, messageObject2.messageOwner.date * 1000, person);
                            }
                            if (messageObject2.isVoice()) {
                                List<NotificationCompat.MessagingStyle.Message> messages = messagingStyle2.getMessages();
                                if (!messages.isEmpty()) {
                                    File f = FileLoader.getPathToMessage(messageObject2.messageOwner);
                                    if (Build.VERSION.SDK_INT >= 24) {
                                        try {
                                            uri = FileProvider.getUriForFile(ApplicationLoader.applicationContext, "im.skmzhmurqt.messenger.provider", f);
                                        } catch (Exception e) {
                                            uri = null;
                                        }
                                    } else {
                                        uri = Uri.fromFile(f);
                                    }
                                    if (uri != null) {
                                        NotificationCompat.MessagingStyle.Message addedMessage = messages.get(messages.size() - 1);
                                        addedMessage.setData("audio/ogg", uri);
                                    }
                                }
                            }
                        } else {
                            personCache = personCache2;
                            selfUserId2 = selfUserId3;
                            str3 = str6;
                            messagingStyle2.addMessage(message, messageObject2.messageOwner.date * 1000, person);
                        }
                        if (serializedMsgs4 == null) {
                            serializedMsgs2 = serializedMsgs4;
                        } else {
                            try {
                                JSONObject jmsg = new JSONObject();
                                jmsg.put("text", message);
                                jmsg.put("date", messageObject2.messageOwner.date);
                                if (messageObject2.isFromUser() && lowerId < 0) {
                                    try {
                                        TLRPC.User sender2 = getMessagesController().getUser(Integer.valueOf(messageObject2.getFromId()));
                                        if (sender2 != null) {
                                            jmsg.put("fname", sender2.first_name);
                                            jmsg.put("lname", sender2.last_name);
                                        }
                                    } catch (JSONException e2) {
                                        serializedMsgs2 = serializedMsgs4;
                                    }
                                }
                                serializedMsgs2 = serializedMsgs4;
                                try {
                                    serializedMsgs2.put(jmsg);
                                } catch (JSONException e3) {
                                }
                            } catch (JSONException e4) {
                                serializedMsgs2 = serializedMsgs4;
                            }
                        }
                        if (dialog_id2 == 777000 && messageObject2.messageOwner.reply_markup != null) {
                            ArrayList<TLRPC.TL_keyboardButtonRow> rows2 = messageObject2.messageOwner.reply_markup.rows;
                            rows = rows2;
                            rowsMid3 = messageObject2.getId();
                        }
                    }
                    str6 = str3;
                    messageObjects = messageObjects2;
                    str5 = str7;
                    preview2 = preview;
                    name2 = name3;
                    senderName2 = senderName;
                    selfUserId3 = selfUserId2;
                    text2 = text;
                    serializedMsgs = serializedMsgs2;
                    a = a3 - 1;
                }
                String name9 = name2;
                ArrayList<MessageObject> messageObjects3 = messageObjects;
                String str8 = str5;
                JSONArray serializedMsgs5 = serializedMsgs;
                selfUserId = selfUserId3;
                StringBuilder text3 = text2;
                String str9 = str6;
                Intent intent = new Intent(ApplicationLoader.applicationContext, (Class<?>) LaunchActivity.class);
                intent.setAction("com.tmessages.openchat" + Math.random() + Integer.MAX_VALUE);
                intent.addCategory("android.intent.category.LAUNCHER");
                if (lowerId == 0) {
                    if (lowerId > 0) {
                        intent.putExtra("userId", lowerId);
                        highId2 = highId;
                    } else {
                        intent.putExtra("chatId", -lowerId);
                        highId2 = highId;
                    }
                } else {
                    highId2 = highId;
                    intent.putExtra("encId", highId2);
                }
                String str10 = str8;
                intent.putExtra(str10, this.currentAccount);
                PendingIntent contentIntent = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent, 1073741824);
                NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender();
                if (wearReplyAction3 != null) {
                    wearReplyAction4 = wearReplyAction3;
                } else {
                    wearReplyAction4 = wearReplyAction3;
                    wearableExtender.addAction(wearReplyAction4);
                }
                Intent msgHeardIntent = new Intent(ApplicationLoader.applicationContext, (Class<?>) AutoMessageHeardReceiver.class);
                msgHeardIntent.addFlags(32);
                msgHeardIntent.setAction("im.skmzhmurqt.messenger.ACTION_MESSAGE_HEARD");
                msgHeardIntent.putExtra("dialog_id", dialog_id2);
                int max_id3 = max_id;
                msgHeardIntent.putExtra("max_id", max_id3);
                msgHeardIntent.putExtra(str10, this.currentAccount);
                PendingIntent readPendingIntent = PendingIntent.getBroadcast(ApplicationLoader.applicationContext, internalId2.intValue(), msgHeardIntent, 134217728);
                NotificationCompat.Action readAction = new NotificationCompat.Action.Builder(R.drawable.menu_read, LocaleController.getString("MarkAsRead", R.string.MarkAsRead), readPendingIntent).setSemanticAction(2).setShowsUserInterface(false).build();
                if (lowerId == 0) {
                    dismissalID = lowerId <= 0 ? "tgchat" + (-lowerId) + "_" + max_id3 : "tguser" + lowerId + "_" + max_id3;
                } else if (dialog_id2 != globalSecretChatId) {
                    dismissalID = "tgenc" + highId2 + "_" + max_id3;
                } else {
                    dismissalID = null;
                }
                if (dismissalID != null) {
                    str = "_";
                } else {
                    wearableExtender.setDismissalId(dismissalID);
                    NotificationCompat.WearableExtender summaryExtender = new NotificationCompat.WearableExtender();
                    StringBuilder sb2 = new StringBuilder();
                    str = "_";
                    sb2.append("summary_");
                    sb2.append(dismissalID);
                    summaryExtender.setDismissalId(sb2.toString());
                    notificationBuilder.extend(summaryExtender);
                }
                wearableExtender.setBridgeTag("tgaccount" + selfUserId);
                long date = ((long) messageObjects3.get(0).messageOwner.date) * 1000;
                NotificationCompat.Builder builder2 = new NotificationCompat.Builder(ApplicationLoader.applicationContext).setContentTitle(name9).setSmallIcon(R.mipmap.notification).setContentText(text3.toString()).setAutoCancel(true).setNumber(messageObjects3.size()).setColor(-15618822).setGroupSummary(false).setWhen(date).setShowWhen(true).setShortcutId("sdid_" + dialog_id2).setStyle(messagingStyle2).setContentIntent(contentIntent).extend(wearableExtender).setSortKey(str9 + (Long.MAX_VALUE - date)).setCategory(NotificationCompat.CATEGORY_MESSAGE);
                Intent dismissIntent2 = new Intent(ApplicationLoader.applicationContext, (Class<?>) NotificationDismissReceiver.class);
                int max_date3 = max_date;
                dismissIntent2.putExtra("messageDate", max_date3);
                dismissIntent2.putExtra("dialogId", dialog_id2);
                dismissIntent2.putExtra(str10, this.currentAccount);
                builder2.setDeleteIntent(PendingIntent.getBroadcast(ApplicationLoader.applicationContext, 1, dismissIntent2, 134217728));
                if (useSummaryNotification) {
                    builder2.setGroup(this.notificationGroup);
                    builder2.setGroupAlertBehavior(1);
                }
                if (wearReplyAction4 != null) {
                    builder2.addAction(wearReplyAction4);
                }
                builder2.addAction(readAction);
                if (this.pushDialogs.size() != 1 && !TextUtils.isEmpty(summary)) {
                    builder2.setSubText(summary);
                }
                if (lowerId != 0) {
                    builder2.setLocalOnly(true);
                }
                if (avatarBitmap5 != null) {
                    avatarBitmap2 = avatarBitmap5;
                } else {
                    avatarBitmap2 = avatarBitmap5;
                    builder2.setLargeIcon(avatarBitmap2);
                }
                if (AndroidUtilities.needShowPasscode(false) && !SharedConfig.isWaitingForPasscodeEnter && rows != null) {
                    int rc = rows.size();
                    int r = 0;
                    while (r < rc) {
                        int rc2 = rc;
                        TLRPC.TL_keyboardButtonRow row = rows.get(r);
                        int cc = row.buttons.size();
                        Bitmap avatarBitmap6 = avatarBitmap2;
                        int c = 0;
                        while (c < cc) {
                            int cc2 = cc;
                            TLRPC.KeyboardButton button = row.buttons.get(c);
                            TLRPC.TL_keyboardButtonRow row2 = row;
                            if (!(button instanceof TLRPC.TL_keyboardButtonCallback)) {
                                str2 = str10;
                                dismissIntent = dismissIntent2;
                                messagingStyle3 = messagingStyle2;
                                rowsMid2 = rowsMid3;
                            } else {
                                dismissIntent = dismissIntent2;
                                messagingStyle3 = messagingStyle2;
                                Intent callbackIntent = new Intent(ApplicationLoader.applicationContext, (Class<?>) NotificationCallbackReceiver.class);
                                callbackIntent.putExtra(str10, this.currentAccount);
                                callbackIntent.putExtra("did", dialog_id2);
                                if (button.data != null) {
                                    callbackIntent.putExtra("data", button.data);
                                }
                                int rowsMid4 = rowsMid3;
                                callbackIntent.putExtra("mid", rowsMid4);
                                String str11 = button.text;
                                Context context = ApplicationLoader.applicationContext;
                                str2 = str10;
                                int i2 = this.lastButtonId;
                                rowsMid2 = rowsMid4;
                                int rowsMid5 = i2 + 1;
                                this.lastButtonId = rowsMid5;
                                builder2.addAction(0, str11, PendingIntent.getBroadcast(context, i2, callbackIntent, 134217728));
                            }
                            c++;
                            cc = cc2;
                            row = row2;
                            dismissIntent2 = dismissIntent;
                            messagingStyle2 = messagingStyle3;
                            str10 = str2;
                            rowsMid3 = rowsMid2;
                        }
                        r++;
                        rc = rc2;
                        avatarBitmap2 = avatarBitmap6;
                        messagingStyle2 = messagingStyle2;
                        str10 = str10;
                    }
                }
                if (chat == null || user2 == null) {
                    user3 = user2;
                } else {
                    user3 = user2;
                    if (user3.phone != null && user3.phone.length() > 0) {
                        builder2.addPerson("tel:+" + user3.phone);
                    }
                }
                if (Build.VERSION.SDK_INT >= 26) {
                    if (useSummaryNotification) {
                        builder2.setChannelId(OTHER_NOTIFICATIONS_CHANNEL);
                    } else {
                        builder2.setChannelId(mainNotification.getChannelId());
                    }
                }
                arrayList2 = arrayList;
                arrayList2.add(new Object(internalId2.intValue(), builder2.build()) {
                    int id;
                    Notification notification;

                    {
                        this.id = i;
                        this.notification = n;
                    }

                    void call() {
                        if (BuildVars.LOGS_ENABLED) {
                            FileLog.w("show dialog notification with id " + this.id);
                        }
                        NotificationsController.notificationManager.notify(this.id, this.notification);
                    }
                });
                this.wearNotificationsIds.put(dialog_id2, internalId2);
                if (lowerId != 0) {
                    serializedNotifications3 = serializedNotifications2;
                } else if (serializedChat4 != null) {
                    try {
                        serializedChat4.put("reply", canReply3);
                        serializedChat4.put("name", name9);
                        try {
                            serializedChat4.put("max_id", max_id3);
                            serializedChat4.put("max_date", max_date3);
                            serializedChat4.put(TtmlNode.ATTR_ID, Math.abs(lowerId));
                            if (photoPath3 != null) {
                                try {
                                    StringBuilder sb3 = new StringBuilder();
                                    try {
                                        sb3.append(photoPath3.dc_id);
                                        String str12 = str;
                                        sb3.append(str12);
                                        try {
                                            sb3.append(photoPath3.volume_id);
                                            sb3.append(str12);
                                            sb3.append(photoPath3.secret);
                                            serializedChat4.put("photo", sb3.toString());
                                        } catch (JSONException e5) {
                                            serializedNotifications3 = serializedNotifications2;
                                        }
                                    } catch (JSONException e6) {
                                        serializedNotifications3 = serializedNotifications2;
                                    }
                                } catch (JSONException e7) {
                                    serializedNotifications3 = serializedNotifications2;
                                }
                            }
                            if (serializedMsgs5 != null) {
                                try {
                                    serializedChat4.put("msgs", serializedMsgs5);
                                } catch (JSONException e8) {
                                    serializedNotifications3 = serializedNotifications2;
                                }
                            }
                            if (lowerId > 0) {
                                serializedChat4.put("type", "user");
                            } else if (lowerId < 0) {
                                if (!isChannel && !isSupergroup) {
                                    serializedChat4.put("type", "group");
                                }
                                serializedChat4.put("type", "channel");
                            }
                            serializedNotifications3 = serializedNotifications2;
                            try {
                                serializedNotifications3.put(serializedChat4);
                            } catch (JSONException e9) {
                            }
                        } catch (JSONException e10) {
                            serializedNotifications3 = serializedNotifications2;
                        }
                    } catch (JSONException e11) {
                        serializedNotifications3 = serializedNotifications2;
                    }
                } else {
                    serializedNotifications3 = serializedNotifications2;
                }
                b = b2 + 1;
                arrayList4 = arrayList2;
                serializedNotifications = serializedNotifications3;
                preferences = preferences2;
                sortedDialogs = sortedDialogs2;
                messagesByDialogs = messagesByDialogs2;
                size = size2;
                mainNotification2 = mainNotification;
                oldIdsWear = oldIdsWear2;
                useSummaryNotification2 = useSummaryNotification;
                selfUserId3 = selfUserId;
                i = 0;
            }
            wearReplyAction2 = wearReplyAction;
            count = this.pushDialogs.get(dialog_id2);
            if (count == null) {
            }
            n = Math.max(count2.intValue(), messageObjects.size());
            if (n > 1) {
            }
            String conversationName22 = name2;
            conversationName = conversationName22;
            String str62 = "";
            messagingStyle = new NotificationCompat.MessagingStyle("");
            if (Build.VERSION.SDK_INT >= 28) {
            }
            messagingStyle2 = messagingStyle;
            messagingStyle2.setConversationTitle(conversationName);
            messagingStyle2.setGroupConversation(Build.VERSION.SDK_INT >= 28 || (!isChannel && lowerId < 0));
            StringBuilder text22 = new StringBuilder();
            String[] senderName22 = new String[1];
            wearReplyAction3 = wearReplyAction2;
            boolean[] preview22 = new boolean[1];
            if (serializedChat != null) {
            }
            JSONObject serializedChat42 = serializedChat;
            a = messageObjects.size() - 1;
            int rowsMid32 = rowsMid;
            ArrayList<TLRPC.TL_keyboardButtonRow> rows3 = null;
            while (a >= 0) {
            }
            String name92 = name2;
            ArrayList<MessageObject> messageObjects32 = messageObjects;
            String str82 = str5;
            JSONArray serializedMsgs52 = serializedMsgs;
            selfUserId = selfUserId3;
            StringBuilder text32 = text22;
            String str92 = str62;
            Intent intent2 = new Intent(ApplicationLoader.applicationContext, (Class<?>) LaunchActivity.class);
            intent2.setAction("com.tmessages.openchat" + Math.random() + Integer.MAX_VALUE);
            intent2.addCategory("android.intent.category.LAUNCHER");
            if (lowerId == 0) {
            }
            String str102 = str82;
            intent2.putExtra(str102, this.currentAccount);
            PendingIntent contentIntent2 = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent2, 1073741824);
            NotificationCompat.WearableExtender wearableExtender2 = new NotificationCompat.WearableExtender();
            if (wearReplyAction3 != null) {
            }
            Intent msgHeardIntent2 = new Intent(ApplicationLoader.applicationContext, (Class<?>) AutoMessageHeardReceiver.class);
            msgHeardIntent2.addFlags(32);
            msgHeardIntent2.setAction("im.skmzhmurqt.messenger.ACTION_MESSAGE_HEARD");
            msgHeardIntent2.putExtra("dialog_id", dialog_id2);
            int max_id32 = max_id;
            msgHeardIntent2.putExtra("max_id", max_id32);
            msgHeardIntent2.putExtra(str102, this.currentAccount);
            PendingIntent readPendingIntent2 = PendingIntent.getBroadcast(ApplicationLoader.applicationContext, internalId2.intValue(), msgHeardIntent2, 134217728);
            NotificationCompat.Action readAction2 = new NotificationCompat.Action.Builder(R.drawable.menu_read, LocaleController.getString("MarkAsRead", R.string.MarkAsRead), readPendingIntent2).setSemanticAction(2).setShowsUserInterface(false).build();
            if (lowerId == 0) {
            }
            if (dismissalID != null) {
            }
            wearableExtender2.setBridgeTag("tgaccount" + selfUserId);
            long date2 = ((long) messageObjects32.get(0).messageOwner.date) * 1000;
            NotificationCompat.Builder builder22 = new NotificationCompat.Builder(ApplicationLoader.applicationContext).setContentTitle(name92).setSmallIcon(R.mipmap.notification).setContentText(text32.toString()).setAutoCancel(true).setNumber(messageObjects32.size()).setColor(-15618822).setGroupSummary(false).setWhen(date2).setShowWhen(true).setShortcutId("sdid_" + dialog_id2).setStyle(messagingStyle2).setContentIntent(contentIntent2).extend(wearableExtender2).setSortKey(str92 + (Long.MAX_VALUE - date2)).setCategory(NotificationCompat.CATEGORY_MESSAGE);
            Intent dismissIntent22 = new Intent(ApplicationLoader.applicationContext, (Class<?>) NotificationDismissReceiver.class);
            int max_date32 = max_date;
            dismissIntent22.putExtra("messageDate", max_date32);
            dismissIntent22.putExtra("dialogId", dialog_id2);
            dismissIntent22.putExtra(str102, this.currentAccount);
            builder22.setDeleteIntent(PendingIntent.getBroadcast(ApplicationLoader.applicationContext, 1, dismissIntent22, 134217728));
            if (useSummaryNotification) {
            }
            if (wearReplyAction4 != null) {
            }
            builder22.addAction(readAction2);
            if (this.pushDialogs.size() != 1) {
            }
            if (lowerId != 0) {
            }
            if (avatarBitmap5 != null) {
            }
            if (AndroidUtilities.needShowPasscode(false)) {
            }
            if (chat == null) {
            }
            user3 = user2;
            if (Build.VERSION.SDK_INT >= 26) {
            }
            arrayList2 = arrayList;
            arrayList2.add(new Object(internalId2.intValue(), builder22.build()) {
                int id;
                Notification notification;

                {
                    this.id = i;
                    this.notification = n;
                }

                void call() {
                    if (BuildVars.LOGS_ENABLED) {
                        FileLog.w("show dialog notification with id " + this.id);
                    }
                    NotificationsController.notificationManager.notify(this.id, this.notification);
                }
            });
            this.wearNotificationsIds.put(dialog_id2, internalId2);
            if (lowerId != 0) {
            }
            b = b2 + 1;
            arrayList4 = arrayList2;
            serializedNotifications = serializedNotifications3;
            preferences = preferences2;
            sortedDialogs = sortedDialogs2;
            messagesByDialogs = messagesByDialogs2;
            size = size2;
            mainNotification2 = mainNotification;
            oldIdsWear = oldIdsWear2;
            useSummaryNotification2 = useSummaryNotification;
            selfUserId3 = selfUserId;
            i = 0;
        }
        Notification mainNotification3 = mainNotification2;
        LongSparseArray<Integer> oldIdsWear3 = oldIdsWear;
        ArrayList arrayList5 = arrayList4;
        JSONArray serializedNotifications4 = serializedNotifications;
        int selfUserId5 = selfUserId3;
        if (!useSummaryNotification2) {
            notificationManager.cancel(this.notificationId);
        } else {
            if (BuildVars.LOGS_ENABLED) {
                FileLog.d("show summary with id " + this.notificationId);
            }
            notificationManager.notify(this.notificationId, mainNotification3);
        }
        int size3 = arrayList5.size();
        for (int a4 = 0; a4 < size3; a4++) {
            ((C1NotificationHolder) arrayList5.get(a4)).call();
        }
        int a5 = 0;
        while (a5 < oldIdsWear3.size()) {
            LongSparseArray<Integer> oldIdsWear4 = oldIdsWear3;
            Integer id = oldIdsWear4.valueAt(a5);
            if (BuildVars.LOGS_ENABLED) {
                FileLog.w("cancel notification id " + id);
            }
            notificationManager.cancel(id.intValue());
            a5++;
            oldIdsWear3 = oldIdsWear4;
        }
        if (serializedNotifications4 != null) {
            try {
                JSONObject s = new JSONObject();
                try {
                    s.put(TtmlNode.ATTR_ID, selfUserId5);
                    s.put("n", serializedNotifications4);
                    WearDataLayerListenerService.sendMessageToWatch("/notify", s.toString().getBytes(), "remote_notifications");
                } catch (Exception e12) {
                }
            } catch (Exception e13) {
            }
        }
    }

    private void loadRoundAvatar(File avatar, Person.Builder personBuilder) {
        if (avatar != null) {
            try {
                Bitmap bitmap = ImageDecoder.decodeBitmap(ImageDecoder.createSource(avatar), new ImageDecoder.OnHeaderDecodedListener() {
                    @Override
                    public final void onHeaderDecoded(ImageDecoder imageDecoder, ImageDecoder.ImageInfo imageInfo, ImageDecoder.Source source) {
                        imageDecoder.setPostProcessor(new PostProcessor() {
                            @Override
                            public final int onPostProcess(Canvas canvas) {
                                return NotificationsController.lambda$null$32(canvas);
                            }
                        });
                    }
                });
                IconCompat icon = IconCompat.createWithBitmap(bitmap);
                personBuilder.setIcon(icon);
            } catch (Throwable th) {
            }
        }
    }

    public static int lambda$null$32(Canvas canvas) {
        Path path = new Path();
        path.setFillType(Path.FillType.INVERSE_EVEN_ODD);
        int width = canvas.getWidth();
        int height = canvas.getHeight();
        path.addRoundRect(0.0f, 0.0f, width, height, width / 2, width / 2, Path.Direction.CW);
        Paint paint = new Paint();
        paint.setAntiAlias(true);
        paint.setColor(0);
        paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC));
        canvas.drawPath(path, paint);
        return -3;
    }

    public void playOutChatSound() {
        if (!this.inChatSoundEnabled || MediaController.getInstance().isRecordingAudio()) {
            return;
        }
        try {
            if (audioManager.getRingerMode() == 0) {
                return;
            }
        } catch (Exception e) {
            FileLog.e(e);
        }
        notificationsQueue.postRunnable(new Runnable() {
            @Override
            public final void run() {
                NotificationsController.this.lambda$playOutChatSound$35$NotificationsController();
            }
        });
    }

    public void lambda$playOutChatSound$35$NotificationsController() {
        try {
            if (Math.abs(System.currentTimeMillis() - this.lastSoundOutPlay) <= 100) {
                return;
            }
            this.lastSoundOutPlay = System.currentTimeMillis();
            if (this.soundPool == null) {
                SoundPool soundPool = new SoundPool(3, 1, 0);
                this.soundPool = soundPool;
                soundPool.setOnLoadCompleteListener(new SoundPool.OnLoadCompleteListener() {
                    @Override
                    public final void onLoadComplete(SoundPool soundPool2, int i, int i2) {
                        NotificationsController.lambda$null$34(soundPool2, i, i2);
                    }
                });
            }
            if (this.soundOut == 0 && !this.soundOutLoaded) {
                this.soundOutLoaded = true;
                this.soundOut = this.soundPool.load(ApplicationLoader.applicationContext, R.raw.sound_out, 1);
            }
            if (this.soundOut != 0) {
                try {
                    this.soundPool.play(this.soundOut, 1.0f, 1.0f, 1, 0, 1.0f);
                } catch (Exception e) {
                    FileLog.e(e);
                }
            }
        } catch (Exception e2) {
            FileLog.e(e2);
        }
    }

    public static void lambda$null$34(SoundPool soundPool, int sampleId, int status) {
        if (status == 0) {
            try {
                soundPool.play(sampleId, 1.0f, 1.0f, 1, 0, 1.0f);
            } catch (Exception e) {
                FileLog.e(e);
            }
        }
    }

    public void setDialogNotificationsSettings(long dialog_id, int setting) {
        long flags;
        SharedPreferences preferences = getAccountInstance().getNotificationsSettings();
        SharedPreferences.Editor editor = preferences.edit();
        TLRPC.Dialog dialog = MessagesController.getInstance(UserConfig.selectedAccount).dialogs_dict.get(dialog_id);
        if (setting == 4) {
            boolean defaultEnabled = isGlobalNotificationsEnabled(dialog_id);
            if (defaultEnabled) {
                editor.remove("notify2_" + dialog_id);
            } else {
                editor.putInt("notify2_" + dialog_id, 0);
            }
            getMessagesStorage().setDialogFlags(dialog_id, 0L);
            if (dialog != null) {
                dialog.notify_settings = new TLRPC.TL_peerNotifySettings();
            }
        } else {
            int untilTime = ConnectionsManager.getInstance(UserConfig.selectedAccount).getCurrentTime();
            if (setting == 0) {
                untilTime += 3600;
            } else if (setting == 1) {
                untilTime += 28800;
            } else if (setting == 2) {
                untilTime += 172800;
            } else if (setting == 3) {
                untilTime = Integer.MAX_VALUE;
            }
            if (setting == 3) {
                editor.putInt("notify2_" + dialog_id, 2);
                flags = 1;
            } else {
                editor.putInt("notify2_" + dialog_id, 3);
                editor.putInt("notifyuntil_" + dialog_id, untilTime);
                flags = (((long) untilTime) << 32) | 1;
            }
            getInstance(UserConfig.selectedAccount).removeNotificationsForDialog(dialog_id);
            MessagesStorage.getInstance(UserConfig.selectedAccount).setDialogFlags(dialog_id, flags);
            if (dialog != null) {
                dialog.notify_settings = new TLRPC.TL_peerNotifySettings();
                dialog.notify_settings.mute_until = untilTime;
            }
        }
        editor.commit();
        updateServerNotificationsSettings(dialog_id);
    }

    public void updateServerNotificationsSettings(long dialog_id) {
        updateServerNotificationsSettings(dialog_id, true);
    }

    public void updateServerNotificationsSettings(long dialog_id, boolean post) {
        if (post) {
            getNotificationCenter().postNotificationName(NotificationCenter.notificationsSettingsUpdated, new Object[0]);
        }
        if (((int) dialog_id) == 0) {
            return;
        }
        SharedPreferences preferences = getAccountInstance().getNotificationsSettings();
        TLRPC.TL_account_updateNotifySettings req = new TLRPC.TL_account_updateNotifySettings();
        req.settings = new TLRPC.TL_inputPeerNotifySettings();
        req.settings.flags |= 1;
        req.settings.show_previews = preferences.getBoolean("content_preview_" + dialog_id, true);
        TLRPC.TL_inputPeerNotifySettings tL_inputPeerNotifySettings = req.settings;
        tL_inputPeerNotifySettings.flags = tL_inputPeerNotifySettings.flags | 2;
        req.settings.silent = preferences.getBoolean("silent_" + dialog_id, false);
        int mute_type = preferences.getInt("notify2_" + dialog_id, -1);
        if (mute_type != -1) {
            req.settings.flags |= 4;
            if (mute_type == 3) {
                req.settings.mute_until = preferences.getInt("notifyuntil_" + dialog_id, 0);
            } else {
                req.settings.mute_until = mute_type == 2 ? Integer.MAX_VALUE : 0;
            }
        }
        req.peer = new TLRPC.TL_inputNotifyPeer();
        ((TLRPC.TL_inputNotifyPeer) req.peer).peer = getMessagesController().getInputPeer((int) dialog_id);
        getConnectionsManager().sendRequest(req, new RequestDelegate() {
            @Override
            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                NotificationsController.lambda$updateServerNotificationsSettings$36(tLObject, tL_error);
            }
        });
    }

    public static void lambda$updateServerNotificationsSettings$36(TLObject response, TLRPC.TL_error error) {
    }

    public void updateServerNotificationsSettings(int type) {
        SharedPreferences preferences = getAccountInstance().getNotificationsSettings();
        TLRPC.TL_account_updateNotifySettings req = new TLRPC.TL_account_updateNotifySettings();
        req.settings = new TLRPC.TL_inputPeerNotifySettings();
        req.settings.flags = 5;
        if (type == 0) {
            req.peer = new TLRPC.TL_inputNotifyChats();
            req.settings.mute_until = preferences.getInt("EnableGroup2", 0);
            req.settings.show_previews = preferences.getBoolean("EnablePreviewGroup", true);
        } else if (type == 1) {
            req.peer = new TLRPC.TL_inputNotifyUsers();
            req.settings.mute_until = preferences.getInt("EnableAll2", 0);
            req.settings.show_previews = preferences.getBoolean("EnablePreviewAll", true);
        } else {
            req.peer = new TLRPC.TL_inputNotifyBroadcasts();
            req.settings.mute_until = preferences.getInt("EnableChannel2", 0);
            req.settings.show_previews = preferences.getBoolean("EnablePreviewChannel", true);
        }
        getConnectionsManager().sendRequest(req, new RequestDelegate() {
            @Override
            public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
                NotificationsController.lambda$updateServerNotificationsSettings$37(tLObject, tL_error);
            }
        });
    }

    public static void lambda$updateServerNotificationsSettings$37(TLObject response, TLRPC.TL_error error) {
    }

    public boolean isGlobalNotificationsEnabled(long did) {
        int type;
        int lower_id = (int) did;
        if (lower_id < 0) {
            TLRPC.Chat chat = getMessagesController().getChat(Integer.valueOf(-lower_id));
            if (ChatObject.isChannel(chat) && !chat.megagroup) {
                type = 2;
            } else {
                type = 0;
            }
        } else {
            type = 1;
        }
        return isGlobalNotificationsEnabled(type);
    }

    public boolean isGlobalNotificationsEnabled(int type) {
        return getAccountInstance().getNotificationsSettings().getInt(getGlobalNotificationsKey(type), 0) < getConnectionsManager().getCurrentTime();
    }

    public void setGlobalNotificationsEnabled(int type, int time) {
        getAccountInstance().getNotificationsSettings().edit().putInt(getGlobalNotificationsKey(type), time).commit();
        updateServerNotificationsSettings(type);
    }

    public String getGlobalNotificationsKey(int type) {
        if (type == 0) {
            return "EnableGroup2";
        }
        if (type == 1) {
            return "EnableAll2";
        }
        return "EnableChannel2";
    }
}