导航菜单

页面标题

页面副标题

Hyouka private v5.8.9 - NotificationController.java 源代码

正在查看: Hyouka private v5.8.9 应用的 NotificationController.java JAVA 源代码文件

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


package com.beint.project.push;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Build;
import android.service.notification.StatusBarNotification;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.widget.RemoteViews;
import androidx.core.app.q1;
import androidx.core.app.s1;
import androidx.core.app.u;
import androidx.core.graphics.drawable.IconCompat;
import com.beint.project.CallActionReceiver;
import com.beint.project.MainApplication;
import com.beint.project.NavigationManagerActivity;
import com.beint.project.R;
import com.beint.project.ReplyMessageBroadcastReceiver;
import com.beint.project.core.dataBase.ZNotification;
import com.beint.project.core.dataBase.ZNotificationDao;
import com.beint.project.core.dataaccess.DBConstants;
import com.beint.project.core.managers.SystemServiceManager;
import com.beint.project.core.model.mute.Mute;
import com.beint.project.core.services.impl.RegistrationService;
import com.beint.project.core.services.impl.ZangiMuteService;
import com.beint.project.core.utils.Constants;
import com.beint.project.enums.ActivityAction;
import com.beint.project.managers.ConversationNotificationManager;
import com.beint.project.screens.CallActivity;
import com.beint.project.screens.CallingFragmentActivity;
import com.beint.project.screens.settings.passCode.UnLockAppActivity;
import com.beint.project.services.PassCodeController;
import gb.l;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import kotlin.jvm.internal.k;

public final class NotificationController {
    private static final int ANSWER_DECLINE_NOTIFICATION_ID = 19833893;
    private static final int CALL_NOTIFICATION_ID = 19833892;
    public static final int FOREGROUND_SERVICE_ID = 101;
    public static final NotificationController INSTANCE = new NotificationController();
    public static final int MISSED_CALL_ID = 19833899;

    private NotificationController() {
    }

    private final PendingIntent answerPending() {
        Intent intent = new Intent(getContext(), (Class<?>) CallingFragmentActivity.class);
        intent.putExtra("action_answer", true);
        PendingIntent activity = PendingIntent.getActivity(getContext(), 0, intent, getFlags());
        k.e(activity, "getActivity(context, 0, intent, this.getFlags())");
        return activity;
    }

    private final boolean canShowNotification(ZNotification zNotification) {
        Mute mute = ZangiMuteService.getInstance().getMute(zNotification.getConversationId());
        return !(mute != null ? k.b(mute.isMuted(), Boolean.TRUE) : false);
    }

    private final boolean canShowNotificationContent(ZNotification zNotification) {
        if (zNotification.getStealthTime() > 0 || zNotification.isStealthModeOn()) {
            return false;
        }
        Mute mute = ZangiMuteService.getInstance().getMute(zNotification.getConversationId());
        if ((mute != null ? k.b(mute.isMuted(), Boolean.TRUE) : false) || isUserOnCall()) {
            return false;
        }
        ConversationNotificationManager conversationNotificationManager = ConversationNotificationManager.INSTANCE;
        Boolean notificationStatus = conversationNotificationManager.getNotificationStatus(Constants.NOTIFICATION + zNotification.getConversationId());
        Boolean bool = Boolean.FALSE;
        if (k.b(notificationStatus, bool) || k.b(conversationNotificationManager.getDefaultNotificationStatus(Constants.SHOW_PREVIEW), bool) || UnLockAppActivity.Companion.getInstance() != null) {
            return false;
        }
        PassCodeController passCodeController = PassCodeController.INSTANCE;
        return !passCodeController.passCodeIsEnable() || passCodeController.showNotification();
    }

    private final RemoteViews createAndGetRemoteViews(ZNotification zNotification) {
        RemoteViews remoteViews = new RemoteViews(getContext().getPackageName(), R.layout.in_call);
        remoteViews.setTextViewText(R.id.app_incoming_call, zNotification.getMsg());
        remoteViews.setTextViewText(R.id.tv_name, zNotification.getName());
        remoteViews.setImageViewBitmap(R.id.photo, getBitmap(zNotification, zNotification.getName()));
        remoteViews.setOnClickPendingIntent(R.id.answer_btn, answerPending());
        remoteViews.setOnClickPendingIntent(R.id.decline_btn, declinePending());
        return remoteViews;
    }

