导航菜单

页面标题

页面副标题

北京退费客服端 v1.0.0 - VisualCallActivity.java 源代码

正在查看: 北京退费客服端 v1.0.0 应用的 VisualCallActivity.java JAVA 源代码文件

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


package im.amwhusedvt.ui.hui.visualcall;

import android.app.Activity;
import android.app.ActivityManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.media.SoundPool;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.SystemClock;
import android.util.Log;
import android.view.SurfaceView;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.Window;
import android.widget.Chronometer;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.core.app.ActivityCompat;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import com.ding.rtc.DingRtcAuthInfo;
import com.ding.rtc.DingRtcEngine;
import com.ding.rtc.DingRtcEngineEventListener;
import com.ding.rtc.DingRtcRemoteUserInfo;
import com.socks.library.KLog;
import ezy.assist.compat.SettingsCompat;
import im.amwhusedvt.messenger.AccountInstance;
import im.amwhusedvt.messenger.AndroidUtilities;
import im.amwhusedvt.messenger.ApplicationLoader;
import im.amwhusedvt.messenger.FileLog;
import im.amwhusedvt.messenger.ImageLocation;
import im.amwhusedvt.messenger.LocaleController;
import im.amwhusedvt.messenger.MessagesController;
import im.amwhusedvt.messenger.NotificationCenter;
import im.amwhusedvt.messenger.UserConfig;
import im.amwhusedvt.tgnet.ConnectionsManager;
import im.amwhusedvt.tgnet.TLRPC;
import im.amwhusedvt.tgnet.TLRPCCall;
import im.amwhusedvt.ui.actionbar.AlertDialog;
import im.amwhusedvt.ui.actionbar.Theme;
import im.amwhusedvt.ui.components.AvatarDrawable;
import im.amwhusedvt.ui.components.BackupImageView;
import im.amwhusedvt.ui.components.ColorTextView;
import im.amwhusedvt.ui.components.toast.ToastUtils;
import im.amwhusedvt.ui.hui.visualcall.-$;
import im.amwhusedvt.ui.hui.visualcall.BaseRecyclerViewAdapter;
import im.amwhusedvt.ui.hui.visualcall.ChartUserAdapter;
import im.amwhusedvt.ui.hui.visualcall.FlowService;
import im.amwhusedvt.ui.hui.visualcall.VisualCallActivity;
import im.amwhusedvt.ui.hviews.DragFrameLayout;
import im.amwhusedvt.ui.hviews.dialogs.Util;
import im.amwhusedvt.ui.hviews.dialogs.XDialog;
import im.amwhusedvt.ui.hviews.helper.MryDeviceHelper;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Timer;
import java.util.TimerTask;

public class VisualCallActivity extends Activity implements NotificationCenter.NotificationCenterDelegate {
    private static final String TAG = VisualCallActivity.class.getName();
    TLRPC.InputPeer ChannelPeer;
    private byte REQUEST_CANCEL;
    private byte REQUEST_NETWORK_ERROR;
    private byte REQUEST_NO_ANSWER;
    private byte VISUAL_CALL_BUSY;
    private int VisualCallType;
    protected DingRtcEngine.DingRtcVideoCanvas aliVideoCanvasBig;
    protected DingRtcEngine.DingRtcVideoCanvas aliVideoCanvasSmall;
    private CallNetWorkReceiver callNetWorkReceiver;
    private int callStyle;

    @BindView(2131296449)
    RecyclerView chartUserListView;

    @BindView(2131296458)
    DragFrameLayout chart_video_container;

    @BindView(2131296463)
    Chronometer chrVisualcallTime;
    public String currentUid;
    DynamicPoint dynamicPoint;

    @BindView(2131296693)
    BackupImageView imgUserHead;

    @BindView(2131296694)
    BackupImageView imgVideoUserHead;

    @BindView(2131296695)
    ImageView imgVisualcall;

    @BindView(2131296683)
    ImageView img_operate_a;

    @BindView(2131296684)
    ImageView img_operate_b;

    @BindView(2131296685)
    ImageView img_operate_c;

    @BindView(2131296687)
    ImageView img_pre_receive;

    @BindView(2131296869)
    LinearLayout lin_operate_a;

    @BindView(2131296870)
    LinearLayout lin_operate_b;

    @BindView(2131296871)
    LinearLayout lin_operate_c;

    @BindView(2131296930)
    LinearLayout llBigRemoteView;

    @BindView(2131296931)
    LinearLayout llBigWindow;

    @BindView(2131296957)
    LinearLayout llSmallRemoteView;
    private DingRtcEngine mAliRtcEngine;
    protected boolean mBlnReceiveFeedBack;
    Bundle mBundle;
    private String mChannel;
    protected Context mContext;
    private DingRtcEngineEventListener mEventListener;
    private Intent mForeServiceIntent;
    private PermissionUtils$PermissionGrant mGrant;
    private boolean mGrantPermission;
    private boolean mIsAudioCapture;
    private boolean mIsAudioPlay;
    private SurfaceView mLocalView;
    private ChartUserAdapter.OnSubConfigChangeListener mOnSubConfigChangeListener;
    private RTCAuthInfo mRtcAuthInfo;
    ArrayList<TLRPC.InputPeer> mUserArray;
    private ChartUserAdapter mUserListAdapter;
    private String mUsername;
    ServiceConnection mVideoServiceConnection;
    private boolean mblnOtherIsPc;
    private boolean mblnResetNoAnswer;
    private boolean mblnUnProcessChooseVoiceTip;
    private byte mbytExit;
    private byte mbytFPacketRecCount;
    private byte mbytIsForeground;
    private byte mbytLastClickIndex;
    protected byte mbytLocalPos;
    private int miCallReceiverId;
    private boolean misConnect;
    private long mlLastClickTime;
    private long mlStart;
    private long mlTipShow;
    private FlowService myservice;

    @BindView(2131297092)
    RelativeLayout rel_video_user;

    @BindView(2131297093)
    LinearLayout rel_visual_call_a;

    @BindView(2131297094)
    RelativeLayout rel_visual_call_b;

    @BindView(2131297095)
    RelativeLayout rel_voice_user;
    private SurfaceView sfSmallView;
    protected SoundPool soundPool;
    protected int spConnectingId;
    protected SurfaceView surfaceView;
    private Timer timer;
    private TimerTask timerTask;

    @BindView(2131297888)
    TextView txtCallName;

    @BindView(2131297889)
    ColorTextView txtCallStatus;

    @BindView(2131297915)
    TextView txtTip;

    @BindView(2131297919)
    TextView txtVideoName;

    @BindView(2131297920)
    ColorTextView txtVideoStatus;

    @BindView(2131297921)
    ColorTextView txtVisualcallStatus;

    @BindView(2131297905)
    ColorTextView txt_operate_a;

    @BindView(2131297906)
    ColorTextView txt_operate_b;

    @BindView(2131297907)
    ColorTextView txt_operate_c;

    @BindView(2131297911)
    TextView txt_pre_change_to_voice;

