导航菜单

页面标题

页面副标题

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

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

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


package com.beint.project.screens;

import android.app.AppOpsManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.graphics.Rect;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Process;
import android.view.KeyEvent;
import android.view.MenuItem;
import android.view.View;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import com.beint.project.Engine;
import com.beint.project.MainApplication;
import com.beint.project.call.CallHelper;
import com.beint.project.core.Conference.IConferenceCallViewModel;
import com.beint.project.core.events.RegistrationEventArgs;
import com.beint.project.core.events.RegistrationEventTypes;
import com.beint.project.core.events.ZangiUIEventArgs;
import com.beint.project.core.events.ZangiUIEventTypes;
import com.beint.project.core.managers.ConferenceCallUiListener;
import com.beint.project.core.managers.ConferenceManager;
import com.beint.project.core.managers.SystemServiceManager;
import com.beint.project.core.managers.ZTelephonyManager;
import com.beint.project.core.services.impl.MediaRoutingService;
import com.beint.project.core.services.impl.SignalingService;
import com.beint.project.core.services.impl.StorageService;
import com.beint.project.core.services.impl.ZangiConfigurationService;
import com.beint.project.core.services.impl.ZangiProfileServiceImpl;
import com.beint.project.core.signal.AVSession;
import com.beint.project.core.signal.CallViewManager;
import com.beint.project.core.signal.ICallViewManager;
import com.beint.project.core.signal.IVideoScreen;
import com.beint.project.core.signal.ZangiAVSessionUI;
import com.beint.project.core.utils.AppUserManager;
import com.beint.project.core.utils.Constants;
import com.beint.project.core.utils.Log;
import com.beint.project.core.utils.NotificationCenter;
import com.beint.project.core.utils.ZangiEngineUtils;
import com.beint.project.core.utils.ZangiPermissionUtils;
import com.beint.project.core.utils.ZangiTimer;
import com.beint.project.core.wrapper.ProjectWrapper;
import com.beint.project.core.wrapper.UpdateStatisticListener;
import com.beint.project.mediabrowser.ImageBrowser;
import com.beint.project.push.NotificationController;
import com.beint.project.screens.groupcall.ConferenceCallFragment;
import com.beint.project.screens.phone.IScreenInCall;
import com.beint.project.screens.phone.ScreenAnsweringFragment;
import com.beint.project.screens.phone.ScreenBusy;
import com.beint.project.screens.phone.ScreenInCall;
import com.beint.project.screens.phone.ScreenIncomingCall;
import com.beint.project.screens.phone.ScreenOutgoingCall;
import com.beint.project.screens.phone.ScreenUnavailable;
import com.beint.project.screens.phone.ScreenVideoCall;
import com.beint.project.screens.phone.event.ChatEventProcessor;
import com.beint.project.screens.phone.event.ShowInCallProcessor;
import com.beint.project.screens.phone.event.ShowOutgoingCallProcessor;
import com.beint.project.screens.phone.event.ZangiUIEventProcessor;
import com.beint.project.screens.sms.AppModeNotifierActivity;
import com.beint.project.screens.sms.ConversationView;
import com.beint.project.services.PassCodeController;
import com.beint.project.services.call_service_forground.ForegroundService;
import com.beint.project.utils.AlertDialogUtils;
import com.beint.project.utils.DeviceTokenResolver;
import com.beint.project.voice.managers.VoiceManager;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.TimerTask;
import java.util.concurrent.atomic.AtomicReference;

public class CallingFragmentActivity extends AppModeNotifierActivity implements UpdateStatisticListener, IVideoScreen, ShowInCallProcessor, ShowOutgoingCallProcessor, ChatEventProcessor, ConferenceCallFragment.ConferenceCallFragmentDelegate, IScreenInCall, ICallViewManager {
    public static final long AUDIO_WAITING_MESSAGE_TIMEOUT = 1500;
    public static final long AUDIO_WAITING_TIMEOUT = 12000;
    public static final long CALL_RESULT_MESSAGE_WAITING_TIMEOUT = 5000;
    public static final long CALL_RESULT_WAITING_TIMEOUT = 7000;
    public static final int STATE_CONFERENCE_AUDIO_CALL = 4;
    public static final int STATE_INCALL = 2;
    public static final int STATE_INCOMING = 0;
    public static final int STATE_OUTGOING = 1;
    public static final int STATE_VIDEOCALL = 3;
    public static final int SUICIDE_LONG_TIME = 500;
    public static final int SUICIDE_NOT_CONNECTED_TIME = 25000;
    public static final int SUICIDE_TIME = 100;
    private static String TAG = "com.beint.project.screens.CallingFragmentActivity";
    public static boolean chatScreenButtonsState;
    public static Intent intent;
    public static boolean isCallingFragmentVisible;
    private static WeakReference<CallingFragmentActivity> thisWeak = new WeakReference<>(null);
    private ZangiTimer audioTimer;
    private AtomicReference<ZangiTimer> callResultMessageTimer;
    private ZangiTimer callResultTimer;
    private BroadcastReceiver closeConnectingReciver;
    private WeakReference<IConferenceCallViewModel> conferenceCallService;
    private ConferenceCallUiListener conferenceCallUiListener;
    private AVSession mAVSession;
    private ZangiAVSessionUI mAVSessionUI;
    private ZangiTimer mRegistrationTimer;
    private BroadcastReceiver mScreenOffReceiver;
    private boolean mStartedFromBackground;
    private ZangiTimer mTimerSuicide;
    private ZangiTimer messageTimer;
    private BroadcastReceiver profileBroadcastReceiver;
    private boolean activityIsActive = false;
    protected WeakReference<ZangiUIEventProcessor> currentUIProccessor = null;
    protected WeakReference<BaseScreen> currentFragment = null;
    private Handler inCallHandler = new Handler();
    private Handler videoCallHandler = new Handler();
    private String callNumber = null;
    private TimerTask mTimerTaskSuicide = null;
    private ZangiTimer mTimerSuicideNotCon = null;
    private TimerTask mTimerTaskSuicideNotCon = null;
    private boolean openChat = false;
    private TimerTask messageTimeTask = null;
    private TimerTask mRegistrationTimerTask = null;
    private TimerTask audioTimerTask = null;
    private TimerTask callResultTimerTask = null;
    private TimerTask callResultMessageTimerTask = null;
    private long callDuration = 0;
    private int currentState = -1;
    public boolean userIntaracted = false;
    private int conferenceCallErrorType = -1;
    private boolean acceptCallAfterMicraphonePermission = false;
    private boolean isRateShareInvite = Constants.IS_ASK_FOR_INVITE;

    static class AnonymousClass12 {
        static final int[] $SwitchMap$com$beint$project$core$events$RegistrationEventTypes;
        static final int[] $SwitchMap$com$beint$project$core$events$ZangiUIEventTypes;