    private final PendingIntent declinePending() {
        Intent intent = new Intent(getContext(), (Class<?>) CallActionReceiver.class);
        intent.putExtra("action_decline", true);
        PendingIntent broadcast = PendingIntent.getBroadcast(getContext(), 1, intent, getFlags());
        k.e(broadcast, "getBroadcast(context, 1, intent, this.getFlags())");
        return broadcast;
    }

    private final PendingIntent getAnswerDeclineContentIntent() {
        Intent intent = new Intent(getContext(), (Class<?>) CallingFragmentActivity.class);
        intent.putExtra("action", ActivityAction.ACTION_SHOW_AVSCREEN.ordinal());
        intent.addFlags(805306368);
        CallingFragmentActivity.intent = intent;
        PendingIntent activity = PendingIntent.getActivity(getContext(), ANSWER_DECLINE_NOTIFICATION_ID, intent, getFlags());
        k.e(activity, "getActivity(context, ANS… intent, this.getFlags())");
        return activity;
    }

    private final android.graphics.Bitmap getBitmap(com.beint.project.core.dataBase.ZNotification r5, java.lang.String r6) {
        throw new UnsupportedOperationException("Method not decompiled: com.beint.project.push.NotificationController.getBitmap(com.beint.project.core.dataBase.ZNotification, java.lang.String):android.graphics.Bitmap");
    }

    private final String getChannelId(boolean z2, boolean z3) {
        return z3 ? SystemServiceManager.INSTANCE.hiddenChatChannelIdGetAndCreate() : z2 ? SystemServiceManager.INSTANCE.groupChanelIdGetAndCreate() : SystemServiceManager.INSTANCE.smsChanelIdGetAndCreate();
    }

    private final PendingIntent getContentIntent(String str) {
        Intent intent = new Intent(getContext(), (Class<?>) NavigationManagerActivity.class);
        intent.addFlags(268435456);
        intent.putExtra(Constants.ZANGI_ACTION, 4);
        intent.putExtra(Constants.CONV_JID, str);
        PendingIntent activity = PendingIntent.getActivity(getContext(), str.hashCode(), intent, getFlags());
        k.e(activity, "getActivity(context, req… intent, this.getFlags())");
        return activity;
    }

    private final Context getContext() {
        return MainApplication.Companion.getMainContext();
    }

    private final String getDisplayName(ZNotification zNotification, boolean z2) {
        if (!z2) {
            return zNotification.getName();
        }
        String string = getContext().getString(2131886181);
        k.e(string, "{\n            context.ge…tring.app_name)\n        }");
        return string;
    }

    private final int getFlags() {
        return Build.VERSION.SDK_INT >= 31 ? 167772160 : 134217728;
    }

    private final PendingIntent getInCallContentIntent() {
        Intent intent = new Intent(getContext(), (Class<?>) CallingFragmentActivity.class);
        intent.putExtra("action", ActivityAction.ACTION_SHOW_AVSCREEN.ordinal());
        intent.addFlags(805306368);
        CallingFragmentActivity.intent = intent;
        PendingIntent activity = PendingIntent.getActivity(getContext(), CALL_NOTIFICATION_ID, intent, getFlags());
        k.e(activity, "getActivity(context, CAL… intent, this.getFlags())");
        return activity;
    }

    private final PendingIntent getMissedCallContentIntent(String str) {
        Intent intent = new Intent(getContext(), (Class<?>) NavigationManagerActivity.class);
        intent.putExtra(Constants.ZANGI_ACTION, 7);
        intent.putExtra(Constants.MISSED_CALL_DISPLAY_NUMBER, str);
        intent.addFlags(268435456);
        PendingIntent activity = PendingIntent.getActivity(getContext(), MISSED_CALL_ID, intent, getFlags());
        k.e(activity, "getActivity(context, MIS… intent, this.getFlags())");
        return activity;
    }

    private final String getNotificationBody(ZNotification zNotification, boolean z2) {
        if (z2) {
            String string = getContext().getString(2131887005);
            k.e(string, "context.getString(R.string.new_message)");
            return string;
        }
        if (canShowNotificationContent(zNotification)) {
            String msg = zNotification.getMsg();
            return msg == null ? "" : msg;
        }
        String string2 = getContext().getString(2131887375);
        k.e(string2, "this.context.getString(R…ng.send_you_message_text)");
        return string2;
    }