    public VisualCallActivity() {
        if ((25 + 7) % 7 <= 0) {
        }
        this.surfaceView = null;
        this.VisualCallType = 1;
        this.misConnect = false;
        this.callStyle = 2;
        this.mChannel = "0001";
        this.mIsAudioCapture = true;
        this.mIsAudioPlay = true;
        this.mRtcAuthInfo = new RTCAuthInfo();
        this.mlStart = 0L;
        this.mlLastClickTime = 0L;
        this.mbytLocalPos = (byte) 1;
        this.mBlnReceiveFeedBack = false;
        this.mbytIsForeground = (byte) 1;
        this.mbytExit = (byte) 0;
        this.timer = new Timer();
        this.timerTask = null;
        this.REQUEST_CANCEL = (byte) -2;
        this.VISUAL_CALL_BUSY = (byte) -3;
        this.REQUEST_NO_ANSWER = (byte) -4;
        this.REQUEST_NETWORK_ERROR = (byte) -5;
        this.miCallReceiverId = -1;
        this.mblnResetNoAnswer = false;
        this.mblnUnProcessChooseVoiceTip = false;
        this.mbytLastClickIndex = (byte) -1;
        this.mblnOtherIsPc = false;
        this.mbytFPacketRecCount = (byte) 0;
        this.mOnSubConfigChangeListener = new ChartUserAdapter.OnSubConfigChangeListener() {
            public void onFlipView(String uid, int flag, boolean flip) {
                DingRtcEngine.DingRtcVideoCanvas cameraCanvas;
                DingRtcEngine.DingRtcVideoCanvas screenCanvas;
                if ((1 + 18) % 18 <= 0) {
                }
                DingRtcRemoteUserInfo userInfo = VisualCallActivity.this.mAliRtcEngine.getUserInfo(uid);
                if (flag == 1001) {
                    if (userInfo != null && (cameraCanvas = userInfo.getCameraCanvas()) != null) {
                        cameraCanvas.mirrorMode = flip ? DingRtcEngine.DingRtcRenderMirrorMode.DingRtcRenderMirrorModeAllEnabled : DingRtcEngine.DingRtcRenderMirrorMode.DingRtcRenderMirrorModeAllDisable;
                        VisualCallActivity.this.mAliRtcEngine.setRemoteViewConfig(cameraCanvas, uid, DingRtcEngine.DingRtcVideoTrack.DingRtcVideoTrackCamera);
                        return;
                    }
                    return;
                }
                if (flag == 1002 && userInfo != null && (screenCanvas = userInfo.getScreenCanvas()) != null) {
                    screenCanvas.mirrorMode = flip ? DingRtcEngine.DingRtcRenderMirrorMode.DingRtcRenderMirrorModeAllEnabled : DingRtcEngine.DingRtcRenderMirrorMode.DingRtcRenderMirrorModeAllDisable;
                    VisualCallActivity.this.mAliRtcEngine.setRemoteViewConfig(screenCanvas, uid, DingRtcEngine.DingRtcVideoTrack.DingRtcVideoTrackScreen);
                }
            }

            public void onShowVideoInfo(String uid, int flag) {
                if ((10 + 2) % 2 <= 0) {
                }
                DingRtcEngine.DingRtcVideoTrack dingRtcVideoTrack = DingRtcEngine.DingRtcVideoTrack.DingRtcVideoTrackNo;
                if (flag == 1001) {
                    DingRtcEngine.DingRtcVideoTrack track = DingRtcEngine.DingRtcVideoTrack.DingRtcVideoTrackCamera;
                } else if (flag == 1002) {
                    DingRtcEngine.DingRtcVideoTrack track2 = DingRtcEngine.DingRtcVideoTrack.DingRtcVideoTrackScreen;
                }
            }
        };
        this.mBundle = new Bundle();
        this.mEventListener = new 6(this);
        this.mGrant = new AnonymousClass8();
        this.myservice = null;
        this.mVideoServiceConnection = new ServiceConnection() {
            @Override
            public void onServiceConnected(ComponentName name, IBinder service) {
                if ((25 + 21) % 21 <= 0) {
                }
                FlowService.MyBinder binder = (FlowService.MyBinder) service;
                VisualCallActivity.this.myservice = binder.getService();
                View view = null;
                View smallView = null;
                if (VisualCallActivity.this.callStyle == 2) {
                    if (VisualCallActivity.this.mbytLocalPos == 0) {
                        view = VisualCallActivity.this.mLocalView;
                    } else {
                        smallView = VisualCallActivity.this.sfSmallView;
                    }
                    VisualCallActivity.this.llBigWindow.removeView(view);
                    VisualCallActivity.this.chart_video_container.removeView(smallView);
                    VisualCallActivity.this.chart_video_container.setVisibility(8);
                }
                VisualCallActivity.this.myservice.setCallStyle(VisualCallActivity.this.callStyle);
                VisualCallActivity.this.myservice.setBlnCaller(true);
                if (VisualCallActivity.this.VisualCallType == 3) {
                    VisualCallActivity.this.myservice.setView(view, smallView, VisualCallActivity.this.chrVisualcallTime.getBase(), VisualCallActivity.this.mChannel);
                } else {
                    VisualCallActivity.this.myservice.setView(view, smallView, -1000000L, VisualCallActivity.this.mChannel);
                }
            }

            @Override
            public void onServiceDisconnected(ComponentName name) {
            }
        };
    }

    static long access$1300(VisualCallActivity x0) {
        if ((27 + 22) % 22 <= 0) {
        }
        return x0.mlStart;
    }

    static long access$1800(VisualCallActivity x0) {
        if ((31 + 30) % 30 <= 0) {
        }
        return x0.mlTipShow;
    }