        static {
            int[] iArr = new int[ZangiUIEventTypes.values().length];
            $SwitchMap$com$beint$project$core$events$ZangiUIEventTypes = iArr;
            try {
                iArr[ZangiUIEventTypes.TERMWAIT.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                $SwitchMap$com$beint$project$core$events$ZangiUIEventTypes[ZangiUIEventTypes.TERMINATED.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                $SwitchMap$com$beint$project$core$events$ZangiUIEventTypes[ZangiUIEventTypes.INFO.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            try {
                $SwitchMap$com$beint$project$core$events$ZangiUIEventTypes[ZangiUIEventTypes.BUSY.ordinal()] = 4;
            } catch (NoSuchFieldError unused4) {
            }
            try {
                $SwitchMap$com$beint$project$core$events$ZangiUIEventTypes[ZangiUIEventTypes.INCOMPLETEADDRESS.ordinal()] = 5;
            } catch (NoSuchFieldError unused5) {
            }
            try {
                $SwitchMap$com$beint$project$core$events$ZangiUIEventTypes[ZangiUIEventTypes.FAILED.ordinal()] = 6;
            } catch (NoSuchFieldError unused6) {
            }
            try {
                $SwitchMap$com$beint$project$core$events$ZangiUIEventTypes[ZangiUIEventTypes.NOCREDIT.ordinal()] = 7;
            } catch (NoSuchFieldError unused7) {
            }
            try {
                $SwitchMap$com$beint$project$core$events$ZangiUIEventTypes[ZangiUIEventTypes.NOT_FOUND.ordinal()] = 8;
            } catch (NoSuchFieldError unused8) {
            }
            try {
                $SwitchMap$com$beint$project$core$events$ZangiUIEventTypes[ZangiUIEventTypes.REQUEST_TIME_OUT.ordinal()] = 9;
            } catch (NoSuchFieldError unused9) {
            }
            try {
                $SwitchMap$com$beint$project$core$events$ZangiUIEventTypes[ZangiUIEventTypes.UNAVAILABLE.ordinal()] = 10;
            } catch (NoSuchFieldError unused10) {
            }
            try {
                $SwitchMap$com$beint$project$core$events$ZangiUIEventTypes[ZangiUIEventTypes.NO_AUDIO.ordinal()] = 11;
            } catch (NoSuchFieldError unused11) {
            }
            try {
                $SwitchMap$com$beint$project$core$events$ZangiUIEventTypes[ZangiUIEventTypes.AUDIO.ordinal()] = 12;
            } catch (NoSuchFieldError unused12) {
            }
            try {
                $SwitchMap$com$beint$project$core$events$ZangiUIEventTypes[ZangiUIEventTypes.CLOSE_ANSWERING_OUTGOING.ordinal()] = 13;
            } catch (NoSuchFieldError unused13) {
            }
            try {
                $SwitchMap$com$beint$project$core$events$ZangiUIEventTypes[ZangiUIEventTypes.CLOSE_ANSWERING_INCOMING.ordinal()] = 14;
            } catch (NoSuchFieldError unused14) {
            }
            try {
                $SwitchMap$com$beint$project$core$events$ZangiUIEventTypes[ZangiUIEventTypes.RESULT_CALL.ordinal()] = 15;
            } catch (NoSuchFieldError unused15) {
            }
            try {
                $SwitchMap$com$beint$project$core$events$ZangiUIEventTypes[ZangiUIEventTypes.CLOSE_CALL_RESULT.ordinal()] = 16;
            } catch (NoSuchFieldError unused16) {
            }
            try {
                $SwitchMap$com$beint$project$core$events$ZangiUIEventTypes[ZangiUIEventTypes.INPROGRESS.ordinal()] = 17;
            } catch (NoSuchFieldError unused17) {
            }
            try {
                $SwitchMap$com$beint$project$core$events$ZangiUIEventTypes[ZangiUIEventTypes.RINGING.ordinal()] = 18;
            } catch (NoSuchFieldError unused18) {
            }
            try {
                $SwitchMap$com$beint$project$core$events$ZangiUIEventTypes[ZangiUIEventTypes.CONNECTED.ordinal()] = 19;
            } catch (NoSuchFieldError unused19) {
            }
            try {
                $SwitchMap$com$beint$project$core$events$ZangiUIEventTypes[ZangiUIEventTypes.EARLY_MEDIA.ordinal()] = 20;
            } catch (NoSuchFieldError unused20) {
            }
            try {
                $SwitchMap$com$beint$project$core$events$ZangiUIEventTypes[ZangiUIEventTypes.INCOMING.ordinal()] = 21;
            } catch (NoSuchFieldError unused21) {
            }
            int[] iArr2 = new int[RegistrationEventTypes.values().length];
            $SwitchMap$com$beint$project$core$events$RegistrationEventTypes = iArr2;
            try {
                iArr2[RegistrationEventTypes.UNREGISTRATION_OK.ordinal()] = 1;
            } catch (NoSuchFieldError unused22) {
            }
            try {
                $SwitchMap$com$beint$project$core$events$RegistrationEventTypes[RegistrationEventTypes.REGISTRATION_INPROGRESS.ordinal()] = 2;
            } catch (NoSuchFieldError unused23) {
            }
            try {
                $SwitchMap$com$beint$project$core$events$RegistrationEventTypes[RegistrationEventTypes.UNREGISTRATION_INPROGRESS.ordinal()] = 3;
            } catch (NoSuchFieldError unused24) {
            }
            try {
                $SwitchMap$com$beint$project$core$events$RegistrationEventTypes[RegistrationEventTypes.UNREGISTRATION_NOK.ordinal()] = 4;
            } catch (NoSuchFieldError unused25) {
            }
            try {
                $SwitchMap$com$beint$project$core$events$RegistrationEventTypes[RegistrationEventTypes.CONNECTION_NOK.ordinal()] = 5;
            } catch (NoSuchFieldError unused26) {
            }
            try {
                $SwitchMap$com$beint$project$core$events$RegistrationEventTypes[RegistrationEventTypes.REGISTRATION_NOK.ordinal()] = 6;
            } catch (NoSuchFieldError unused27) {
            }
            try {
                $SwitchMap$com$beint$project$core$events$RegistrationEventTypes[RegistrationEventTypes.REGISTRATION_OK.ordinal()] = 7;
            } catch (NoSuchFieldError unused28) {
            }
        }
    }

    private static final class InCallRunnable implements Runnable {
        private final WeakReference<CallingFragmentActivity> activity;
        private boolean needSpeakerOff;

        InCallRunnable(CallingFragmentActivity callingFragmentActivity, boolean z) {
            this.activity = new WeakReference<>(callingFragmentActivity);
            this.needSpeakerOff = z;
        }

        @Override
        public void run() {
            try {
                CallingFragmentActivity callingFragmentActivity = this.activity.get();
                if (callingFragmentActivity == 0) {
                    return;
                }
                SharedPreferences sharedPreferences = callingFragmentActivity.getSharedPreferences(Constants.CAll_VIDEO_ACTION, 0);
                AVSession.Companion companion = AVSession.Companion;
                AVSession activeSession = companion.getActiveSession();
                if ((activeSession != null && activeSession.isCallStartFromVideo()) || sharedPreferences.getBoolean(Constants.CAll_VIDEO, false)) {
                    callingFragmentActivity.remoteVideoOn();
                    CallingFragmentActivity.chatScreenButtonsState = true;
                    return;
                }
                AVSession activeSession2 = companion.getActiveSession();
                if (activeSession2 == null || !activeSession2.isConferenceCall()) {
                    callingFragmentActivity.openInCallScreen(Boolean.valueOf(this.needSpeakerOff));
                } else {
                    Engine.getInstance().getScreenService().getArguments().putInt(Constants.CALL_SCREEN_STATE, 4);
                }
            } catch (Exception e) {
                Log.e(CallingFragmentActivity.TAG, e.getMessage(), e);
            }
        }
    }

    private void addObservers() {
        registerSignalingEvent();
        if (this.mScreenOffReceiver == null) {
            this.mScreenOffReceiver = new BroadcastReceiver() {
                @Override
                public void onReceive(Context context, Intent intent2) {
                    Log.i(CallingFragmentActivity.TAG, "mScreenOffReceiver");
                    if (intent2 == null || !intent2.getAction().equals("android.intent.action.SCREEN_OFF")) {
                        return;
                    }
                    CallingFragmentActivity.this.stopRingTone();
                }
            };
        }
        if (this.closeConnectingReciver == null) {
            this.closeConnectingReciver = new BroadcastReceiver() {
                @Override
                public void onReceive(Context context, Intent intent2) {
                    CallingFragmentActivity.this.connectionStatusChanged(true, true);
                }
            };
        }
        registerReceiver(this.mScreenOffReceiver, new IntentFilter("android.intent.action.SCREEN_OFF"));
        initProfileReceiver();
        NotificationCenter notificationCenter = NotificationCenter.INSTANCE;
        notificationCenter.addObserver(this, NotificationCenter.NotificationType.REGISTRATION_EVENT, new qb.l() {
            public final Object invoke(Object obj) {
                fb.r lambda$addObservers$5;
                lambda$addObservers$5 = CallingFragmentActivity.this.lambda$addObservers$5(obj);
                return lambda$addObservers$5;
            }
        });
        notificationCenter.addObserver(this, NotificationCenter.NotificationType.REPLACE_CALL_ID, new qb.l() {
            public final Object invoke(Object obj) {
                fb.r lambda$addObservers$6;
                lambda$addObservers$6 = CallingFragmentActivity.this.lambda$addObservers$6(obj);
                return lambda$addObservers$6;
            }
        });
    }

    private void answerCallIfNeeded() {
        Intent intent2 = getIntent();
        if (intent2 == null || !intent2.getBooleanExtra("action_answer", false)) {
            return;
        }
        AVSession.Companion companion = AVSession.Companion;
        if (companion.getCurrentAvSession() != null) {
            boolean hasPermission = ZangiPermissionUtils.hasPermission(this, 1001, false, new ZangiPermissionUtils.OnPermissionResult() {
                public final void onResult(ArrayList arrayList, boolean z) {
                    CallingFragmentActivity.lambda$answerCallIfNeeded$1(arrayList, z);
                }
            });
            ZTelephonyManager.INSTANCE.stopListenNativeCalls();
            MainApplication.Companion companion2 = MainApplication.Companion;
            companion2.getMainContext().stopService(new Intent(companion2.getMainContext(), (Class<?>) ForegroundService.class));
            if (hasPermission) {
                companion.getCurrentAvSession().acceptCall();
            } else {
                this.acceptCallAfterMicraphonePermission = true;
            }
        }
    }

    private void checkLocalVideoNeedToOn() {
        AVSession aVSession = this.mAVSession;
        if (aVSession == null || !aVSession.isCallStartFromVideo() || this.mAVSession.isLocalVideoOn()) {
            return;
        }
        this.mAVSession.startLocalVideo();
    }

    private boolean checkOps() {
        int checkOp;
        AppOpsManager appOpsManager = (AppOpsManager) getSystemService("appops");
        if (appOpsManager == null) {
            return false;
        }
        if (Build.VERSION.SDK_INT >= 29) {
            checkOp = appOpsManager.unsafeCheckOpNoThrow("android:picture_in_picture", Process.myUid(), MainApplication.Companion.getMainContext().getPackageName());
        } else {
            try {
                checkOp = appOpsManager.checkOp("android:picture_in_picture", Process.myUid(), getPackageName());
            } catch (SecurityException unused) {
                return false;
            }
        }
        return checkOp == 0;
    }

    private void checkPermissions() {
        ZangiPermissionUtils.hasPermission(this, 1001, true, new ZangiPermissionUtils.OnPermissionResult() {
            public final void onResult(ArrayList arrayList, boolean z) {
                CallingFragmentActivity.this.lambda$checkPermissions$2(arrayList, z);
            }
        });
        AVSession.Companion companion = AVSession.Companion;
        if (companion.getActiveSession() == null || !companion.getActiveSession().isCallStartFromVideo()) {
            return;
        }
        ZangiPermissionUtils.hasPermission(this, 1011, true, new ZangiPermissionUtils.OnPermissionResult() {
            public final void onResult(ArrayList arrayList, boolean z) {
                CallingFragmentActivity.lambda$checkPermissions$3(arrayList, z);
            }
        });
    }

    public void connectionStatusChanged(final boolean z, final boolean z6) {
        runOnUiThread(new Runnable() {
            @Override
            public final void run() {
                CallingFragmentActivity.this.lambda$connectionStatusChanged$12(z, z6);
            }
        });
    }

    public void lambda$onCreate$0() {
        AVSession.Companion companion = AVSession.Companion;
        if (companion.getCallId() != null) {
            Log.i(TAG, "PING-PONG createCallIfBundleExist -> " + companion.getCallId());
            AVSession session = companion.getSession(companion.getCallId());
            this.mAVSession = session;
            if (session == null) {
                Log.i(TAG, "PING-PONG createCallIfBundleExist -> mAVSession == null");
            }
            AVSession aVSession = this.mAVSession;
            if (aVSession == null || aVSession.isIncoming() || this.mAVSession.isCallSended()) {
                return;
            }
            Log.i(TAG, "PING-PONG createCallIfBundleExist -> try to Send Call");
            SignalingService signalingService = SignalingService.INSTANCE;
            if (signalingService.isRegistered()) {
                Log.i(TAG, "PING-PONG createCallIfBundleExist -> sendCall");
                this.mAVSession.setCallSended(true);
                sendCall(0);
                return;
            }
            Log.i(TAG, "PING-PONG createCallIfBundleExist -> start fake call");
            this.mAVSession.startFakeCall();
            if (signalingService.isFirstCheckPhaseActual()) {
                this.messageTimer = new ZangiTimer("Message Timer");
                TimerTask messageTimerTask = getMessageTimerTask();
                this.messageTimeTask = messageTimerTask;
                this.messageTimer.schedule(messageTimerTask, signalingService.getFirstCheckPhaseActualDuration());
                Log.i(TAG, "CHECK_PHASE getFirstCheckPhaseActualDuration() = " + signalingService.getFirstCheckPhaseActualDuration());
            } else {
                connectionStatusChanged(false, false);
            }
            this.mRegistrationTimer = new ZangiTimer("Registration timer");
            TimerTask registrationTimerTask = getRegistrationTimerTask();
            this.mRegistrationTimerTask = registrationTimerTask;
            this.mRegistrationTimer.schedule(registrationTimerTask, signalingService.getSecondCheckPhaseActualDuration());
            Log.i(TAG, "CHECK_PHASE getSecondCheckPhaseActualDuration() = " + signalingService.getSecondCheckPhaseActualDuration());
            Log.i(TAG, "PING-PONG FakeCallCreated");
        }
    }

    private void createConferenceCallUiListener() {
        this.conferenceCallUiListener = new ConferenceCallUiListener() {
            public void callEnd() {
                CallingFragmentActivity.this.hangupConferenceCall();
            }

            public void performMuteAction() {
                ConferenceCallFragment conferenceCallFragment = (ConferenceCallFragment) CallingFragmentActivity.this.currentFragment.get();
                if (conferenceCallFragment != null) {
                    conferenceCallFragment.performMuteAction();
                }
            }

            public void performUnMuteAction() {
                ConferenceCallFragment conferenceCallFragment = (ConferenceCallFragment) CallingFragmentActivity.this.currentFragment.get();
                if (conferenceCallFragment != null) {
                    conferenceCallFragment.performUnMuteAction();
                }
            }

            public void runInCallTimer() {
                ConferenceCallFragment conferenceCallFragment = (ConferenceCallFragment) CallingFragmentActivity.this.currentFragment.get();
                if (conferenceCallFragment == null || conferenceCallFragment.getModel() == null) {
                    return;
                }
                conferenceCallFragment.getModel().runInCallTimer();
            }
        };
    }

    private void deleteConferenceCalListeners() {
        ConferenceManager.INSTANCE.removeUiListener();
        this.conferenceCallService = null;
        this.conferenceCallUiListener = null;
    }

    private void enterPipMode() {
        throw new UnsupportedOperationException("Method not decompiled: com.beint.project.screens.CallingFragmentActivity.enterPipMode():void");
    }

    private ZangiAVSessionUI getAVSessionUI() {
        return this.mAVSessionUI;
    }

    private TimerTask getAudioTimerTask() {
        return new TimerTask() {
            @Override
            public void run() {
                AVSession currentAvSession = AVSession.Companion.getCurrentAvSession();
                if (currentAvSession == null || currentAvSession.isAudioEventReceived()) {
                    return;
                }
                currentAvSession.hangupAnsweringCall();
            }
        };
    }

    public TimerTask getCallResultMessageTimerTask() {
        return new TimerTask() {
            @Override
            public void run() {
                AVSession.Companion companion = AVSession.Companion;
                AVSession currentAvSession = companion.getCurrentAvSession();
                Log.i(CallingFragmentActivity.TAG, "CHECK_PHASE getCallResultMessageTimerTask()");
                if (currentAvSession == null || companion.getSecondCallId() != null) {
                    return;
                }
                currentAvSession.hangupCallResult();
            }
        };
    }

    private TimerTask getCallResultTimerTask() {
        return new TimerTask() {
            @Override
            public void run() {
                AVSession.Companion companion = AVSession.Companion;
                if (companion.getCurrentAvSession() == null || companion.getSecondCallId() != null) {
                    return;
                }
                CallingFragmentActivity.this.connectionStatusChanged(false, false);
                Log.i(CallingFragmentActivity.TAG, "CHECK_PHASE getCallResultTimerTask()");
                CallingFragmentActivity.this.callResultMessageTimer = new AtomicReference();
                CallingFragmentActivity.this.callResultMessageTimer.set(new ZangiTimer("Call Result Message Timer"));
                CallingFragmentActivity callingFragmentActivity = CallingFragmentActivity.this;
                callingFragmentActivity.callResultMessageTimerTask = callingFragmentActivity.getCallResultMessageTimerTask();
                ((ZangiTimer) CallingFragmentActivity.this.callResultMessageTimer.get()).schedule(CallingFragmentActivity.this.callResultMessageTimerTask, CallingFragmentActivity.CALL_RESULT_MESSAGE_WAITING_TIMEOUT);
            }
        };
    }

    public static synchronized CallingFragmentActivity getInstance() {
        CallingFragmentActivity callingFragmentActivity;
        synchronized (CallingFragmentActivity.class) {
            callingFragmentActivity = thisWeak.get();
        }
        return callingFragmentActivity;
    }

    private TimerTask getMessageTimerTask() {
        return new TimerTask() {
            @Override
            public void run() {
                Log.i(CallingFragmentActivity.TAG, "PING-PONG getMessageTimerTask()()");
                CallingFragmentActivity.this.connectionStatusChanged(false, false);
            }
        };
    }

    private TimerTask getRegistrationTimerTask() {
        return new TimerTask() {
            @Override
            public void run() {
                Log.i(CallingFragmentActivity.TAG, "PING-PONG getRegistrationTimerTask()");
                CallingFragmentActivity.this.closeFakeCall();
            }
        };
    }

    private TimerTask getTimerTaskSuicide() {
        return new TimerTask() {
            @Override
            public void run() {
                CallingFragmentActivity.this.closeCall();
            }
        };
    }

    private static void getUserProfileIfnotContact(final String str) {
        MainApplication.Companion.getRequestServiceExecutor().execute(new Runnable() {
            @Override
            public final void run() {
                CallingFragmentActivity.lambda$getUserProfileIfnotContact$8(str);
            }
        });
    }

    private boolean handlePipModeIfNeeded() {
        if (!canHandlePipMode()) {
            return false;
        }
        checkOpsAndEnterPip();
        return true;
    }

    private void initProfileReceiver() {
        this.profileBroadcastReceiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent2) {
                WeakReference<BaseScreen> weakReference;
                String stringExtra = intent2.getStringExtra("com.beint.project.PROFILE_PICTURE_USER_NUMBER");
                AVSession currentAvSession = AVSession.Companion.getCurrentAvSession();
                if (currentAvSession == null || stringExtra == null || !stringExtra.equals(currentAvSession.getRemotePartyUri()) || (weakReference = CallingFragmentActivity.this.currentFragment) == null || weakReference.get() == null) {
                    return;
                }
                if (CallingFragmentActivity.this.currentFragment.get() instanceof ScreenIncomingCall) {
                    ((ScreenIncomingCall) CallingFragmentActivity.this.currentFragment.get()).showCallInfo();
                } else if (CallingFragmentActivity.this.currentFragment.get() instanceof ScreenOutgoingCall) {
                    ((ScreenOutgoingCall) CallingFragmentActivity.this.currentFragment.get()).showCallInfo();
                } else if (CallingFragmentActivity.this.currentFragment.get() instanceof ScreenInCall) {
                    ((ScreenInCall) CallingFragmentActivity.this.currentFragment.get()).showCallInfo();
                }
            }
        };
    }

    private void invalidateCallResultMessageTimer() {
        AtomicReference<ZangiTimer> atomicReference = this.callResultMessageTimer;
        if (atomicReference == null || atomicReference.get() == null) {
            return;
        }
        this.callResultMessageTimer.get().cancel();
        this.callResultMessageTimer.get().purge();
        this.callResultMessageTimer = null;
        this.callResultMessageTimerTask.cancel();
        this.callResultMessageTimerTask = null;
    }

    private void invalidateCallResultTimer() {
        ZangiTimer zangiTimer = this.callResultTimer;
        if (zangiTimer != null) {
            zangiTimer.cancel();
            this.callResultTimer.purge();
            this.callResultTimer = null;
            this.callResultTimerTask.cancel();
            this.callResultTimerTask = null;
        }
    }

    public fb.r lambda$addObservers$5(Object obj) {
        final RegistrationEventArgs registrationEventArgs = (RegistrationEventArgs) obj;
        runOnUiThread(new Runnable() {
            @Override
            public final void run() {
                CallingFragmentActivity.this.lambda$addObservers$4(registrationEventArgs);
            }
        });
        return fb.r.a;
    }

    public fb.r lambda$addObservers$6(Object obj) {
        invalidateCallResultTimer();
        invalidateCallResultMessageTimer();
        return fb.r.a;
    }

    public static void lambda$answerCallIfNeeded$1(ArrayList arrayList, boolean z) {
    }

    public void lambda$checkPermissions$2(ArrayList arrayList, boolean z) {
        if (!z) {
            AVSession.Companion companion = AVSession.Companion;
            if (companion.getCurrentAvSession() != null) {
                companion.getCurrentAvSession().hangUpCall();
                return;
            }
        }
        if (this.acceptCallAfterMicraphonePermission) {
            AVSession.Companion.getCurrentAvSession().acceptCall();
        }
    }

    public static void lambda$checkPermissions$3(ArrayList arrayList, boolean z) {
    }

    public void lambda$connectionStatusChanged$12(boolean z, boolean z6) {
        WeakReference<BaseScreen> weakReference = this.currentFragment;
        if (weakReference == null || weakReference.get() == null) {
            return;
        }
        if (this.currentFragment.get() instanceof ScreenIncomingCall) {
            ((ScreenIncomingCall) this.currentFragment.get()).showWaitingNetwork(z, Boolean.valueOf(z6));
        } else if (this.currentFragment.get() instanceof ScreenOutgoingCall) {
            ((ScreenOutgoingCall) this.currentFragment.get()).showWaitingNetwork(z, Boolean.valueOf(z6));
        } else if (this.currentFragment.get() instanceof ScreenInCall) {
            ((ScreenInCall) this.currentFragment.get()).showWaitingNetwork(z, Boolean.valueOf(z6));
        }
    }

    public static void lambda$getUserProfileIfnotContact$8(String str) {
        String e164WithoutPlus = ZangiEngineUtils.getE164WithoutPlus(str, ZangiEngineUtils.getZipCode(), true);
        if (e164WithoutPlus != null) {
            ZangiProfileServiceImpl.getInstance().getUserProfileFromServer(e164WithoutPlus);
        }
    }

    public fb.r lambda$onResume$13(Object obj) {
        connectionStatusChanged(((Boolean) obj).booleanValue(), true);
        return fb.r.a;
    }

    public static void lambda$onVideoButtonClick$10(ArrayList arrayList, boolean z) {
        if (z) {
            MainApplication.Companion.getMainHandler().postDelayed(new Runnable() {
                @Override
                public final void run() {
                    CallingFragmentActivity.lambda$onVideoButtonClick$9();
                }
            }, 1000L);
        }
    }

    public static void lambda$onVideoButtonClick$9() {
        AVSession activeSession = AVSession.Companion.getActiveSession();
        if (activeSession != null) {
            activeSession.startLocalVideo();
        }
    }

    public fb.r lambda$registerSignalingEvent$7(Object obj) {
        boolean z;
        Log.i(TAG, "PING-PONG OnRtmpEvent onReceive");
        ZangiUIEventArgs parcelableExtra = ((Intent) obj).getParcelableExtra(ZangiUIEventArgs.EXTRA_EMBEDDED);
        Log.i(TAG, "event args");
        if (parcelableExtra == null) {
            Log.e(TAG, "Invalid event args");
            return fb.r.a;
        }
        String sessionId = parcelableExtra.getSessionId();
        if (sessionId == null) {
            Log.e(TAG, "PING-PONG OnRtmpEvent onReceive sessionId=" + sessionId);
            return fb.r.a;
        }
        ZangiAVSessionUI avsessionUi = parcelableExtra.getAvsessionUi();
        if (avsessionUi == null) {
            Log.e(TAG, "PING-PONG OnRtmpEvent onReceive sessionUI is null");
            return fb.r.a;
        }
        setAVSessionUI(avsessionUi);
        Log.i(TAG, "PING-PONG OnRtmpEvent onReceive sessionId=" + sessionId);
        String str = TAG;
        StringBuilder sb = new StringBuilder();
        sb.append("PING-PONG OnRtmpEvent onReceive currentSessionId=");
        AVSession.Companion companion = AVSession.Companion;
        sb.append(companion.getCallId());
        Log.i(str, sb.toString());
        if (companion.getCallId() == null || !companion.getCallId().equals(sessionId)) {
            Log.i(TAG, "PING-PONG OnRtmpEvent onReceive NOT EQUALS");
            return fb.r.a;
        }
        Log.i(TAG, "EventType = " + parcelableExtra.getEventType());
        switch (AnonymousClass12.$SwitchMap$com$beint$project$core$events$ZangiUIEventTypes[parcelableExtra.getEventType().ordinal()]) {
            case 1:
            case 2:
                Log.i(TAG, "!!!!!Terminated call");
                this.mTimerTaskSuicide = getTimerTaskSuicide();
                ZangiTimer zangiTimer = new ZangiTimer("outgoing call suicide timer");
                this.mTimerSuicide = zangiTimer;
                zangiTimer.schedule(this.mTimerTaskSuicide, 100L);
                break;
            case 4:
                Log.i(TAG, "PING-PONG OnRtmpEvent onReceive BUSY sessionId=" + sessionId);
                ScreenBusy screenBusy = new ScreenBusy();
                screenBusy.setPreviousAvSession(avsessionUi);
                this.currentUIProccessor = new WeakReference<>(screenBusy);
                this.currentFragment = new WeakReference<>(screenBusy);
                getSupportFragmentManager().n().q(2131362950, screenBusy).j();
                getSupportFragmentManager().f0();
                invalidateCallResultTimer();
                invalidateCallResultMessageTimer();
                break;
            case 5:
                ScreenBusy screenBusy2 = new ScreenBusy();
                screenBusy2.setPreviousAvSession(avsessionUi);
                this.currentUIProccessor = new WeakReference<>(screenBusy2);
                this.currentFragment = new WeakReference<>(screenBusy2);
                getSupportFragmentManager().n().q(2131362950, screenBusy2).j();
                getSupportFragmentManager().f0();
                break;
            case 6:
                if (avsessionUi.isOutgoing()) {
                    ScreenBusy screenBusy3 = new ScreenBusy();
                    screenBusy3.setPreviousAvSession(avsessionUi);
                    this.currentUIProccessor = new WeakReference<>(screenBusy3);
                    this.currentFragment = new WeakReference<>(screenBusy3);
                    getSupportFragmentManager().n().q(2131362950, screenBusy3).j();
                    getSupportFragmentManager().f0();
                    break;
                }
                break;
            case 8:
                ScreenUnavailable screenUnavailable = new ScreenUnavailable();
                Log.i(TAG, "PING-PONG OnRtmpEvent onReceive NOT_FOUND");
                screenUnavailable.setPreviousAvSession(avsessionUi);
                screenUnavailable.setUIEventType(ZangiUIEventTypes.NOT_FOUND);
                this.currentUIProccessor = new WeakReference<>(screenUnavailable);
                this.currentFragment = new WeakReference<>(screenUnavailable);
                getSupportFragmentManager().n().q(2131362950, screenUnavailable).j();
                getSupportFragmentManager().f0();
                break;
            case 9:
                if (avsessionUi.isVoipCall()) {
                    this.mTimerTaskSuicide = getTimerTaskSuicide();
                    ZangiTimer zangiTimer2 = new ZangiTimer("outgoing call suicide timer");
                    this.mTimerSuicide = zangiTimer2;
                    zangiTimer2.schedule(this.mTimerTaskSuicide, 100L);
                    break;
                }
            case 10:
                ScreenUnavailable screenUnavailable2 = new ScreenUnavailable();
                screenUnavailable2.setPreviousAvSession(avsessionUi);
                this.currentUIProccessor = new WeakReference<>(screenUnavailable2);
                this.currentFragment = new WeakReference<>(screenUnavailable2);
                getSupportFragmentManager().n().q(2131362950, screenUnavailable2).j();
                getSupportFragmentManager().f0();
                break;
            case 11:
                Log.i(TAG, "!!!!!Terminated call");
                this.mTimerTaskSuicide = getTimerTaskSuicide();
                ZangiTimer zangiTimer3 = new ZangiTimer("outgoing call suicide timer");
                this.mTimerSuicide = zangiTimer3;
                zangiTimer3.schedule(this.mTimerTaskSuicide, 100L);
                break;
            case 12:
                ZangiTimer zangiTimer4 = this.audioTimer;
                if (zangiTimer4 != null) {
                    zangiTimer4.cancel();
                    this.audioTimer.purge();
                    this.audioTimer = null;
                    this.audioTimerTask.cancel();
                    this.audioTimerTask = null;
                }
                invalidateCallResultTimer();
                invalidateCallResultMessageTimer();
                break;
            case 13:
                ScreenAnsweringFragment screenAnsweringFragment = new ScreenAnsweringFragment();
                screenAnsweringFragment.setPreviousAvSession(avsessionUi);
                this.currentUIProccessor = new WeakReference<>(screenAnsweringFragment);
                this.currentFragment = new WeakReference<>(screenAnsweringFragment);
                getSupportFragmentManager().n().q(2131362950, screenAnsweringFragment).j();
                getSupportFragmentManager().f0();
                break;
            case 14:
                Log.i(TAG, "!!!!!Terminated call");
                ScreenAnsweringFragment screenAnsweringFragment2 = new ScreenAnsweringFragment();
                screenAnsweringFragment2.setPreviousAvSession(avsessionUi);
                this.currentUIProccessor = new WeakReference<>(screenAnsweringFragment2);
                this.currentFragment = new WeakReference<>(screenAnsweringFragment2);
                getSupportFragmentManager().n().q(2131362950, screenAnsweringFragment2).j();
                getSupportFragmentManager().f0();
                break;
            case 15:
                Log.i(TAG, "RESULT_CALL");
                invalidateCallResultTimer();
                invalidateCallResultMessageTimer();
                connectionStatusChanged(true, true);
                AVSession aVSession = this.mAVSession;
                if (aVSession != null) {
                    aVSession.setTimerSuicideExtended();
                    break;
                }
                break;
            case 16:
                Log.i(TAG, "!!!!!Terminated call");
                this.mTimerTaskSuicide = getTimerTaskSuicide();
                ZangiTimer zangiTimer5 = new ZangiTimer("outgoing call suicide timer");
                this.mTimerSuicide = zangiTimer5;
                zangiTimer5.schedule(this.mTimerTaskSuicide, 500L);
                break;
            case 19:
                AVSession currentAvSession = companion.getCurrentAvSession();
                if (currentAvSession != null && currentAvSession.isConferenceCall()) {
                    processInCall(false);
                    break;
                } else {
                    if (!avsessionUi.isAudioEventReceived()) {
                        this.audioTimer = new ZangiTimer("Audio Timer");
                        TimerTask audioTimerTask = getAudioTimerTask();
                        this.audioTimerTask = audioTimerTask;
                        this.audioTimer.schedule(audioTimerTask, 13500L);
                    }
                    processInCall(false);
                    break;
                }
            case 21:
                Log.i(TAG, "PING-PONG OnRtmpEvent onReceive INCOMING");
                try {
                    z = getSupportFragmentManager().d1("INCOMING", 0);
                } catch (IllegalStateException e) {
                    Log.e(TAG, e.getMessage());
                    z = false;
                }
                if (!z && getSupportFragmentManager().j0("INCOMING") == null) {
                    ScreenIncomingCall screenIncomingCall = new ScreenIncomingCall();
                    this.currentUIProccessor = new WeakReference<>(screenIncomingCall);
                    this.currentFragment = new WeakReference<>(screenIncomingCall);
                    getSupportFragmentManager().n().r(2131362950, screenIncomingCall, "INCOMING").j();
                    getSupportFragmentManager().f0();
                }
                CallHelper.callVideo(false);
                getUserProfileIfnotContact(avsessionUi.getDialNumber());
                break;
        }
        WeakReference<ZangiUIEventProcessor> weakReference = this.currentUIProccessor;
        if (weakReference != null && weakReference.get() != null) {
            Log.e(TAG, "currentInviteProcessor processInviteEvent(args) called");
            this.currentUIProccessor.get().processUIEvent(parcelableExtra);
        }
        return fb.r.a;
    }

    public void lambda$setMute$11(boolean z) {
        WeakReference<BaseScreen> weakReference = this.currentFragment;
        if (weakReference == null || weakReference.get() == null) {
            return;
        }
        if (this.currentFragment.get() instanceof ScreenVideoCall) {
            ((ScreenVideoCall) this.currentFragment.get()).onMute(z);
        } else if (this.currentFragment.get() instanceof ScreenInCall) {
            ((ScreenInCall) this.currentFragment.get()).onMute(z);
        }
    }

    private void openConferenceScreen() {
        ConferenceCallFragment conferenceCallFragment = new ConferenceCallFragment();
        Bundle bundle = new Bundle();
        bundle.putInt("error_type", this.conferenceCallErrorType);
        conferenceCallFragment.setArguments(bundle);
        conferenceCallFragment.setDelegate(new WeakReference<>(this));
        this.currentUIProccessor = new WeakReference<>(conferenceCallFragment);
        this.currentFragment = new WeakReference<>(conferenceCallFragment);
        getSupportFragmentManager().n().r(2131362950, conferenceCallFragment, "CONFERENCE").j();
        getSupportFragmentManager().f0();
        createConferenceCallUiListener();
        ConferenceManager.INSTANCE.setUiListener(new WeakReference(this.conferenceCallUiListener));
    }

    public void openInCallScreen(Boolean bool) {
        Engine.getInstance().getScreenService().getArguments().putInt(Constants.CALL_SCREEN_STATE, 2);
        ScreenInCall screenInCall = (ScreenInCall) Fragment.instantiate(this, ScreenInCall.class.getName());
        screenInCall.delegate = new WeakReference<>(this);
        this.currentUIProccessor = new WeakReference<>(screenInCall);
        this.currentFragment = new WeakReference<>(screenInCall);
        if (bool.booleanValue() && SystemServiceManager.INSTANCE.getAudioManager().isSpeakerphoneOn()) {
            MediaRoutingService.INSTANCE.setHeadsetOn();
            AVSession activeSession = AVSession.Companion.getActiveSession();
            if (activeSession != null) {
                activeSession.setSpeakerphoneOn();
            }
        }
        getSupportFragmentManager().n().q(2131362950, screenInCall).j();
        getSupportFragmentManager().f0();
    }

    private void openVideoScreen() {
        Engine.getInstance().getScreenService().getArguments().putInt(Constants.CALL_SCREEN_STATE, 3);
        if (isVideoScreenVisible().booleanValue()) {
            return;
        }
        try {
            ScreenVideoCall screenVideoCall = new ScreenVideoCall();
            this.currentUIProccessor = new WeakReference<>(screenVideoCall);
            this.currentFragment = new WeakReference<>(screenVideoCall);
            getSupportFragmentManager().n().q(2131362950, screenVideoCall).j();
            getSupportFragmentManager().f0();
        } catch (Exception e) {
            Log.e(TAG, e.getLocalizedMessage());
        }
    }

    private void prepareNewCallState() {
        int i = Engine.getInstance().getScreenService().getArguments().getInt(Constants.CALL_SCREEN_STATE, 0);
        this.currentState = i;
        if (i == 0) {
            if (!getSupportFragmentManager().d1("INCOMING", 0) && getSupportFragmentManager().j0("INCOMING") == null) {
                ScreenIncomingCall screenIncomingCall = new ScreenIncomingCall();
                this.currentUIProccessor = new WeakReference<>(screenIncomingCall);
                this.currentFragment = new WeakReference<>(screenIncomingCall);
                getSupportFragmentManager().n().r(2131362950, screenIncomingCall, "INCOMING").j();
                getSupportFragmentManager().f0();
            }
            AVSession.Companion companion = AVSession.Companion;
            if (!companion.hasActiveSession() || companion.getActiveSession() == null || companion.getActiveSession().isConferenceCall()) {
                return;
            }
            getUserProfileIfnotContact(companion.getActiveSession().getContactNumber());
            return;
        }
        if (i != 1) {
            if (i == 2) {
                openInCallScreen(Boolean.FALSE);
                return;
            } else if (i == 3) {
                openVideoScreen();
                return;
            } else {
                if (i != 4) {
                    return;
                }
                openConferenceScreen();
                return;
            }
        }
        ScreenOutgoingCall screenOutgoingCall = new ScreenOutgoingCall();
        this.currentUIProccessor = new WeakReference<>(screenOutgoingCall);
        this.currentFragment = new WeakReference<>(screenOutgoingCall);
        AVSession currentAvSession = AVSession.Companion.getCurrentAvSession();
        if (currentAvSession == null) {
            finish();
            return;
        }
        screenOutgoingCall.setPreviousAvSession(currentAvSession.buildAVSessionUI());
        getSupportFragmentManager().n().q(2131362950, screenOutgoingCall).j();
        getSupportFragmentManager().f0();
        getUserProfileIfnotContact(currentAvSession.getDialNumber());
    }

    private void registerSignalingEvent() {
        Log.i(TAG, "PING-PONG onCreate registerSignalingEvent");
        NotificationCenter.INSTANCE.addObserver(this, NotificationCenter.NotificationType.ACTION_UI_EVENT, new qb.l() {
            public final Object invoke(Object obj) {
                fb.r lambda$registerSignalingEvent$7;
                lambda$registerSignalingEvent$7 = CallingFragmentActivity.this.lambda$registerSignalingEvent$7(obj);
                return lambda$registerSignalingEvent$7;
            }
        });
    }

    private void sendCall(int i) {
        Log.i(TAG, "CHECK_PHASE sendCall() = ");
        this.mAVSession.startCall(i, AppUserManager.INSTANCE.getUserEmail());
        AVSession.Companion companion = AVSession.Companion;
        if (companion.getCurrentAvSession() == null || companion.getCurrentAvSession().getDoubleCallid() == null) {
            this.callResultTimer = new ZangiTimer("Call Result Timer");
            this.callResultTimerTask = getCallResultTimerTask();
            if (this.mAVSession.isConferenceCall()) {
                this.callResultTimer.schedule(this.callResultTimerTask, 60000L);
            } else {
                this.callResultTimer.schedule(this.callResultTimerTask, CALL_RESULT_WAITING_TIMEOUT);
            }
        }
    }

    private void setAVSessionUI(ZangiAVSessionUI zangiAVSessionUI) {
        this.mAVSessionUI = zangiAVSessionUI;
    }

    private void setActivityFlags() {
        getWindow().addFlags(6848640);
    }

    public static synchronized void setInstance(CallingFragmentActivity callingFragmentActivity) {
        synchronized (CallingFragmentActivity.class) {
            thisWeak = new WeakReference<>(callingFragmentActivity);
        }
    }

    private void showPipDialog() {
        AlertDialogUtils.showAlertWithMessage((Context) this, 2131887162, 2131887163, 2131887077, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                CallingFragmentActivity.this.startActivity(new Intent("android.settings.PICTURE_IN_PICTURE_SETTINGS", Uri.parse("package:" + CallingFragmentActivity.this.getPackageName())));
            }
        }, true);
    }

