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

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

MD5 校验值:1036132062d4d223cd1a714f5bbea98b

反编译源代码说明

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


package im.skmzhmurqt.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.text.TextUtils;
import android.util.Log;
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.alivc.rtc.AliRtcAuthInfo;
import com.alivc.rtc.AliRtcEngine;
import com.alivc.rtc.AliRtcEngineEventListener;
import com.alivc.rtc.AliRtcEngineImpl;
import com.alivc.rtc.AliRtcEngineNotify;
import com.alivc.rtc.AliRtcRemoteUserInfo;
import com.blankj.utilcode.constant.TimeConstants;
import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection;
import com.google.android.exoplayer2.upstream.DefaultLoadErrorHandlingPolicy;
import com.king.zxing.util.LogUtils;
import com.socks.library.KLog;
import ezy.assist.compat.SettingsCompat;
import im.skmzhmurqt.messenger.AccountInstance;
import im.skmzhmurqt.messenger.AndroidUtilities;
import im.skmzhmurqt.messenger.ApplicationLoader;
import im.skmzhmurqt.messenger.FileLog;
import im.skmzhmurqt.messenger.ImageLocation;
import im.skmzhmurqt.messenger.LocaleController;
import im.skmzhmurqt.messenger.MessagesController;
import im.skmzhmurqt.messenger.NotificationCenter;
import im.skmzhmurqt.messenger.R;
import im.skmzhmurqt.messenger.UserConfig;
import im.skmzhmurqt.tgnet.ConnectionsManager;
import im.skmzhmurqt.tgnet.TLObject;
import im.skmzhmurqt.tgnet.TLRPC;
import im.skmzhmurqt.tgnet.TLRPCCall;
import im.skmzhmurqt.ui.actionbar.AlertDialog;
import im.skmzhmurqt.ui.actionbar.Theme;
import im.skmzhmurqt.ui.components.AvatarDrawable;
import im.skmzhmurqt.ui.components.BackupImageView;
import im.skmzhmurqt.ui.components.ColorTextView;
import im.skmzhmurqt.ui.components.toast.ToastUtils;
import im.skmzhmurqt.ui.hui.visualcall.AVideoCallInterface;
import im.skmzhmurqt.ui.hui.visualcall.BaseRecyclerViewAdapter;
import im.skmzhmurqt.ui.hui.visualcall.CallNetWorkReceiver;
import im.skmzhmurqt.ui.hui.visualcall.ChartUserAdapter;
import im.skmzhmurqt.ui.hui.visualcall.FlowService;
import im.skmzhmurqt.ui.hui.visualcall.PermissionUtils;
import im.skmzhmurqt.ui.hui.visualcall.RTCAuthInfo;
import im.skmzhmurqt.ui.hui.visualcall.VisualCallActivity;
import im.skmzhmurqt.ui.hviews.DragFrameLayout;
import im.skmzhmurqt.ui.hviews.dialogs.Util;
import im.skmzhmurqt.ui.hviews.dialogs.XDialog;
import im.skmzhmurqt.ui.hviews.helper.MryDeviceHelper;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Timer;
import java.util.TimerTask;
import org.json.JSONException;
import org.json.JSONObject;
import org.webrtc.alirtcInterface.ALI_RTC_INTERFACE;
import org.webrtc.alirtcInterface.AliParticipantInfo;
import org.webrtc.alirtcInterface.AliStatusInfo;
import org.webrtc.alirtcInterface.AliSubscriberInfo;
import org.webrtc.sdk.SophonSurfaceView;

public class VisualCallActivity extends Activity implements NotificationCenter.NotificationCenterDelegate {
    private static final String TAG = VisualCallActivity.class.getName();
    TLRPC.InputPeer ChannelPeer;
    protected AliRtcEngine.AliVideoCanvas aliVideoCanvasBig;
    protected AliRtcEngine.AliVideoCanvas aliVideoCanvasSmall;
    private CallNetWorkReceiver callNetWorkReceiver;

    @BindView(R.id.chart_content_userlist)
    RecyclerView chartUserListView;

    @BindView(R.id.chart_video_container)
    DragFrameLayout chart_video_container;

    @BindView(R.id.chr_visualcall_time)
    Chronometer chrVisualcallTime;
    public String currentUid;
    DynamicPoint dynamicPoint;

    @BindView(R.id.img_user_head)
    BackupImageView imgUserHead;

    @BindView(R.id.img_video_user_head)
    BackupImageView imgVideoUserHead;

    @BindView(R.id.img_visualcall)
    ImageView imgVisualcall;

    @BindView(R.id.img_operate_a)
    ImageView img_operate_a;

    @BindView(R.id.img_operate_b)
    ImageView img_operate_b;

    @BindView(R.id.img_operate_c)
    ImageView img_operate_c;

    @BindView(R.id.img_pre_receive)
    ImageView img_pre_receive;

    @BindView(R.id.lin_operate_a)
    LinearLayout lin_operate_a;

    @BindView(R.id.lin_operate_b)
    LinearLayout lin_operate_b;

    @BindView(R.id.lin_operate_c)
    LinearLayout lin_operate_c;

    @BindView(R.id.ll_big_remote_view)
    LinearLayout llBigRemoteView;

    @BindView(R.id.ll_big_window)
    LinearLayout llBigWindow;

    @BindView(R.id.ll_small_remote_view)
    LinearLayout llSmallRemoteView;
    private AliRtcEngine mAliRtcEngine;
    protected Context mContext;
    private Intent mForeServiceIntent;
    private boolean mGrantPermission;

    @BindView(R.id.sf_local_view)
    SophonSurfaceView mLocalView;
    ArrayList<TLRPC.InputPeer> mUserArray;
    private ChartUserAdapter mUserListAdapter;
    private String mUsername;
    private long mlTipShow;

    @BindView(R.id.rel_video_user)
    RelativeLayout rel_video_user;

    @BindView(R.id.rel_visual_call_a)
    LinearLayout rel_visual_call_a;

    @BindView(R.id.rel_visual_call_b)
    RelativeLayout rel_visual_call_b;

    @BindView(R.id.rel_voice_user)
    RelativeLayout rel_voice_user;

    @BindView(R.id.sf_small_view)
    SophonSurfaceView sfSmallView;
    protected SoundPool soundPool;
    protected int spConnectingId;

    @BindView(R.id.txt_call_name)
    TextView txtCallName;

    @BindView(R.id.txt_call_status)
    ColorTextView txtCallStatus;

    @BindView(R.id.txt_tip)
    TextView txtTip;

    @BindView(R.id.txt_video_name)
    TextView txtVideoName;

    @BindView(R.id.txt_video_status)
    ColorTextView txtVideoStatus;

    @BindView(R.id.txt_visualcall_status)
    ColorTextView txtVisualcallStatus;

    @BindView(R.id.txt_operate_a)
    ColorTextView txt_operate_a;

    @BindView(R.id.txt_operate_b)
    ColorTextView txt_operate_b;

    @BindView(R.id.txt_operate_c)
    ColorTextView txt_operate_c;