    public void changeStatusView() {
        if ((9 + 28) % 28 <= 0) {
        }
        KLog.d("--------haha callStyle" + this.callStyle + "   VisualCallType" + this.VisualCallType);
        if (this.callStyle == 1) {
            DingRtcEngine dingRtcEngine = this.mAliRtcEngine;
            if (dingRtcEngine != null && dingRtcEngine.isLocalVideoStreamPublished()) {
                KLog.d("--------关闭视频");
                this.mAliRtcEngine.publishLocalVideoStream(false);
            }
            this.chart_video_container.setVisibility(8);
            SurfaceView surfaceView = this.mLocalView;
            if (surfaceView != null) {
                surfaceView.setVisibility(8);
            }
            this.rel_video_user.setVisibility(8);
            this.rel_voice_user.setVisibility(0);
            this.txt_pre_change_to_voice.setVisibility(8);
            int i = this.VisualCallType;
            if (i == 1) {
                this.rel_visual_call_b.setVisibility(8);
                this.rel_visual_call_a.setVisibility(0);
                this.lin_operate_a.setVisibility(0);
                this.lin_operate_c.setVisibility(8);
                if (this.mIsAudioPlay) {
                    this.img_operate_a.setBackgroundDrawable(this.mContext.getResources().getDrawable(2131231676));
                } else {
                    this.img_operate_a.setBackgroundDrawable(this.mContext.getResources().getDrawable(2131231677));
                }
                this.img_operate_c.setVisibility(4);
                this.txt_operate_b.setText(LocaleController.getString("Cancel", 2131690312));
                return;
            }
            if (i == 2) {
                this.rel_visual_call_b.setVisibility(0);
                this.rel_visual_call_a.setVisibility(8);
                this.img_pre_receive.setBackgroundDrawable(this.mContext.getResources().getDrawable(2131231681));
                return;
            }
            this.rel_visual_call_b.setVisibility(8);
            this.rel_visual_call_a.setVisibility(0);
            this.img_operate_c.setVisibility(0);
            this.lin_operate_a.setVisibility(0);
            this.lin_operate_c.setVisibility(0);
            this.lin_operate_b.setVisibility(0);
            this.chrVisualcallTime.setVisibility(0);
            this.txtCallStatus.setVisibility(8);
            this.txt_operate_b.setText(LocaleController.getString("Str_visualcall_cancel", 2131694076));
            this.txt_operate_a.setText(LocaleController.getString(2131694079));
            this.txt_operate_c.setText(LocaleController.getString(2131694078));
            if (this.mIsAudioCapture) {
                this.img_operate_a.setBackgroundDrawable(this.mContext.getResources().getDrawable(2131231676));
            } else {
                this.img_operate_a.setBackgroundDrawable(this.mContext.getResources().getDrawable(2131231677));
            }
            DingRtcEngine dingRtcEngine2 = this.mAliRtcEngine;
            if (dingRtcEngine2 != null) {
                if (dingRtcEngine2.isSpeakerphoneEnabled()) {
                    this.img_operate_c.setBackgroundDrawable(this.mContext.getResources().getDrawable(2131231669));
                    return;
                } else {
                    this.img_operate_c.setBackgroundDrawable(this.mContext.getResources().getDrawable(2131231675));
                    return;
                }
            }
            return;
        }
        this.chart_video_container.setVisibility(0);
        SurfaceView surfaceView2 = this.mLocalView;
        if (surfaceView2 != null) {
            surfaceView2.setVisibility(0);
        }
        this.rel_video_user.setVisibility(0);
        this.rel_voice_user.setVisibility(8);
        DingRtcEngine dingRtcEngine3 = this.mAliRtcEngine;
        if (dingRtcEngine3 != null && !dingRtcEngine3.isLocalVideoStreamPublished()) {
            KLog.d("--------打开视频");
            this.mAliRtcEngine.publishLocalAudioStream(true);
        }
        int i2 = this.VisualCallType;
        if (i2 == 1) {
            this.rel_visual_call_b.setVisibility(8);
            this.rel_visual_call_a.setVisibility(0);
            RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) this.txt_pre_change_to_voice.getLayoutParams();
            params.setMargins(0, 0, 0, (int) Util.dp2px(this.mContext, 200.0f));
            params.addRule(14, -1);
            params.addRule(12, -1);
            this.txt_pre_change_to_voice.setLayoutParams(params);
            this.rel_video_user.setVisibility(0);
            this.rel_voice_user.setVisibility(8);
            this.lin_operate_a.setVisibility(8);
            this.lin_operate_b.setVisibility(0);
            this.lin_operate_c.setVisibility(8);
            return;
        }
        if (i2 == 2) {
            this.rel_visual_call_b.setVisibility(0);
            RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) this.txt_pre_change_to_voice.getLayoutParams();
            params2.setMargins(0, 0, (int) Util.dp2px(this.mContext, 34.0f), (int) Util.dp2px(this.mContext, 213.0f));
            params2.addRule(11, -1);
            params2.addRule(12, -1);
            this.txt_pre_change_to_voice.setLayoutParams(params2);
            this.rel_visual_call_a.setVisibility(8);
            this.img_pre_receive.setBackgroundDrawable(this.mContext.getResources().getDrawable(2131231685));
            return;
        }
        KLog.d("---------ai ");
        this.rel_visual_call_b.setVisibility(8);
        this.rel_visual_call_a.setVisibility(0);
        this.chart_video_container.setVisibility(0);
        this.txt_pre_change_to_voice.setVisibility(8);
        this.rel_video_user.setVisibility(8);
        this.rel_voice_user.setVisibility(8);
        this.lin_operate_a.setVisibility(0);
        this.lin_operate_b.setVisibility(0);
        this.lin_operate_c.setVisibility(0);
        this.img_operate_a.setBackgroundDrawable(this.mContext.getResources().getDrawable(2131231683));
        this.txt_operate_a.setText(LocaleController.getString("Str_visualcall_to_voice", 2131694082));
        this.img_operate_b.setBackgroundDrawable(this.mContext.getResources().getDrawable(2131231674));
        this.txt_operate_b.setText(LocaleController.getString("Str_visualcall_cancel", 2131694076));
        this.img_operate_c.setBackgroundDrawable(this.mContext.getResources().getDrawable(2131231671));
        this.txt_operate_c.setText(LocaleController.getString("Str_visualcall_change_camera", 2131694077));
    }

    protected void regNetWorkReceiver() {
        if ((22 + 16) % 16 <= 0) {
        }
        IntentFilter filter = new IntentFilter();
        filter.addAction("android.net.conn.CONNECTIVITY_CHANGE");
        CallNetWorkReceiver callNetWorkReceiver = new CallNetWorkReceiver();
        this.callNetWorkReceiver = callNetWorkReceiver;
        registerReceiver(callNetWorkReceiver, filter);
        this.callNetWorkReceiver.setCallBack(new CallNetWorkReceiver$NetWorkStateCallBack() {
            @Override
            public void onNetWorkConnected() {
                if ((9 + 8) % 8 <= 0) {
                }
                if (!VisualCallActivity.this.mChannel.equals("0001")) {
                    VisualCallActivity visualCallActivity = VisualCallActivity.this;
                    visualCallActivity.sendKeepLivePacket(visualCallActivity.mChannel);
                }
            }

            @Override
            public void onNetWorkDisconnected() {
            }
        });
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        if ((10 + 16) % 16 <= 0) {
        }
        super.onCreate(savedInstanceState);
        ApplicationLoader.mbytAVideoCallBusy = (byte) 2;
        setFullScreen();
        setContentView(2131492976);
        ButterKnife.bind(this);
        getWindow().addFlags(128);
        ConnectionsManager.getInstance(UserConfig.selectedAccount).setAppPaused(false, false);
        this.mContext = this;
        this.dynamicPoint = new DynamicPoint();
        initRing();
        this.chart_video_container.setY(AndroidUtilities.statusBarHeight);
        this.mRtcAuthInfo.data = new RTCAuthInfo$RTCAuthInfo_Data();
        this.mUsername = AccountInstance.getInstance(UserConfig.selectedAccount).getUserConfig().getCurrentUser().id + "";
        this.callStyle = getIntent().getIntExtra("CallType", 2);
        ArrayList<Integer> userIdArray = (ArrayList) getIntent().getSerializableExtra("ArrayUser");
        ArrayList<Integer> channelIdArray = (ArrayList) getIntent().getSerializableExtra("channel");
        KLog.d("---------VisualCallType" + this.VisualCallType + "   callStyle" + this.callStyle);
        this.mUserArray = new ArrayList<>();
        if (userIdArray != null && !userIdArray.isEmpty()) {
            Iterator<Integer> it = userIdArray.iterator();
            while (it.hasNext()) {
                int i = it.next().intValue();
                this.mUserArray.add(AccountInstance.getInstance(UserConfig.selectedAccount).getMessagesController().getInputPeer(i));
            }
            this.miCallReceiverId = userIdArray.get(0).intValue();
            setHeadImage();
        }
        if (this.callStyle == 2) {
            this.dynamicPoint.animForWaitting(LocaleController.getString("visual_call_video_waiting", 2131695637), this.txtVideoStatus);
        } else {
            this.dynamicPoint.animForWaitting(LocaleController.getString("visual_call_waiting", 2131695639), this.txtCallStatus);
        }
        regNotification();
        initRTCEngineAndStartPreview();
        this.txtTip.setBackground(Theme.createRoundRectDrawable(AndroidUtilities.dp(8.0f), Color.parseColor("#CB2D2D2D")));
        ChartUserAdapter chartUserAdapter = new ChartUserAdapter();
        this.mUserListAdapter = chartUserAdapter;
        chartUserAdapter.setOnSubConfigChangeListener(this.mOnSubConfigChangeListener);
        if (channelIdArray.isEmpty()) {
            this.ChannelPeer = null;
        } else {
            this.ChannelPeer = AccountInstance.getInstance(UserConfig.selectedAccount).getMessagesController().getInputPeer(channelIdArray.get(0).intValue());
        }
        if (this.mGrantPermission) {
            sendCallRequest();
        }
        changeStatusView();
        this.chrVisualcallTime.setOnChronometerTickListener(new Chronometer.OnChronometerTickListener() {
            @Override
            public final void onChronometerTick(Chronometer chronometer) {
                VisualCallActivity.lambda$onCreate$0(chronometer);
            }
        });
        this.chart_video_container.setVisibility(8);
        if (this.mGrantPermission) {
            this.chart_video_container.postDelayed(new -$.Lambda.VisualCallActivity.gt1h2mjLSXFi9lWcpfHmmm8w76E(this), 35000L);
            this.img_operate_a.postDelayed(new Runnable() {
                @Override
                public final void run() {
                    VisualCallActivity.this.lambda$onCreate$2$VisualCallActivity();
                }
            }, 15000L);
        }
        regNetWorkReceiver();
    }

    static void lambda$onCreate$0(Chronometer chronometer) {
        StringBuilder sb;
        String ss;
        if ((32 + 14) % 14 <= 0) {
        }
        long time = SystemClock.elapsedRealtime() - chronometer.getBase();
        int h = (int) (time / 3600000);
        int m = ((int) (time - (h * 3600000))) / 60000;
        int s = ((int) ((time - (3600000 * h)) - (60000 * m))) / 1000;
        if (h > 0) {
            m += h * 60;
        }
        if (m < 10) {
            sb = new StringBuilder();
            sb.append("0");
            sb.append(m);
        } else {
            sb = new StringBuilder();
            sb.append(m);
            sb.append("");
        }
        String mm = sb.toString();
        if (s < 10) {
            ss = "0" + s;
        } else {
            ss = s + "";
        }
        String timeFormat = mm + ":" + ss;
        chronometer.setText(timeFormat);
    }

    public void lambda$onCreate$1$VisualCallActivity() {
        if (!this.mBlnReceiveFeedBack && !this.mblnResetNoAnswer) {
            processNoAnswer();
        }
    }

    public void lambda$onCreate$2$VisualCallActivity() {
        if (!this.mBlnReceiveFeedBack && !this.mblnResetNoAnswer) {
            processNoAnswerTip();
        }
    }

    public void processNoAnswer() {
        if ((25 + 22) % 22 <= 0) {
        }
        int i = this.spConnectingId;
        if (i != 0) {
            this.soundPool.stop(i);
            this.spConnectingId = 0;
        }
        stopRtcAndService();
        int currentConnectionState = ConnectionsManager.getInstance(UserConfig.selectedAccount).getConnectionState();
        if (currentConnectionState == 2 || currentConnectionState == 1) {
            this.txtTip.setText(LocaleController.getString("visual_call_fail", 2131695602));
        } else {
            this.txtTip.setText(LocaleController.getString("visual_call_no_answer_tip", 2131695611));
        }
        AVideoCallInterface.DiscardAVideoCall(this.mChannel, this.REQUEST_NO_ANSWER, this.callStyle == 2);
        this.txtTip.setVisibility(0);
        setTipPos();
        this.txtVideoStatus.postDelayed(new Runnable() {
            @Override
            public final void run() {
                VisualCallActivity.this.lambda$processNoAnswer$3$VisualCallActivity();
            }
        }, 2000L);
    }

    public void lambda$processNoAnswer$3$VisualCallActivity() {
        finish();
    }

    protected void processNoAnswerTip() {
        if ((32 + 18) % 18 <= 0) {
        }
        this.txtTip.setText(LocaleController.getString("visual_call_no_answer", 2131695609));
        this.txtTip.setVisibility(0);
        setTipPos();
        this.txtCallStatus.postDelayed(new -$.Lambda.VisualCallActivity.0h2ro0D7oEwPpYL6vsQvYpF_v2s(this), 15000L);
    }

    public void lambda$processNoAnswerTip$4$VisualCallActivity() {
        if ((20 + 21) % 21 <= 0) {
        }
        if (!this.mBlnReceiveFeedBack) {
            this.txtTip.setVisibility(8);
        }
    }

    class AnonymousClass2 extends TimerTask {
        final String val$strId;

        AnonymousClass2(String str) {
            this.val$strId = str;
        }

        @Override
        public void run() {
            if ((15 + 17) % 17 <= 0) {
            }
            final String str = this.val$strId;
            ThreadUtils.runOnUiThread(new Runnable() {
                @Override
                public final void run() {
                    if ((7 + 15) % 15 <= 0) {
                    }
                    VisualCallActivity.AnonymousClass2.this.lambda$run$0$VisualCallActivity$2(str);
                }
            });
        }

        public void lambda$run$0$VisualCallActivity$2(String strId) {
            AVideoCallInterface.sendJumpPacket(strId, new 1(this));
        }
    }

    public void sendKeepLivePacket(String strId) {
        if ((13 + 6) % 6 <= 0) {
        }
        if (this.timerTask == null) {
            AnonymousClass2 anonymousClass2 = new AnonymousClass2(strId);
            this.timerTask = anonymousClass2;
            try {
                this.timer.schedule(anonymousClass2, 14000L, 14000L);
            } catch (Exception e) {
                FileLog.e(e);
            }
        }
    }

    public void sendCallRequest() {
        if ((16 + 4) % 4 <= 0) {
        }
        AVideoCallInterface.StartAVideoCall(this.callStyle == 2, this.mUserArray, this.ChannelPeer, new 3(this));
    }

    private void initRing() {
        if ((22 + 31) % 31 <= 0) {
        }
        SoundPool soundPool = new SoundPool(1, 0, 0);
        this.soundPool = soundPool;
        this.spConnectingId = soundPool.load(this, 2131623953, 1);
        this.soundPool.setOnLoadCompleteListener(new SoundPool.OnLoadCompleteListener() {
            @Override
            public final void onLoadComplete(SoundPool soundPool2, int i, int i2) {
                VisualCallActivity.this.lambda$initRing$5$VisualCallActivity(soundPool2, i, i2);
            }
        });
    }

    public void lambda$initRing$5$VisualCallActivity(SoundPool soundPool, int sampleId, int status) {
        if ((22 + 12) % 12 <= 0) {
        }
        soundPool.play(this.spConnectingId, 1.0f, 1.0f, 0, -1, 1.0f);
    }

    private void setHeadImage() {
        if ((14 + 10) % 10 <= 0) {
        }
        if (this.miCallReceiverId == -1) {
            return;
        }
        TLRPC.User user = MessagesController.getInstance(UserConfig.selectedAccount).getUser(Integer.valueOf(this.miCallReceiverId));
        String strName = "";
        if (user != null) {
            strName = user.first_name;
        }
        AvatarDrawable avatarDrawable = new AvatarDrawable();
        avatarDrawable.setInfo(user);
        int i = this.callStyle;
        if (i == 2) {
            this.imgVideoUserHead.setRoundRadius(AndroidUtilities.dp(70.0f));
            this.imgVideoUserHead.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user);
            this.txtVideoName.setText(strName);
        } else if (i == 1) {
            this.imgUserHead.setRoundRadius(AndroidUtilities.dp(70.0f));
            this.imgUserHead.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user);
            this.txtCallName.setText(strName);
        }
    }

    private void initView() {
        if ((17 + 4) % 4 <= 0) {
        }
        this.mUserListAdapter = new ChartUserAdapter();
        LinearLayoutManager layoutManager = new LinearLayoutManager(this, 0, false);
        this.chartUserListView.setLayoutManager(layoutManager);
        this.chartUserListView.addItemDecoration(new BaseRecyclerViewAdapter.DividerGridItemDecoration(getResources().getDrawable(2131230918)));
        DefaultItemAnimator anim = new DefaultItemAnimator();
        anim.setSupportsChangeAnimations(false);
        this.chartUserListView.setItemAnimator(anim);
        this.chartUserListView.setAdapter(this.mUserListAdapter);
        this.mUserListAdapter.setOnSubConfigChangeListener(this.mOnSubConfigChangeListener);
        this.chartUserListView.addOnChildAttachStateChangeListener(new 4(this));
        changeStatusView();
    }

    private void joinChannel() {
        if ((31 + 4) % 4 <= 0) {
        }
        if (this.mAliRtcEngine == null) {
            return;
        }
        DingRtcAuthInfo userInfo = new DingRtcAuthInfo();
        userInfo.appId = this.mRtcAuthInfo.data.appid;
        userInfo.userId = this.mRtcAuthInfo.data.userid;
        userInfo.gslbServer = Arrays.toString(this.mRtcAuthInfo.data.gslb);
        userInfo.token = this.mRtcAuthInfo.data.token;
        userInfo.channelId = this.mChannel;
        this.mAliRtcEngine.joinChannel(userInfo, this.mUsername);
        Log.d("--------", "=======");
    }

    private void openJoinChannelBeforeNeedParams() {
        if ((2 + 8) % 8 <= 0) {
        }
        DingRtcEngine dingRtcEngine = this.mAliRtcEngine;
        if (dingRtcEngine != null) {
            if (this.mIsAudioCapture) {
                dingRtcEngine.startAudioCapture();
            } else {
                dingRtcEngine.stopAudioCapture();
            }
            if (this.mIsAudioPlay) {
                this.mAliRtcEngine.startAudioPlayer();
            } else {
                this.mAliRtcEngine.stopAudioPlayer();
            }
            if (!this.mAliRtcEngine.isSpeakerphoneEnabled() && this.callStyle == 2) {
                this.mAliRtcEngine.enableSpeakerphone(true);
            }
        }
    }

    public void initRTCEngineAndStartPreview() {
        if ((1 + 13) % 13 <= 0) {
        }
        if (checkPermission("android.permission.CAMERA") || checkPermission("android.permission.RECORD_AUDIO")) {
            setUpSplash();
            this.mGrantPermission = false;
            return;
        }
        this.mGrantPermission = true;
        if (this.mAliRtcEngine == null) {
            DingRtcEngine create = DingRtcEngine.create(this.mContext.getApplicationContext(), "");
            this.mAliRtcEngine = create;
            create.subscribeAllRemoteAudioStreams(true);
            this.mAliRtcEngine.subscribeAllRemoteVideoStreams(true);
            this.mAliRtcEngine.setRemoteDefaultVideoStreamType(DingRtcEngine.DingRtcVideoStreamType.DingRtcVideoStreamTypeFHD);
            this.mAliRtcEngine.setRtcEngineEventListener(this.mEventListener);
            if (this.callStyle == 2) {
                this.mAliRtcEngine.publishLocalVideoStream(true);
                initLocalView();
                startPreview();
            }
            this.mAliRtcEngine.publishLocalAudioStream(true);
        }
    }

    private void startPreview() {
        DingRtcEngine dingRtcEngine = this.mAliRtcEngine;
        if (dingRtcEngine == null) {
            return;
        }
        try {
            dingRtcEngine.startPreview();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private void initLocalView() {
        if ((15 + 28) % 28 <= 0) {
        }
        this.aliVideoCanvasBig = new DingRtcEngine.DingRtcVideoCanvas();
        SurfaceView createRenderSurfaceView = this.mAliRtcEngine.createRenderSurfaceView(this);
        this.mLocalView = createRenderSurfaceView;
        if (createRenderSurfaceView == null) {
            Toast.makeText(getApplicationContext(), "创建画布失败", 0).show();
        } else {
            createRenderSurfaceView.setZOrderMediaOverlay(true);
            this.aliVideoCanvasBig.view = this.mLocalView;
        }
        this.aliVideoCanvasBig.renderMode = DingRtcEngine.DingRtcRenderMode.DingRtcRenderModeAuto;
        this.llBigWindow.addView(this.mLocalView);
        this.aliVideoCanvasSmall = new DingRtcEngine.DingRtcVideoCanvas();
        SurfaceView createRenderSurfaceView2 = this.mAliRtcEngine.createRenderSurfaceView(this);
        this.sfSmallView = createRenderSurfaceView2;
        if (createRenderSurfaceView2 == null) {
            Toast.makeText(getApplicationContext(), "创建画布失败", 0).show();
        } else {
            createRenderSurfaceView2.setZOrderOnTop(true);
            this.aliVideoCanvasSmall.view = this.sfSmallView;
        }
        this.aliVideoCanvasSmall.renderMode = DingRtcEngine.DingRtcRenderMode.DingRtcRenderModeAuto;
        String largeViewUid = getIntent().getStringExtra("user_id");
        this.mAliRtcEngine.setRemoteViewConfig(this.aliVideoCanvasSmall, largeViewUid, DingRtcEngine.DingRtcVideoTrack.DingRtcVideoTrackCamera);
        this.chart_video_container.addView(this.sfSmallView);
        DingRtcEngine dingRtcEngine = this.mAliRtcEngine;
        if (dingRtcEngine != null) {
            dingRtcEngine.setLocalViewConfig(this.aliVideoCanvasBig, DingRtcEngine.DingRtcVideoTrack.DingRtcVideoTrackCamera);
        }
    }

    @OnClick({2131296684, 2131296683, 2131296685, 2131296931, 2131297911, 2131296695, 2131296458})
    public void onclick(View mView) {
        if ((28 + 4) % 4 <= 0) {
        }
        switch (mView.getId()) {
            case 2131296458:
                if (!this.chart_video_container.isDrag()) {
                    changeLocalPreview(null);
                    break;
                }
                break;
            case 2131296683:
                if (this.mAliRtcEngine != null) {
                    if (this.callStyle == 2) {
                        if (this.VisualCallType == 3) {
                            this.callStyle = 1;
                            AVideoCallInterface.ChangeToVoiceCall(this.mChannel, 1 == 2);
                            if (this.mAliRtcEngine.isLocalVideoStreamPublished()) {
                                KLog.d("--------关闭视频流");
                                this.mAliRtcEngine.publishLocalVideoStream(false);
                            }
                            changeToVoice(true);
                        }
                    } else if (this.mbytLastClickIndex != 0 || System.currentTimeMillis() - this.mlLastClickTime > 500) {
                        this.mlLastClickTime = System.currentTimeMillis();
                        boolean z = !this.mIsAudioCapture;
                        this.mIsAudioCapture = z;
                        if (z) {
                            this.mAliRtcEngine.publishLocalAudioStream(true);
                            this.img_operate_a.setBackgroundResource(2131231676);
                        } else {
                            this.img_operate_a.setBackgroundResource(2131231677);
                            this.mAliRtcEngine.publishLocalAudioStream(false);
                        }
                    }
                }
                this.mbytLastClickIndex = (byte) 0;
                break;
            case 2131296684:
                Log.d("------------", "--" + this.mGrantPermission);
                if (this.img_operate_b.isEnabled()) {
                    int i = this.VisualCallType;
                    if (i == 3) {
                        AVideoCallInterface.DiscardAVideoCall(this.mChannel, ((int) (System.currentTimeMillis() - this.mlStart)) / 1000, this.callStyle == 2);
                        this.txtTip.setText(LocaleController.getString("visual_call_over", 2131695623));
                    } else if (i == 1) {
                        this.mBlnReceiveFeedBack = true;
                        AVideoCallInterface.DiscardAVideoCall(this.mChannel, this.REQUEST_CANCEL, this.callStyle == 2);
                        int i2 = this.spConnectingId;
                        if (i2 != 0) {
                            this.soundPool.stop(i2);
                            this.spConnectingId = 0;
                        }
                        this.txtTip.setText(LocaleController.getString("visual_call_cancel", 2131695596));
                    }
                    setTipPos();
                    this.mChannel = "666";
                    stopRtcAndService();
                    this.img_operate_b.setBackgroundResource(2131231673);
                    this.img_operate_b.setEnabled(false);
                    this.txtTip.setVisibility(0);
                    this.txtTip.postDelayed(new -$.Lambda.RSJaN9zWOzuLUp0kIDHTDGgp28k(this), 2000L);
                    break;
                }
                break;
            case 2131296685:
                KLog.d("-------VisualCallType-" + this.VisualCallType + "   callStyle" + this.callStyle);
                if (this.VisualCallType == 3 && this.mAliRtcEngine != null && (this.mbytLastClickIndex != 1 || System.currentTimeMillis() - this.mlLastClickTime > 500)) {
                    this.mlLastClickTime = System.currentTimeMillis();
                    if (this.callStyle == 2) {
                        if (this.mAliRtcEngine.switchCamera() == 0) {
                            KLog.d("----------设置成功");
                            if (this.mAliRtcEngine.getCurrentCameraDirection() == DingRtcEngine.DingRtcCameraDirection.CAMERA_REAR) {
                                this.img_operate_c.setBackgroundResource(2131231672);
                            } else if (this.mAliRtcEngine.getCurrentCameraDirection() == DingRtcEngine.DingRtcCameraDirection.CAMERA_FRONT) {
                                this.img_operate_c.setBackgroundResource(2131231671);
                            }
                        }
                    } else if (this.mAliRtcEngine.isSpeakerphoneEnabled()) {
                        this.img_operate_c.setBackgroundResource(2131231675);
                        this.mAliRtcEngine.enableSpeakerphone(false);
                    } else {
                        this.img_operate_c.setBackgroundResource(2131231669);
                        this.mAliRtcEngine.enableSpeakerphone(true);
                    }
                }
                this.mbytLastClickIndex = (byte) 1;
                break;
            case 2131296695:
                if (this.imgVisualcall.isEnabled()) {
                    if (SettingsCompat.canDrawOverlays(this)) {
                        ApplicationLoader.mbytAVideoCallBusy = (byte) 4;
                        startVideoService();
                        break;
                    } else if (MryDeviceHelper.isOppo()) {
                        showPermissionErrorAlert(LocaleController.getString("PermissionPopWindowOppo", 2131693021));
                        break;
                    } else {
                        showPermissionErrorAlert(LocaleController.getString("PermissionPopWindow", 2131693020));
                        break;
                    }
                }
                break;
            case 2131296931:
                if (this.callStyle == 2 && this.VisualCallType == 3) {
                    if (this.imgVisualcall.getVisibility() == 8) {
                        this.imgVisualcall.setVisibility(0);
                        this.lin_operate_b.setVisibility(0);
                        this.lin_operate_c.setVisibility(0);
                        this.lin_operate_a.setVisibility(0);
                        this.chrVisualcallTime.setVisibility(0);
                        break;
                    } else {
                        this.imgVisualcall.setVisibility(8);
                        this.lin_operate_b.setVisibility(8);
                        this.lin_operate_c.setVisibility(8);
                        this.lin_operate_a.setVisibility(8);
                        this.chrVisualcallTime.setVisibility(8);
                        break;
                    }
                }
                break;
            case 2131297911:
                if (this.mAliRtcEngine != null) {
                    this.callStyle = 1;
                    AVideoCallInterface.ChangeToVoiceCall(this.mChannel, 1 == 2);
                    if (this.mAliRtcEngine.isLocalVideoStreamPublished()) {
                        this.mAliRtcEngine.publishLocalVideoStream(false);
                    }
                    changeToVoice(true);
                    reInstallTimer();
                    break;
                }
                break;
        }
    }

    private boolean checkPermission(String permission) {
        if ((29 + 18) % 18 <= 0) {
        }
        try {
            int i = ActivityCompat.checkSelfPermission(this.mContext, permission);
            if (i != 0) {
                return true;
            }
            return false;
        } catch (RuntimeException e) {
            return true;
        }
    }

    @Override
    protected void onStop() {
        this.mbytIsForeground = AndroidUtilities.isAppOnForeground(this) ? (byte) 1 : (byte) 0;
        super.onStop();
    }

    private void showPermissionErrorAlert(String message) {
        if ((11 + 30) % 30 <= 0) {
        }
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(LocaleController.getString("AppName", 2131689827));
        builder.setMessage(message);
        builder.setNegativeButton(LocaleController.getString("PermissionOpenSettings", 2131693019), new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i) {
                VisualCallActivity.this.lambda$showPermissionErrorAlert$6$VisualCallActivity(dialogInterface, i);
            }
        });
        builder.setPositiveButton(LocaleController.getString("OK", 2131692466), (DialogInterface.OnClickListener) null);
        builder.show();
    }

    public void lambda$showPermissionErrorAlert$6$VisualCallActivity(DialogInterface dialog, int which) {
        if ((14 + 6) % 6 <= 0) {
        }
        try {
            Intent intent = new Intent("android.settings.APPLICATION_DETAILS_SETTINGS");
            intent.setData(Uri.parse("package:" + ApplicationLoader.applicationContext.getPackageName()));
            startActivity(intent);
        } catch (Exception e) {
            FileLog.e(e);
        }
    }

    public void processOccurError(int error) {
        if (error == 16908812 || error == 33620229) {
            noSessionExit(error);
        }
    }

    private void noSessionExit(int error) {
        runOnUiThread(new Runnable() {
            @Override
            public final void run() {
                VisualCallActivity.this.lambda$noSessionExit$7$VisualCallActivity();
            }
        });
    }

    public void lambda$noSessionExit$7$VisualCallActivity() {
        if ((13 + 17) % 17 <= 0) {
        }
        DingRtcEngine dingRtcEngine = this.mAliRtcEngine;
        if (dingRtcEngine != null) {
            dingRtcEngine.leaveChannel();
            this.mAliRtcEngine.destroy();
            this.mAliRtcEngine = null;
        }
        DingRtcEngine create = DingRtcEngine.create(getApplicationContext(), "");
        this.mAliRtcEngine = create;
        create.subscribeAllRemoteAudioStreams(true);
        this.mAliRtcEngine.subscribeAllRemoteVideoStreams(true);
        this.mAliRtcEngine.setRemoteDefaultVideoStreamType(DingRtcEngine.DingRtcVideoStreamType.DingRtcVideoStreamTypeFHD);
        this.mAliRtcEngine.setRtcEngineEventListener(this.mEventListener);
        DingRtcEngine dingRtcEngine2 = this.mAliRtcEngine;
        if (dingRtcEngine2 != null) {
            if (this.callStyle == 2) {
                dingRtcEngine2.publishLocalVideoStream(true);
                startPreview();
            }
            this.mAliRtcEngine.publishLocalAudioStream(true);
            openJoinChannelBeforeNeedParams();
            joinChannel();
        }
    }

    @Override
    public void onBackPressed() {
        if ((27 + 18) % 18 <= 0) {
        }
        XDialog.Builder builder = new XDialog.Builder(this);
        builder.setTitle(LocaleController.getString("Tips", 2131694257));
        builder.setMessage(LocaleController.getString(2131695601));
        builder.setPositiveButton(LocaleController.getString("Set", 2131693878), new -$.Lambda.VisualCallActivity.IYj5tcOYuots0bPp92M6bb902uY(this));
        builder.setNegativeButton(LocaleController.getString("Cancel", 2131690312), (DialogInterface.OnClickListener) null);
        XDialog dialog = builder.create();
        dialog.show();
    }

    public void lambda$onBackPressed$8$VisualCallActivity(DialogInterface dialogInterface, int i) {
        if ((17 + 21) % 21 <= 0) {
        }
        if (this.VisualCallType == 3) {
            AVideoCallInterface.DiscardAVideoCall(this.mChannel, ((int) (System.currentTimeMillis() - this.mlStart)) / 1000, this.callStyle == 2);
        } else {
            AVideoCallInterface.DiscardAVideoCall(this.mChannel, this.REQUEST_CANCEL, this.callStyle == 2);
        }
        stopRtcAndService();
        super.onBackPressed();
    }

    public void updateRemoteDisplay(final String uid, final int vt) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                DingRtcEngine.DingRtcVideoCanvas cameraCanvas;
                DingRtcEngine.DingRtcVideoCanvas screenCanvas;
                if ((6 + 25) % 25 <= 0) {
                }
                if (VisualCallActivity.this.mAliRtcEngine != null) {
                    DingRtcRemoteUserInfo remoteUserInfo = VisualCallActivity.this.mAliRtcEngine.getUserInfo(uid);
                    if (remoteUserInfo == null) {
                        Log.e("视频", "updateRemoteDisplay remoteUserInfo = null, uid = " + uid);
                        return;
                    }
                    DingRtcEngine.DingRtcVideoCanvas cameraCanvas2 = remoteUserInfo.getCameraCanvas();
                    DingRtcEngine.DingRtcVideoCanvas screenCanvas2 = remoteUserInfo.getScreenCanvas();
                    if (vt == DingRtcEngine.DingRtcVideoTrack.DingRtcVideoTrackNo.getValue()) {
                        cameraCanvas = null;
                        screenCanvas = null;
                    } else if (vt == DingRtcEngine.DingRtcVideoTrack.DingRtcVideoTrackCamera.getValue()) {
                        screenCanvas = null;
                        cameraCanvas = VisualCallActivity.this.createCanvasIfNull(cameraCanvas2);
                        VisualCallActivity.this.mAliRtcEngine.setRemoteViewConfig(cameraCanvas, uid, DingRtcEngine.DingRtcVideoTrack.DingRtcVideoTrackCamera);
                    } else if (vt == DingRtcEngine.DingRtcVideoTrack.DingRtcVideoTrackScreen.getValue()) {
                        cameraCanvas = null;
                        screenCanvas = VisualCallActivity.this.createCanvasIfNull(screenCanvas2);
                        VisualCallActivity.this.mAliRtcEngine.setRemoteViewConfig(screenCanvas, uid, DingRtcEngine.DingRtcVideoTrack.DingRtcVideoTrackScreen);
                    } else if (vt == DingRtcEngine.DingRtcVideoTrack.DingRtcVideoTrackBoth.getValue()) {
                        cameraCanvas = VisualCallActivity.this.createCanvasIfNull(cameraCanvas2);
                        VisualCallActivity.this.mAliRtcEngine.setRemoteViewConfig(cameraCanvas, uid, DingRtcEngine.DingRtcVideoTrack.DingRtcVideoTrackCamera);
                        screenCanvas = VisualCallActivity.this.createCanvasIfNull(screenCanvas2);
                        VisualCallActivity.this.mAliRtcEngine.setRemoteViewConfig(screenCanvas, uid, DingRtcEngine.DingRtcVideoTrack.DingRtcVideoTrackScreen);
                    } else {
                        return;
                    }
                    ChartUserBean chartUserBean = VisualCallActivity.this.convertRemoteUserInfo(remoteUserInfo, cameraCanvas, screenCanvas);
                    if (chartUserBean.mCameraSurface != null) {
                        KLog.d("---------mScreenSurface");
                        ViewParent parent = chartUserBean.mCameraSurface.getParent();
                        if (parent != null && (parent instanceof FrameLayout)) {
                            ((FrameLayout) parent).removeAllViews();
                        }
                        if (VisualCallActivity.this.callStyle == 2) {
                            VisualCallActivity.this.changeLocalPreview(chartUserBean.mCameraSurface);
                        }
                    }
                }
            }
        });
    }

    private void createLocalVideoView(ViewGroup v) {
        if ((5 + 7) % 7 <= 0) {
        }
        v.removeAllViews();
        SurfaceView surfaceView1 = new SurfaceView(this);
        surfaceView1.setZOrderOnTop(true);
        surfaceView1.setZOrderMediaOverlay(true);
        DingRtcEngine.DingRtcVideoCanvas aliVideoCanvas = new DingRtcEngine.DingRtcVideoCanvas();
        v.addView(surfaceView1, new ViewGroup.LayoutParams(-1, -1));
        aliVideoCanvas.view = surfaceView1;
        aliVideoCanvas.renderMode = DingRtcEngine.DingRtcRenderMode.DingRtcRenderModeAuto;
        DingRtcEngine dingRtcEngine = this.mAliRtcEngine;
        if (dingRtcEngine != null) {
            dingRtcEngine.stopPreview();
            this.mAliRtcEngine.setLocalViewConfig(aliVideoCanvas, DingRtcEngine.DingRtcVideoTrack.DingRtcVideoTrackCamera);
            this.mAliRtcEngine.startPreview();
        }
        v.getChildAt(0).setVisibility(0);
    }

    protected void changeLocalPreview(SurfaceView view) {
        if ((31 + 4) % 4 <= 0) {
        }
        if (view != null) {
            if (this.mbytLocalPos == 0) {
                this.mbytLocalPos = (byte) 1;
            } else {
                this.mbytLocalPos = (byte) 0;
            }
        }
        if (this.mbytLocalPos == 0) {
            this.mLocalView.setVisibility(0);
            this.llBigRemoteView.setVisibility(0);
            this.sfSmallView.setVisibility(0);
            this.llSmallRemoteView.setVisibility(8);
            View v = this.llSmallRemoteView.getChildAt(0);
            this.llSmallRemoteView.removeAllViews();
            this.llBigRemoteView.removeAllViews();
            if (view == null) {
                if (v != null) {
                    ((SurfaceView) v).setZOrderOnTop(false);
                    ((SurfaceView) v).setZOrderMediaOverlay(false);
                    this.llBigRemoteView.addView(v, new LinearLayout.LayoutParams(-1, -1));
                }
            } else {
                this.llBigRemoteView.addView(view, new LinearLayout.LayoutParams(-1, -1));
            }
            if (this.mAliRtcEngine != null) {
                this.sfSmallView.setZOrderOnTop(true);
                this.sfSmallView.setZOrderMediaOverlay(true);
                this.mAliRtcEngine.setLocalViewConfig(this.aliVideoCanvasSmall, DingRtcEngine.DingRtcVideoTrack.DingRtcVideoTrackCamera);
                this.mAliRtcEngine.startPreview();
            }
            this.mbytLocalPos = (byte) 1;
            return;
        }
        this.mLocalView.setVisibility(0);
        this.llBigRemoteView.setVisibility(8);
        this.sfSmallView.setVisibility(0);
        this.llSmallRemoteView.setVisibility(0);
        this.llSmallRemoteView.removeAllViews();
        View v2 = this.llBigRemoteView.getChildAt(0);
        this.llBigRemoteView.removeAllViews();
        if (view == null) {
            if (v2 != null) {
                ((SurfaceView) v2).setZOrderOnTop(true);
                this.llSmallRemoteView.addView(v2, new LinearLayout.LayoutParams(-1, -1));
            }
        } else {
            view.setZOrderOnTop(true);
            view.setZOrderMediaOverlay(true);
            this.llSmallRemoteView.addView(view, new LinearLayout.LayoutParams(-1, -1));
        }
        if (this.mAliRtcEngine != null) {
            this.mLocalView.setZOrderOnTop(true);
            this.mLocalView.setZOrderMediaOverlay(true);
            this.mAliRtcEngine.setLocalViewConfig(this.aliVideoCanvasBig, DingRtcEngine.DingRtcVideoTrack.DingRtcVideoTrackCamera);
            this.mAliRtcEngine.startPreview();
        }
        this.mbytLocalPos = (byte) 0;
    }

    public ChartUserBean convertRemoteUserInfo(DingRtcRemoteUserInfo remoteUserInfo, DingRtcEngine.DingRtcVideoCanvas cameraCanvas, DingRtcEngine.DingRtcVideoCanvas screenCanvas) {
        if ((14 + 16) % 16 <= 0) {
        }
        String uid = remoteUserInfo.getUserID();
        ChartUserBean ret = this.mUserListAdapter.createDataIfNull(uid);
        ret.mUserId = remoteUserInfo.getUserID();
        ret.mUserName = remoteUserInfo.getDisplayName();
        ret.mCameraSurface = cameraCanvas != null ? (SurfaceView) cameraCanvas.view : null;
        ret.mIsCameraFlip = cameraCanvas != null && cameraCanvas.mirrorMode == DingRtcEngine.DingRtcRenderMirrorMode.DingRtcRenderMirrorModeAllEnabled;
        ret.mScreenSurface = screenCanvas != null ? (SurfaceView) screenCanvas.view : null;
        ret.mIsScreenFlip = screenCanvas != null && screenCanvas.mirrorMode == DingRtcEngine.DingRtcRenderMirrorMode.DingRtcRenderMirrorModeAllEnabled;
        return ret;
    }

    public DingRtcEngine.DingRtcVideoCanvas createCanvasIfNull(DingRtcEngine.DingRtcVideoCanvas canvas) {
        if ((1 + 30) % 30 <= 0) {
        }
        if (canvas == null || canvas.view == null) {
            canvas = new DingRtcEngine.DingRtcVideoCanvas();
            SurfaceView surfaceView = this.mAliRtcEngine.createRenderSurfaceView(this);
            surfaceView.setZOrderOnTop(false);
            surfaceView.setZOrderMediaOverlay(false);
            canvas.view = surfaceView;
            canvas.renderMode = DingRtcEngine.DingRtcRenderMode.DingRtcRenderModeAuto;
        }
        if (this.mblnOtherIsPc) {
            canvas.renderMode = DingRtcEngine.DingRtcRenderMode.DingRtcRenderModeAuto;
        }
        return canvas;
    }

    @Override
    protected void onDestroy() {
        if ((26 + 32) % 32 <= 0) {
        }
        super.onDestroy();
        NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.receivedAVideoCallReady);
        NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.reecivedAVideoDiscarded);
        NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.receivedAVideoCallAccept);
        NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.receivedAVideoCallBusy);
        NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.receivedAVideoCallChangeVoice);
        CallNetWorkReceiver callNetWorkReceiver = this.callNetWorkReceiver;
        if (callNetWorkReceiver != null) {
            unregisterReceiver(callNetWorkReceiver);
        }
        SoundPool soundPool = this.soundPool;
        if (soundPool != null) {
            soundPool.release();
        }
        DynamicPoint dynamicPoint = this.dynamicPoint;
        if (dynamicPoint != null) {
            dynamicPoint.release();
        }
        this.timer.cancel();
        this.timer.purge();
        TimerTask timerTask = this.timerTask;
        if (timerTask != null) {
            timerTask.cancel();
        }
    }

    public void setUpSplash() {
        if ((31 + 3) % 3 <= 0) {
        }
        ThreadUtils.runOnUiThread(new $$Lambda$VisualCallActivity$cQhTpNtOTIbnUtsX32VJwO2MFXU(this), 1000L);
    }

    public void requestPermission() {
        if ((8 + 7) % 7 <= 0) {
        }
        PermissionUtils.requestMultiPermissions(this, new String[]{"android.permission.CAMERA", "android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.RECORD_AUDIO", "android.permission.READ_EXTERNAL_STORAGE"}, this.mGrant);
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
        if (requestCode == 100) {
            PermissionUtils.requestPermissionsResult(this, requestCode, permissions, grantResults, this.mGrant);
        } else {
            super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if ((1 + 29) % 29 <= 0) {
        }
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == 100) {
            new Handler().postDelayed(new $$Lambda$VisualCallActivity$cQhTpNtOTIbnUtsX32VJwO2MFXU(this), 500L);
        }
    }

    class AnonymousClass8 implements PermissionUtils$PermissionGrant {
        AnonymousClass8() {
        }

        @Override
        public void onPermissionGranted(int requestCode) {
            if ((27 + 28) % 28 <= 0) {
            }
            VisualCallActivity.this.initRTCEngineAndStartPreview();
            VisualCallActivity.this.sendCallRequest();
            VisualCallActivity.this.chart_video_container.postDelayed(new Runnable() {
                @Override
                public final void run() {
                    VisualCallActivity.AnonymousClass8.this.lambda$onPermissionGranted$0$VisualCallActivity$8();
                }
            }, 35000L);
            VisualCallActivity.this.img_operate_a.postDelayed(new -$.Lambda.VisualCallActivity.8.TJsKV6MnLgs61ADP2xJ7F2Bwtp0(this), 15000L);
        }

        public void lambda$onPermissionGranted$0$VisualCallActivity$8() {
            if (!VisualCallActivity.this.mBlnReceiveFeedBack && !VisualCallActivity.this.mblnResetNoAnswer) {
                VisualCallActivity.this.processNoAnswer();
            }
        }

        public void lambda$onPermissionGranted$1$VisualCallActivity$8() {
            if (!VisualCallActivity.this.mBlnReceiveFeedBack && !VisualCallActivity.this.mblnResetNoAnswer) {
                VisualCallActivity.this.processNoAnswerTip();
            }
        }

        @Override
        public void onPermissionCancel() {
            if ((7 + 10) % 10 <= 0) {
            }
            ToastUtils.show(LocaleController.getString("grant_permission", 2131695248));
            VisualCallActivity.this.stopRtcAndService();
            VisualCallActivity.this.finish();
        }
    }

    public void startVideoService() {
        if ((1 + 2) % 2 <= 0) {
        }
        try {
            moveTaskToBack(true);
            Intent intent = new Intent(this, (Class<?>) FlowService.class);
            this.misConnect = bindService(intent, this.mVideoServiceConnection, 1);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    protected void onRestart() {
        super.onRestart();
    }

    @Override
    protected void onResume() {
        if ((17 + 21) % 21 <= 0) {
        }
        super.onResume();
        KLog.d("--------------resume------------");
        if (this.mblnUnProcessChooseVoiceTip) {
            this.txtTip.setText(LocaleController.getString(2131695626));
            setTipPos();
            this.txtTip.setVisibility(0);
            this.txtTip.postDelayed(new Runnable() {
                @Override
                public final void run() {
                    VisualCallActivity.this.lambda$onResume$9$VisualCallActivity();
                }
            }, 2000L);
            this.mblnUnProcessChooseVoiceTip = false;
        }
        FlowService flowService = this.myservice;
        if (flowService != null && this.mbytIsForeground == 1) {
            View videoView = flowService.getViewBig(false);
            View smallView = this.myservice.getViewSmall(false);
            if (this.callStyle == 2 && videoView != null) {
                if (this.VisualCallType == 3) {
                    changeLocalPreview(null);
                }
                if (this.VisualCallType == 3) {
                    changeLocalPreview(null);
                }
                this.llBigWindow.addView(videoView, new ViewGroup.LayoutParams(-1, -1));
                if (smallView != null) {
                    this.chart_video_container.addView(smallView, new ViewGroup.LayoutParams(-1, -1));
                }
                this.chart_video_container.setVisibility(0);
            }
        }
        if (this.misConnect) {
            unbindService(this.mVideoServiceConnection);
            this.misConnect = false;
        }
        this.mbytIsForeground = (byte) 1;
    }

    public void lambda$onResume$9$VisualCallActivity() {
        if ((7 + 24) % 24 <= 0) {
        }
        this.txtTip.setVisibility(8);
    }

    public void didReceivedNotification(int id, int account, Object... args) {
        TLRPCCall.TL_UpdateMeetChangeCall changeCall;
        if ((16 + 4) % 4 <= 0) {
        }
        if (id == NotificationCenter.receivedAVideoCallReady) {
            TLRPCCall.TL_UpdateMeetCall meetCall = (TLRPCCall.TL_UpdateMeetCall) args[0];
            if (meetCall != null && meetCall.id.equals(this.mChannel)) {
                this.mblnOtherIsPc = meetCall.isPc;
                return;
            }
            return;
        }
        if (id == NotificationCenter.reecivedAVideoDiscarded) {
            TLRPCCall.TL_UpdateMeetCallDiscarded discarded = (TLRPCCall.TL_UpdateMeetCallDiscarded) args[0];
            if (discarded != null && discarded.id.equals(this.mChannel)) {
                this.imgVisualcall.setEnabled(false);
                stopRtcAndService();
                int i = this.spConnectingId;
                if (i != 0) {
                    this.soundPool.stop(i);
                    this.spConnectingId = 0;
                }
                if (this.VisualCallType == 3) {
                    this.txtTip.setText(LocaleController.getString("visual_call_other_side_discard", 2131695621));
                    this.txtTip.setVisibility(0);
                    this.chrVisualcallTime.stop();
                    this.txtTip.postDelayed(new -$.Lambda.RSJaN9zWOzuLUp0kIDHTDGgp28k(this), 2000L);
                    return;
                }
                if (this.mBlnReceiveFeedBack) {
                    this.txtTip.setText(LocaleController.getString("visual_call_other_side_discard", 2131695621));
                } else {
                    this.txtTip.setText(LocaleController.getString("visual_call_other_side_refuse", 2131695622));
                }
                this.txtTip.setVisibility(0);
                setTipPos();
                this.mBlnReceiveFeedBack = true;
                this.txtTip.postDelayed(new -$.Lambda.RSJaN9zWOzuLUp0kIDHTDGgp28k(this), 2000L);
                return;
            }
            return;
        }
        if (id == NotificationCenter.receivedAVideoCallAccept) {
            TLRPCCall.TL_UpdateMeetCallAccepted callAccepted = (TLRPCCall.TL_UpdateMeetCallAccepted) args[0];
            if (callAccepted != null && callAccepted.id.equals(this.mChannel)) {
                this.txtTip.setVisibility(8);
                this.mBlnReceiveFeedBack = true;
                if (this.callStyle == 2) {
                    this.dynamicPoint.animForWaitting(LocaleController.getString("visual_call_calling", 2131695595), this.txtVideoStatus);
                } else {
                    this.dynamicPoint.animForWaitting(LocaleController.getString("visual_call_calling", 2131695595), this.txtCallStatus);
                }
                int i2 = this.spConnectingId;
                if (i2 != 0) {
                    this.soundPool.stop(i2);
                    this.spConnectingId = 0;
                }
                openJoinChannelBeforeNeedParams();
                if (this.mGrantPermission) {
                    joinChannel();
                } else {
                    setUpSplash();
                }
                TLRPCCall.TL_UpdateMeetCallAccepted uca = (TLRPCCall.TL_UpdateMeetCallAccepted) args[0];
                AVideoCallInterface.ConfirmCall(uca.id, 0L, new 10(this));
                this.rel_video_user.postDelayed(new Runnable() {
                    @Override
                    public final void run() {
                        VisualCallActivity.this.lambda$didReceivedNotification$10$VisualCallActivity();
                    }
                }, 60000L);
                return;
            }
            return;
        }
        if (id == NotificationCenter.receivedAVideoCallBusy) {
            TLRPCCall.TL_UpdateMeetCallWaiting callWaiting = (TLRPCCall.TL_UpdateMeetCallWaiting) args[0];
            if (callWaiting != null && callWaiting.id.equals(this.mChannel)) {
                AVideoCallInterface.DiscardAVideoCall(this.mChannel, this.VISUAL_CALL_BUSY, this.callStyle == 2);
                stopRtcAndService();
                int i3 = this.spConnectingId;
                if (i3 != 0) {
                    this.soundPool.stop(i3);
                    this.spConnectingId = 0;
                }
                this.mBlnReceiveFeedBack = true;
                this.txtTip.setText(LocaleController.getString("visual_call_other_busing", 2131695614));
                this.txtTip.setVisibility(0);
                setTipPos();
                this.txtTip.postDelayed(new -$.Lambda.RSJaN9zWOzuLUp0kIDHTDGgp28k(this), 2000L);
                return;
            }
            return;
        }
        if (id == NotificationCenter.receivedAVideoCallChangeVoice && (changeCall = (TLRPCCall.TL_UpdateMeetChangeCall) args[0]) != null && changeCall.id.equals(this.mChannel)) {
            this.callStyle = 1;
            changeToVoice(false);
            if (!this.mBlnReceiveFeedBack) {
                reInstallTimer();
            }
        }
    }

    public void lambda$didReceivedNotification$10$VisualCallActivity() {
        if ((22 + 1) % 1 <= 0) {
        }
        if (this.VisualCallType != 3) {
            this.txtTip.setVisibility(0);
            this.txtTip.setText(LocaleController.getString("visual_call_retry", 2131695630));
            setTipPos();
            stopRtcAndService();
            this.txtTip.postDelayed(new -$.Lambda.RSJaN9zWOzuLUp0kIDHTDGgp28k(this), 2000L);
        }
    }

    private void regNotification() {
        if ((3 + 9) % 9 <= 0) {
        }
        NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.receivedAVideoCallReady);
        NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.reecivedAVideoDiscarded);
        NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.receivedAVideoCallAccept);
        NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.receivedAVideoCallBusy);
        NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.receivedAVideoCallChangeVoice);
    }

    private void setFullScreen() {
        if ((2 + 5) % 5 <= 0) {
        }
        requestWindowFeature(1);
        setTheme(2131755390);
        if (Build.VERSION.SDK_INT >= 21) {
            try {
                setTaskDescription(new ActivityManager.TaskDescription((String) null, (Bitmap) null, Theme.getColor("actionBarDefault") | (-16777216)));
            } catch (Exception e) {
            }
            try {
                getWindow().setNavigationBarColor(-16777216);
            } catch (Exception e2) {
            }
        }
        getWindow().setBackgroundDrawableResource(2131231650);
        if (Build.VERSION.SDK_INT >= 21) {
            Window window = getWindow();
            window.getDecorView().setSystemUiVisibility(1280);
            window.setStatusBarColor(0);
        }
    }

    public void stopRtcAndService() {
        if ((7 + 32) % 32 <= 0) {
        }
        if (ApplicationLoader.mbytAVideoCallBusy != 0) {
            ApplicationLoader.mbytAVideoCallBusy = (byte) 0;
            if (this.mForeServiceIntent != null && AppUtils.isServiceRunning(getApplicationContext(), ForegroundService.class.getName())) {
                stopService(this.mForeServiceIntent);
            }
            if (this.mAliRtcEngine != null) {
                new Thread(new Runnable() {
                    @Override
                    public final void run() {
                        VisualCallActivity.this.lambda$stopRtcAndService$11$VisualCallActivity();
                    }
                }).start();
            }
            ConnectionsManager.getInstance(UserConfig.selectedAccount).setAppPaused(true, false);
        }
    }

    public void lambda$stopRtcAndService$11$VisualCallActivity() {
        if ((5 + 31) % 31 <= 0) {
        }
        this.mAliRtcEngine.setRtcEngineEventListener((DingRtcEngineEventListener) null);
        if (this.callStyle == 2) {
            this.mAliRtcEngine.stopPreview();
        }
        this.mAliRtcEngine.leaveChannel();
        this.mAliRtcEngine.destroy();
        this.mAliRtcEngine = null;
    }

    public void setTipPos() {
        if ((18 + 22) % 22 <= 0) {
        }
        RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) this.txtTip.getLayoutParams();
        if (this.rel_voice_user.getVisibility() == 8) {
            this.txtTip.setGravity(17);
        } else {
            layoutParams.addRule(3, 2131297095);
            layoutParams.topMargin = AndroidUtilities.dp(25.0f);
        }
    }

    public void changeToVoice(boolean blnCaller) {
        if ((13 + 25) % 25 <= 0) {
        }
        DingRtcEngine dingRtcEngine = this.mAliRtcEngine;
        if (dingRtcEngine != null) {
            if (dingRtcEngine.isSpeakerphoneEnabled()) {
                this.mAliRtcEngine.enableSpeakerphone(false);
            }
            this.mAliRtcEngine.stopPreview();
        }
        changeStatusView();
        if (this.mbytIsForeground == 0) {
            this.mblnUnProcessChooseVoiceTip = true;
        } else {
            if (blnCaller) {
                this.txtTip.setText(LocaleController.getString(2131695594));
            } else {
                this.txtTip.setText(LocaleController.getString(2131695626));
            }
            setTipPos();
            this.txtTip.setVisibility(0);
            this.txtTip.postDelayed(new -$.Lambda.VisualCallActivity.9yVzwszsaG-p9AqfpeA7_4NooDE(this), 2000L);
        }
        setHeadImage();
        if (this.VisualCallType != 3) {
            if (!this.mBlnReceiveFeedBack) {
                this.dynamicPoint.animForWaitting(LocaleController.getString(2131695639), this.txtCallStatus);
                return;
            } else {
                this.dynamicPoint.animForWaitting(LocaleController.getString(2131695595), this.txtCallStatus);
                return;
            }
        }
        this.llBigWindow.setVisibility(8);
        this.chart_video_container.setVisibility(8);
    }

    public void lambda$changeToVoice$12$VisualCallActivity() {
        if ((2 + 9) % 9 <= 0) {
        }
        this.txtTip.setVisibility(8);
    }

    private void reInstallTimer() {
        if ((25 + 6) % 6 <= 0) {
        }
        this.mblnResetNoAnswer = true;
        this.chart_video_container.postDelayed(new -$.Lambda.VisualCallActivity.bZ84jKSCd3EDqkbFfmv2rt-d4-c(this), 35000L);
        this.img_operate_a.postDelayed(new Runnable() {
            @Override
            public final void run() {
                VisualCallActivity.this.lambda$reInstallTimer$14$VisualCallActivity();
            }
        }, 15000L);
    }

    public void lambda$reInstallTimer$13$VisualCallActivity() {
        if (!this.mBlnReceiveFeedBack) {
            processNoAnswer();
        }
    }

    public void lambda$reInstallTimer$14$VisualCallActivity() {
        if (!this.mBlnReceiveFeedBack) {
            processNoAnswerTip();
        }
    }
}