    public boolean stopRingTone() {
        MediaRoutingService mediaRoutingService = MediaRoutingService.INSTANCE;
        boolean isRinging = mediaRoutingService.isRinging();
        if (isRinging) {
            mediaRoutingService.stopRingTone();
        }
        return isRinging;
    }

    public void lambda$addObservers$4(RegistrationEventArgs registrationEventArgs) {
        switch (AnonymousClass12.$SwitchMap$com$beint$project$core$events$RegistrationEventTypes[registrationEventArgs.getEventType().ordinal()]) {
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
                Log.i(TAG, " REGISTRATION_NOK");
                if (this.mTimerTaskSuicideNotCon == null) {
                    Log.i(TAG, "init mTimerTaskSuicideNotCon");
                    this.mTimerTaskSuicideNotCon = getTimerTaskSuicide();
                    ZangiTimer zangiTimer = new ZangiTimer("REGISTRATION_NOK suicide timer");
                    this.mTimerSuicideNotCon = zangiTimer;
                    zangiTimer.schedule(this.mTimerTaskSuicideNotCon, 25000L);
                    break;
                }
                break;
            case 7:
                Log.w(TAG, " REGISTRATION_OK");
                connectionStatusChanged(true, true);
                TimerTask timerTask = this.mTimerTaskSuicideNotCon;
                if (timerTask != null) {
                    timerTask.cancel();
                    this.mTimerTaskSuicideNotCon = null;
                }
                ZangiTimer zangiTimer2 = this.mTimerSuicideNotCon;
                if (zangiTimer2 != null) {
                    zangiTimer2.cancel();
                    this.mTimerSuicideNotCon.purge();
                    this.mTimerSuicideNotCon = null;
                }
                TimerTask timerTask2 = this.messageTimeTask;
                if (timerTask2 != null) {
                    timerTask2.cancel();
                    this.messageTimeTask = null;
                }
                ZangiTimer zangiTimer3 = this.messageTimer;
                if (zangiTimer3 != null) {
                    zangiTimer3.cancel();
                    this.messageTimer.purge();
                    this.messageTimer = null;
                }
                ZangiTimer zangiTimer4 = this.mRegistrationTimer;
                if (zangiTimer4 != null) {
                    zangiTimer4.cancel();
                    this.mRegistrationTimer.purge();
                    this.mRegistrationTimer = null;
                }
                TimerTask timerTask3 = this.mRegistrationTimerTask;
                if (timerTask3 != null) {
                    timerTask3.cancel();
                    this.mRegistrationTimerTask = null;
                }
                AVSession aVSession = this.mAVSession;
                if (aVSession != null && aVSession.isInFakeCallState()) {
                    sendCall(0);
                    break;
                }
                break;
        }
    }

