导航菜单

页面标题

页面副标题

Plus 12 v10.13.1.1 - NotificationsDisabledReceiver.java 源代码

正在查看: Plus 12 v10.13.1.1 应用的 NotificationsDisabledReceiver.java JAVA 源代码文件

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


package org.telegram.messenger;

import android.annotation.TargetApi;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.SystemClock;
import android.text.TextUtils;

@TargetApi(28)
public class NotificationsDisabledReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        if ("android.app.action.NOTIFICATION_CHANNEL_BLOCK_STATE_CHANGED".equals(intent.getAction())) {
            String stringExtra = intent.getStringExtra("android.app.extra.NOTIFICATION_CHANNEL_ID");
            boolean booleanExtra = intent.getBooleanExtra("android.app.extra.BLOCKED_STATE", false);
            if (TextUtils.isEmpty(stringExtra) || stringExtra.contains("_ia_")) {
                return;
            }
            String[] split = stringExtra.split("_");
            if (split.length < 3) {
                return;
            }
            ApplicationLoader.postInitApplication();
            int intValue = Utilities.parseInt((CharSequence) split[0]).intValue();
            if (intValue < 0 || intValue >= UserConfig.MAX_ACCOUNT_COUNT) {
                return;
            }
            if (BuildVars.LOGS_ENABLED) {
                FileLog.d("received disabled notification channel event for " + stringExtra + " state = " + booleanExtra);
            }
            if (SystemClock.elapsedRealtime() - AccountInstance.getInstance(intValue).getNotificationsController().lastNotificationChannelCreateTime <= 1000) {
                if (BuildVars.LOGS_ENABLED) {
                    FileLog.d("received disable notification event right after creating notification channel, ignoring");
                    return;
                }
                return;
            }
            SharedPreferences notificationsSettings = AccountInstance.getInstance(intValue).getNotificationsSettings();
            if (split[1].startsWith("channel")) {
                if (!stringExtra.equals(notificationsSettings.getString("channels", null))) {
                    return;
                }
                if (BuildVars.LOGS_ENABLED) {
                    FileLog.d("apply channel{channel} " + stringExtra + " state");
                }
                notificationsSettings.edit().putInt(NotificationsController.getGlobalNotificationsKey(2), booleanExtra ? Integer.MAX_VALUE : 0).commit();
                AccountInstance.getInstance(intValue).getNotificationsController().updateServerNotificationsSettings(2);
            } else if (split[1].startsWith("groups")) {
                if (!stringExtra.equals(notificationsSettings.getString("groups", null))) {
                    return;
                }
                if (BuildVars.LOGS_ENABLED) {
                    FileLog.d("apply channel{groups} " + stringExtra + " state");
                }
                notificationsSettings.edit().putInt(NotificationsController.getGlobalNotificationsKey(0), booleanExtra ? Integer.MAX_VALUE : 0).commit();
                AccountInstance.getInstance(intValue).getNotificationsController().updateServerNotificationsSettings(0);
            } else if (split[1].startsWith("private")) {
                if (!stringExtra.equals(notificationsSettings.getString("private", null))) {
                    return;
                }
                if (BuildVars.LOGS_ENABLED) {
                    FileLog.d("apply channel{private} " + stringExtra + " state");
                }
                notificationsSettings.edit().putInt(NotificationsController.getGlobalNotificationsKey(1), booleanExtra ? Integer.MAX_VALUE : 0).commit();
                AccountInstance.getInstance(intValue).getNotificationsController().updateServerNotificationsSettings(1);
            } else if (split[1].startsWith("stories")) {
                if (!stringExtra.equals(notificationsSettings.getString("stories", null))) {
                    return;
                }
                if (BuildVars.LOGS_ENABLED) {
                    FileLog.d("apply channel{stories} " + stringExtra + " state");
                }
                notificationsSettings.edit().putBoolean(NotificationsController.getGlobalNotificationsKey(3), !booleanExtra).commit();
                AccountInstance.getInstance(intValue).getNotificationsController().updateServerNotificationsSettings(1);
            } else {
                long longValue = Utilities.parseLong(split[1]).longValue();
                if (longValue == 0) {
                    return;
                }
                String sharedPrefKey = NotificationsController.getSharedPrefKey(longValue, 0);
                if (!stringExtra.equals(notificationsSettings.getString("org.telegram.key" + longValue, null))) {
                    return;
                }
                if (BuildVars.LOGS_ENABLED) {
                    FileLog.d("apply channel{else} " + stringExtra + " state");
                }
                SharedPreferences.Editor edit = notificationsSettings.edit();
                edit.putInt(NotificationsSettingsFacade.PROPERTY_NOTIFY + sharedPrefKey, booleanExtra ? 2 : 0);
                if (!booleanExtra) {
                    edit.remove(NotificationsSettingsFacade.PROPERTY_NOTIFY_UNTIL + sharedPrefKey);
                }
                edit.commit();
                AccountInstance.getInstance(intValue).getNotificationsController().updateServerNotificationsSettings(longValue, 0L, true);
            }
            AccountInstance.getInstance(intValue).getConnectionsManager().resumeNetworkMaybe();
        }
    }
}