正在查看: 万能钥匙 v1.1.23 应用的 ForegroundService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: 万能钥匙 v1.1.23 应用的 ForegroundService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.finogeeks.lib.applet.modules.service;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.IBinder;
import android.util.Log;
import androidx.annotation.Nullable;
import com.finogeeks.lib.applet.R;
import com.finogeeks.lib.applet.client.FinAppClient;
import com.finogeeks.lib.applet.client.FinAppConfig;
import com.finogeeks.lib.applet.modules.ext.ContextKt;
import com.finogeeks.lib.applet.modules.ext.s;
import kotlin.Metadata;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.n;
import lg0.t;
@Metadata(d1 = {"\u0000@\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\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0002\b\u0004\n\u0002\u0010\u000b\n\u0002\b\u0004\u0018\u00002\u00020\u0001:\u0001\u001cB\u0007¢\u0006\u0004\b\u0002\u0010\u0003J\u000f\u0010\u0005\u001a\u00020\u0004H\u0016¢\u0006\u0004\b\u0005\u0010\u0003J\u0019\u0010\t\u001a\u0004\u0018\u00010\b2\u0006\u0010\u0007\u001a\u00020\u0006H\u0017¢\u0006\u0004\b\t\u0010\nJ)\u0010\u000e\u001a\u00020\u000b2\b\u0010\u0007\u001a\u0004\u0018\u00010\u00062\u0006\u0010\f\u001a\u00020\u000b2\u0006\u0010\r\u001a\u00020\u000bH\u0016¢\u0006\u0004\b\u000e\u0010\u000fJ\u000f\u0010\u0010\u001a\u00020\u0004H\u0016¢\u0006\u0004\b\u0010\u0010\u0003J\u000f\u0010\u0012\u001a\u00020\u0011H\u0002¢\u0006\u0004\b\u0012\u0010\u0013J\u0017\u0010\u0016\u001a\u00020\u00042\u0006\u0010\u0015\u001a\u00020\u0014H\u0002¢\u0006\u0004\b\u0016\u0010\u0017J\u000f\u0010\u0018\u001a\u00020\u0004H\u0002¢\u0006\u0004\b\u0018\u0010\u0003R\u0016\u0010\u001a\u001a\u00020\u00198\u0002@\u0002X\u0082\u000e¢\u0006\u0006\n\u0004\b\u001a\u0010\u001b¨\u0006\u001d"}, d2 = {"Lcom/finogeeks/lib/applet/modules/service/ForegroundService;", "Landroid/app/Service;", "<init>", "()V", "Llg0/e0;", "onCreate", "Landroid/content/Intent;", "intent", "Landroid/os/IBinder;", "onBind", "(Landroid/content/Intent;)Landroid/os/IBinder;", "", "flags", "startId", "onStartCommand", "(Landroid/content/Intent;II)I", "onDestroy", "Landroid/app/Notification;", "createForegroundNotification", "()Landroid/app/Notification;", "", "type", "startForeground", "(Ljava/lang/String;)V", "stopForeground", "", "isForegroundStarted", "Z", "Companion", "finapplet_release"}, k = 1, mv = {1, 4, 0})
public final class ForegroundService extends Service {
private boolean a;
public static final a c = new a(null);
private static final String b = ForegroundService.class.getSimpleName();
public static final class a {
private a() {
}
public a(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
public final void a(Context context) {
n.j(context, "context");
Intent intent = new Intent(context, (Class<?>) ForegroundService.class);
if (Build.VERSION.SDK_INT < 26) {
try {
context.startService(intent);
return;
} catch (Throwable th2) {
th2.printStackTrace();
return;
}
}
if (ContextKt.isPermissionDeclared(context, "android.permission.FOREGROUND_SERVICE")) {
try {
context.startForegroundService(intent);
} catch (Throwable th3) {
th3.printStackTrace();
}
}
}
public final void b(Context context) {
n.j(context, "context");
try {
context.stopService(new Intent(context, (Class<?>) ForegroundService.class));
} catch (Throwable th2) {
th2.printStackTrace();
}
}
}
private final Notification a() {
String str;
String a2;
String str2;
String str3;
String str4;
Object systemService = getSystemService("notification");
if (systemService == null) {
throw new t("null cannot be cast to non-null type android.app.NotificationManager");
}
NotificationManager notificationManager = (NotificationManager) systemService;
FinAppConfig finAppConfig = FinAppClient.INSTANCE.getFinAppConfig();
FinAppConfig.ForegroundServiceConfig foregroundServiceConfig = finAppConfig != null ? finAppConfig.getForegroundServiceConfig() : null;
if (foregroundServiceConfig == null || (str = foregroundServiceConfig.notificationChannelId) == null) {
str = "notification_channel_id_01";
}
int i = Build.VERSION.SDK_INT;
if (i >= 26) {
if (foregroundServiceConfig == null || (str3 = foregroundServiceConfig.notificationChannelName) == null) {
str3 = "Foreground Service Notification";
}
NotificationChannel notificationChannel = new NotificationChannel(str, str3, 1);
if (foregroundServiceConfig == null || (str4 = foregroundServiceConfig.notificationChannelDesc) == null) {
str4 = "Channel description";
}
notificationChannel.setDescription(str4);
notificationChannel.setLightColor(-65536);
notificationManager.createNotificationChannel(notificationChannel);
}
Notification.Builder builder = i >= 26 ? new Notification.Builder(this, str) : new Notification.Builder(this);
builder.setSmallIcon(foregroundServiceConfig != null ? foregroundServiceConfig.notificationIcon : 0);
if (foregroundServiceConfig == null || (a2 = foregroundServiceConfig.notificationTitle) == null) {
a2 = s.a(getString(R.string.fin_applet_applet_running), null, 1, null);
}
builder.setContentTitle(a2);
if (foregroundServiceConfig == null || (str2 = foregroundServiceConfig.notificationContent) == null) {
str2 = "";
}
builder.setContentText(str2);
builder.setWhen(System.currentTimeMillis());
Notification build = builder.build();
n.e(build, "builder.build()");
return build;
}
private final void a(String str) {
Log.d(b, "startForeground " + this.a + ", " + str);
if (this.a) {
return;
}
this.a = true;
startForeground(12, a());
}
private final void b() {
this.a = false;
stopForeground(true);
}
@Override
@Nullable
public IBinder onBind(Intent intent) {
n.j(intent, "intent");
Log.d(b, "onBind");
return null;
}
@Override
public void onCreate() {
super.onCreate();
Log.d(b, "onCreate");
a("onCreate");
}
@Override
public void onDestroy() {
Log.d(b, "onDestroy");
b();
super.onDestroy();
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.d(b, "onStartCommand");
a("onStartCommand");
return super.onStartCommand(intent, flags, startId);
}
}