    public boolean canHandlePipMode() {
        WeakReference<BaseScreen> weakReference = this.currentFragment;
        return (weakReference == null || weakReference.get() == null || !this.currentFragment.get().canHandlePipMode()) ? false : true;
    }

    public void checkOpsAndEnterPip() {
        if (checkOps()) {
            enterPipMode();
        } else {
            showPipDialog();
        }
    }

    protected void closeActivity() {
        Log.i(TAG, "PING-PONG OnRtmpEvent closeCall() closeCallingActivity()");
        CallHelper.callVideo(false);
        ZangiConfigurationService.INSTANCE.putBoolean("CALL_OUT_ACTION", false);
        chatScreenButtonsState = false;
        if (isStartedFromBackground() && !this.openChat) {
            moveTaskToBack(true);
        }
        finish();
        Log.i(TAG, "!!!!!Activity finish");
        Log.i(TAG, "closeActivity() Call_Duration = " + this.callDuration);
        if (!this.isRateShareInvite || this.callDuration < 300000) {
            return;
        }
        StorageService storageService = StorageService.INSTANCE;
        int intValue = Integer.valueOf(storageService.getStringSetting(Constants.RATE_SHARE_INVITE_SCREEN_STATE, "0")).intValue();
        long parseLong = Long.parseLong(storageService.getStringSetting(Constants.RATE_SHARE_INVITE_LAST_TIME, "0"));
        if (intValue < 0 || intValue > 2 || System.currentTimeMillis() - parseLong < DeviceTokenResolver.REGISTRATION_EXPIRY_TIME_MS) {
            return;
        }
        startActivity(new Intent((Context) this, (Class<?>) RateShareInviteActivity.class));
        Log.i(TAG, "startActivity()  RateShareInviteActivity");
    }

