正在查看: Dostt v1.0.89 应用的 ForegroundService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Dostt v1.0.89 应用的 ForegroundService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.supersami.foregroundservice;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.Service;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.util.Log;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.modules.core.DeviceEventManagerModule;
import com.truecaller.android.sdk.legacy.TruecallerSdkScope;
public class ForegroundService extends Service {
private static ForegroundService e;
private static Bundle f;
private static ReactContext o;
public Bundle b;
private int a = 0;
private Handler c = new Handler();
private Runnable d = new a();
class a implements Runnable {
a() {
}
@Override
public void run() {
Intent intent = new Intent(ForegroundService.this.getApplicationContext(), (Class<?>) ForegroundServiceTask.class);
intent.putExtras(ForegroundService.this.b);
ForegroundService.this.getApplicationContext().startService(intent);
ForegroundService.this.b.getDouble("delay");
int i = (int) ForegroundService.this.b.getDouble("loopDelay");
Log.d("SuperLog", "" + i);
ForegroundService.this.c.postDelayed(this, (long) i);
}
}
class b implements Runnable {
final Intent a;
b(Intent intent) {
this.a = intent;
}
@Override
public void run() {
if (ForegroundService.this.a <= 0) {
return;
}
try {
ForegroundService.this.getApplicationContext().startService(this.a);
} catch (Exception e) {
Log.e("ForegroundService", "Failed to start delayed headless task: " + e.getMessage());
}
}
}
public static ForegroundService c() {
if (e()) {
return e;
}
return null;
}
public static boolean e() {
try {
ForegroundService foregroundService = e;
if (foregroundService != null) {
return foregroundService.g();
}
return false;
} catch (NullPointerException unused) {
return false;
}
}
private int f(String str) {
str.hashCode();
switch (str) {
case "mediaPlayback":
return 2;
case "camera":
return 64;
case "health":
return 256;
case "phoneCall":
return 4;
case "specialUse":
return 1073741824;
case "shortService":
return TruecallerSdkScope.BUTTON_SHAPE_RECTANGLE;
case "remoteMessaging":
return 512;
case "connectedDevice":
return 16;
case "mediaProjection":
return 32;
case "systemExempted":
return 1024;
case "microphone":
return 128;
case "dataSync":
return 1;
case "location":
return 8;
default:
throw new IllegalArgumentException("Unknown foreground service type: " + str);
}
}
private boolean g() {
return true;
}
public static void i(ReactContext reactContext) {
o = reactContext;
}
private boolean j(Bundle bundle) {
try {
int i = (int) bundle.getDouble("id");
String string = bundle.getString("ServiceType");
Notification a2 = com.supersami.foregroundservice.b.c(getApplicationContext()).a(getApplicationContext(), bundle);
if (Build.VERSION.SDK_INT >= 29) {
startForeground(i, a2, f(string));
} else {
startForeground(i, a2);
}
this.a++;
f = bundle;
return true;
} catch (Exception e2) {
if (o == null) {
return false;
}
Log.e("ForegroundService", "Failed to start service: " + e2.getMessage());
o.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("onServiceError", e2.getMessage());
return false;
}
}
public int d() {
return this.a;
}
public void h(Bundle bundle) {
Intent intent = new Intent(getApplicationContext(), (Class<?>) ForegroundServiceTask.class);
intent.putExtras(bundle);
int i = (int) bundle.getDouble("delay");
if (i <= 0) {
getApplicationContext().startService(intent);
} else {
new Handler().postDelayed(new b(intent), i);
}
}
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onCreate() {
this.a = 0;
e = this;
}
@Override
public void onDestroy() {
this.c.removeCallbacks(this.d);
this.a = 0;
e = null;
}
@Override
public int onStartCommand(Intent intent, int i, int i2) {
String action = intent.getAction();
if (action != null) {
if (action.equals("com.supersami.foregroundservice.service_start") && intent.getExtras() != null && intent.getExtras().containsKey("com.supersami.foregroundservice.notif_config")) {
j(intent.getExtras().getBundle("com.supersami.foregroundservice.notif_config"));
}
if (action.equals("com.supersami.foregroundservice.service_update_notification")) {
if (intent.getExtras() != null && intent.getExtras().containsKey("com.supersami.foregroundservice.notif_config")) {
Bundle bundle = intent.getExtras().getBundle("com.supersami.foregroundservice.notif_config");
if (this.a <= 0) {
Log.d("ForegroundService", "Update Notification called without a running service, trying to restart service.");
j(bundle);
} else {
try {
int i3 = (int) bundle.getDouble("id");
Notification a2 = com.supersami.foregroundservice.b.c(getApplicationContext()).a(getApplicationContext(), bundle);
getApplicationContext();
((NotificationManager) getSystemService("notification")).notify(i3, a2);
f = bundle;
} catch (Exception e2) {
Log.e("ForegroundService", "Failed to update notification: " + e2.getMessage());
}
}
}
} else if (action.equals("com.supersami.foregroundservice.service_run_task")) {
int i4 = this.a;
if (i4 <= 0 && f == null) {
Log.e("ForegroundService", "Service is not running to run tasks.");
stopSelf();
return 2;
}
if (i4 <= 0) {
Log.d("ForegroundService", "Run Task called without a running service, trying to restart service.");
if (!j(f)) {
Log.e("ForegroundService", "Service is not running to run tasks.");
return 3;
}
}
if (intent.getExtras() != null && intent.getExtras().containsKey("com.supersami.foregroundservice.task_config")) {
Bundle bundle2 = intent.getExtras().getBundle("com.supersami.foregroundservice.task_config");
this.b = bundle2;
try {
if (bundle2.getBoolean("onLoop")) {
this.c.post(this.d);
} else {
h(this.b);
}
} catch (Exception e3) {
Log.e("ForegroundService", "Failed to start task: " + e3.getMessage());
}
}
} else {
if (action.equals("com.supersami.foregroundservice.service_stop")) {
int i5 = this.a;
if (i5 > 0) {
int i6 = i5 - 1;
this.a = i6;
if (i6 == 0) {
stopSelf();
f = null;
}
} else {
Log.d("ForegroundService", "Service is not running to stop.");
stopSelf();
f = null;
}
return 2;
}
if (action.equals("com.supersami.foregroundservice.service_all")) {
this.a = 0;
e = null;
f = null;
stopSelf();
return 2;
}
}
}
return 3;
}
}