    private final PendingIntent getOpenCallContentIntent(String str, String str2) {
        Intent intent = new Intent(getContext(), (Class<?>) CallActivity.class);
        intent.addFlags(268435456);
        intent.putExtra(Constants.CALLING_ACTION, str2);
        intent.putExtra(Constants.CALLING_ACTION_DISPLAY_NAME, str);
        intent.putExtra(Constants.HIDE_MSG_NOTIFICATION_FROM_MISSED, true);
        PendingIntent activity = PendingIntent.getActivity(getContext(), MISSED_CALL_ID, intent, getFlags());
        k.e(activity, "getActivity(context, MIS… intent, this.getFlags())");
        return activity;
    }

    private final int getPriority(boolean z2) {
        return z2 ? Build.VERSION.SDK_INT >= 24 ? 4 : 1 : Build.VERSION.SDK_INT >= 24 ? 2 : -1;
    }

    private final u.a getReplyAction(String str) {
        Intent intent = new Intent(getContext(), (Class<?>) ReplyMessageBroadcastReceiver.class);
        intent.addFlags(268435456);
        intent.putExtra(Constants.HIDE_MSG_NOTIFICATION, true);
        intent.putExtra(Constants.ZANGI_ACTION, 4);
        intent.putExtra(Constants.CONV_JID, str);
        String string = getContext().getString(2131887279);
        k.e(string, "context.getString(R.string.reply)");
        s1 a2 = new s1.d(Constants.REPLY_MESSAGE_TEXT).b(string).a();
        k.e(a2, "Builder(Constants.REPLY_…Label(replyLabel).build()");
        u.a b2 = new u.a.C0036a(android.R.drawable.ic_menu_send, string, PendingIntent.getBroadcast(getContext(), str.hashCode(), intent, getFlags())).a(a2).e(1).f(false).d(true).b();
        k.e(b2, "Builder(android.R.drawab…rue)\n            .build()");
        return b2;
    }

    private final u.i getStyle(String str, Bitmap bitmap, List<ZNotification> list, boolean z2) {
        ?? gVar;
        if (Build.VERSION.SDK_INT >= 28) {
            q1.b f2 = new q1.b().f(str);
            k.e(f2, "Builder().setName(name)");
            IconCompat f3 = IconCompat.f(bitmap);
            k.e(f3, "createWithBitmap(avatar)");
            f2.c(f3);
            q1 a2 = f2.a();
            k.e(a2, "personBuilder.build()");
            gVar = new u.h(a2);
            for (ZNotification zNotification : list) {
                gVar.q(new u.h.a(getNotificationBody(zNotification, z2), zNotification.getTime(), a2));
            }
            gVar.w(str);
        } else {
            gVar = new u.g();
            Iterator<ZNotification> it = list.iterator();
            while (it.hasNext()) {
                gVar.q(getNotificationBody(it.next(), z2));
            }
        }
        return gVar;
    }

    private final boolean isUserOnCall() {
        int callStateForSubscription;
        MainApplication.Companion companion = MainApplication.Companion;
        TelephonyManager telephonyManager = (TelephonyManager) companion.getMainContext().getSystemService("phone");
        if (Build.VERSION.SDK_INT >= 31) {
            try {
                if (androidx.core.content.a.a(companion.getMainContext(), "android.permission.READ_PHONE_STATE") == 0 && telephonyManager != null) {
                    callStateForSubscription = telephonyManager.getCallStateForSubscription();
                }
            } catch (Exception unused) {
            }
            callStateForSubscription = 0;
        } else {
            if (telephonyManager != null) {
                callStateForSubscription = telephonyManager.getCallState();
            }
            callStateForSubscription = 0;
        }
        return callStateForSubscription == 1 || callStateForSubscription == 2;
    }

    public final void hideAnswerDeclineNotification() {
        try {
            NotificationManager notificationManager = SystemServiceManager.INSTANCE.getNotificationManager();
            if (notificationManager != null) {
                notificationManager.cancel(ANSWER_DECLINE_NOTIFICATION_ID);
            }
        } catch (Exception e2) {
            String localizedMessage = e2.getLocalizedMessage();
            if (localizedMessage != null) {
                Log.e("NotificationController", localizedMessage);
            }
        }
    }

    public final void hideCallNotification() {
        hideAnswerDeclineNotification();
        try {
            NotificationManager notificationManager = SystemServiceManager.INSTANCE.getNotificationManager();
            if (notificationManager != null) {
                notificationManager.cancel(CALL_NOTIFICATION_ID);
            }
        } catch (Exception e2) {
            String localizedMessage = e2.getLocalizedMessage();
            if (localizedMessage != null) {
                Log.e("NotificationController", localizedMessage);
            }
        }
    }