    public void closeCall() {
        Log.i(TAG, "PING-PONG OnRtmpEvent closeCall()");
        Log.i(TAG, "!!!!!Finish time = " + System.currentTimeMillis());
        if (this.callNumber != null) {
            ZangiProfileServiceImpl.getInstance().getUserProfileFromServer(this.callNumber);
        }
        TimerTask timerTask = this.mTimerTaskSuicide;
        if (timerTask != null) {
            timerTask.cancel();
            this.mTimerTaskSuicide = null;
        }
        ZangiTimer zangiTimer = this.mTimerSuicide;
        if (zangiTimer != null) {
            zangiTimer.cancel();
            this.mTimerSuicide.purge();
            this.mTimerSuicide = null;
        }
        TimerTask timerTask2 = this.mTimerTaskSuicideNotCon;
        if (timerTask2 != null) {
            timerTask2.cancel();
            this.mTimerTaskSuicideNotCon = null;
        }
        ZangiTimer zangiTimer2 = this.mTimerSuicideNotCon;
        if (zangiTimer2 != null) {
            zangiTimer2.cancel();
            this.mTimerSuicideNotCon.purge();
            this.mTimerSuicideNotCon = null;
        }
        TimerTask timerTask3 = this.messageTimeTask;
        if (timerTask3 != null) {
            timerTask3.cancel();
            this.messageTimeTask = null;
        }
        ZangiTimer zangiTimer3 = this.messageTimer;
        if (zangiTimer3 != null) {
            zangiTimer3.cancel();
            this.messageTimer.purge();
            this.messageTimer = null;
        }
        TimerTask timerTask4 = this.mRegistrationTimerTask;
        if (timerTask4 != null) {
            timerTask4.cancel();
            this.mRegistrationTimerTask = null;
        }
        ZangiTimer zangiTimer4 = this.mRegistrationTimer;
        if (zangiTimer4 != null) {
            zangiTimer4.cancel();
            this.mRegistrationTimer.purge();
            this.mRegistrationTimer = null;
        }
        ZangiTimer zangiTimer5 = this.audioTimer;
        if (zangiTimer5 != null) {
            zangiTimer5.cancel();
            this.audioTimer.purge();
            this.audioTimer = null;
            this.audioTimerTask.cancel();
            this.audioTimerTask = null;
        }
        WeakReference<IConferenceCallViewModel> weakReference = this.conferenceCallService;
        if (weakReference != null && weakReference.get() != null) {
            this.conferenceCallService.get().closeCall();
        }
        invalidateCallResultTimer();
        invalidateCallResultMessageTimer();
        terminateSession();
        closeActivity();
    }

