discord-jadx/app/src/main/java/com/discord/overlay/OverlayService.java

180 lines
6.2 KiB
Java

package com.discord.overlay;
import android.app.Notification;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.view.View;
import c.a.o.f;
import com.discord.overlay.views.OverlayBubbleWrap;
import d0.j;
import d0.z.d.m;
import d0.z.d.o;
import java.util.Objects;
import kotlin.Unit;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
/* compiled from: OverlayService.kt */
public abstract class OverlayService extends Service {
public static final Companion Companion = new Companion(null);
public static final int NOTIFICATION_ID = 5858;
public OverlayManager overlayManager;
/* compiled from: OverlayService.kt */
public static final class Companion {
public Companion() {
}
public Companion(DefaultConstructorMarker defaultConstructorMarker) {
}
}
/* compiled from: OverlayService.kt */
public static final class a implements Runnable {
public final /* synthetic */ OverlayService i;
public final /* synthetic */ OverlayBubbleWrap j;
public a(OverlayService overlayService, OverlayBubbleWrap overlayBubbleWrap) {
this.i = overlayService;
this.j = overlayBubbleWrap;
}
@Override // java.lang.Runnable
public final void run() {
this.i.getOverlayManager().b(this.j);
}
}
/* compiled from: OverlayService.kt */
public static final class b implements f {
public final /* synthetic */ OverlayService i;
public b(OverlayService overlayService) {
this.i = overlayService;
}
@Override // c.a.o.f
public void a(OverlayBubbleWrap overlayBubbleWrap) {
}
@Override // c.a.o.f
public void b(OverlayBubbleWrap overlayBubbleWrap) {
m.checkNotNullParameter(overlayBubbleWrap, "bubble");
this.i.getOverlayManager().d(overlayBubbleWrap);
}
}
/* compiled from: OverlayService.kt */
public static final class c extends o implements Function1<View, Unit> {
public final /* synthetic */ OverlayService this$0;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public c(OverlayService overlayService) {
super(1);
this.this$0 = overlayService;
}
/* Return type fixed from 'java.lang.Object' to match base method */
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
@Override // kotlin.jvm.functions.Function1
public Unit invoke(View view) {
m.checkNotNullParameter(view, "it");
if (!this.this$0.getOverlayManager().j.isEmpty()) {
return Unit.a;
}
throw new j(c.d.b.a.a.t("An operation is not implemented: ", "handle stop service"));
}
}
private final boolean attachBubbleToWindow(Intent intent) {
OverlayBubbleWrap createOverlayBubble = createOverlayBubble(intent);
if (createOverlayBubble == null) {
return false;
}
OverlayManager overlayManager = this.overlayManager;
if (overlayManager == null) {
m.throwUninitializedPropertyAccessException("overlayManager");
}
overlayManager.a(createOverlayBubble);
createOverlayBubble.post(new a(this, createOverlayBubble));
OverlayManager overlayManager2 = this.overlayManager;
if (overlayManager2 == null) {
m.throwUninitializedPropertyAccessException("overlayManager");
}
if (overlayManager2.m != null) {
return true;
}
Context applicationContext = getApplicationContext();
m.checkNotNullExpressionValue(applicationContext, "applicationContext");
c.a.o.h.a aVar = new c.a.o.h.a(applicationContext);
OverlayManager overlayManager3 = this.overlayManager;
if (overlayManager3 == null) {
m.throwUninitializedPropertyAccessException("overlayManager");
}
Objects.requireNonNull(overlayManager3);
m.checkNotNullParameter(aVar, "trashWrap");
overlayManager3.m = aVar;
overlayManager3.r.addView(aVar, aVar.getWindowLayoutParams());
return true;
}
public abstract Notification createNotification(Intent intent);
public abstract OverlayBubbleWrap createOverlayBubble(Intent intent);
public final OverlayManager getOverlayManager() {
OverlayManager overlayManager = this.overlayManager;
if (overlayManager == null) {
m.throwUninitializedPropertyAccessException("overlayManager");
}
return overlayManager;
}
public final void handleStart(Intent intent) {
if (intent == null) {
intent = new Intent();
}
if (attachBubbleToWindow(intent)) {
startForeground(5858, createNotification(intent));
}
}
@Override // android.app.Service
public IBinder onBind(Intent intent) {
return null;
}
@Override // android.app.Service
public void onCreate() {
super.onCreate();
Context applicationContext = getApplicationContext();
m.checkNotNullExpressionValue(applicationContext, "applicationContext");
OverlayManager overlayManager = new OverlayManager(applicationContext, null, 2);
this.overlayManager = overlayManager;
overlayManager.n = new b(this);
if (overlayManager == null) {
m.throwUninitializedPropertyAccessException("overlayManager");
}
c cVar = new c(this);
Objects.requireNonNull(overlayManager);
m.checkNotNullParameter(cVar, "<set-?>");
overlayManager.l = cVar;
}
@Override // android.app.Service
public void onDestroy() {
OverlayManager overlayManager = this.overlayManager;
if (overlayManager == null) {
m.throwUninitializedPropertyAccessException("overlayManager");
}
overlayManager.close();
super.onDestroy();
}
public final void setOverlayManager(OverlayManager overlayManager) {
m.checkNotNullParameter(overlayManager, "<set-?>");
this.overlayManager = overlayManager;
}
}