    public final Notification makeAnswerDeclineNotification(ZNotification zNotification) {
        k.f(zNotification, DBConstants.TABLE_MESSAGE);
        if (!RegistrationService.INSTANCE.getOnBackground() || Build.VERSION.SDK_INT < 29) {
            return makeInCallNotification(zNotification);
        }
        String inCallAppChanelIdBackgroundGetAndCreate = SystemServiceManager.INSTANCE.inCallAppChanelIdBackgroundGetAndCreate();
        PendingIntent answerDeclineContentIntent = getAnswerDeclineContentIntent();
        RemoteViews createAndGetRemoteViews = createAndGetRemoteViews(zNotification);
        u.e eVar = new u.e(getContext(), inCallAppChanelIdBackgroundGetAndCreate);
        eVar.I(2131230935).m(false).J(Uri.parse("")).p(androidx.core.content.a.c(getContext(), 2131099695)).t(createAndGetRemoteViews).K(new u.f()).x(answerDeclineContentIntent, true).n("call").F(2);
        Notification c2 = eVar.c();
        k.e(c2, "builder.build()");
        return c2;
    }

    public final Notification makeInCallNotification(ZNotification zNotification) {
        k.f(zNotification, DBConstants.TABLE_MESSAGE);
        String inCallAppChanelIdForGroundGetAndCreate = SystemServiceManager.INSTANCE.inCallAppChanelIdForGroundGetAndCreate();
        PendingIntent inCallContentIntent = getInCallContentIntent();
        u.e eVar = new u.e(getContext(), inCallAppChanelIdForGroundGetAndCreate);
        eVar.I(2131230935).m(false).p(androidx.core.content.a.c(getContext(), 2131099695)).q(inCallContentIntent).s("Zangi").L(zNotification.getMsg()).r(zNotification.getMsg()).E(true).n("service").F(2);
        Notification c2 = eVar.c();
        k.e(c2, "builder.build()");
        return c2;
    }

    public final void removeAllNotifications() {
        NotificationManager notificationManager = SystemServiceManager.INSTANCE.getNotificationManager();
        if (notificationManager != null) {
            try {
                notificationManager.cancelAll();
            } catch (Exception e2) {
                String localizedMessage = e2.getLocalizedMessage();
                if (localizedMessage != null) {
                    Log.e("NotificationController", localizedMessage);
                }
            }
        }
        ZNotificationDao.INSTANCE.deleteAll();
    }

    public final void removeMissedNotifications() {
        try {
            NotificationManager notificationManager = SystemServiceManager.INSTANCE.getNotificationManager();
            if (notificationManager != null) {
                notificationManager.cancel(MISSED_CALL_ID);
            }
        } catch (Exception e2) {
            String localizedMessage = e2.getLocalizedMessage();
            if (localizedMessage != null) {
                Log.e("NotificationController", localizedMessage);
            }
        }
    }

    public final void removeNotifications(String str) {
        StatusBarNotification[] activeNotifications;
        if (str == null) {
            return;
        }
        Log.i("NotificationController", "hideMSGNotification -> start " + str);
        NotificationManager notificationManager = SystemServiceManager.INSTANCE.getNotificationManager();
        if (Build.VERSION.SDK_INT >= 23) {
            if ((notificationManager != null ? notificationManager.getActiveNotifications() : null) != null) {
                try {
                    notificationManager.cancel(str.hashCode());
                    Log.i("NotificationController", "hideMSGNotification -> manager.cancel " + str);
                    activeNotifications = notificationManager.getActiveNotifications();
                    int i2 = 0;
                    for (StatusBarNotification statusBarNotification : activeNotifications) {
                        if (statusBarNotification.getNotification().getGroup() != null && k.b(statusBarNotification.getNotification().getGroup(), Constants.SMS_NOTIFICATION_SINGL_KEY) && statusBarNotification.getId() != str.hashCode()) {
                            i2++;
                        }
                    }
                    Log.i("NotificationController", "hideMSGNotification -> count == " + i2);
                    if (i2 == 1) {
                        Log.i("NotificationController", "hideMSGNotification -> cancel");
                        notificationManager.cancel(111111);
                        notificationManager.cancel(1);
                        notificationManager.cancelAll();
                    }
                } catch (Exception e2) {
                    Log.e("NotificationController", "hideMSGNotification -> Exception e = " + e2.getMessage() + ' ' + str);
                }
            } else {
                Log.e("NotificationController", "hideMSGNotification -> getNotificationManager() == null " + str);
            }
        } else if (notificationManager != null) {
            try {
                notificationManager.cancel(str.hashCode());
            } catch (Exception e3) {
                String localizedMessage = e3.getLocalizedMessage();
                if (localizedMessage != null) {
                    Log.e("NotificationController", localizedMessage);
                }
            }
        }
        ZNotificationDao.INSTANCE.delete(str);
    }