    public void closeFakeCall() {
        Log.i(TAG, "PING-PONG closeFakeCall()");
        Log.i(TAG, "!!!!!Finish time = " + System.currentTimeMillis());
        TimerTask timerTask = this.messageTimeTask;
        if (timerTask != null) {
            timerTask.cancel();
            this.messageTimeTask = null;
        }
        ZangiTimer zangiTimer = this.messageTimer;
        if (zangiTimer != null) {
            zangiTimer.cancel();
            this.messageTimer.purge();
            this.messageTimer = null;
        }
        TimerTask timerTask2 = this.mRegistrationTimerTask;
        if (timerTask2 != null) {
            timerTask2.cancel();
            this.mRegistrationTimerTask = null;
        }
        ZangiTimer zangiTimer2 = this.mRegistrationTimer;
        if (zangiTimer2 != null) {
            zangiTimer2.cancel();
            this.mRegistrationTimer.purge();
            this.mRegistrationTimer = null;
        }
        AVSession.Companion companion = AVSession.Companion;
        if (companion.getCurrentAvSession() == null || !companion.getCurrentAvSession().isInFakeCallState()) {
            return;
        }
        companion.getCurrentAvSession().hangUpFakeCall();
    }

    public void enableDisableVideoWhenUserNavigateOtherPage(int i) {
        if (Build.VERSION.SDK_INT < 26 && this.currentFragment.get() != null && (this.currentFragment.get() instanceof ScreenVideoCall)) {
            ((ScreenVideoCall) this.currentFragment.get()).enableDisableVideoWhenGoOtherScreen(i);
            ((ScreenVideoCall) this.currentFragment.get()).hideShowScreenLayoutsWhenAppScreenChange(i);
        }
    }

