正在查看: Life Church v15.20.21 应用的 LocationTaskService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Life Church v15.20.21 应用的 LocationTaskService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package expo.modules.location.services;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Binder;
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Log;
public class LocationTaskService extends Service {
private static final String TAG = "LocationTaskService";
private static int sServiceId = 481756;
private final IBinder mBinder;
private String mChannelId;
private boolean mKillService = false;
private Context mParentContext;
private int mServiceId;
public LocationTaskService() {
int i = sServiceId;
sServiceId = i + 1;
this.mServiceId = i;
this.mBinder = new ServiceBinder();
}
public class ServiceBinder extends Binder {
public ServiceBinder() {
}
public LocationTaskService getService() {
return LocationTaskService.this;
}
}
@Override
public IBinder onBind(Intent intent) {
Log.w(TAG, "onBind");
return this.mBinder;
}
@Override
public int onStartCommand(Intent intent, int i, int i2) {
Bundle extras = intent.getExtras();
if (extras == null) {
return 3;
}
this.mChannelId = extras.getString("appId") + ":" + extras.getString("taskName");
this.mKillService = extras.getBoolean("killService", false);
return 3;
}
public void setParentContext(Context context) {
this.mParentContext = context;
}
public void stop() {
stopForeground(true);
stopSelf();
}
@Override
public void onTaskRemoved(Intent intent) {
if (this.mKillService) {
super.onTaskRemoved(intent);
stop();
}
}
public void startForeground(Bundle bundle) {
startForeground(this.mServiceId, buildServiceNotification(bundle));
}
private Notification buildServiceNotification(Bundle bundle) {
prepareChannel(this.mChannelId);
Notification.Builder builder = new Notification.Builder(this, this.mChannelId);
String string = bundle.getString("notificationTitle");
String string2 = bundle.getString("notificationBody");
Integer colorStringToInteger = colorStringToInteger(bundle.getString("notificationColor"));
if (string != null) {
builder.setContentTitle(string);
}
if (string2 != null) {
builder.setContentText(string2);
}
if (colorStringToInteger != null) {
builder.setColorized(true).setColor(colorStringToInteger.intValue());
} else {
builder.setColorized(false);
}
Intent launchIntentForPackage = this.mParentContext.getPackageManager().getLaunchIntentForPackage(this.mParentContext.getPackageName());
if (launchIntentForPackage != null) {
launchIntentForPackage.setFlags(536870912);
builder.setContentIntent(PendingIntent.getActivity(this, 0, launchIntentForPackage, (Build.VERSION.SDK_INT >= 31 ? 33554432 : 0) | 134217728));
}
return builder.setCategory("service").setSmallIcon(getApplicationInfo().icon).build();
}
private void prepareChannel(String str) {
NotificationManager notificationManager = (NotificationManager) getSystemService("notification");
if (notificationManager != null) {
String charSequence = getApplicationInfo().loadLabel(getPackageManager()).toString();
if (notificationManager.getNotificationChannel(str) == null) {
NotificationChannel notificationChannel = new NotificationChannel(str, charSequence, 2);
notificationChannel.setDescription("Background location notification channel");
notificationManager.createNotificationChannel(notificationChannel);
}
}
}
private Integer colorStringToInteger(String str) {
try {
return Integer.valueOf(Color.parseColor(str));
} catch (Exception unused) {
return null;
}
}
}