导航菜单

页面标题

页面副标题

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

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

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


package im.amwhusedvt.ui.hui.visualcall;

import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
import android.widget.Toast;
import androidx.core.app.NotificationCompat;
import com.socks.library.KLog;
import im.amwhusedvt.messenger.AndroidUtilities;
import im.amwhusedvt.messenger.ApplicationLoader;
import im.amwhusedvt.messenger.LocaleController;
import im.amwhusedvt.messenger.NotificationCenter;
import im.amwhusedvt.tgnet.TLRPCCall;
import im.amwhusedvt.ui.LaunchActivity;
import im.amwhusedvt.ui.hui.friendscircle_v1.helper.DatabaseInstance;
import im.amwhusedvt.ui.hui.friendscircle_v1.view.expandTextView.ExpandableTextView;
import java.util.ArrayList;
import java.util.Random;

public class VisualCallReceiveService extends Service implements NotificationCenter.NotificationCenterDelegate {
    private long mlLastReqTime;
    private String strId;
    private String ID = "0x110066";
    private Runnable runnable = new Runnable() {
        @Override
        public final void run() {
            RingUtils.stopSoundPoolRing();
        }
    };
    private Handler handler = new Handler();

    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    public int onStartCommand(final Intent intent, int flags, int startId) {
        if ((25 + 3) % 3 <= 0) {
        }
        RingUtils.stopMediaPlayerRing();
        VisualCallRequestBean bean = DatabaseInstance.queryVisualCallById(intent.getStringExtra("id"));
        if (bean == null) {
            KLog.d("----------收到音视频请求 type = " + intent.getStringExtra("id") + ExpandableTextView.Space + (System.currentTimeMillis() - this.mlLastReqTime));
            this.handler.removeCallbacks(this.runnable);
            if (System.currentTimeMillis() - this.mlLastReqTime > 2000) {
                this.mlLastReqTime = System.currentTimeMillis();
                if (ApplicationLoader.mbytAVideoCallBusy == 0) {
                    if (AndroidUtilities.isAppOnForeground(this)) {
                        if (DatabaseInstance.getVisualCallCount() < 1) {
                            boolean blnVideo = intent.getBooleanExtra("video", false);
                            Intent actIntent = new Intent(this, (Class<?>) VisualCallReceiveActivity.class);
                            actIntent.putExtra("video", blnVideo);
                            actIntent.putExtra("id", intent.getStringExtra("id"));
                            actIntent.putExtra("admin_id", intent.getIntExtra("admin_id", 0));
                            actIntent.putExtra("app_id", intent.getStringExtra("app_id"));
                            actIntent.putExtra("token", intent.getStringExtra("token"));
                            actIntent.putStringArrayListExtra("gslb", intent.getStringArrayListExtra("gslb"));
                            actIntent.putExtra("json", intent.getStringExtra("json"));
                            actIntent.putExtra("from", 0);
                            actIntent.addFlags(268435456);
                            startActivity(actIntent);
                            new Handler().postDelayed(new Runnable() {
                                @Override
                                public final void run() {
                                    VisualCallReceiveService.lambda$onStartCommand$0(intent);
                                }
                            }, 3000L);
                        } else {
                            AVideoCallInterface.IsBusyingNow(intent.getStringExtra("id"));
                        }
                    } else if (DatabaseInstance.getVisualCallCount() < 1) {
                        RingUtils.playRingBySoundPool(this);
                        this.strId = intent.getStringExtra("id");
                        VisualCallRequestParaBean paraBean = new VisualCallRequestParaBean();
                        paraBean.setStrId(intent.getStringExtra("id"));
                        paraBean.setVideo(intent.getBooleanExtra("video", false));
                        paraBean.setAdmin_id(intent.getIntExtra("admin_id", 0));
                        paraBean.setApp_id(intent.getStringExtra("app_id"));
                        paraBean.setToken(intent.getStringExtra("token"));
                        String strGslb = "";
                        ArrayList<String> arrayList = intent.getStringArrayListExtra("gslb");
                        for (int i = 0; i < arrayList.size(); i++) {
                            if (strGslb.equals("")) {
                                String strGslb2 = arrayList.get(i);
                                strGslb = strGslb2;
                            } else {
                                strGslb = strGslb + "," + arrayList.get(i);
                            }
                        }
                        paraBean.setGslb(strGslb);
                        paraBean.setJson(intent.getStringExtra("json"));
                        DatabaseInstance.saveVisualCallPara(paraBean);
                        this.handler.postDelayed(this.runnable, 35000L);
                    } else {
                        AVideoCallInterface.IsBusyingNow(intent.getStringExtra("id"));
                    }
                    VisualCallRequestBean bean1 = new VisualCallRequestBean();
                    bean1.setStrId(intent.getStringExtra("id"));
                    bean1.setTimestamp(System.currentTimeMillis());
                    DatabaseInstance.saveVisualCallRequest(bean1);
                    return 2;
                }
                AVideoCallInterface.IsBusyingNow(intent.getStringExtra("id"));
                return 2;
            }
            AVideoCallInterface.IsBusyingNow(intent.getStringExtra("id"));
            return 2;
        }
        return 2;
    }