    public FragmentManager getCurrentFragmentChildFragmentManager() {
        WeakReference<BaseScreen> weakReference = this.currentFragment;
        if (weakReference == null || weakReference.get() == null) {
            return null;
        }
        return this.currentFragment.get().getChildFragmentManager();
    }

    @Override
    public void hangupConferenceCall() {
        ConferenceCallFragment conferenceCallFragment = (ConferenceCallFragment) this.currentFragment.get();
        if (conferenceCallFragment != null && conferenceCallFragment.getModel() != null) {
            conferenceCallFragment.getModel().cancelTimer();
        }
        finish();
    }

    public boolean isActivityIsActive() {
        return this.activityIsActive;
    }

    public boolean isBusyScreen() {
        WeakReference<BaseScreen> weakReference = this.currentFragment;
        return weakReference != null && ((weakReference.get() instanceof ScreenBusy) || (this.currentFragment.get() instanceof ScreenUnavailable));
    }

    public boolean isStartedFromBackground() {
        return this.mStartedFromBackground;
    }

    public Boolean isVideoScreenVisible() {
        WeakReference<BaseScreen> weakReference = this.currentFragment;
        return Boolean.valueOf((weakReference == null || weakReference.get() == null || !(this.currentFragment.get() instanceof ScreenVideoCall)) ? false : true);
    }

    public void localVideoOff() {
        if (isVideoScreenVisible().booleanValue()) {
            ((ScreenVideoCall) this.currentFragment.get()).localVideoOff();
        }
    }

    public void localVideoOn() {
        if (isVideoScreenVisible().booleanValue()) {
            ((ScreenVideoCall) this.currentFragment.get()).localVideoOn();
        } else {
            openVideoScreen();
        }
    }

    @Override
    protected void onCreate(Bundle bundle) {
        this.activityIsActive = true;
        answerCallIfNeeded();
        Intent intent2 = intent;
        if (intent2 != null) {
            setIntent(intent2);
        }
        VoiceManager voiceManager = VoiceManager.INSTANCE;
        if (voiceManager.isRecording()) {
            voiceManager.onCallStart();
        }
        MainApplication.Companion companion = MainApplication.Companion;
        companion.setCallContext(this);
        requestWindowFeature(1);
        setActivityFlags();
        super.onCreate(bundle);
        CallViewManager.INSTANCE.setCallView(new WeakReference(this));
        overridePendingTransition(2130772027, 2130772003);
        setInstance(this);
        ProjectWrapper.addStatisticListener(this);
        Log.i(TAG, "PING-PONG onCreate");
        AVSession.Companion companion2 = AVSession.Companion;
        if (companion2.getActiveSession() != null) {
            String contactNumber = companion2.getActiveSession().getContactNumber();
            this.callNumber = contactNumber;
            if (contactNumber != null && contactNumber.contains("+")) {
                this.callNumber = this.callNumber.replace("+", "");
            }
        }
        setContentView(2131558444);
        getWindow().addFlags(Integer.MIN_VALUE);
        getWindow().setStatusBarColor(0);
        getWindow().setNavigationBarColor(0);
        getWindow().getDecorView().setSystemUiVisibility(1792);
        View findViewById = findViewById(2131363849);
        if (findViewById != null) {
            findViewById.setVisibility(8);
        }
        findViewById(2131362883).setVisibility(8);
        this.mStartedFromBackground = getEngine().isBackGroundMode();
        if (getIntent() != null) {
            this.conferenceCallErrorType = getIntent().getIntExtra("conference_call_error_type", -1);
        }
        prepareNewCallState();
        companion.getMainExecutor2().submit(new Runnable() {
            @Override
            public final void run() {
                CallingFragmentActivity.this.lambda$onCreate$0();
            }
        });
        checkPermissions();
        addObservers();
        checkLocalVideoNeedToOn();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        deleteConferenceCalListeners();
        setInstance(null);
        ProjectWrapper.removeStatisticListener(this);
        Log.i(TAG, "PING-PONG onDestroy");
        chatScreenButtonsState = false;
        TimerTask timerTask = this.mTimerTaskSuicide;
        if (timerTask != null) {
            timerTask.cancel();
            this.mTimerTaskSuicide = null;
        }
        ZangiTimer zangiTimer = this.mTimerSuicide;
        if (zangiTimer != null) {
            zangiTimer.cancel();
            this.mTimerSuicide.purge();
            this.mTimerSuicide = null;
        }
        TimerTask timerTask2 = this.mTimerTaskSuicideNotCon;
        if (timerTask2 != null) {
            timerTask2.cancel();
            this.mTimerTaskSuicideNotCon = null;
        }
        ZangiTimer zangiTimer2 = this.mTimerSuicideNotCon;
        if (zangiTimer2 != null) {
            zangiTimer2.cancel();
            this.mTimerSuicideNotCon.purge();
            this.mTimerSuicideNotCon = null;
        }
        BroadcastReceiver broadcastReceiver = this.mScreenOffReceiver;
        if (broadcastReceiver != null) {
            unregisterReceiver(broadcastReceiver);
            this.mScreenOffReceiver = null;
        }
        TimerTask timerTask3 = this.messageTimeTask;
        if (timerTask3 != null) {
            timerTask3.cancel();
            this.messageTimeTask = null;
        }
        ZangiTimer zangiTimer3 = this.messageTimer;
        if (zangiTimer3 != null) {
            zangiTimer3.cancel();
            this.messageTimer.purge();
            this.messageTimer = null;
        }
        TimerTask timerTask4 = this.mRegistrationTimerTask;
        if (timerTask4 != null) {
            timerTask4.cancel();
            this.mRegistrationTimerTask = null;
        }
        ZangiTimer zangiTimer4 = this.mRegistrationTimer;
        if (zangiTimer4 != null) {
            zangiTimer4.cancel();
            this.mRegistrationTimer.purge();
            this.mRegistrationTimer = null;
        }
        invalidateCallResultTimer();
        invalidateCallResultMessageTimer();
        NotificationCenter.INSTANCE.removeObserver(this);
        long currentTimeMillis = System.currentTimeMillis();
        Log.i(TAG, "!!!!!On destroy time = " + currentTimeMillis);
        NotificationController.INSTANCE.hideCallNotification();
        Log.i(TAG, "PING-PONG onDestroy sInstance=null");
        Log.i(TAG, "!!!!!Destroy finished = " + (System.currentTimeMillis() - currentTimeMillis));
    }

    protected void onNewIntent(Intent intent2) {
        super/*androidx.fragment.app.FragmentActivity*/.onNewIntent(intent2);
        AVSession.Companion companion = AVSession.Companion;
        if (companion.getCallId() == null || companion.getSession(companion.getCallId()) == null) {
            return;
        }
        prepareNewCallState();
        if (intent2.getExtras() == null) {
            return;
        }
        lambda$onCreate$0();
        Log.i(TAG, "PING-PONG onNewIntent");
    }

    public boolean onOptionsItemSelected(MenuItem menuItem) {
        ConversationView conversationView;
        if (menuItem.getItemId() == 16908332) {
            ConversationManager conversationManager = ConversationManager.INSTANCE;
            if (conversationManager.getConversationScreenRef() != null && (conversationView = conversationManager.getConversationScreenRef().get()) != null && conversationView.isVisible() && conversationView.getView() != null && conversationView.getView().getGlobalVisibleRect(new Rect())) {
                if (conversationView.imageBrowserIsOpen(this)) {
                    return true;
                }
                if (removeImageBrowserWhenExist()) {
                    enableDisableVideoWhenUserNavigateOtherPage(0);
                    return true;
                }
            }
            WeakReference<BaseScreen> weakReference = this.currentFragment;
            if (weakReference != null && weakReference.get() != null && (this.currentFragment.get() instanceof ScreenVideoCall) && !((ScreenVideoCall) this.currentFragment.get()).checkChatScreenExisting() && handlePipModeIfNeeded()) {
                return true;
            }
            onBackPressed();
        }
        return super/*android.app.Activity*/.onOptionsItemSelected(menuItem);
    }

    @Override
    public void onPause() {
        super.onPause();
        unregisterReceiver(this.profileBroadcastReceiver);
        unregisterReceiver(this.closeConnectingReciver);
        NotificationCenter.INSTANCE.removeObserver(this, NotificationCenter.NotificationType.CONNECTION_STATUS_CHANGED);
    }

