正在查看: Rilo v2.0.21 应用的 UserCohostService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Rilo v2.0.21 应用的 UserCohostService.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.app.Person;
import android.content.Intent;
import android.os.Build;
import android.os.IBinder;
import androidx.core.app.NotificationCompat;
import androidx.core.app.ServiceCompat;
import app.callpe.App;
import app.callpe.common.utils.Constants;
import app.callpe.common.utils.RxBus;
import app.callpe.common.utils.receivers.UserCohostBroadcastReceiver;
import app.callpe.data.model.LiveStreamModel;
import app.callpe.data.model.StreamerModel;
import app.callpe.rtc.RtcManagerFactory;
import app.callpe.ui.call.RtcScreenHandler;
import app.callpe.ui.livestreaming.LiveStreamingActivity;
import app.module.common.rtcmanager.RtcManager;
import com.google.gson.Gson;
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 = {"\u0000f\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\t\n\u0002\b\u0002\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\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0007\b\u0007\u0018\u0000 +2\u00020\u0001:\u0001+B\u0005¢\u0006\u0002\u0010\u0002J\b\u0010\u0015\u001a\u00020\u0016H\u0003J\b\u0010\u0017\u001a\u00020\u0018H\u0002J\b\u0010\u0019\u001a\u00020\u0016H\u0002J\b\u0010\u001a\u001a\u00020\u001bH\u0003J\u0012\u0010\u001c\u001a\u00020\u001b2\b\u0010\u001d\u001a\u0004\u0018\u00010\u001eH\u0002J\u0010\u0010\u001f\u001a\u00020 2\u0006\u0010!\u001a\u00020\"H\u0002J\b\u0010#\u001a\u00020\u001bH\u0002J\u0012\u0010$\u001a\u0004\u0018\u00010%2\u0006\u0010\u001d\u001a\u00020\u001eH\u0016J\b\u0010&\u001a\u00020\u001bH\u0016J\b\u0010'\u001a\u00020\u001bH\u0016J\"\u0010(\u001a\u00020 2\b\u0010\u001d\u001a\u0004\u0018\u00010\u001e2\u0006\u0010)\u001a\u00020 2\u0006\u0010*\u001a\u00020 H\u0016R\u0012\u0010\u0003\u001a\u0004\u0018\u00010\u0004X\u0082\u000e¢\u0006\u0004\n\u0002\u0010\u0005R\u0010\u0010\u0006\u001a\u0004\u0018\u00010\u0007X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\b\u001a\u0004\u0018\u00010\tX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\n\u001a\u0004\u0018\u00010\u000bX\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\f\u001a\u0004\u0018\u00010\rX\u0082\u000e¢\u0006\u0002\n\u0000R\u001e\u0010\u000e\u001a\u00020\u000f8\u0006@\u0006X\u0087.¢\u0006\u000e\n\u0000\u001a\u0004\b\u0010\u0010\u0011\"\u0004\b\u0012\u0010\u0013R\u0010\u0010\u0014\u001a\u0004\u0018\u00010\u000bX\u0082\u000e¢\u0006\u0002\n\u0000¨\u0006,"}, d2 = {"Lapp/callpe/service/UserCohostService;", "Landroid/app/Service;", "()V", "cohostId", "", "Ljava/lang/Long;", "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", "createCallStyleNotification", "Landroid/app/Notification;", "createEndAction", "Landroidx/core/app/NotificationCompat$Action;", "createNotification", "createNotificationChannel", "", "getCohostDetails", "intent", "Landroid/content/Intent;", "getNotificationIcon", "", "notificationBuilder", "Landroidx/core/app/NotificationCompat$Builder;", "manageNotification", "onBind", "Landroid/os/IBinder;", "onCreate", "onDestroy", "onStartCommand", "flags", "startId", "Companion", "app_riloRelease"}, k = 1, mv = {1, 8, 0}, xi = 48)
@AndroidEntryPoint
public final class UserCohostService extends Hilt_UserCohostService {
public static final long INTERVAL = 2000;
private static boolean isCohostRunning;
private static boolean isOngoingCohostWebview;
private Long cohostId;
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;
@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\u000b\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\u0006X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\n\u0010\u0007\"\u0004\b\u000b\u0010\tR\u001a\u0010\f\u001a\u00020\u0004X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\r\u0010\u000e\"\u0004\b\u000f\u0010\u0010¨\u0006\u0011"}, d2 = {"Lapp/callpe/service/UserCohostService$Companion;", "", "()V", "INTERVAL", "", "isCohostRunning", "", "()Z", "setCohostRunning", "(Z)V", "isOngoingCohostWebview", "setOngoingCohostWebview", "liveStreamId", "getLiveStreamId", "()J", "setLiveStreamId", "(J)V", "app_riloRelease"}, k = 1, mv = {1, 8, 0}, xi = 48)
public static final class Companion {
public Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
private Companion() {
}
public final boolean isCohostRunning() {
return UserCohostService.isCohostRunning;
}
public final void setCohostRunning(boolean z) {
UserCohostService.isCohostRunning = z;
}
public final long getLiveStreamId() {
return UserCohostService.liveStreamId;
}
public final void setLiveStreamId(long j) {
UserCohostService.liveStreamId = j;
}
public final boolean isOngoingCohostWebview() {
return UserCohostService.isOngoingCohostWebview;
}
public final void setOngoingCohostWebview(boolean z) {
UserCohostService.isOngoingCohostWebview = z;
}
}
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);
isOngoingCohostWebview = App.Companion.getWebViewLivestream();
getCohostDetails(intent);
String action = intent != null ? intent.getAction() : null;
if (action != null && action.hashCode() == 505408682 && action.equals(Constants.END_COHOSTING)) {
stopSelf();
} else if (!isCohostRunning) {
isCohostRunning = 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;
this.job = BuildersKt.launch$default(CoroutineScopeKt.CoroutineScope(Dispatchers.getDefault()), (CoroutineContext) null, (CoroutineStart) null, new UserCohostService$onStartCommand$1(this, null), 3, (Object) null);
manageNotification();
}
return 1;
}
private final void getCohostDetails(Intent intent) {
if (intent == null || intent.getExtras() == null) {
return;
}
String stringExtra = intent.getStringExtra(LiveStreamingActivity.LIVE_STREAM_MODEL);
if (stringExtra != null) {
this.liveStreamModel = (LiveStreamModel) new Gson().fromJson(stringExtra, LiveStreamModel.class);
}
this.cohostId = Long.valueOf(intent.getLongExtra(LiveStreamingActivity.COHOST_ID, -1L));
}
private final void manageNotification() {
if (Build.VERSION.SDK_INT > 26) {
createNotificationChannel();
} else {
startForeground(9, createNotification());
}
}
private final Notification createNotification() {
String str;
StreamerModel streamerModel;
UserCohostService userCohostService = this;
Intent rtcScreenIntent = RtcScreenHandler.getRtcScreenIntent(userCohostService, RtcScreenHandler.getRtcScreenType(true));
rtcScreenIntent.putExtra(Constants.FROM_COHOST_NOTIFICATION_CLICK, true);
rtcScreenIntent.putExtra(LiveStreamingActivity.COHOST_ID, this.cohostId);
rtcScreenIntent.putExtra(LiveStreamingActivity.LIVE_STREAM_ID, liveStreamId);
rtcScreenIntent.putExtra(LiveStreamingActivity.ROOM_ID, this.roomId);
rtcScreenIntent.putExtra(LiveStreamingActivity.ZEGO_TOKEN, this.zegoToken);
rtcScreenIntent.putExtra(LiveStreamingActivity.LIVE_STREAM_MODEL, new Gson().toJson(this.liveStreamModel));
PendingIntent activity = PendingIntent.getActivity(userCohostService, 122, rtcScreenIntent, 201326592);
new Intent(userCohostService, (Class<?>) UserCohostBroadcastReceiver.class).setAction(Constants.END_COHOSTING);
LiveStreamModel liveStreamModel = this.liveStreamModel;
if (liveStreamModel == null || (streamerModel = liveStreamModel.getStreamerModel()) == null || (str = streamerModel.getName()) == null) {
str = "Streamer";
}
Notification build = new NotificationCompat.Builder(userCohostService, "Cohost_Channel").setContentTitle("Co-hosting with " + str).setPriority(0).setSmallIcon(2131231572).setContentIntent(activity).addAction(createEndAction()).build();
Intrinsics.checkNotNullExpressionValue(build, "Builder(this, \"Cohost_Ch…n())\n .build()");
return build;
}
private final void createNotificationChannel() {
NotificationChannel notificationChannel = new NotificationChannel("Cohost_Channel", "Co-host Notification", 2);
notificationChannel.enableLights(true);
notificationChannel.setLightColor(getColor(2131099815));
notificationChannel.enableVibration(true);
notificationChannel.setLockscreenVisibility(1);
Object systemService = getSystemService("notification");
Intrinsics.checkNotNull(systemService, "null cannot be cast to non-null type android.app.NotificationManager");
((NotificationManager) systemService).createNotificationChannel(notificationChannel);
if (Build.VERSION.SDK_INT > 30) {
if (Build.VERSION.SDK_INT >= 34) {
ServiceCompat.startForeground(this, 9, createCallStyleNotification(), 4);
return;
} else {
startForeground(9, createCallStyleNotification());
return;
}
}
startForeground(9, createNotification());
}
private final Notification createCallStyleNotification() {
String str;
StreamerModel streamerModel;
UserCohostService userCohostService = this;
Intent intent = new Intent(userCohostService, (Class<?>) LiveStreamingActivity.class);
intent.putExtra(Constants.FROM_COHOST_NOTIFICATION_CLICK, true);
intent.putExtra(LiveStreamingActivity.COHOST_ID, this.cohostId);
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));
PendingIntent activity = PendingIntent.getActivity(userCohostService, 122, intent, 201326592);
Intent intent2 = new Intent(userCohostService, (Class<?>) UserCohostBroadcastReceiver.class);
intent2.setAction(Constants.END_COHOSTING);
intent2.putExtra(LiveStreamingActivity.COHOST_ID, this.cohostId);
PendingIntent broadcast = PendingIntent.getBroadcast(userCohostService, 122, intent2, 201326592);
LiveStreamModel liveStreamModel = this.liveStreamModel;
if (liveStreamModel == null || (streamerModel = liveStreamModel.getStreamerModel()) == null || (str = streamerModel.getName()) == null) {
str = "Streamer";
}
Person build = new Person.Builder().setName(str).setImportant(true).build();
Intrinsics.checkNotNullExpressionValue(build, "Builder()\n .s…rue)\n .build()");
Notification build2 = new Notification.Builder(userCohostService, "Cohost_Channel").setContentText("Ongoing Co-host with " + str).setSmallIcon(2131231572).setUsesChronometer(true).setShowWhen(true).setStyle(Notification.CallStyle.forOngoingCall(build, broadcast)).setOngoing(true).setContentIntent(activity).build();
Intrinsics.checkNotNullExpressionValue(build2, "Builder(this, \"Cohost_Ch…ent)\n .build()");
return build2;
}
private final NotificationCompat.Action createEndAction() {
UserCohostService userCohostService = this;
Intent intent = new Intent(userCohostService, (Class<?>) UserCohostBroadcastReceiver.class);
intent.setAction(Constants.END_COHOSTING);
intent.putExtra(LiveStreamingActivity.COHOST_ID, this.cohostId);
NotificationCompat.Action build = new NotificationCompat.Action.Builder(122, "End Co-host", PendingIntent.getBroadcast(userCohostService, 122, intent, 201326592)).build();
Intrinsics.checkNotNullExpressionValue(build, "Builder(\n 122…gIntent\n ).build()");
return build;
}
@Override
public void onDestroy() {
super.onDestroy();
Job job = this.job;
if (job != null) {
Job.DefaultImpls.cancel$default(job, (CancellationException) null, 1, (Object) null);
}
isCohostRunning = false;
isOngoingCohostWebview = false;
RtcManager rtcManager = this.rtcManager;
if (rtcManager != null) {
rtcManager.enableCamera(false);
}
RtcManager rtcManager2 = this.rtcManager;
if (rtcManager2 != null) {
rtcManager2.openMicrophone(false);
}
Timber.i("Co-host Service Destroyed", new Object[0]);
}
private final int getNotificationIcon(NotificationCompat.Builder notificationBuilder) {
notificationBuilder.setColor(32768);
return 2131231572;
}
}