正在查看: Biko v2.0.23 应用的 LiveStreamingService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Biko v2.0.23 应用的 LiveStreamingService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package app.callpe.service;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.IBinder;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.ForegroundColorSpan;
import androidx.core.app.NotificationCompat;
import androidx.core.app.ServiceCompat;
import app.callpe.common.agora.LiveStreamEvent;
import app.callpe.common.agora.LiveStreamEventTypes;
import app.callpe.common.utils.Constants;
import app.callpe.common.utils.RxBus;
import app.callpe.common.utils.receivers.LiveStreamBroadcastReceiver;
import app.callpe.common.utils.sharedpref.PrefKeys;
import app.callpe.common.utils.sharedpref.SharedPref;
import app.callpe.data.model.LiveStreamModel;
import app.callpe.rtc.RtcManagerFactory;
import app.callpe.ui.livestreaming.LiveStreamingActivity;
import app.module.common.interfaces.SignOutListener;
import app.module.common.rtcmanager.RtcManager;
import com.facebook.internal.NativeProtocol;
import com.google.gson.Gson;
import com.zegocloud.zegosdk.beauty.components.BeautyDialog;
import dagger.hilt.android.AndroidEntryPoint;
import java.util.concurrent.CancellationException;
import javax.inject.Inject;
import kotlin.Metadata;
import kotlin.coroutines.CoroutineContext;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlinx.coroutines.BuildersKt;
import kotlinx.coroutines.CoroutineScopeKt;
import kotlinx.coroutines.CoroutineStart;
import kotlinx.coroutines.Dispatchers;
import kotlinx.coroutines.Job;
import timber.log.Timber;
@Metadata(d1 = {"\u0000t\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\b\b\u0007\u0018\u0000 22\u00020\u0001:\u00012B\u0005¢\u0006\u0002\u0010\u0002J\b\u0010\u0014\u001a\u00020\u0015H\u0002J\u0012\u0010\u0016\u001a\u00020\u00172\b\b\u0002\u0010\u0018\u001a\u00020\nH\u0003J$\u0010\u0019\u001a\u0004\u0018\u00010\u001a2\u0006\u0010\u001b\u001a\u00020\u001c2\u0006\u0010\u001d\u001a\u00020\n2\b\b\u0001\u0010\u001e\u001a\u00020\u001fH\u0002J\u0010\u0010 \u001a\u00020\u001f2\u0006\u0010!\u001a\u00020\"H\u0002J\"\u0010#\u001a\u0004\u0018\u00010$2\u0006\u0010\u001b\u001a\u00020\u001c2\u0006\u0010\u0018\u001a\u00020\n2\u0006\u0010%\u001a\u00020\u001fH\u0002J\u0012\u0010&\u001a\u00020\u00172\b\u0010'\u001a\u0004\u0018\u00010(H\u0002J\u0012\u0010)\u001a\u00020\u00172\b\b\u0002\u0010\u0018\u001a\u00020\nH\u0002J\u0012\u0010*\u001a\u0004\u0018\u00010+2\u0006\u0010'\u001a\u00020(H\u0016J\b\u0010,\u001a\u00020\u0017H\u0016J\b\u0010-\u001a\u00020\u0017H\u0016J\"\u0010.\u001a\u00020\u001f2\b\u0010'\u001a\u0004\u0018\u00010(2\u0006\u0010/\u001a\u00020\u001f2\u0006\u00100\u001a\u00020\u001fH\u0016J\b\u00101\u001a\u00020\u0017H\u0002R\u0010\u0010\u0003\u001a\u0004\u0018\u00010\u0004X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u0005\u001a\u0004\u0018\u00010\u0006X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u0007\u001a\u0004\u0018\u00010\bX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\t\u001a\u0004\u0018\u00010\nX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u000b\u001a\u0004\u0018\u00010\fX\u0082\u000e¢\u0006\u0002\n\u0000R\u001e\u0010\r\u001a\u00020\u000e8\u0006@\u0006X\u0087.¢\u0006\u000e\n\u0000\u001a\u0004\b\u000f\u0010\u0010\"\u0004\b\u0011\u0010\u0012R\u0010\u0010\u0013\u001a\u0004\u0018\u00010\nX\u0082\u000e¢\u0006\u0002\n\u0000¨\u00063"}, d2 = {"Lapp/callpe/service/LiveStreamingService;", "Landroid/app/Service;", "()V", "beautyDialog", "Lcom/zegocloud/zegosdk/beauty/components/BeautyDialog;", "job", "Lkotlinx/coroutines/Job;", "liveStreamModel", "Lapp/callpe/data/model/LiveStreamModel;", "roomId", "", "rtcManager", "Lapp/module/common/rtcmanager/RtcManager;", "rxBus", "Lapp/callpe/common/utils/RxBus;", "getRxBus", "()Lapp/callpe/common/utils/RxBus;", "setRxBus", "(Lapp/callpe/common/utils/RxBus;)V", "zegoToken", "createNotification", "Landroid/app/Notification;", "createNotificationChanel", "", NativeProtocol.WEB_DIALOG_ACTION, "getActionText", "Landroid/text/Spannable;", "context", "Landroid/content/Context;", "stringRes", "colorRes", "", "getNotificationIcon", "notificationBuilder", "Landroidx/core/app/NotificationCompat$Builder;", "getPendingIntent", "Landroid/app/PendingIntent;", "requestCode", "getStreamDetails", "intent", "Landroid/content/Intent;", "manageNotification", "onBind", "Landroid/os/IBinder;", "onCreate", "onDestroy", "onStartCommand", "flags", "startId", "sendEndEvent", "Companion", "app_bikoRelease"}, k = 1, mv = {1, 8, 0}, xi = 48)
@AndroidEntryPoint
public final class LiveStreamingService extends Hilt_LiveStreamingService {
public static final long INTERVAL = 2000;
private static boolean isLiveStreamingRunning;
private BeautyDialog beautyDialog;
private Job job;
private LiveStreamModel liveStreamModel;
private String roomId;
private RtcManager rtcManager;
@Inject
public RxBus rxBus;
private String zegoToken;
public static final Companion INSTANCE = new Companion(null);
private static long liveStreamId = -1;
public static final void onDestroy$lambda$1() {
}
@Override
public IBinder onBind(Intent intent) {
Intrinsics.checkNotNullParameter(intent, "intent");
return null;
}
@Metadata(d1 = {"\u0000\u001a\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\t\n\u0000\n\u0002\u0010\u000b\n\u0002\b\t\b\u0086\u0003\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002R\u000e\u0010\u0003\u001a\u00020\u0004X\u0086T¢\u0006\u0002\n\u0000R\u001a\u0010\u0005\u001a\u00020\u0006X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0005\u0010\u0007\"\u0004\b\b\u0010\tR\u001a\u0010\n\u001a\u00020\u0004X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u000b\u0010\f\"\u0004\b\r\u0010\u000e¨\u0006\u000f"}, d2 = {"Lapp/callpe/service/LiveStreamingService$Companion;", "", "()V", "INTERVAL", "", "isLiveStreamingRunning", "", "()Z", "setLiveStreamingRunning", "(Z)V", "liveStreamId", "getLiveStreamId", "()J", "setLiveStreamId", "(J)V", "app_bikoRelease"}, k = 1, mv = {1, 8, 0}, xi = 48)
public static final class Companion {
public Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
private Companion() {
}
public final boolean isLiveStreamingRunning() {
return LiveStreamingService.isLiveStreamingRunning;
}
public final void setLiveStreamingRunning(boolean z) {
LiveStreamingService.isLiveStreamingRunning = z;
}
public final long getLiveStreamId() {
return LiveStreamingService.liveStreamId;
}
public final void setLiveStreamId(long j) {
LiveStreamingService.liveStreamId = j;
}
}
public final RxBus getRxBus() {
RxBus rxBus = this.rxBus;
if (rxBus != null) {
return rxBus;
}
Intrinsics.throwUninitializedPropertyAccessException("rxBus");
return null;
}
public final void setRxBus(RxBus rxBus) {
Intrinsics.checkNotNullParameter(rxBus, "<set-?>");
this.rxBus = rxBus;
}
@Override
public void onCreate() {
super.onCreate();
this.rtcManager = RtcManagerFactory.getCurrentRtcInstance();
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
super.onStartCommand(intent, flags, startId);
String action = intent != null ? intent.getAction() : null;
if (action != null) {
int hashCode = action.hashCode();
if (hashCode != 75902422) {
if (hashCode == 437377757 && action.equals(Constants.UNPAUSE)) {
manageNotification(Constants.PAUSE);
}
} else if (action.equals(Constants.PAUSE)) {
manageNotification(Constants.UNPAUSE);
}
return 1;
}
isLiveStreamingRunning = true;
this.roomId = intent != null ? intent.getStringExtra(LiveStreamingActivity.ROOM_ID) : null;
liveStreamId = intent != null ? intent.getLongExtra(LiveStreamingActivity.LIVE_STREAM_ID, -1L) : -1L;
this.zegoToken = intent != null ? intent.getStringExtra(LiveStreamingActivity.ZEGO_TOKEN) : null;
getStreamDetails(intent);
this.job = BuildersKt.launch$default(CoroutineScopeKt.CoroutineScope(Dispatchers.getDefault()), (CoroutineContext) null, (CoroutineStart) null, new LiveStreamingService$onStartCommand$1(this, null), 3, (Object) null);
manageNotification$default(this, null, 1, null);
return 1;
}
private final void getStreamDetails(Intent intent) {
String stringExtra;
if (intent == null || intent.getExtras() == null || (stringExtra = intent.getStringExtra(LiveStreamingActivity.LIVE_STREAM_MODEL)) == null) {
return;
}
this.liveStreamModel = (LiveStreamModel) new Gson().fromJson(stringExtra, LiveStreamModel.class);
}
static void manageNotification$default(LiveStreamingService liveStreamingService, String str, int i, Object obj) {
if ((i & 1) != 0) {
str = "";
}
liveStreamingService.manageNotification(str);
}
private final void manageNotification(String action) {
if (Build.VERSION.SDK_INT > 26) {
createNotificationChanel(action);
} else {
startForeground(1, createNotification());
}
}
private final Notification createNotification() {
LiveStreamingService liveStreamingService = this;
Intrinsics.areEqual(SharedPref.getString(liveStreamingService, PrefKeys.USER_ROLE), "STREAMER");
Intent intent = new Intent(liveStreamingService, (Class<?>) LiveStreamingActivity.class);
intent.putExtra(Constants.FROM_NOTIFICATION_CLICK, true);
intent.putExtra(LiveStreamingActivity.LIVE_STREAM_ID, liveStreamId);
intent.putExtra(LiveStreamingActivity.ROOM_ID, this.roomId);
intent.putExtra(LiveStreamingActivity.ZEGO_TOKEN, this.zegoToken);
intent.putExtra(LiveStreamingActivity.LIVE_STREAM_MODEL, new Gson().toJson(this.liveStreamModel));
String string = getString(2131952183);
Intrinsics.checkNotNullExpressionValue(string, "getString(app.callpe.R.string.live_streaming)");
PendingIntent activity = PendingIntent.getActivity(liveStreamingService, 0, intent, 201326592);
NotificationCompat.Builder priority = new NotificationCompat.Builder(liveStreamingService, "Live_Streaming_Channel").setContentTitle(string).setContentText(getString(2131952387)).setPriority(0);
Intrinsics.checkNotNullExpressionValue(priority, "Builder(this, \"Live_Stre…nCompat.PRIORITY_DEFAULT)");
priority.setSmallIcon(getNotificationIcon(priority));
priority.setContentIntent(activity);
Notification build = priority.build();
Intrinsics.checkNotNullExpressionValue(build, "builder.build()");
return build;
}
static void createNotificationChanel$default(LiveStreamingService liveStreamingService, String str, int i, Object obj) {
if ((i & 1) != 0) {
str = "";
}
liveStreamingService.createNotificationChanel(str);
}
private final void createNotificationChanel(String action) {
LiveStreamingService liveStreamingService = this;
Intent intent = new Intent(liveStreamingService, (Class<?>) LiveStreamingActivity.class);
intent.putExtra(Constants.FROM_NOTIFICATION_CLICK, true);
intent.putExtra(LiveStreamingActivity.LIVE_STREAM_ID, liveStreamId);
intent.putExtra(LiveStreamingActivity.ROOM_ID, this.roomId);
intent.putExtra(LiveStreamingActivity.ZEGO_TOKEN, this.zegoToken);
intent.putExtra(LiveStreamingActivity.LIVE_STREAM_MODEL, new Gson().toJson(this.liveStreamModel));
String string = getString(2131952183);
Intrinsics.checkNotNullExpressionValue(string, "getString(app.callpe.R.string.live_streaming)");
PendingIntent activity = PendingIntent.getActivity(liveStreamingService, 0, intent, 201326592);
Object systemService = getSystemService("notification");
Intrinsics.checkNotNull(systemService, "null cannot be cast to non-null type android.app.NotificationManager");
NotificationManager notificationManager = (NotificationManager) systemService;
NotificationChannel notificationChannel = new NotificationChannel("35002", "Live Stream Notification", 2);
notificationChannel.enableLights(true);
notificationChannel.enableVibration(true);
notificationChannel.setLightColor(2131099815);
notificationChannel.setLockscreenVisibility(1);
notificationChannel.setDescription("Live Streaming");
notificationManager.createNotificationChannel(notificationChannel);
Spannable actionText = getActionText(liveStreamingService, "End Stream", 2131100956);
Context applicationContext = getApplicationContext();
Intrinsics.checkNotNullExpressionValue(applicationContext, "applicationContext");
NotificationCompat.Action build = new NotificationCompat.Action.Builder(0, actionText, getPendingIntent(applicationContext, Constants.END_STREAM, 30)).build();
Intrinsics.checkNotNullExpressionValue(build, "Builder(\n 0,\n…AM, 30)\n ).build()");
Spannable actionText2 = getActionText(liveStreamingService, "Pause", 2131100956);
Context applicationContext2 = getApplicationContext();
Intrinsics.checkNotNullExpressionValue(applicationContext2, "applicationContext");
NotificationCompat.Action build2 = new NotificationCompat.Action.Builder(0, actionText2, getPendingIntent(applicationContext2, Constants.PAUSE, 31)).build();
Intrinsics.checkNotNullExpressionValue(build2, "Builder(\n 0,\n…SE, 31)\n ).build()");
Spannable actionText3 = getActionText(liveStreamingService, "Resume", 2131100956);
Context applicationContext3 = getApplicationContext();
Intrinsics.checkNotNullExpressionValue(applicationContext3, "applicationContext");
NotificationCompat.Action build3 = new NotificationCompat.Action.Builder(0, actionText3, getPendingIntent(applicationContext3, Constants.UNPAUSE, 32)).build();
Intrinsics.checkNotNullExpressionValue(build3, "Builder(\n 0,\n…SE, 32)\n ).build()");
NotificationCompat.Builder autoCancel = new NotificationCompat.Builder(liveStreamingService, "35002").setContentTitle(string).setContentText(getString(2131952387)).setAutoCancel(false);
if (Intrinsics.areEqual(action, Constants.PAUSE)) {
build2 = build3;
}
NotificationCompat.Builder ongoing = autoCancel.addAction(build2).addAction(build).setContentIntent(activity).setOngoing(true);
Intrinsics.checkNotNullExpressionValue(ongoing, "Builder(this, \"35002\").s… .setOngoing(true)");
ongoing.setSmallIcon(getNotificationIcon(ongoing));
Notification build4 = ongoing.build();
Intrinsics.checkNotNullExpressionValue(build4, "builder.build()");
notificationManager.notify(5, build4);
if (Build.VERSION.SDK_INT >= 34) {
ServiceCompat.startForeground(this, 5, build4, 4);
} else {
startForeground(5, build4);
}
}
private final PendingIntent getPendingIntent(Context context, String action, int requestCode) {
try {
Intent intent = new Intent(context, (Class<?>) LiveStreamBroadcastReceiver.class);
intent.setAction(action);
intent.putExtra(LiveStreamingActivity.LIVE_STREAM_ID, liveStreamId);
return PendingIntent.getBroadcast(context, requestCode, intent, 201326592);
} catch (Exception unused) {
return null;
}
}
@Override
public void onDestroy() {
super.onDestroy();
Job job = this.job;
if (job != null) {
Job.DefaultImpls.cancel$default(job, (CancellationException) null, 1, (Object) null);
}
RtcManager rtcManager = this.rtcManager;
if (rtcManager != null) {
rtcManager.stopLocalPreview();
}
RtcManager rtcManager2 = this.rtcManager;
if (rtcManager2 != null) {
rtcManager2.leaveRtcRoom(new SignOutListener() {
@Override
public final void signOut() {
LiveStreamingService.onDestroy$lambda$1();
}
});
}
RtcManager rtcManager3 = this.rtcManager;
if (rtcManager3 != null) {
rtcManager3.setEventHandler(null);
}
RtcManager rtcManager4 = this.rtcManager;
if (rtcManager4 != null) {
rtcManager4.disconnectUser(true);
}
isLiveStreamingRunning = false;
liveStreamId = -1L;
sendEndEvent();
Timber.i("Live Streaming Service Destroyed", new Object[0]);
}
private final void sendEndEvent() {
for (int i = 1; i < 4; i++) {
getRxBus().send(new LiveStreamEvent(LiveStreamEventTypes.ENDED, this.liveStreamModel));
}
}
private final int getNotificationIcon(NotificationCompat.Builder notificationBuilder) {
notificationBuilder.setColor(32768);
return 2131231746;
}
private final Spannable getActionText(Context context, String stringRes, int colorRes) {
SpannableString spannableString = new SpannableString(stringRes);
if (Build.VERSION.SDK_INT >= 25) {
spannableString.setSpan(new ForegroundColorSpan(context.getColor(colorRes)), 0, spannableString.length(), 0);
}
return spannableString;
}
}