    @Override
    public void onResume() {
        super.onResume();
        AVSession.Companion companion = AVSession.Companion;
        if (companion.getCurrentAvSession() != null) {
            companion.getCurrentAvSession().setVideoCallScreen(this);
        }
        if (companion.getCurrentAvSession() == null && this.conferenceCallErrorType == -1) {
            finish();
        }
        NotificationCenter.INSTANCE.addObserver(this, NotificationCenter.NotificationType.CONNECTION_STATUS_CHANGED, new qb.l() {
            public final Object invoke(Object obj) {
                fb.r lambda$onResume$13;
                lambda$onResume$13 = CallingFragmentActivity.this.lambda$onResume$13(obj);
                return lambda$onResume$13;
            }
        });
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction("com.beint.project.PROFILE_PICTURE_INTENT");
        intentFilter.addAction("com.beint.project.REMOVE_SINGLE_PROFILE_AVATAR_FROM_CACHE");
        registerReceiver(this.profileBroadcastReceiver, intentFilter);
        registerReceiver(this.closeConnectingReciver, new IntentFilter("close connecting"));
        AVSession aVSession = this.mAVSession;
        if (aVSession == null || !aVSession.isLocalVideoOn()) {
            return;
        }
        openVideoScreen();
    }

    @Override
    protected void onStart() {
        if (this.currentState == 0) {
            AppModeNotifierActivity.inst++;
        }
        isCallingFragmentVisible = true;
        super.onStart();
    }

    @Override
    protected void onStop() {
        if (this.currentState == 0) {
            AppModeNotifierActivity.inst--;
        }
        isCallingFragmentVisible = false;
        super.onStop();
        this.activityIsActive = false;
    }

    protected void onUserLeaveHint() {
        if (canHandlePipMode() && checkOps()) {
            enterPipMode();
        }
    }

    @Override
    public void onVideoButtonClick() {
        AVSession activeSession;
        if (!ZangiPermissionUtils.hasPermission(this, 1009, true, new ZangiPermissionUtils.OnPermissionResult() {
            public final void onResult(ArrayList arrayList, boolean z) {
                CallingFragmentActivity.lambda$onVideoButtonClick$10(arrayList, z);
            }
        }) || (activeSession = AVSession.Companion.getActiveSession()) == null) {
            return;
        }
        activeSession.startLocalVideo();
    }

    public boolean pictureInPictureModeEnable() {
        if (Build.VERSION.SDK_INT >= 26) {
            return isInPictureInPictureMode();
        }
        return false;
    }

    @Override
    public void processInCall(boolean z) {
        this.inCallHandler.post(new InCallRunnable(this, z));
    }

    public boolean processKeyDown(int i, KeyEvent keyEvent) {
        ConversationView conversationView;
        if (i == 4) {
            ConversationManager conversationManager = ConversationManager.INSTANCE;
            if (conversationManager.getConversationScreenRef() != null && (conversationView = conversationManager.getConversationScreenRef().get()) != null && conversationView.isVisible() && conversationView.getView() != null && conversationView.getView().getGlobalVisibleRect(new Rect())) {
                if (conversationView.imageBrowserIsOpen(this)) {
                    return true;
                }
                if (removeImageBrowserWhenExist()) {
                    enableDisableVideoWhenUserNavigateOtherPage(0);
                    return true;
                }
            }
            AVSession aVSession = this.mAVSession;
            if (aVSession != null && aVSession.isConferenceCall()) {
                Intent intent2 = new Intent();
                intent2.putExtra("callId", this.mAVSession.getId());
                NotificationCenter.INSTANCE.postNotificationName(NotificationCenter.NotificationType.UPDATE_RECENT_ITEM, intent2);
                WeakReference<BaseScreen> weakReference = this.currentFragment;
                if (weakReference == null || weakReference.get() == null || !(this.currentFragment.get() instanceof ConferenceCallFragment)) {
                    finish();
                    PassCodeController.INSTANCE.toWorkPassCodeInCallCase();
                } else {
                    if (((ConferenceCallFragment) this.currentFragment.get()).handleBack()) {
                        return true;
                    }
                    finish();
                    PassCodeController.INSTANCE.toWorkPassCodeInCallCase();
                }
            }
            if (handlePipModeIfNeeded()) {
                return true;
            }
            super.processKeyDown(i, keyEvent);
        } else if (i != 24) {
            if (i != 25) {
                return false;
            }
            return stopRingTone();
        }
        return stopRingTone();
    }

    @Override
    public void processOutgoingCall() {
        ScreenOutgoingCall screenOutgoingCall = new ScreenOutgoingCall();
        this.currentUIProccessor = new WeakReference<>(screenOutgoingCall);
        this.currentFragment = new WeakReference<>(screenOutgoingCall);
        getSupportFragmentManager().n().q(2131362950, screenOutgoingCall).j();
        getSupportFragmentManager().f0();
    }

    public void remoteVideoOff() {
        if (ScreenVideoCall.Companion.getFromVideo()) {
            AVSession.Companion companion = AVSession.Companion;
            if (companion.getActiveSession() != null && !companion.getActiveSession().isLocalVideoOn()) {
                WeakReference<BaseScreen> weakReference = this.currentFragment;
                if (weakReference == null || weakReference.get() == null || !this.currentFragment.get().isInPipMode()) {
                    openInCallScreen(Boolean.TRUE);
                } else {
                    Engine.getInstance().getScreenService().getArguments().putInt(Constants.CALL_SCREEN_STATE, 2);
                    finish();
                }
            }
        }
        if (isVideoScreenVisible().booleanValue()) {
            ((ScreenVideoCall) this.currentFragment.get()).remoteVideoOff();
        }
    }

    public void remoteVideoOn() {
        openVideoScreen();
        if (isVideoScreenVisible().booleanValue()) {
            ((ScreenVideoCall) this.currentFragment.get()).remoteVideoOn();
        }
    }

    public boolean removeImageBrowserWhenExist() {
        if (Build.VERSION.SDK_INT >= 26 || getCurrentFragmentChildFragmentManager() == null || getCurrentFragmentChildFragmentManager().j0(ImageBrowser.TAG) == null) {
            return false;
        }
        getCurrentFragmentChildFragmentManager().Z0();
        return true;
    }

    public void setConferenceCallService(IConferenceCallViewModel iConferenceCallViewModel) {
        this.conferenceCallService = new WeakReference<>(iConferenceCallViewModel);
    }

    public void setMute(final boolean z) {
        runOnUiThread(new Runnable() {
            @Override
            public final void run() {
                CallingFragmentActivity.this.lambda$setMute$11(z);
            }
        });
    }

    @Override
    public void setOpenChat(boolean z) {
        this.openChat = z;
    }

    public void setUserInterated() {
        this.userIntaracted = true;
        userIsOnline();
    }

    protected void terminateSession() {
        Log.i(TAG, "PING-PONG OnRtmpEvent closeCall() terminateSession()");
        ZangiAVSessionUI aVSessionUI = getAVSessionUI();
        if (aVSessionUI == null) {
            this.callDuration = -1L;
            Log.i(TAG, "PING-PONG OnRtmpEvent closeCall() terminateSession() sessionUI Is Null");
            return;
        }
        String callId = aVSessionUI.getCallId();
        this.callDuration = aVSessionUI.getCallDuration().longValue();
        Log.i(TAG, "Call_Duration = " + this.callDuration);
        Log.i(TAG, "PING-PONG OnRtmpEvent closeCall() terminateSession() Session ID= " + callId);
        AVSession.Companion companion = AVSession.Companion;
        AVSession session = companion.getSession(callId);
        if (session == null) {
            Log.i(TAG, "Session is already closed");
            return;
        }
        if (!session.isLocalCall()) {
            Log.i(TAG, "!!!!!RTMP_CALL_EVENT_TYPE_CANCELED");
            session.closeCall();
            Log.i(TAG, "PING-PONG OnRtmpEvent closeCall() closeCall " + callId);
        }
        if (session.isInFakeCallState()) {
            session.closeCall();
        }
        companion.releaseSession(session);
        Log.i(TAG, "PING-PONG OnRtmpEvent closeCall() releaseSession " + callId);
    }

    public void updateBCStatistic(int i, int i7, int i8) {
        Log.i("statisticsBCHandler", "CallingFragmentActivity");
        ZangiConfigurationService.INSTANCE.putInt("BC_COUNT", i);
    }

    public void updateP2PStatistic(String str, boolean z) {
        Log.i("updateP2PStatistic", "CallingFragmentActivity " + str);
    }

    public void updateStatistic(int i, int i7, double d, double d7, double d8, int i8, int i9) {
    }

    public void videoPauseOff() {
        if (isVideoScreenVisible().booleanValue()) {
            ((ScreenVideoCall) this.currentFragment.get()).videoPauseOff();
        }
    }

    public void videoPauseOn() {
        if (isVideoScreenVisible().booleanValue()) {
            ((ScreenVideoCall) this.currentFragment.get()).videoPauseOn();
        }
    }

    public void waitingVideoData() {
        if (isVideoScreenVisible().booleanValue()) {
            ((ScreenVideoCall) this.currentFragment.get()).waitingVideoData();
        }
    }
}