MD5 校验值:1036132062d4d223cd1a714f5bbea98b
VisualCallReceiveService.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。
package im.skmzhmurqt.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.os.Build; import android.os.Handler; import android.os.IBinder; import android.widget.Toast; import androidx.core.app.NotificationCompat; import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.extractor.ogg.DefaultOggSeeker; import com.google.android.exoplayer2.text.ttml.TtmlNode; import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection; import com.google.android.exoplayer2.util.MimeTypes; import com.socks.library.KLog; import im.skmzhmurqt.messenger.AndroidUtilities; import im.skmzhmurqt.messenger.ApplicationLoader; import im.skmzhmurqt.messenger.LocaleController; import im.skmzhmurqt.messenger.NotificationCenter; import im.skmzhmurqt.messenger.R; import im.skmzhmurqt.tgnet.TLRPCCall; import im.skmzhmurqt.ui.LaunchActivity; import im.skmzhmurqt.ui.hui.friendscircle_v1.helper.DatabaseInstance; 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) { RingUtils.stopMediaPlayerRing(); VisualCallRequestBean bean = DatabaseInstance.queryVisualCallById(intent.getStringExtra(TtmlNode.ATTR_ID)); if (bean == null) { KLog.d("----------收到音视频请求 type = " + intent.getStringExtra(TtmlNode.ATTR_ID) + " " + (System.currentTimeMillis() - this.mlLastReqTime)); this.handler.removeCallbacks(this.runnable); if (System.currentTimeMillis() - this.mlLastReqTime > AdaptiveTrackSelection.DEFAULT_MIN_TIME_BETWEEN_BUFFER_REEVALUTATION_MS) { this.mlLastReqTime = System.currentTimeMillis(); if (ApplicationLoader.mbytAVideoCallBusy == 0) { if (AndroidUtilities.isAppOnForeground(this)) { if (DatabaseInstance.getVisualCallCount() < 1) { boolean blnVideo = intent.getBooleanExtra(MimeTypes.BASE_TYPE_VIDEO, false); Intent actIntent = new Intent(this, (Class<?>) VisualCallReceiveActivity.class); actIntent.putExtra(MimeTypes.BASE_TYPE_VIDEO, blnVideo); actIntent.putExtra(TtmlNode.ATTR_ID, intent.getStringExtra(TtmlNode.ATTR_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(C.ENCODING_PCM_MU_LAW); startActivity(actIntent); new Handler().postDelayed(new Runnable() { @Override public final void run() { VisualCallReceiveService.lambda$onStartCommand$0(intent); } }, 3000L); } else { AVideoCallInterface.IsBusyingNow(intent.getStringExtra(TtmlNode.ATTR_ID)); } } else if (DatabaseInstance.getVisualCallCount() < 1) { RingUtils.playRingBySoundPool(this); this.strId = intent.getStringExtra(TtmlNode.ATTR_ID); VisualCallRequestParaBean paraBean = new VisualCallRequestParaBean(); paraBean.setStrId(intent.getStringExtra(TtmlNode.ATTR_ID)); paraBean.setVideo(intent.getBooleanExtra(MimeTypes.BASE_TYPE_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(TtmlNode.ATTR_ID)); } VisualCallRequestBean bean1 = new VisualCallRequestBean(); bean1.setStrId(intent.getStringExtra(TtmlNode.ATTR_ID)); bean1.setTimestamp(System.currentTimeMillis()); DatabaseInstance.saveVisualCallRequest(bean1); return 2; } AVideoCallInterface.IsBusyingNow(intent.getStringExtra(TtmlNode.ATTR_ID)); return 2; } AVideoCallInterface.IsBusyingNow(intent.getStringExtra(TtmlNode.ATTR_ID)); return 2; } return 2; } public static void lambda$onStartCommand$0(Intent intent) { if (ApplicationLoader.mbytAVideoCallBusy == 0) { AVideoCallInterface.IsBusyingNow(intent.getStringExtra(TtmlNode.ATTR_ID)); } } private void WaitForCallReceiveActivity(final Intent intent) { new Thread(new Runnable() { @Override public final void run() { VisualCallReceiveService.this.lambda$WaitForCallReceiveActivity$2$VisualCallReceiveService(intent); } }).start(); } public void lambda$WaitForCallReceiveActivity$2$VisualCallReceiveService(final Intent intent) { 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() { 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() { super.onCreate(); if (Build.VERSION.SDK_INT >= 26) { startForeground(101, createCompatibleNotification(this)); } NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.reecivedAVideoDiscarded); } public Notification createCompatibleNotification(Context context) { Random ra = new Random(); int iRand = ra.nextInt(DefaultOggSeeker.MATCH_BYTE_RANGE) + 100; this.ID = "0x" + iRand; NotificationChannel chan = new NotificationChannel("to-do-it", context.getResources().getString(2131694932), 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", R.string.visual_call_doing)).setContentText(LocaleController.getString("visual_call_doing_now", R.string.visual_call_doing_now)).setSmallIcon(R.mipmap.notification).setContentIntent(pendingIntent).setOngoing(false).setWhen(System.currentTimeMillis()).setSound(null).setChannelId("to-do-it").setPriority(-2).build(); } public Notification createMainNotification(Context context) { 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(), R.mipmap.ic_launcher)).setContentTitle(LocaleController.getString("visual_call_doing", R.string.visual_call_doing)).setContentText(LocaleController.getString("visual_call_doing_now", R.string.visual_call_doing_now)).setSmallIcon(R.mipmap.notification).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() { stopForeground(true); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.reecivedAVideoDiscarded); super.onDestroy(); } @Override public void didReceivedNotification(int id, int account, Object... args) { TLRPCCall.TL_UpdateMeetCallDiscarded discarded; 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", R.string.visual_call_other_side_cancel), 1).show(); DatabaseInstance.deleteVisualCallRequest(); RingUtils.stopSoundPoolRing(); } } }