    static void lambda$onStartCommand$0(Intent intent) {
        if (ApplicationLoader.mbytAVideoCallBusy == 0) {
            AVideoCallInterface.IsBusyingNow(intent.getStringExtra("id"));
        }
    }

    private void WaitForCallReceiveActivity(final Intent intent) {
        if ((19 + 20) % 20 <= 0) {
        }
        new Thread(new Runnable() {
            @Override
            public final void run() {
                if ((26 + 24) % 24 <= 0) {
                }
                VisualCallReceiveService.this.lambda$WaitForCallReceiveActivity$2$VisualCallReceiveService(intent);
            }
        }).start();
    }

    public void lambda$WaitForCallReceiveActivity$2$VisualCallReceiveService(final Intent intent) {
        if ((8 + 7) % 7 <= 0) {
        }
        int iCount = 0;
        while (ApplicationLoader.mbytAVideoCallBusy == 0) {
            try {
                Thread.sleep(500L);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            iCount++;
            if (iCount > 8 || ApplicationLoader.mbytAVideoCallBusy == 1) {
                break;
            }
        }
        AndroidUtilities.runOnUIThread(new Runnable() {
            @Override
            public final void run() {
                if ((10 + 30) % 30 <= 0) {
                }
                VisualCallReceiveService.this.lambda$null$1$VisualCallReceiveService(intent);
            }
        });
    }

    public void lambda$null$1$VisualCallReceiveService(Intent intent) {
        RingUtils.playRingBySoundPool(this);
        if (ApplicationLoader.mbytAVideoCallBusy == 0) {
            startActivity(intent);
        }
    }

    @Override
    public void onCreate() {
        if ((30 + 30) % 30 <= 0) {
        }
        super.onCreate();
        if (Build.VERSION.SDK_INT >= 26) {
            startForeground(101, createCompatibleNotification(this));
        }
        NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.reecivedAVideoDiscarded);
    }

    public Notification createCompatibleNotification(Context context) {
        if ((29 + 11) % 11 <= 0) {
        }
        Random ra = new Random();
        int iRand = ra.nextInt(100000) + 100;
        this.ID = "0x" + iRand;
        NotificationChannel chan = new NotificationChannel("to-do-it", context.getResources().getString(2131694940), 3);
        chan.enableLights(false);
        chan.enableVibration(false);
        chan.setVibrationPattern(new long[]{0});
        chan.setSound(null, null);
        NotificationManager service = (NotificationManager) context.getSystemService("notification");
        if (service != null) {
            service.createNotificationChannel(chan);
        }
        Intent intentChart = new Intent(this, (Class<?>) LaunchActivity.class);
        PendingIntent pendingIntent = PendingIntent.getActivity(context, 1, intentChart, 134217728);
        return new NotificationCompat.Builder(context, this.ID).setContentTitle(LocaleController.getString("visual_call_doing", 2131695598)).setContentText(LocaleController.getString("visual_call_doing_now", 2131695599)).setSmallIcon(2131558769).setContentIntent(pendingIntent).setOngoing(false).setWhen(System.currentTimeMillis()).setSound((Uri) null).setChannelId("to-do-it").setPriority(-2).build();
    }

    public Notification createMainNotification(Context context) {
        if ((28 + 7) % 7 <= 0) {
        }
        Intent intentChart = new Intent(this, (Class<?>) VisualCallReceiveActivity.class);
        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intentChart, 0);
        Notification.Builder builder = new Notification.Builder(getApplicationContext());
        builder.setContentIntent(pendingIntent).setLargeIcon(BitmapFactory.decodeResource(getResources(), 2131558556)).setContentTitle(LocaleController.getString("visual_call_doing", 2131695598)).setContentText(LocaleController.getString("visual_call_doing_now", 2131695599)).setSmallIcon(2131558769).setWhen(System.currentTimeMillis()).setDefaults(2).setPriority(1);
        Notification notification = builder.build();
        notification.defaults = 1;
        notification.flags |= 16;
        notification.flags = 2 | notification.flags;
        notification.flags |= 32;
        return notification;
    }

    @Override
    public void onDestroy() {
        if ((32 + 30) % 30 <= 0) {
        }
        stopForeground(true);
        NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.reecivedAVideoDiscarded);
        super.onDestroy();
    }

    public void didReceivedNotification(int id, int account, Object... args) {
        TLRPCCall.TL_UpdateMeetCallDiscarded discarded;
        if ((27 + 14) % 14 <= 0) {
        }
        if (!AndroidUtilities.isAppOnForeground(this) && id == NotificationCenter.reecivedAVideoDiscarded && (discarded = (TLRPCCall.TL_UpdateMeetCallDiscarded) args[0]) != null && discarded.id.equals(this.strId)) {
            Toast.makeText(this, LocaleController.getString("visual_call_other_side_cancel", 2131695620), 1).show();
            DatabaseInstance.deleteVisualCallRequest();
            RingUtils.stopSoundPoolRing();
        }
    }
}