    public final void showMessageNotification(List<ZNotification> list) {
        k.f(list, "messages");
        Log.i("NotificationController", "showMessageNotification");
        if (list.isEmpty()) {
            return;
        }
        ZNotification zNotification = list.get(0);
        if (canShowNotification(zNotification)) {
            for (ZNotification zNotification2 : list) {
                Log.i("NotificationController", "NT -> start " + zNotification2.getMsgId());
                ZNotificationDao.INSTANCE.insert(zNotification2);
            }
            boolean z2 = !PassCodeController.INSTANCE.conversationIsVisible(zNotification.getConversationId());
            String displayName = getDisplayName(zNotification, z2);
            Bitmap bitmap = getBitmap(zNotification, displayName);
            String notificationBody = getNotificationBody(zNotification, z2);
            ArrayList<ZNotification> c2 = z2 ? l.c(new ZNotification[]{zNotification}) : ZNotificationDao.INSTANCE.get(zNotification.getConversationId());
            if (c2.size() > 1) {
                l.l(c2, new Comparator() {
                    @Override
                    public final int compare(T t2, T t3) {
                        return hb.a.a(Long.valueOf(((ZNotification) t2).getTime()), Long.valueOf(((ZNotification) t3).getTime()));
                    }
                });
            }
            Log.i("NotificationController", "NT -> start display " + notificationBody + " msgId = " + zNotification.getMsgId());
            u.e K = new u.e(getContext(), getChannelId(zNotification.isGroup(), z2)).I(2131231649).u(6).L(displayName + ": " + notificationBody).m(true).p(androidx.core.content.a.c(getContext(), 2131099695)).q(getContentIntent(zNotification.getConversationId())).s(displayName).B(-16776961, 100, 3000).D(c2.size() + 1).z(true).F(getPriority(z2)).A(bitmap).y(Constants.SMS_NOTIFICATION_SINGL_KEY).K(getStyle(displayName, bitmap, c2, z2));
            k.e(K, "Builder(context, this.ge…s, isHiddenConversation))");
            if (!z2) {
                K.b(getReplyAction(zNotification.getConversationId()));
            }
            SystemServiceManager systemServiceManager = SystemServiceManager.INSTANCE;
            NotificationManager notificationManager = systemServiceManager.getNotificationManager();
            if (notificationManager != null) {
                notificationManager.notify(zNotification.getConversationId().hashCode(), K.c());
            }
            systemServiceManager.acquirePartialWakeLock(100L);
        }
    }

    public final void showMissedCallNotification(ZNotification zNotification) {
        k.f(zNotification, DBConstants.TABLE_MESSAGE);
        Log.i("NotificationController", "showMissedCallNotification");
        SystemServiceManager systemServiceManager = SystemServiceManager.INSTANCE;
        String missedCallChanelIdGetAndCreate = systemServiceManager.missedCallChanelIdGetAndCreate();
        u.e B = new u.e(getContext(), missedCallChanelIdGetAndCreate).u(7).L(zNotification.getMsg()).I(2131231657).m(true).p(androidx.core.content.a.c(getContext(), 2131099695)).s(zNotification.getMsg()).q(getMissedCallContentIntent(zNotification.getFrom())).r(zNotification.getName()).B(-16776961, 100, 3000);
        k.e(B, "Builder(context, channel…hts(-0xffff01, 100, 3000)");
        if (!zNotification.isGroup()) {
            B.a(2131231727, getContext().getString(2131887546), getOpenCallContentIntent(zNotification.getName(), zNotification.getConversationId()));
            B.b(getReplyAction(zNotification.getConversationId()));
        }
        NotificationManager notificationManager = systemServiceManager.getNotificationManager();
        if (notificationManager != null) {
            notificationManager.notify(MISSED_CALL_ID, B.c());
        }
        systemServiceManager.acquirePartialWakeLock(100L);
    }
}