正在查看: Online Loans v421.2.42 应用的 JobIntentService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Online Loans v421.2.42 应用的 JobIntentService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package org.infobip.mobile.messaging.platform;
import B5.E;
import B5.F;
import B5.G;
import B5.H;
import B5.I;
import android.annotation.SuppressLint;
import android.app.Service;
import android.app.job.JobInfo;
import android.app.job.JobParameters;
import android.app.job.JobScheduler;
import android.app.job.JobServiceEngine;
import android.app.job.JobWorkItem;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Build;
import android.os.IBinder;
import android.os.PowerManager;
import androidx.annotation.NonNull;
import java.util.ArrayList;
import java.util.HashMap;
public abstract class JobIntentService extends Service {
public static final Object j = new Object();
public static final HashMap k = new HashMap();
public CompatJobEngine a;
public WorkEnqueuer b;
public CommandProcessor e;
public boolean f = false;
public boolean g = false;
public boolean h = false;
public final ArrayList i;
@SuppressLint({"StaticFieldLeak"})
public final class CommandProcessor extends AsyncTask<Void, Void, Void> {
public CommandProcessor() {
}
@Override
public Void doInBackground(Void... voidArr) {
while (true) {
GenericWorkItem a = JobIntentService.this.a();
if (a == null) {
return null;
}
JobIntentService.this.onHandleWork(a.getIntent());
a.complete();
}
}
@Override
public void onCancelled(Void r1) {
JobIntentService.this.e();
}
@Override
public void onPostExecute(Void r1) {
JobIntentService.this.e();
}
}
public interface CompatJobEngine {
IBinder compatGetBinder();
GenericWorkItem dequeueWork();
}
public static final class CompatWorkEnqueuer extends WorkEnqueuer {
private final Context mContext;
private final PowerManager.WakeLock mLaunchWakeLock;
boolean mLaunchingService;
private final PowerManager.WakeLock mRunWakeLock;
boolean mServiceProcessing;
public CompatWorkEnqueuer(Context context, ComponentName componentName) {
super(componentName);
this.mContext = context.getApplicationContext();
PowerManager powerManager = (PowerManager) context.getSystemService("power");
PowerManager.WakeLock newWakeLock = powerManager.newWakeLock(1, componentName.getClassName() + ":launch");
this.mLaunchWakeLock = newWakeLock;
newWakeLock.setReferenceCounted(false);
PowerManager.WakeLock newWakeLock2 = powerManager.newWakeLock(1, componentName.getClassName() + ":run");
this.mRunWakeLock = newWakeLock2;
newWakeLock2.setReferenceCounted(false);
}
@Override
public void enqueueWork(Intent intent) {
Intent intent2 = new Intent(intent);
intent2.setComponent(this.mComponentName);
if (this.mContext.startService(intent2) != null) {
synchronized (this) {
try {
if (!this.mLaunchingService) {
this.mLaunchingService = true;
if (!this.mServiceProcessing) {
this.mLaunchWakeLock.acquire(60000L);
}
}
} finally {
}
}
}
}
@Override
public void serviceProcessingFinished() {
synchronized (this) {
try {
if (this.mServiceProcessing) {
if (this.mLaunchingService) {
this.mLaunchWakeLock.acquire(60000L);
}
this.mServiceProcessing = false;
this.mRunWakeLock.release();
}
} catch (Throwable th) {
throw th;
}
}
}
@Override
public void serviceProcessingStarted() {
synchronized (this) {
try {
if (!this.mServiceProcessing) {
this.mServiceProcessing = true;
this.mRunWakeLock.acquire(600000L);
this.mLaunchWakeLock.release();
}
} catch (Throwable th) {
throw th;
}
}
}
@Override
public void serviceStartReceived() {
synchronized (this) {
this.mLaunchingService = false;
}
}
}
public final class CompatWorkItem implements GenericWorkItem {
final Intent mIntent;
final int mStartId;
public CompatWorkItem(Intent intent, int i) {
this.mIntent = intent;
this.mStartId = i;
}
@Override
public void complete() {
JobIntentService.this.stopSelf(this.mStartId);
}
@Override
public Intent getIntent() {
return this.mIntent;
}
}
public interface GenericWorkItem {
void complete();
Intent getIntent();
}
public static final class JobServiceEngineImpl extends JobServiceEngine implements CompatJobEngine {
static final boolean DEBUG = false;
static final String TAG = "JobServiceEngineImpl";
final Object mLock;
JobParameters mParams;
final JobIntentService mService;
public final class WrapperWorkItem implements GenericWorkItem {
final JobWorkItem mJobWork;
public WrapperWorkItem(JobWorkItem jobWorkItem) {
this.mJobWork = jobWorkItem;
}
@Override
public void complete() {
synchronized (JobServiceEngineImpl.this.mLock) {
JobParameters jobParameters = JobServiceEngineImpl.this.mParams;
if (jobParameters != null) {
try {
G.a(jobParameters, this.mJobWork);
} catch (IllegalArgumentException | SecurityException unused) {
}
}
}
}
@Override
public Intent getIntent() {
return F.a(this.mJobWork);
}
}
public JobServiceEngineImpl(JobIntentService jobIntentService) {
super(jobIntentService);
this.mLock = new Object();
this.mService = jobIntentService;
}
@Override
public IBinder compatGetBinder() {
IBinder binder;
binder = getBinder();
return binder;
}
@Override
public GenericWorkItem dequeueWork() {
synchronized (this.mLock) {
JobParameters jobParameters = this.mParams;
if (jobParameters == null) {
return null;
}
try {
JobWorkItem a = E.a(jobParameters);
if (a == null) {
return null;
}
F.a(a).setExtrasClassLoader(this.mService.getClassLoader());
return new WrapperWorkItem(a);
} catch (SecurityException unused) {
return null;
}
}
}
@Override
public boolean onStartJob(JobParameters jobParameters) {
this.mParams = jobParameters;
this.mService.c(false);
return true;
}
@Override
public boolean onStopJob(JobParameters jobParameters) {
boolean b = this.mService.b();
synchronized (this.mLock) {
this.mParams = null;
}
return b;
}
}
public static final class JobWorkEnqueuer extends WorkEnqueuer {
private final JobInfo mJobInfo;
private final JobScheduler mJobScheduler;
public JobWorkEnqueuer(Context context, ComponentName componentName, int i) {
super(componentName);
ensureJobId(i);
this.mJobInfo = new JobInfo.Builder(i, this.mComponentName).setOverrideDeadline(0L).build();
this.mJobScheduler = (JobScheduler) context.getApplicationContext().getSystemService("jobscheduler");
}
@Override
public void enqueueWork(Intent intent) {
H.a(this.mJobScheduler, this.mJobInfo, I.a(intent));
}
}
public static abstract class WorkEnqueuer {
final ComponentName mComponentName;
boolean mHasJobId;
int mJobId;
public WorkEnqueuer(ComponentName componentName) {
this.mComponentName = componentName;
}
public abstract void enqueueWork(Intent intent);
public void ensureJobId(int i) {
if (!this.mHasJobId) {
this.mHasJobId = true;
this.mJobId = i;
} else {
if (this.mJobId == i) {
return;
}
throw new IllegalArgumentException("Given job ID " + i + " is different than previous " + this.mJobId);
}
}
public void serviceProcessingFinished() {
}
public void serviceProcessingStarted() {
}
public void serviceStartReceived() {
}
}
public JobIntentService() {
if (Build.VERSION.SDK_INT >= 26) {
this.i = null;
} else {
this.i = new ArrayList();
}
}
public static WorkEnqueuer d(Context context, ComponentName componentName, boolean z, int i) {
WorkEnqueuer compatWorkEnqueuer;
HashMap hashMap = k;
WorkEnqueuer workEnqueuer = (WorkEnqueuer) hashMap.get(componentName);
if (workEnqueuer == null) {
if (Build.VERSION.SDK_INT < 26) {
compatWorkEnqueuer = new CompatWorkEnqueuer(context, componentName);
} else {
if (!z) {
throw new IllegalArgumentException("Can't be here without a job id");
}
compatWorkEnqueuer = new JobWorkEnqueuer(context, componentName, i);
}
workEnqueuer = compatWorkEnqueuer;
hashMap.put(componentName, workEnqueuer);
}
return workEnqueuer;
}
public static void enqueueWork(@NonNull Context context, @NonNull Class cls, int i, @NonNull Intent intent) {
enqueueWork(context, new ComponentName(context, (Class<?>) cls), i, intent);
}
public GenericWorkItem a() {
GenericWorkItem dequeueWork;
CompatJobEngine compatJobEngine = this.a;
if (compatJobEngine != null && (dequeueWork = compatJobEngine.dequeueWork()) != null) {
return dequeueWork;
}
ArrayList arrayList = this.i;
if (arrayList == null) {
return null;
}
synchronized (arrayList) {
try {
if (this.i.size() > 0) {
return (GenericWorkItem) this.i.remove(0);
}
return null;
} catch (Throwable th) {
throw th;
}
}
}
public boolean b() {
CommandProcessor commandProcessor = this.e;
if (commandProcessor != null) {
commandProcessor.cancel(this.f);
}
this.g = true;
return onStopCurrentWork();
}
public void c(boolean z) {
if (this.e == null) {
this.e = new CommandProcessor();
WorkEnqueuer workEnqueuer = this.b;
if (workEnqueuer != null && z) {
workEnqueuer.serviceProcessingStarted();
}
this.e.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new Void[0]);
}
}
public void e() {
ArrayList arrayList = this.i;
if (arrayList != null) {
synchronized (arrayList) {
try {
this.e = null;
ArrayList arrayList2 = this.i;
if (arrayList2 != null && arrayList2.size() > 0) {
c(false);
} else if (!this.h) {
this.b.serviceProcessingFinished();
}
} finally {
}
}
}
}
public boolean isStopped() {
return this.g;
}
@Override
public IBinder onBind(@NonNull Intent intent) {
CompatJobEngine compatJobEngine = this.a;
if (compatJobEngine != null) {
return compatJobEngine.compatGetBinder();
}
return null;
}
@Override
public void onCreate() {
super.onCreate();
if (Build.VERSION.SDK_INT >= 26) {
this.a = new JobServiceEngineImpl(this);
this.b = null;
} else {
this.a = null;
this.b = d(this, new ComponentName(this, getClass()), false, 0);
}
}
@Override
public void onDestroy() {
super.onDestroy();
b();
ArrayList arrayList = this.i;
if (arrayList != null) {
synchronized (arrayList) {
this.h = true;
this.b.serviceProcessingFinished();
}
}
}
public abstract void onHandleWork(@NonNull Intent intent);
@Override
public int onStartCommand(Intent intent, int i, int i2) {
if (this.i == null) {
return 2;
}
this.b.serviceStartReceived();
synchronized (this.i) {
ArrayList arrayList = this.i;
if (intent == null) {
intent = new Intent();
}
arrayList.add(new CompatWorkItem(intent, i2));
c(true);
}
return 3;
}
public boolean onStopCurrentWork() {
return true;
}
public void setInterruptIfStopped(boolean z) {
this.f = z;
}
public static void enqueueWork(@NonNull Context context, @NonNull ComponentName componentName, int i, @NonNull Intent intent) {
if (intent == null) {
throw new IllegalArgumentException("work must not be null");
}
synchronized (j) {
WorkEnqueuer d = d(context, componentName, true, i);
d.ensureJobId(i);
d.enqueueWork(intent);
}
}
}