    @BindView(R.id.txt_pre_change_to_voice)
    TextView txt_pre_change_to_voice;
    protected SophonSurfaceView surfaceView = null;
    private int VisualCallType = 1;
    private boolean misConnect = false;
    private int callStyle = 2;
    private String mChannel = "0001";
    private boolean mIsAudioCapture = true;
    private boolean mIsAudioPlay = true;
    private RTCAuthInfo mRtcAuthInfo = new RTCAuthInfo();
    private long mlStart = 0;
    private long mlLastClickTime = 0;
    protected byte mbytLocalPos = 0;
    protected boolean mBlnReceiveFeedBack = false;
    private byte mbytIsForeground = 1;
    private byte mbytExit = 0;
    private Timer timer = new Timer();
    private TimerTask timerTask = null;
    private byte REQUEST_CANCEL = -2;
    private byte VISUAL_CALL_BUSY = -3;
    private byte REQUEST_NO_ANSWER = -4;
    private byte REQUEST_NETWORK_ERROR = -5;
    private int miCallReceiverId = -1;
    private boolean mblnResetNoAnswer = false;
    private boolean mblnUnProcessChooseVoiceTip = false;
    private byte mbytLastClickIndex = -1;
    private boolean mblnOtherIsPc = false;
    private byte mbytFPacketRecCount = 0;
    private ChartUserAdapter.OnSubConfigChangeListener mOnSubConfigChangeListener = new ChartUserAdapter.OnSubConfigChangeListener() {
        AnonymousClass5() {
        }

        @Override
        public void onFlipView(String uid, int flag, boolean flip) {
            AliRtcEngine.AliVideoCanvas cameraCanvas;
            AliRtcEngine.AliVideoCanvas screenCanvas;
            AliRtcRemoteUserInfo userInfo = VisualCallActivity.this.mAliRtcEngine.getUserInfo(uid);
            if (flag == 1001) {
                if (userInfo != null && (cameraCanvas = userInfo.getCameraCanvas()) != null) {
                    cameraCanvas.mirrorMode = flip ? AliRtcEngine.AliRtcRenderMirrorMode.AliRtcRenderMirrorModeAllEnabled : AliRtcEngine.AliRtcRenderMirrorMode.AliRtcRenderMirrorModeAllDisable;
                    VisualCallActivity.this.mAliRtcEngine.setRemoteViewConfig(cameraCanvas, uid, AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackCamera);
                    return;
                }
                return;
            }
            if (flag == 1002 && userInfo != null && (screenCanvas = userInfo.getScreenCanvas()) != null) {
                screenCanvas.mirrorMode = flip ? AliRtcEngine.AliRtcRenderMirrorMode.AliRtcRenderMirrorModeAllEnabled : AliRtcEngine.AliRtcRenderMirrorMode.AliRtcRenderMirrorModeAllDisable;
                VisualCallActivity.this.mAliRtcEngine.setRemoteViewConfig(screenCanvas, uid, AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackScreen);
            }
        }

        @Override
        public void onShowVideoInfo(String uid, int flag) {
            AliRtcEngine.AliRtcVideoTrack track = AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackNo;
            if (flag == 1001) {
                track = AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackCamera;
            } else if (flag == 1002) {
                track = AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackScreen;
            }
            if (VisualCallActivity.this.mAliRtcEngine != null) {
                String result = VisualCallActivity.this.mAliRtcEngine.getMediaInfoWithUserId(uid, track, AliRtcConstants.VIDEO_INFO_KEYS);
                Toast.makeText(VisualCallActivity.this, result, 0).show();
            }
        }
    };
    Bundle mBundle = new Bundle();
    private AliRtcEngineEventListener mEventListener = new AnonymousClass6();
    private AliRtcEngineNotify mEngineNotify = new AnonymousClass7();
    private PermissionUtils.PermissionGrant mGrant = new AnonymousClass9();
    private FlowService myservice = null;
    ServiceConnection mVideoServiceConnection = new ServiceConnection() {
        AnonymousClass10() {
        }

        @Override
        public void onServiceConnected(ComponentName name, IBinder service) {
            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;
                    smallView = VisualCallActivity.this.llSmallRemoteView;
                } else {
                    view = VisualCallActivity.this.llBigRemoteView;
                    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 byte access$1808(VisualCallActivity x0) {
        byte b = x0.mbytFPacketRecCount;
        x0.mbytFPacketRecCount = (byte) (b + 1);
        return b;
    }

    public void changeStatusView() {
        KLog.d("--------haha callStyle" + this.callStyle + "   VisualCallType" + this.VisualCallType);
        if (this.callStyle == 1) {
            AliRtcEngine aliRtcEngine = this.mAliRtcEngine;
            if (aliRtcEngine != null && aliRtcEngine.isLocalCameraPublishEnabled()) {
                KLog.d("--------关闭视频");
                this.mAliRtcEngine.configLocalCameraPublish(false);
                this.mAliRtcEngine.publish();
            }
            this.chart_video_container.setVisibility(8);
            this.mLocalView.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(R.drawable.visualcall_no_voice));
                } else {
                    this.img_operate_a.setBackgroundDrawable(this.mContext.getResources().getDrawable(R.drawable.visualcall_no_voice_selected));
                }
                this.img_operate_c.setVisibility(4);
                this.txt_operate_b.setText(LocaleController.getString("Cancel", R.string.Cancel));
                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(R.drawable.visualcall_receive_common));
                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", R.string.Str_visualcall_cancel));
            this.txt_operate_a.setText(LocaleController.getString(R.string.Str_visualcall_no_voice));
            this.txt_operate_c.setText(LocaleController.getString(R.string.Str_visualcall_hands_free));
            if (this.mIsAudioCapture) {
                this.img_operate_a.setBackgroundDrawable(this.mContext.getResources().getDrawable(R.drawable.visualcall_no_voice));
            } else {
                this.img_operate_a.setBackgroundDrawable(this.mContext.getResources().getDrawable(R.drawable.visualcall_no_voice_selected));
            }
            AliRtcEngine aliRtcEngine2 = this.mAliRtcEngine;
            if (aliRtcEngine2 != null) {
                if (aliRtcEngine2.isSpeakerOn()) {
                    this.img_operate_c.setBackgroundDrawable(this.mContext.getResources().getDrawable(R.drawable.visual_hands_free_selected));
                    return;
                } else {
                    this.img_operate_c.setBackgroundDrawable(this.mContext.getResources().getDrawable(R.drawable.visualcall_hands_free));
                    return;
                }
            }
            return;
        }
        this.chart_video_container.setVisibility(0);
        this.mLocalView.setVisibility(0);
        this.rel_video_user.setVisibility(0);
        this.rel_voice_user.setVisibility(8);
        AliRtcEngine aliRtcEngine3 = this.mAliRtcEngine;
        if (aliRtcEngine3 != null && !aliRtcEngine3.isLocalCameraPublishEnabled()) {
            KLog.d("--------打开视频");
            this.mAliRtcEngine.configLocalCameraPublish(true);
            this.mAliRtcEngine.publish();
        }
        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(R.drawable.visualcall_video_receive));
            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(R.drawable.visualcall_to_voice));
        this.txt_operate_a.setText(LocaleController.getString("Str_visualcall_to_voice", R.string.Str_visualcall_to_voice));
        this.img_operate_b.setBackgroundDrawable(this.mContext.getResources().getDrawable(R.drawable.visualcall_cancel_common));
        this.txt_operate_b.setText(LocaleController.getString("Str_visualcall_cancel", R.string.Str_visualcall_cancel));
        this.img_operate_c.setBackgroundDrawable(this.mContext.getResources().getDrawable(R.drawable.visualcall_camera));
        this.txt_operate_c.setText(LocaleController.getString("Str_visualcall_change_camera", R.string.Str_visualcall_change_camera));
    }

    protected void regNetWorkReceiver() {
        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() {
            AnonymousClass1() {
            }

            @Override
            public void onNetWorkConnected() {
                if (!VisualCallActivity.this.mChannel.equals("0001")) {
                    VisualCallActivity visualCallActivity = VisualCallActivity.this;
                    visualCallActivity.sendKeepLivePacket(visualCallActivity.mChannel);
                }
            }

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

    public class AnonymousClass1 implements CallNetWorkReceiver.NetWorkStateCallBack {
        AnonymousClass1() {
        }

        @Override
        public void onNetWorkConnected() {
            if (!VisualCallActivity.this.mChannel.equals("0001")) {
                VisualCallActivity visualCallActivity = VisualCallActivity.this;
                visualCallActivity.sendKeepLivePacket(visualCallActivity.mChannel);
            }
        }

        @Override
        public void onNetWorkDisconnected() {
        }
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ApplicationLoader.mbytAVideoCallBusy = (byte) 2;
        setFullScreen();
        setContentView(R.layout.activity_visualcall);
        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", R.string.visual_call_video_waiting), this.txtVideoStatus);
        } else {
            this.dynamicPoint.animForWaitting(LocaleController.getString("visual_call_waiting", R.string.visual_call_waiting), 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 Runnable() {
                @Override
                public final void run() {
                    VisualCallActivity.this.lambda$onCreate$1$VisualCallActivity();
                }
            }, 35000L);
            this.img_operate_a.postDelayed(new Runnable() {
                @Override
                public final void run() {
                    VisualCallActivity.this.lambda$onCreate$2$VisualCallActivity();
                }
            }, 15000L);
        }
        regNetWorkReceiver();
    }

    public static void lambda$onCreate$0(Chronometer chronometer) {
        StringBuilder sb;
        String ss;
        long time = SystemClock.elapsedRealtime() - chronometer.getBase();
        int h = (int) (time / 3600000);
        int m = ((int) (time - (h * TimeConstants.HOUR))) / TimeConstants.MIN;
        int s = ((int) ((time - (TimeConstants.HOUR * h)) - (TimeConstants.MIN * 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 + LogUtils.COLON + 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() {
        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", R.string.visual_call_fail));
        } else {
            this.txtTip.setText(LocaleController.getString("visual_call_no_answer_tip", R.string.visual_call_no_answer_tip));
        }
        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();
            }
        }, AdaptiveTrackSelection.DEFAULT_MIN_TIME_BETWEEN_BUFFER_REEVALUTATION_MS);
    }

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

    protected void processNoAnswerTip() {
        this.txtTip.setText(LocaleController.getString("visual_call_no_answer", R.string.visual_call_no_answer));
        this.txtTip.setVisibility(0);
        setTipPos();
        this.txtCallStatus.postDelayed(new Runnable() {
            @Override
            public final void run() {
                VisualCallActivity.this.lambda$processNoAnswerTip$4$VisualCallActivity();
            }
        }, 15000L);
    }

    public void lambda$processNoAnswerTip$4$VisualCallActivity() {
        if (!this.mBlnReceiveFeedBack) {
            this.txtTip.setVisibility(8);
        }
    }

    public class AnonymousClass2 extends TimerTask {
        final String val$strId;

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

        public class AnonymousClass1 implements AVideoCallInterface.AVideoRequestCallBack {
            AnonymousClass1() {
            }

            @Override
            public void onError(TLRPC.TL_error error) {
            }

            @Override
            public void onSuccess(TLObject object) {
                if (object instanceof TLRPCCall.TL_MeetModel) {
                    TLRPCCall.TL_MeetModel model = (TLRPCCall.TL_MeetModel) object;
                    if (model.id.equals(VisualCallActivity.this.mChannel) && !model.video && VisualCallActivity.this.callStyle == 2) {
                        VisualCallActivity.this.callStyle = 1;
                        VisualCallActivity.this.changeToVoice(false);
                    }
                }
            }
        }

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

        public void lambda$run$0$VisualCallActivity$2(String strId) {
            AVideoCallInterface.sendJumpPacket(strId, new AVideoCallInterface.AVideoRequestCallBack() {
                AnonymousClass1() {
                }

                @Override
                public void onError(TLRPC.TL_error error) {
                }

                @Override
                public void onSuccess(TLObject object) {
                    if (object instanceof TLRPCCall.TL_MeetModel) {
                        TLRPCCall.TL_MeetModel model = (TLRPCCall.TL_MeetModel) object;
                        if (model.id.equals(VisualCallActivity.this.mChannel) && !model.video && VisualCallActivity.this.callStyle == 2) {
                            VisualCallActivity.this.callStyle = 1;
                            VisualCallActivity.this.changeToVoice(false);
                        }
                    }
                }
            });
        }
    }

    public void sendKeepLivePacket(String strId) {
        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 class AnonymousClass3 implements AVideoCallInterface.AVideoRequestCallBack {
        AnonymousClass3() {
        }

        @Override
        public void onError(TLRPC.TL_error error) {
            if (error.text.equals("MUTUALCONTACTNEED")) {
                VisualCallActivity.this.txtTip.setText(LocaleController.getString("visual_call_no_friend_tip", R.string.visual_call_no_friend_tip));
                VisualCallActivity.this.txtTip.setVisibility(0);
                VisualCallActivity.this.setTipPos();
                return;
            }
            if (error.text.equals("VIDEO_RPC_ERROR")) {
                VisualCallActivity.this.txtTip.setText(LocaleController.getString("visual_call_server_err", R.string.visual_call_server_err));
                VisualCallActivity.this.txtTip.setVisibility(0);
                VisualCallActivity.this.setTipPos();
                return;
            }
            if (error.text.equals("IS_BUSYING") || error.text.equals("FROM_IS_BLOCKED") || error.text.equals("TO_IS_BLOCKED")) {
                VisualCallActivity.this.stopRtcAndService();
                if (VisualCallActivity.this.spConnectingId != 0) {
                    VisualCallActivity.this.soundPool.stop(VisualCallActivity.this.spConnectingId);
                    VisualCallActivity.this.spConnectingId = 0;
                }
                VisualCallActivity.this.mBlnReceiveFeedBack = true;
                String str = error.text;
                char c = 65535;
                int hashCode = str.hashCode();
                if (hashCode != -2133636844) {
                    if (hashCode != -2013590676) {
                        if (hashCode == 1424217083 && str.equals("TO_IS_BLOCKED")) {
                            c = 2;
                        }
                    } else if (str.equals("FROM_IS_BLOCKED")) {
                        c = 1;
                    }
                } else if (str.equals("IS_BUSYING")) {
                    c = 0;
                }
                if (c == 0) {
                    VisualCallActivity.this.txtTip.setText(LocaleController.getString(R.string.visual_call_other_calling));
                } else if (c == 1) {
                    VisualCallActivity.this.txtTip.setText(LocaleController.getString(R.string.visual_call_block_tip));
                } else if (c == 2) {
                    VisualCallActivity.this.txtTip.setText(LocaleController.getString(R.string.visual_call_blocked_tip));
                }
                VisualCallActivity.this.txtTip.setVisibility(0);
                VisualCallActivity.this.setTipPos();
                VisualCallActivity.this.txtTip.postDelayed(new $$Lambda$adnAVaveXsclOTbH56jgwpBLVCM(VisualCallActivity.this), AdaptiveTrackSelection.DEFAULT_MIN_TIME_BETWEEN_BUFFER_REEVALUTATION_MS);
            }
        }

        @Override
        public void onSuccess(TLObject object) {
            TLRPCCall.TL_UpdateMeetCallWaiting res = (TLRPCCall.TL_UpdateMeetCallWaiting) object;
            KLog.d("call id === " + res.id);
            VisualCallActivity.this.mChannel = res.id;
            VisualCallActivity.this.mRtcAuthInfo.data.appid = res.appid;
            VisualCallActivity.this.mRtcAuthInfo.data.token = res.token;
            VisualCallActivity.this.mRtcAuthInfo.data.userid = String.valueOf(AccountInstance.getInstance(UserConfig.selectedAccount).getUserConfig().getCurrentUser().id);
            String[] strArr = new String[res.gslb.size()];
            int i = 0;
            Iterator<String> it = res.gslb.iterator();
            while (it.hasNext()) {
                String strServer = it.next();
                strArr[i] = strServer;
                i++;
            }
            VisualCallActivity.this.mRtcAuthInfo.data.gslb = strArr;
            if (res.data != null) {
                try {
                    JSONObject jsonObject = new JSONObject(res.data.data);
                    VisualCallActivity.this.mRtcAuthInfo.data.timestamp = jsonObject.getLong("time_stamp");
                    VisualCallActivity.this.mRtcAuthInfo.data.setNonce(jsonObject.getString("nonce"));
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
            VisualCallActivity visualCallActivity = VisualCallActivity.this;
            visualCallActivity.sendKeepLivePacket(visualCallActivity.mChannel);
        }
    }

    public void sendCallRequest() {
        AVideoCallInterface.StartAVideoCall(this.callStyle == 2, this.mUserArray, this.ChannelPeer, new AVideoCallInterface.AVideoRequestCallBack() {
            AnonymousClass3() {
            }

            @Override
            public void onError(TLRPC.TL_error error) {
                if (error.text.equals("MUTUALCONTACTNEED")) {
                    VisualCallActivity.this.txtTip.setText(LocaleController.getString("visual_call_no_friend_tip", R.string.visual_call_no_friend_tip));
                    VisualCallActivity.this.txtTip.setVisibility(0);
                    VisualCallActivity.this.setTipPos();
                    return;
                }
                if (error.text.equals("VIDEO_RPC_ERROR")) {
                    VisualCallActivity.this.txtTip.setText(LocaleController.getString("visual_call_server_err", R.string.visual_call_server_err));
                    VisualCallActivity.this.txtTip.setVisibility(0);
                    VisualCallActivity.this.setTipPos();
                    return;
                }
                if (error.text.equals("IS_BUSYING") || error.text.equals("FROM_IS_BLOCKED") || error.text.equals("TO_IS_BLOCKED")) {
                    VisualCallActivity.this.stopRtcAndService();
                    if (VisualCallActivity.this.spConnectingId != 0) {
                        VisualCallActivity.this.soundPool.stop(VisualCallActivity.this.spConnectingId);
                        VisualCallActivity.this.spConnectingId = 0;
                    }
                    VisualCallActivity.this.mBlnReceiveFeedBack = true;
                    String str = error.text;
                    char c = 65535;
                    int hashCode = str.hashCode();
                    if (hashCode != -2133636844) {
                        if (hashCode != -2013590676) {
                            if (hashCode == 1424217083 && str.equals("TO_IS_BLOCKED")) {
                                c = 2;
                            }
                        } else if (str.equals("FROM_IS_BLOCKED")) {
                            c = 1;
                        }
                    } else if (str.equals("IS_BUSYING")) {
                        c = 0;
                    }
                    if (c == 0) {
                        VisualCallActivity.this.txtTip.setText(LocaleController.getString(R.string.visual_call_other_calling));
                    } else if (c == 1) {
                        VisualCallActivity.this.txtTip.setText(LocaleController.getString(R.string.visual_call_block_tip));
                    } else if (c == 2) {
                        VisualCallActivity.this.txtTip.setText(LocaleController.getString(R.string.visual_call_blocked_tip));
                    }
                    VisualCallActivity.this.txtTip.setVisibility(0);
                    VisualCallActivity.this.setTipPos();
                    VisualCallActivity.this.txtTip.postDelayed(new $$Lambda$adnAVaveXsclOTbH56jgwpBLVCM(VisualCallActivity.this), AdaptiveTrackSelection.DEFAULT_MIN_TIME_BETWEEN_BUFFER_REEVALUTATION_MS);
                }
            }

            @Override
            public void onSuccess(TLObject object) {
                TLRPCCall.TL_UpdateMeetCallWaiting res = (TLRPCCall.TL_UpdateMeetCallWaiting) object;
                KLog.d("call id === " + res.id);
                VisualCallActivity.this.mChannel = res.id;
                VisualCallActivity.this.mRtcAuthInfo.data.appid = res.appid;
                VisualCallActivity.this.mRtcAuthInfo.data.token = res.token;
                VisualCallActivity.this.mRtcAuthInfo.data.userid = String.valueOf(AccountInstance.getInstance(UserConfig.selectedAccount).getUserConfig().getCurrentUser().id);
                String[] strArr = new String[res.gslb.size()];
                int i = 0;
                Iterator<String> it = res.gslb.iterator();
                while (it.hasNext()) {
                    String strServer = it.next();
                    strArr[i] = strServer;
                    i++;
                }
                VisualCallActivity.this.mRtcAuthInfo.data.gslb = strArr;
                if (res.data != null) {
                    try {
                        JSONObject jsonObject = new JSONObject(res.data.data);
                        VisualCallActivity.this.mRtcAuthInfo.data.timestamp = jsonObject.getLong("time_stamp");
                        VisualCallActivity.this.mRtcAuthInfo.data.setNonce(jsonObject.getString("nonce"));
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                }
                VisualCallActivity visualCallActivity = VisualCallActivity.this;
                visualCallActivity.sendKeepLivePacket(visualCallActivity.mChannel);
            }
        });
    }

    private void initRing() {
        SoundPool soundPool = new SoundPool(1, 0, 0);
        this.soundPool = soundPool;
        this.spConnectingId = soundPool.load(this, R.raw.voip_ringback, 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) {
        soundPool.play(this.spConnectingId, 1.0f, 1.0f, 0, -1, 1.0f);
    }

    private void setHeadImage() {
        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() {
        this.mUserListAdapter = new ChartUserAdapter();
        LinearLayoutManager layoutManager = new LinearLayoutManager(this, 0, false);
        this.chartUserListView.setLayoutManager(layoutManager);
        this.chartUserListView.addItemDecoration(new BaseRecyclerViewAdapter.DividerGridItemDecoration(getResources().getDrawable(R.drawable.chart_content_userlist_item_divider)));
        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 RecyclerView.OnChildAttachStateChangeListener() {
            AnonymousClass4() {
            }

            @Override
            public void onChildViewAttachedToWindow(View view) {
                Log.i(VisualCallActivity.TAG, "onChildViewAttachedToWindow : " + view);
            }

            @Override
            public void onChildViewDetachedFromWindow(View view) {
                Log.i(VisualCallActivity.TAG, "onChildViewDetachedFromWindow : " + view);
            }
        });
        changeStatusView();
    }

    class AnonymousClass4 implements RecyclerView.OnChildAttachStateChangeListener {
        AnonymousClass4() {
        }

        @Override
        public void onChildViewAttachedToWindow(View view) {
            Log.i(VisualCallActivity.TAG, "onChildViewAttachedToWindow : " + view);
        }

        @Override
        public void onChildViewDetachedFromWindow(View view) {
            Log.i(VisualCallActivity.TAG, "onChildViewDetachedFromWindow : " + view);
        }
    }

    private void joinChannel() {
        if (this.mAliRtcEngine == null) {
            return;
        }
        AliRtcAuthInfo userInfo = new AliRtcAuthInfo();
        userInfo.setAppid(this.mRtcAuthInfo.data.appid);
        userInfo.setNonce(this.mRtcAuthInfo.data.nonce);
        userInfo.setTimestamp(this.mRtcAuthInfo.data.timestamp);
        userInfo.setUserId(this.mRtcAuthInfo.data.userid);
        userInfo.setGslb(this.mRtcAuthInfo.data.gslb);
        userInfo.setToken(this.mRtcAuthInfo.data.token);
        userInfo.setConferenceId(this.mChannel);
        this.mAliRtcEngine.setAutoPublish(true, true);
        this.mAliRtcEngine.joinChannel(userInfo, this.mUsername);
        Log.d("--------", "=======");
    }

    class AnonymousClass5 implements ChartUserAdapter.OnSubConfigChangeListener {
        AnonymousClass5() {
        }

        @Override
        public void onFlipView(String uid, int flag, boolean flip) {
            AliRtcEngine.AliVideoCanvas cameraCanvas;
            AliRtcEngine.AliVideoCanvas screenCanvas;
            AliRtcRemoteUserInfo userInfo = VisualCallActivity.this.mAliRtcEngine.getUserInfo(uid);
            if (flag == 1001) {
                if (userInfo != null && (cameraCanvas = userInfo.getCameraCanvas()) != null) {
                    cameraCanvas.mirrorMode = flip ? AliRtcEngine.AliRtcRenderMirrorMode.AliRtcRenderMirrorModeAllEnabled : AliRtcEngine.AliRtcRenderMirrorMode.AliRtcRenderMirrorModeAllDisable;
                    VisualCallActivity.this.mAliRtcEngine.setRemoteViewConfig(cameraCanvas, uid, AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackCamera);
                    return;
                }
                return;
            }
            if (flag == 1002 && userInfo != null && (screenCanvas = userInfo.getScreenCanvas()) != null) {
                screenCanvas.mirrorMode = flip ? AliRtcEngine.AliRtcRenderMirrorMode.AliRtcRenderMirrorModeAllEnabled : AliRtcEngine.AliRtcRenderMirrorMode.AliRtcRenderMirrorModeAllDisable;
                VisualCallActivity.this.mAliRtcEngine.setRemoteViewConfig(screenCanvas, uid, AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackScreen);
            }
        }

        @Override
        public void onShowVideoInfo(String uid, int flag) {
            AliRtcEngine.AliRtcVideoTrack track = AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackNo;
            if (flag == 1001) {
                track = AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackCamera;
            } else if (flag == 1002) {
                track = AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackScreen;
            }
            if (VisualCallActivity.this.mAliRtcEngine != null) {
                String result = VisualCallActivity.this.mAliRtcEngine.getMediaInfoWithUserId(uid, track, AliRtcConstants.VIDEO_INFO_KEYS);
                Toast.makeText(VisualCallActivity.this, result, 0).show();
            }
        }
    }

    private void openJoinChannelBeforeNeedParams() {
        AliRtcEngine aliRtcEngine = this.mAliRtcEngine;
        if (aliRtcEngine != null) {
            if (this.mIsAudioCapture) {
                aliRtcEngine.startAudioCapture();
            } else {
                aliRtcEngine.stopAudioCapture();
            }
            if (this.mIsAudioPlay) {
                this.mAliRtcEngine.startAudioPlayer();
            } else {
                this.mAliRtcEngine.stopAudioPlayer();
            }
            this.mAliRtcEngine.enableEarBack(false);
            if (!this.mAliRtcEngine.isSpeakerOn() && this.callStyle == 2) {
                this.mAliRtcEngine.enableSpeakerphone(true);
            }
        }
    }

    public void initRTCEngineAndStartPreview() {
        if (checkPermission("android.permission.CAMERA") || checkPermission("android.permission.RECORD_AUDIO")) {
            setUpSplash();
            this.mGrantPermission = false;
            return;
        }
        this.mGrantPermission = true;
        if (this.mAliRtcEngine == null) {
            AliRtcEngineImpl aliRtcEngine = AliRtcEngine.getInstance(this.mContext.getApplicationContext());
            this.mAliRtcEngine = aliRtcEngine;
            aliRtcEngine.setRtcEngineEventListener(this.mEventListener);
            this.mAliRtcEngine.setRtcEngineNotify(this.mEngineNotify);
            if (this.callStyle != 2) {
                this.mAliRtcEngine.setAudioOnlyMode(true);
            } else {
                initLocalView();
                startPreview();
            }
        }
    }

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

    private void initLocalView() {
        this.mLocalView.setZOrderOnTop(false);
        this.mLocalView.setZOrderMediaOverlay(false);
        AliRtcEngine.AliVideoCanvas aliVideoCanvas = new AliRtcEngine.AliVideoCanvas();
        this.aliVideoCanvasBig = aliVideoCanvas;
        aliVideoCanvas.view = this.mLocalView;
        this.aliVideoCanvasBig.renderMode = AliRtcEngine.AliRtcRenderMode.AliRtcRenderModeAuto;
        this.sfSmallView.setZOrderOnTop(true);
        this.sfSmallView.setZOrderMediaOverlay(true);
        AliRtcEngine.AliVideoCanvas aliVideoCanvas2 = new AliRtcEngine.AliVideoCanvas();
        this.aliVideoCanvasSmall = aliVideoCanvas2;
        aliVideoCanvas2.view = this.sfSmallView;
        this.aliVideoCanvasSmall.renderMode = AliRtcEngine.AliRtcRenderMode.AliRtcRenderModeAuto;
        AliRtcEngine aliRtcEngine = this.mAliRtcEngine;
        if (aliRtcEngine != null) {
            aliRtcEngine.setLocalViewConfig(this.aliVideoCanvasBig, AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackCamera);
        }
    }

    @OnClick({R.id.img_operate_b, R.id.img_operate_a, R.id.img_operate_c, R.id.ll_big_window, R.id.txt_pre_change_to_voice, R.id.img_visualcall, R.id.chart_video_container})
    public void onclick(View mView) {
        switch (mView.getId()) {
            case R.id.chart_video_container:
                if (!this.chart_video_container.isDrag()) {
                    changeLocalPreview(null);
                    return;
                }
                return;
            case R.id.img_operate_a:
                if (this.mAliRtcEngine != null) {
                    if (this.callStyle == 2) {
                        if (this.VisualCallType == 3) {
                            this.callStyle = 1;
                            AVideoCallInterface.ChangeToVoiceCall(this.mChannel, 1 == 2);
                            if (this.mAliRtcEngine.isLocalCameraPublishEnabled()) {
                                KLog.d("--------关闭视频流");
                                this.mAliRtcEngine.configLocalCameraPublish(false);
                                this.mAliRtcEngine.publish();
                            }
                            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.muteLocalMic(false);
                            this.img_operate_a.setBackgroundResource(R.drawable.visualcall_no_voice);
                        } else {
                            this.img_operate_a.setBackgroundResource(R.drawable.visualcall_no_voice_selected);
                            this.mAliRtcEngine.muteLocalMic(true);
                        }
                    }
                }
                this.mbytLastClickIndex = (byte) 0;
                return;
            case R.id.img_operate_b:
                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", R.string.visual_call_over));
                    } 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", R.string.visual_call_cancel));
                    }
                    setTipPos();
                    this.mChannel = "666";
                    stopRtcAndService();
                    this.img_operate_b.setBackgroundResource(R.drawable.visualcall_cancel);
                    this.img_operate_b.setEnabled(false);
                    this.txtTip.setVisibility(0);
                    this.txtTip.postDelayed(new $$Lambda$adnAVaveXsclOTbH56jgwpBLVCM(this), AdaptiveTrackSelection.DEFAULT_MIN_TIME_BETWEEN_BUFFER_REEVALUTATION_MS);
                    return;
                }
                return;
            case R.id.img_operate_c:
                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.getCurrentCameraType().getCameraType() == AliRtcEngine.AliRTCCameraType.AliRTCCameraBack.getCameraType()) {
                                this.img_operate_c.setBackgroundResource(R.drawable.visualcall_camera_changed);
                            } else if (this.mAliRtcEngine.getCurrentCameraType().getCameraType() == AliRtcEngine.AliRTCCameraType.AliRTCCameraFront.getCameraType()) {
                                this.img_operate_c.setBackgroundResource(R.drawable.visualcall_camera);
                            }
                        }
                    } else if (this.mAliRtcEngine.isSpeakerOn()) {
                        this.img_operate_c.setBackgroundResource(R.drawable.visualcall_hands_free);
                        this.mAliRtcEngine.enableSpeakerphone(false);
                    } else {
                        this.img_operate_c.setBackgroundResource(R.drawable.visual_hands_free_selected);
                        this.mAliRtcEngine.enableSpeakerphone(true);
                    }
                }
                this.mbytLastClickIndex = (byte) 1;
                return;
            case R.id.img_visualcall:
                if (this.imgVisualcall.isEnabled()) {
                    if (SettingsCompat.canDrawOverlays(this)) {
                        ApplicationLoader.mbytAVideoCallBusy = (byte) 4;
                        startVideoService();
                        return;
                    } else if (MryDeviceHelper.isOppo()) {
                        showPermissionErrorAlert(LocaleController.getString("PermissionPopWindowOppo", R.string.PermissionPopWindowOppo));
                        return;
                    } else {
                        showPermissionErrorAlert(LocaleController.getString("PermissionPopWindow", R.string.PermissionPopWindow));
                        return;
                    }
                }
                return;
            case R.id.ll_big_window:
                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);
                        return;
                    }
                    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);
                    return;
                }
                return;
            case R.id.txt_pre_change_to_voice:
                if (this.mAliRtcEngine != null) {
                    this.callStyle = 1;
                    AVideoCallInterface.ChangeToVoiceCall(this.mChannel, 1 == 2);
                    if (this.mAliRtcEngine.isLocalCameraPublishEnabled()) {
                        this.mAliRtcEngine.configLocalCameraPublish(false);
                        this.mAliRtcEngine.publish();
                    }
                    changeToVoice(true);
                    reInstallTimer();
                    return;
                }
                return;
            default:
                return;
        }
    }

    private boolean checkPermission(String permission) {
        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) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
        builder.setMessage(message);
        builder.setNegativeButton(LocaleController.getString("PermissionOpenSettings", R.string.PermissionOpenSettings), 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", R.string.OK), null);
        builder.show();
    }

    public void lambda$showPermissionErrorAlert$6$VisualCallActivity(DialogInterface dialog, int which) {
        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 class AnonymousClass6 implements AliRtcEngineEventListener {
        AnonymousClass6() {
        }

        @Override
        public void onJoinChannelResult(final int i) {
            KLog.d("++++++++++成功加入房间");
            VisualCallActivity.this.runOnUiThread(new Runnable() {
                @Override
                public final void run() {
                    VisualCallActivity.AnonymousClass6.this.lambda$onJoinChannelResult$0$VisualCallActivity$6(i);
                }
            });
        }

        public void lambda$onJoinChannelResult$0$VisualCallActivity$6(int i) {
            if (i == 0) {
                if (VisualCallActivity.this.mForeServiceIntent == null) {
                    VisualCallActivity.this.mForeServiceIntent = new Intent(VisualCallActivity.this.mContext.getApplicationContext(), (Class<?>) ForegroundService.class);
                    VisualCallActivity.this.mForeServiceIntent.putExtras(VisualCallActivity.this.mBundle);
                }
                if (Build.VERSION.SDK_INT >= 26) {
                    VisualCallActivity visualCallActivity = VisualCallActivity.this;
                    visualCallActivity.startForegroundService(visualCallActivity.mForeServiceIntent);
                } else {
                    VisualCallActivity visualCallActivity2 = VisualCallActivity.this;
                    visualCallActivity2.startService(visualCallActivity2.mForeServiceIntent);
                }
            }
        }

        @Override
        public void onLeaveChannelResult(int i) {
            KLog.d("-------离开房间");
        }

        @Override
        public void onPublishResult(int i, String s) {
        }

        @Override
        public void onUnpublishResult(int i) {
        }

        @Override
        public void onSubscribeResult(String s, int i, AliRtcEngine.AliRtcVideoTrack aliRtcVideoTrack, AliRtcEngine.AliRtcAudioTrack aliRtcAudioTrack) {
            if (i == 0) {
                VisualCallActivity.this.updateRemoteDisplay(s, aliRtcAudioTrack, aliRtcVideoTrack);
            }
        }

        @Override
        public void onUnsubscribeResult(int i, String s) {
            VisualCallActivity.this.updateRemoteDisplay(s, AliRtcEngine.AliRtcAudioTrack.AliRtcAudioTrackNo, AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackNo);
        }

        @Override
        public void onNetworkQualityChanged(final String s, final AliRtcEngine.AliRtcNetworkQuality upQuality, final AliRtcEngine.AliRtcNetworkQuality downQuality) {
            VisualCallActivity.this.runOnUiThread(new Runnable() {
                @Override
                public final void run() {
                    VisualCallActivity.AnonymousClass6.this.lambda$onNetworkQualityChanged$1$VisualCallActivity$6(upQuality, downQuality, s);
                }
            });
        }

        public void lambda$onNetworkQualityChanged$1$VisualCallActivity$6(AliRtcEngine.AliRtcNetworkQuality upQuality, AliRtcEngine.AliRtcNetworkQuality downQuality, String s) {
            if (upQuality == AliRtcEngine.AliRtcNetworkQuality.Network_Disconnected) {
            }
            VisualCallActivity.this.mbytExit = (byte) 1;
            if (VisualCallActivity.this.VisualCallType == 3) {
                AVideoCallInterface.DiscardAVideoCall(VisualCallActivity.this.mChannel, ((int) (System.currentTimeMillis() - VisualCallActivity.this.mlStart)) / 1000, VisualCallActivity.this.callStyle == 2);
                VisualCallActivity.this.txtTip.setText(LocaleController.getString("visual_call_stop", R.string.visual_call_stop));
            } else if (VisualCallActivity.this.VisualCallType == 1) {
                AVideoCallInterface.DiscardAVideoCall(VisualCallActivity.this.mChannel, VisualCallActivity.this.REQUEST_CANCEL, VisualCallActivity.this.callStyle == 2);
                if (VisualCallActivity.this.spConnectingId != 0) {
                    VisualCallActivity.this.soundPool.stop(VisualCallActivity.this.spConnectingId);
                    VisualCallActivity.this.spConnectingId = 0;
                }
                VisualCallActivity.this.txtTip.setText(LocaleController.getString("visual_call_stop", R.string.visual_call_stop));
            }
            VisualCallActivity.this.stopRtcAndService();
            VisualCallActivity.this.img_operate_b.setBackgroundResource(R.drawable.visualcall_cancel);
            VisualCallActivity.this.img_operate_b.setEnabled(false);
            VisualCallActivity.this.txtTip.setVisibility(0);
            VisualCallActivity.this.txtTip.postDelayed(new $$Lambda$adnAVaveXsclOTbH56jgwpBLVCM(VisualCallActivity.this), AdaptiveTrackSelection.DEFAULT_MIN_TIME_BETWEEN_BUFFER_REEVALUTATION_MS);
            if (VisualCallActivity.this.mbytExit != 1 && VisualCallActivity.this.callStyle == 2) {
                if (!s.equals(Integer.valueOf(AccountInstance.getInstance(UserConfig.selectedAccount).getUserConfig().getCurrentUser().id))) {
                    if (upQuality.getValue() > AliRtcEngine.AliRtcNetworkQuality.Network_Bad.getValue()) {
                        VisualCallActivity.this.txtTip.setText(LocaleController.getString("visual_call_other_net_bad", R.string.visual_call_other_net_bad));
                        VisualCallActivity.this.txtTip.setVisibility(0);
                        VisualCallActivity.this.mlTipShow = System.currentTimeMillis();
                        return;
                    } else {
                        if (VisualCallActivity.this.txtTip.getVisibility() == 0 && System.currentTimeMillis() - VisualCallActivity.this.mlTipShow > AdaptiveTrackSelection.DEFAULT_MIN_TIME_BETWEEN_BUFFER_REEVALUTATION_MS) {
                            VisualCallActivity.this.txtTip.setVisibility(8);
                            return;
                        }
                        return;
                    }
                }
                if (downQuality.getValue() > AliRtcEngine.AliRtcNetworkQuality.Network_Bad.getValue()) {
                    VisualCallActivity.this.txtTip.setText(LocaleController.getString("visual_call_net_bad", R.string.visual_call_net_bad));
                    VisualCallActivity.this.txtTip.setVisibility(0);
                    VisualCallActivity.this.mlTipShow = System.currentTimeMillis();
                } else if (VisualCallActivity.this.txtTip.getVisibility() == 0 && System.currentTimeMillis() - VisualCallActivity.this.mlTipShow > AdaptiveTrackSelection.DEFAULT_MIN_TIME_BETWEEN_BUFFER_REEVALUTATION_MS) {
                    VisualCallActivity.this.txtTip.setVisibility(8);
                }
            }
        }

        @Override
        public void onOccurWarning(int i) {
        }

        @Override
        public void onOccurError(int error) {
            VisualCallActivity.this.processOccurError(error);
        }

        @Override
        public void onPerformanceLow() {
        }

        @Override
        public void onPermormanceRecovery() {
        }

        @Override
        public void onConnectionLost() {
            VisualCallActivity.this.runOnUiThread(new Runnable() {
                @Override
                public final void run() {
                    VisualCallActivity.AnonymousClass6.this.lambda$onConnectionLost$2$VisualCallActivity$6();
                }
            });
        }

        public void lambda$onConnectionLost$2$VisualCallActivity$6() {
            VisualCallActivity.this.txtTip.setText(LocaleController.getString("visual_call_network_disconnect", R.string.visual_call_network_disconnect));
            VisualCallActivity.this.txtTip.setVisibility(0);
        }

        @Override
        public void onTryToReconnect() {
            VisualCallActivity.this.runOnUiThread(new Runnable() {
                @Override
                public final void run() {
                    VisualCallActivity.AnonymousClass6.this.lambda$onTryToReconnect$3$VisualCallActivity$6();
                }
            });
        }

        public void lambda$onTryToReconnect$3$VisualCallActivity$6() {
            VisualCallActivity.this.txtTip.setText(LocaleController.getString("visual_call_retry_connect", R.string.visual_call_retry_connect));
            VisualCallActivity.this.txtTip.setVisibility(0);
        }

        public void lambda$onConnectionRecovery$4$VisualCallActivity$6() {
            VisualCallActivity.this.txtTip.setVisibility(8);
        }

        @Override
        public void onConnectionRecovery() {
            VisualCallActivity.this.runOnUiThread(new Runnable() {
                @Override
                public final void run() {
                    VisualCallActivity.AnonymousClass6.this.lambda$onConnectionRecovery$4$VisualCallActivity$6();
                }
            });
        }

        @Override
        public void onUpdateRoleNotify(ALI_RTC_INTERFACE.AliRTCSDK_Client_Role aliRTCSDK_client_role, ALI_RTC_INTERFACE.AliRTCSDK_Client_Role aliRTCSDK_client_role1) {
        }
    }

    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() {
        AliRtcEngine aliRtcEngine = this.mAliRtcEngine;
        if (aliRtcEngine != null) {
            aliRtcEngine.leaveChannel();
            this.mAliRtcEngine.destroy();
            this.mAliRtcEngine = null;
        }
        AliRtcEngineImpl aliRtcEngine2 = AliRtcEngine.getInstance(this.mContext.getApplicationContext());
        this.mAliRtcEngine = aliRtcEngine2;
        if (aliRtcEngine2 != null) {
            aliRtcEngine2.setRtcEngineEventListener(this.mEventListener);
            this.mAliRtcEngine.setRtcEngineNotify(this.mEngineNotify);
            if (this.callStyle == 2) {
                startPreview();
            } else {
                this.mAliRtcEngine.setAudioOnlyMode(true);
            }
            openJoinChannelBeforeNeedParams();
            joinChannel();
        }
    }

    @Override
    public void onBackPressed() {
        XDialog.Builder builder = new XDialog.Builder(this);
        builder.setTitle(LocaleController.getString("Tips", R.string.Tips));
        builder.setMessage(LocaleController.getString(R.string.visual_call_exit_ask));
        builder.setPositiveButton(LocaleController.getString("Set", R.string.Set), new DialogInterface.OnClickListener() {
            @Override
            public final void onClick(DialogInterface dialogInterface, int i) {
                VisualCallActivity.this.lambda$onBackPressed$8$VisualCallActivity(dialogInterface, i);
            }
        });
        builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
        XDialog dialog = builder.create();
        dialog.show();
    }

    public void lambda$onBackPressed$8$VisualCallActivity(DialogInterface dialogInterface, int i) {
        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 class AnonymousClass7 implements AliRtcEngineNotify {
        AnonymousClass7() {
        }

        @Override
        public void onRemoteUserUnPublish(AliRtcEngine aliRtcEngine, String s) {
            KLog.d("---------远端用户停止发布通知" + s);
            VisualCallActivity.this.updateRemoteDisplay(s, AliRtcEngine.AliRtcAudioTrack.AliRtcAudioTrackNo, AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackNo);
            VisualCallActivity.this.runOnUiThread(new Runnable() {
                @Override
                public final void run() {
                    VisualCallActivity.AnonymousClass7.this.lambda$onRemoteUserUnPublish$0$VisualCallActivity$7();
                }
            });
        }

        public void lambda$onRemoteUserUnPublish$0$VisualCallActivity$7() {
            if (!VisualCallActivity.this.mChannel.equals("666")) {
                VisualCallActivity.this.stopRtcAndService();
                if (VisualCallActivity.this.spConnectingId != 0) {
                    VisualCallActivity.this.soundPool.stop(VisualCallActivity.this.spConnectingId);
                    VisualCallActivity.this.spConnectingId = 0;
                }
                if (VisualCallActivity.this.VisualCallType == 3) {
                    VisualCallActivity.this.txtTip.setText(LocaleController.getString("visual_call_other_side_discard", R.string.visual_call_other_side_discard));
                    VisualCallActivity.this.txtTip.setVisibility(0);
                    VisualCallActivity.this.chrVisualcallTime.stop();
                    VisualCallActivity.this.txtTip.postDelayed(new $$Lambda$adnAVaveXsclOTbH56jgwpBLVCM(VisualCallActivity.this), AdaptiveTrackSelection.DEFAULT_MIN_TIME_BETWEEN_BUFFER_REEVALUTATION_MS);
                    return;
                }
                VisualCallActivity.this.mBlnReceiveFeedBack = true;
                VisualCallActivity.this.txtTip.setText(LocaleController.getString("visual_call_other_side_refuse", R.string.visual_call_other_side_refuse));
                VisualCallActivity.this.txtTip.setVisibility(0);
                VisualCallActivity.this.txtTip.postDelayed(new $$Lambda$adnAVaveXsclOTbH56jgwpBLVCM(VisualCallActivity.this), AdaptiveTrackSelection.DEFAULT_MIN_TIME_BETWEEN_BUFFER_REEVALUTATION_MS);
            }
        }

        @Override
        public void onRemoteUserOnLineNotify(final String s) {
            KLog.d("----------远端用户上线通知" + s);
            VisualCallActivity.this.mAliRtcEngine.configRemoteAudio(s, true);
            VisualCallActivity.this.mAliRtcEngine.muteRemoteAudioPlaying(s, false);
            if (TextUtils.isEmpty(VisualCallActivity.this.currentUid)) {
                VisualCallActivity.this.currentUid = s;
                VisualCallActivity.this.runOnUiThread(new Runnable() {
                    @Override
                    public final void run() {
                        VisualCallActivity.AnonymousClass7.this.lambda$onRemoteUserOnLineNotify$2$VisualCallActivity$7(s);
                    }
                });
            }
        }

        public void lambda$onRemoteUserOnLineNotify$2$VisualCallActivity$7(String s) {
            addRemoteUser(s);
            VisualCallActivity.this.VisualCallType = 3;
            VisualCallActivity.this.imgVisualcall.setVisibility(0);
            VisualCallActivity.this.chrVisualcallTime.setVisibility(0);
            VisualCallActivity.this.chrVisualcallTime.setBase(SystemClock.elapsedRealtime());
            VisualCallActivity.this.chrVisualcallTime.start();
            VisualCallActivity.this.rel_video_user.setVisibility(8);
            VisualCallActivity.this.txtVisualcallStatus.setVisibility(0);
            VisualCallActivity.this.imgVisualcall.postDelayed(new Runnable() {
                @Override
                public final void run() {
                    VisualCallActivity.AnonymousClass7.this.lambda$null$1$VisualCallActivity$7();
                }
            }, AdaptiveTrackSelection.DEFAULT_MIN_TIME_BETWEEN_BUFFER_REEVALUTATION_MS);
            VisualCallActivity.this.mlStart = System.currentTimeMillis();
            if (ApplicationLoader.mbytAVideoCallBusy == 4 && VisualCallActivity.this.myservice != null) {
                VisualCallActivity.this.myservice.setView(null, null, VisualCallActivity.this.chrVisualcallTime.getBase(), VisualCallActivity.this.mChannel);
            }
            VisualCallActivity.this.changeStatusView();
        }

        public void lambda$null$1$VisualCallActivity$7() {
            VisualCallActivity.this.txtVisualcallStatus.setVisibility(8);
        }

        private void addRemoteUser(String uid) {
            AliRtcRemoteUserInfo remoteUserInfo;
            if (VisualCallActivity.this.mAliRtcEngine != null && (remoteUserInfo = VisualCallActivity.this.mAliRtcEngine.getUserInfo(uid)) != null) {
                ChartUserBean data = convertRemoteUserToUserData(remoteUserInfo);
                KLog.d("---------mScreenSurface-" + data.mCameraSurface + "   " + data.mScreenSurface);
                if (data.mCameraSurface != null) {
                    KLog.d("---------mScreenSurface");
                    ViewParent parent = data.mCameraSurface.getParent();
                    if (parent != null && (parent instanceof FrameLayout)) {
                        ((FrameLayout) parent).removeAllViews();
                    }
                    if (VisualCallActivity.this.callStyle == 2) {
                        VisualCallActivity.this.changeLocalPreview(convertRemoteUserToUserData(remoteUserInfo).mCameraSurface);
                    }
                }
            }
        }

        private ChartUserBean convertRemoteUserToUserData(AliRtcRemoteUserInfo remoteUserInfo) {
            String uid = remoteUserInfo.getUserID();
            ChartUserBean ret = VisualCallActivity.this.mUserListAdapter.createDataIfNull(uid);
            ret.mUserId = uid;
            ret.mUserName = remoteUserInfo.getDisplayName();
            ret.mIsCameraFlip = false;
            ret.mIsScreenFlip = false;
            return ret;
        }

        @Override
        public void onRemoteUserOffLineNotify(String s) {
            removeRemoteUser(s);
        }

        private void removeRemoteUser(final String uid) {
            KLog.d("---------远端用户下线通知" + uid);
            VisualCallActivity.this.runOnUiThread(new Runnable() {
                @Override
                public final void run() {
                    VisualCallActivity.AnonymousClass7.this.lambda$removeRemoteUser$3$VisualCallActivity$7(uid);
                }
            });
        }

        public void lambda$removeRemoteUser$3$VisualCallActivity$7(String uid) {
            VisualCallActivity.this.mUserListAdapter.removeData(uid, true);
            if (!VisualCallActivity.this.mChannel.equals("666")) {
                VisualCallActivity.this.stopRtcAndService();
                if (VisualCallActivity.this.spConnectingId != 0) {
                    VisualCallActivity.this.soundPool.stop(VisualCallActivity.this.spConnectingId);
                    VisualCallActivity.this.spConnectingId = 0;
                }
                if (VisualCallActivity.this.VisualCallType == 3) {
                    VisualCallActivity.this.txtTip.setText(LocaleController.getString("visual_call_other_side_discard", R.string.visual_call_other_side_discard));
                    VisualCallActivity.this.txtTip.setVisibility(0);
                    VisualCallActivity.this.chrVisualcallTime.stop();
                    VisualCallActivity.this.txtTip.postDelayed(new $$Lambda$adnAVaveXsclOTbH56jgwpBLVCM(VisualCallActivity.this), AdaptiveTrackSelection.DEFAULT_MIN_TIME_BETWEEN_BUFFER_REEVALUTATION_MS);
                    return;
                }
                VisualCallActivity.this.mBlnReceiveFeedBack = true;
                VisualCallActivity.this.txtTip.setText(LocaleController.getString("visual_call_other_side_refuse", R.string.visual_call_other_side_refuse));
                VisualCallActivity.this.txtTip.setVisibility(0);
                VisualCallActivity.this.txtTip.postDelayed(new $$Lambda$adnAVaveXsclOTbH56jgwpBLVCM(VisualCallActivity.this), AdaptiveTrackSelection.DEFAULT_MIN_TIME_BETWEEN_BUFFER_REEVALUTATION_MS);
            }
        }

        @Override
        public void onRemoteTrackAvailableNotify(String s, AliRtcEngine.AliRtcAudioTrack aliRtcAudioTrack, AliRtcEngine.AliRtcVideoTrack aliRtcVideoTrack) {
            StringBuilder sb = new StringBuilder();
            sb.append("---------视频流变化 ");
            sb.append(aliRtcVideoTrack.getValue() == 0 ? "没有视频" : "视频");
            KLog.d(sb.toString());
            StringBuilder sb2 = new StringBuilder();
            sb2.append("---------音频流变化 ");
            sb2.append(aliRtcAudioTrack.getValue() == 0 ? "没有音频" : "音频");
            KLog.d(sb2.toString());
            VisualCallActivity.this.updateRemoteDisplay(s, aliRtcAudioTrack, aliRtcVideoTrack);
            if (aliRtcVideoTrack.getValue() != 0 && aliRtcVideoTrack.getValue() > AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackNo.getValue()) {
                VisualCallActivity.this.runOnUiThread(new Runnable() {
                    @Override
                    public final void run() {
                        VisualCallActivity.AnonymousClass7.this.lambda$onRemoteTrackAvailableNotify$4$VisualCallActivity$7();
                    }
                });
            }
        }

        public void lambda$onRemoteTrackAvailableNotify$4$VisualCallActivity$7() {
            VisualCallActivity.this.VisualCallType = 3;
            if (VisualCallActivity.this.callStyle == 2) {
                VisualCallActivity.this.chart_video_container.setVisibility(0);
            }
        }

        @Override
        public void onSubscribeChangedNotify(String s, AliRtcEngine.AliRtcAudioTrack aliRtcAudioTrack, AliRtcEngine.AliRtcVideoTrack aliRtcVideoTrack) {
        }

        @Override
        public void onParticipantSubscribeNotify(AliSubscriberInfo[] aliSubscriberInfos, int i) {
        }

        @Override
        public void onFirstFramereceived(String s, String s1, String s2, int i) {
            KLog.d("------------首桢接收成功");
        }

        @Override
        public void onFirstPacketSent(String s, String s1, String s2, int i) {
            KLog.d("------------首包的发送回调");
            ThreadUtils.runOnUiThread(new Runnable() {
                AnonymousClass1() {
                }

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

        class AnonymousClass1 implements Runnable {
            AnonymousClass1() {
            }

            @Override
            public void run() {
            }
        }

        @Override
        public void onFirstPacketReceived(String callId, String streamLabel, String trackLabel, int timeCost) {
            KLog.d("+++++++++++首包数据接收成功");
            VisualCallActivity.this.runOnUiThread(new Runnable() {
                @Override
                public final void run() {
                    VisualCallActivity.AnonymousClass7.this.lambda$onFirstPacketReceived$5$VisualCallActivity$7();
                }
            });
        }

        public void lambda$onFirstPacketReceived$5$VisualCallActivity$7() {
            if (VisualCallActivity.this.callStyle == 2 && VisualCallActivity.this.mbytFPacketRecCount <= 0) {
                VisualCallActivity.access$1808(VisualCallActivity.this);
                VisualCallActivity.this.changeLocalPreview(null);
                if (VisualCallActivity.this.myservice != null && ApplicationLoader.mbytAVideoCallBusy == 4) {
                    VisualCallActivity.this.llBigWindow.addView(VisualCallActivity.this.myservice.getViewBig(true), new ViewGroup.LayoutParams(-1, -1));
                    VisualCallActivity.this.llBigWindow.removeView(VisualCallActivity.this.llBigRemoteView);
                    VisualCallActivity.this.chart_video_container.addView(VisualCallActivity.this.myservice.getViewSmall(true), new ViewGroup.LayoutParams(-1, -1));
                    VisualCallActivity.this.chart_video_container.removeView(VisualCallActivity.this.sfSmallView);
                    VisualCallActivity.this.myservice.setView(VisualCallActivity.this.llBigRemoteView, VisualCallActivity.this.sfSmallView, VisualCallActivity.this.chrVisualcallTime.getBase(), VisualCallActivity.this.mChannel);
                }
            }
        }

        @Override
        public void onParticipantUnsubscribeNotify(AliParticipantInfo[] aliParticipantInfos, int i) {
            KLog.d("------当前订阅人数" + i);
        }

        @Override
        public void onBye(int i) {
            KLog.d("------被服务器踢出或者频道关闭时回调");
        }

        @Override
        public void onParticipantStatusNotify(AliStatusInfo[] aliStatusInfos, int i) {
        }

        @Override
        public void onAliRtcStats(ALI_RTC_INTERFACE.AliRtcStats aliRtcStats) {
        }
    }

    public class AnonymousClass8 implements Runnable {
        final String val$uid;
        final AliRtcEngine.AliRtcVideoTrack val$vt;

        AnonymousClass8(String str, AliRtcEngine.AliRtcVideoTrack aliRtcVideoTrack) {
            r2 = str;
            r3 = aliRtcVideoTrack;
        }

        @Override
        public void run() {
            AliRtcEngine.AliVideoCanvas cameraCanvas;
            AliRtcEngine.AliVideoCanvas screenCanvas;
            if (VisualCallActivity.this.mAliRtcEngine != null) {
                AliRtcRemoteUserInfo remoteUserInfo = VisualCallActivity.this.mAliRtcEngine.getUserInfo(r2);
                if (remoteUserInfo == null) {
                    Log.e("视频", "updateRemoteDisplay remoteUserInfo = null, uid = " + r2);
                    return;
                }
                AliRtcEngine.AliVideoCanvas cameraCanvas2 = remoteUserInfo.getCameraCanvas();
                AliRtcEngine.AliVideoCanvas screenCanvas2 = remoteUserInfo.getScreenCanvas();
                if (r3 == AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackNo) {
                    cameraCanvas = null;
                    screenCanvas = null;
                } else if (r3 == AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackCamera) {
                    screenCanvas = null;
                    cameraCanvas = VisualCallActivity.this.createCanvasIfNull(cameraCanvas2);
                    VisualCallActivity.this.mAliRtcEngine.setRemoteViewConfig(cameraCanvas, r2, AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackCamera);
                } else if (r3 == AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackScreen) {
                    cameraCanvas = null;
                    screenCanvas = VisualCallActivity.this.createCanvasIfNull(screenCanvas2);
                    VisualCallActivity.this.mAliRtcEngine.setRemoteViewConfig(screenCanvas, r2, AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackScreen);
                } else if (r3 == AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackBoth) {
                    cameraCanvas = VisualCallActivity.this.createCanvasIfNull(cameraCanvas2);
                    VisualCallActivity.this.mAliRtcEngine.setRemoteViewConfig(cameraCanvas, r2, AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackCamera);
                    screenCanvas = VisualCallActivity.this.createCanvasIfNull(screenCanvas2);
                    VisualCallActivity.this.mAliRtcEngine.setRemoteViewConfig(screenCanvas, r2, AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackScreen);
                } 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);
                    }
                }
            }
        }
    }

    public void updateRemoteDisplay(String uid, AliRtcEngine.AliRtcAudioTrack at, AliRtcEngine.AliRtcVideoTrack vt) {
        runOnUiThread(new Runnable() {
            final String val$uid;
            final AliRtcEngine.AliRtcVideoTrack val$vt;

            AnonymousClass8(String uid2, AliRtcEngine.AliRtcVideoTrack vt2) {
                r2 = uid2;
                r3 = vt2;
            }

            @Override
            public void run() {
                AliRtcEngine.AliVideoCanvas cameraCanvas;
                AliRtcEngine.AliVideoCanvas screenCanvas;
                if (VisualCallActivity.this.mAliRtcEngine != null) {
                    AliRtcRemoteUserInfo remoteUserInfo = VisualCallActivity.this.mAliRtcEngine.getUserInfo(r2);
                    if (remoteUserInfo == null) {
                        Log.e("视频", "updateRemoteDisplay remoteUserInfo = null, uid = " + r2);
                        return;
                    }
                    AliRtcEngine.AliVideoCanvas cameraCanvas2 = remoteUserInfo.getCameraCanvas();
                    AliRtcEngine.AliVideoCanvas screenCanvas2 = remoteUserInfo.getScreenCanvas();
                    if (r3 == AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackNo) {
                        cameraCanvas = null;
                        screenCanvas = null;
                    } else if (r3 == AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackCamera) {
                        screenCanvas = null;
                        cameraCanvas = VisualCallActivity.this.createCanvasIfNull(cameraCanvas2);
                        VisualCallActivity.this.mAliRtcEngine.setRemoteViewConfig(cameraCanvas, r2, AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackCamera);
                    } else if (r3 == AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackScreen) {
                        cameraCanvas = null;
                        screenCanvas = VisualCallActivity.this.createCanvasIfNull(screenCanvas2);
                        VisualCallActivity.this.mAliRtcEngine.setRemoteViewConfig(screenCanvas, r2, AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackScreen);
                    } else if (r3 == AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackBoth) {
                        cameraCanvas = VisualCallActivity.this.createCanvasIfNull(cameraCanvas2);
                        VisualCallActivity.this.mAliRtcEngine.setRemoteViewConfig(cameraCanvas, r2, AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackCamera);
                        screenCanvas = VisualCallActivity.this.createCanvasIfNull(screenCanvas2);
                        VisualCallActivity.this.mAliRtcEngine.setRemoteViewConfig(screenCanvas, r2, AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackScreen);
                    } 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) {
        v.removeAllViews();
        SophonSurfaceView surfaceView1 = new SophonSurfaceView(this);
        surfaceView1.setZOrderOnTop(true);
        surfaceView1.setZOrderMediaOverlay(true);
        AliRtcEngine.AliVideoCanvas aliVideoCanvas = new AliRtcEngine.AliVideoCanvas();
        v.addView(surfaceView1, new ViewGroup.LayoutParams(-1, -1));
        aliVideoCanvas.view = surfaceView1;
        aliVideoCanvas.renderMode = AliRtcEngine.AliRtcRenderMode.AliRtcRenderModeAuto;
        AliRtcEngine aliRtcEngine = this.mAliRtcEngine;
        if (aliRtcEngine != null) {
            aliRtcEngine.stopPreview();
            this.mAliRtcEngine.setLocalViewConfig(aliVideoCanvas, AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackCamera);
            this.mAliRtcEngine.startPreview();
        }
        v.getChildAt(0).setVisibility(0);
    }

    protected void changeLocalPreview(SophonSurfaceView view) {
        if (view != null) {
            if (this.mbytLocalPos == 0) {
                this.mbytLocalPos = (byte) 1;
            } else {
                this.mbytLocalPos = (byte) 0;
            }
        }
        if (this.mbytLocalPos == 0) {
            this.mLocalView.setVisibility(8);
            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) {
                    ((SophonSurfaceView) v).setZOrderOnTop(false);
                    ((SophonSurfaceView) 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, AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackCamera);
                this.mAliRtcEngine.startPreview();
            }
            this.mbytLocalPos = (byte) 1;
            return;
        }
        this.mLocalView.setVisibility(0);
        this.llBigRemoteView.setVisibility(8);
        this.sfSmallView.setVisibility(8);
        this.llSmallRemoteView.setVisibility(0);
        this.llSmallRemoteView.removeAllViews();
        View v2 = this.llBigRemoteView.getChildAt(0);
        this.llBigRemoteView.removeAllViews();
        if (view == null) {
            if (v2 != null) {
                ((SophonSurfaceView) 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));
        }
        AliRtcEngine aliRtcEngine = this.mAliRtcEngine;
        if (aliRtcEngine != null) {
            aliRtcEngine.setLocalViewConfig(this.aliVideoCanvasBig, AliRtcEngine.AliRtcVideoTrack.AliRtcVideoTrackCamera);
            this.mAliRtcEngine.startPreview();
        }
        this.mbytLocalPos = (byte) 0;
    }

    public ChartUserBean convertRemoteUserInfo(AliRtcRemoteUserInfo remoteUserInfo, AliRtcEngine.AliVideoCanvas cameraCanvas, AliRtcEngine.AliVideoCanvas screenCanvas) {
        String uid = remoteUserInfo.getUserID();
        ChartUserBean ret = this.mUserListAdapter.createDataIfNull(uid);
        ret.mUserId = remoteUserInfo.getUserID();
        ret.mUserName = remoteUserInfo.getDisplayName();
        ret.mCameraSurface = cameraCanvas != null ? cameraCanvas.view : null;
        ret.mIsCameraFlip = cameraCanvas != null && cameraCanvas.mirrorMode == AliRtcEngine.AliRtcRenderMirrorMode.AliRtcRenderMirrorModeAllEnabled;
        ret.mScreenSurface = screenCanvas != null ? screenCanvas.view : null;
        ret.mIsScreenFlip = screenCanvas != null && screenCanvas.mirrorMode == AliRtcEngine.AliRtcRenderMirrorMode.AliRtcRenderMirrorModeAllEnabled;
        return ret;
    }

    public AliRtcEngine.AliVideoCanvas createCanvasIfNull(AliRtcEngine.AliVideoCanvas canvas) {
        if (canvas == null || canvas.view == null) {
            canvas = new AliRtcEngine.AliVideoCanvas();
            SophonSurfaceView surfaceView = new SophonSurfaceView(this);
            surfaceView.setZOrderOnTop(false);
            surfaceView.setZOrderMediaOverlay(false);
            canvas.view = surfaceView;
            canvas.renderMode = AliRtcEngine.AliRtcRenderMode.AliRtcRenderModeAuto;
        }
        if (this.mblnOtherIsPc) {
            canvas.renderMode = AliRtcEngine.AliRtcRenderMode.AliRtcRenderModeClip;
        }
        return canvas;
    }

    @Override
    protected void onDestroy() {
        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() {
        ThreadUtils.runOnUiThread(new $$Lambda$VisualCallActivity$G3bNenmZC0gDzcrPaAZNQzceeE(this), 1000L);
    }

    public void requestPermission() {
        PermissionUtils.requestMultiPermissions(this, new String[]{"android.permission.CAMERA", "android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.RECORD_AUDIO", PermissionUtils.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) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == 100) {
            new Handler().postDelayed(new $$Lambda$VisualCallActivity$G3bNenmZC0gDzcrPaAZNQzceeE(this), 500L);
        }
    }

    public class AnonymousClass9 implements PermissionUtils.PermissionGrant {
        AnonymousClass9() {
        }

        @Override
        public void onPermissionGranted(int requestCode) {
            VisualCallActivity.this.initRTCEngineAndStartPreview();
            VisualCallActivity.this.sendCallRequest();
            VisualCallActivity.this.chart_video_container.postDelayed(new Runnable() {
                @Override
                public final void run() {
                    VisualCallActivity.AnonymousClass9.this.lambda$onPermissionGranted$0$VisualCallActivity$9();
                }
            }, 35000L);
            VisualCallActivity.this.img_operate_a.postDelayed(new Runnable() {
                @Override
                public final void run() {
                    VisualCallActivity.AnonymousClass9.this.lambda$onPermissionGranted$1$VisualCallActivity$9();
                }
            }, 15000L);
        }

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

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

        @Override
        public void onPermissionCancel() {
            ToastUtils.show((CharSequence) LocaleController.getString("grant_permission", R.string.grant_permission));
            VisualCallActivity.this.stopRtcAndService();
            VisualCallActivity.this.finish();
        }
    }

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

    class AnonymousClass10 implements ServiceConnection {
        AnonymousClass10() {
        }

        @Override
        public void onServiceConnected(ComponentName name, IBinder service) {
            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;
                    smallView = VisualCallActivity.this.llSmallRemoteView;
                } else {
                    view = VisualCallActivity.this.llBigRemoteView;
                    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) {
        }
    }

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

    @Override
    protected void onResume() {
        super.onResume();
        KLog.d("--------------resume------------");
        if (this.mblnUnProcessChooseVoiceTip) {
            this.txtTip.setText(LocaleController.getString(R.string.visual_call_receive_to_voice));
            setTipPos();
            this.txtTip.setVisibility(0);
            this.txtTip.postDelayed(new Runnable() {
                @Override
                public final void run() {
                    VisualCallActivity.this.lambda$onResume$9$VisualCallActivity();
                }
            }, AdaptiveTrackSelection.DEFAULT_MIN_TIME_BETWEEN_BUFFER_REEVALUTATION_MS);
            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() {
        this.txtTip.setVisibility(8);
    }

    @Override
    public void didReceivedNotification(int id, int account, Object... args) {
        TLRPCCall.TL_UpdateMeetChangeCall changeCall;
        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", R.string.visual_call_other_side_discard));
                    this.txtTip.setVisibility(0);
                    this.chrVisualcallTime.stop();
                    this.txtTip.postDelayed(new $$Lambda$adnAVaveXsclOTbH56jgwpBLVCM(this), AdaptiveTrackSelection.DEFAULT_MIN_TIME_BETWEEN_BUFFER_REEVALUTATION_MS);
                    return;
                }
                if (this.mBlnReceiveFeedBack) {
                    this.txtTip.setText(LocaleController.getString("visual_call_other_side_discard", R.string.visual_call_other_side_discard));
                } else {
                    this.txtTip.setText(LocaleController.getString("visual_call_other_side_refuse", R.string.visual_call_other_side_refuse));
                }
                this.txtTip.setVisibility(0);
                setTipPos();
                this.mBlnReceiveFeedBack = true;
                this.txtTip.postDelayed(new $$Lambda$adnAVaveXsclOTbH56jgwpBLVCM(this), AdaptiveTrackSelection.DEFAULT_MIN_TIME_BETWEEN_BUFFER_REEVALUTATION_MS);
                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", R.string.visual_call_calling), this.txtVideoStatus);
                } else {
                    this.dynamicPoint.animForWaitting(LocaleController.getString("visual_call_calling", R.string.visual_call_calling), 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 AnonymousClass11());
                this.rel_video_user.postDelayed(new Runnable() {
                    @Override
                    public final void run() {
                        VisualCallActivity.this.lambda$didReceivedNotification$10$VisualCallActivity();
                    }
                }, DefaultLoadErrorHandlingPolicy.DEFAULT_TRACK_BLACKLIST_MS);
                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", R.string.visual_call_other_busing));
                this.txtTip.setVisibility(0);
                setTipPos();
                this.txtTip.postDelayed(new $$Lambda$adnAVaveXsclOTbH56jgwpBLVCM(this), AdaptiveTrackSelection.DEFAULT_MIN_TIME_BETWEEN_BUFFER_REEVALUTATION_MS);
                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();
            }
        }
    }

    class AnonymousClass11 implements AVideoCallInterface.AVideoRequestCallBack {
        AnonymousClass11() {
        }

        @Override
        public void onError(TLRPC.TL_error error) {
        }

        @Override
        public void onSuccess(final TLObject object) {
            if (object instanceof TLRPCCall.TL_UpdateMeetCall) {
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public final void run() {
                        NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.receivedAVideoCallReady, TLObject.this);
                    }
                });
            }
        }
    }

    public void lambda$didReceivedNotification$10$VisualCallActivity() {
        if (this.VisualCallType != 3) {
            this.txtTip.setVisibility(0);
            this.txtTip.setText(LocaleController.getString("visual_call_retry", R.string.visual_call_retry));
            setTipPos();
            stopRtcAndService();
            this.txtTip.postDelayed(new $$Lambda$adnAVaveXsclOTbH56jgwpBLVCM(this), AdaptiveTrackSelection.DEFAULT_MIN_TIME_BETWEEN_BUFFER_REEVALUTATION_MS);
        }
    }

    private void regNotification() {
        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() {
        requestWindowFeature(1);
        setTheme(R.style.Theme_TMessages);
        if (Build.VERSION.SDK_INT >= 21) {
            try {
                setTaskDescription(new ActivityManager.TaskDescription((String) null, (Bitmap) null, Theme.getColor(Theme.key_actionBarDefault) | (-16777216)));
            } catch (Exception e) {
            }
            try {
                getWindow().setNavigationBarColor(-16777216);
            } catch (Exception e2) {
            }
        }
        getWindow().setBackgroundDrawableResource(R.drawable.transparent);
        if (Build.VERSION.SDK_INT >= 21) {
            Window window = getWindow();
            window.getDecorView().setSystemUiVisibility(1280);
            window.setStatusBarColor(0);
        }
    }

    public void stopRtcAndService() {
        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() {
        this.mAliRtcEngine.setRtcEngineNotify(null);
        this.mAliRtcEngine.setRtcEngineEventListener(null);
        if (this.callStyle == 2) {
            this.mAliRtcEngine.stopPreview();
        }
        this.mAliRtcEngine.leaveChannel();
        this.mAliRtcEngine.destroy();
        this.mAliRtcEngine = null;
    }

    public void setTipPos() {
        RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) this.txtTip.getLayoutParams();
        if (this.rel_voice_user.getVisibility() == 8) {
            this.txtTip.setGravity(17);
        } else {
            layoutParams.addRule(3, R.id.rel_voice_user);
            layoutParams.topMargin = AndroidUtilities.dp(25.0f);
        }
    }

    public void changeToVoice(boolean blnCaller) {
        AliRtcEngine aliRtcEngine = this.mAliRtcEngine;
        if (aliRtcEngine != null) {
            if (aliRtcEngine.isSpeakerOn()) {
                this.mAliRtcEngine.enableSpeakerphone(false);
            }
            this.mAliRtcEngine.stopPreview();
        }
        changeStatusView();
        if (this.mbytIsForeground == 0) {
            this.mblnUnProcessChooseVoiceTip = true;
        } else {
            if (blnCaller) {
                this.txtTip.setText(LocaleController.getString(R.string.visual_call_caller_to_voice));
            } else {
                this.txtTip.setText(LocaleController.getString(R.string.visual_call_receive_to_voice));
            }
            setTipPos();
            this.txtTip.setVisibility(0);
            this.txtTip.postDelayed(new Runnable() {
                @Override
                public final void run() {
                    VisualCallActivity.this.lambda$changeToVoice$12$VisualCallActivity();
                }
            }, AdaptiveTrackSelection.DEFAULT_MIN_TIME_BETWEEN_BUFFER_REEVALUTATION_MS);
        }
        setHeadImage();
        if (this.VisualCallType != 3) {
            if (!this.mBlnReceiveFeedBack) {
                this.dynamicPoint.animForWaitting(LocaleController.getString(R.string.visual_call_waiting), this.txtCallStatus);
                return;
            } else {
                this.dynamicPoint.animForWaitting(LocaleController.getString(R.string.visual_call_calling), this.txtCallStatus);
                return;
            }
        }
        this.llBigWindow.setVisibility(8);
        this.chart_video_container.setVisibility(8);
    }

    public void lambda$changeToVoice$12$VisualCallActivity() {
        this.txtTip.setVisibility(8);
    }

    private void reInstallTimer() {
        this.mblnResetNoAnswer = true;
        this.chart_video_container.postDelayed(new Runnable() {
            @Override
            public final void run() {
                VisualCallActivity.this.lambda$reInstallTimer$13$VisualCallActivity();
            }
        }, 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();
        }
    }
}