Files
rr3-apk/decompiled-community/sources/androidx/core/app/JobIntentService.java
Daniel Elliott c080f0d97f Add Discord community version (64-bit only)
- Added realracing3-community.apk (71.57 MB)
- Removed 32-bit support (armeabi-v7a)
- Only includes arm64-v8a libraries
- Decompiled source code included
- Added README-community.md with analysis
2026-02-18 15:48:36 -08:00

452 lines
16 KiB
Java

package androidx.core.app;
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.IBinder;
import android.os.PowerManager;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import com.facebook.AuthenticationTokenClaims;
import com.mbridge.msdk.playercommon.exoplayer2.source.chunk.ChunkedTrackBlacklistUtil;
import java.util.ArrayList;
import java.util.HashMap;
@Deprecated
/* loaded from: classes.dex */
public abstract class JobIntentService extends Service {
static final boolean DEBUG = false;
static final String TAG = "JobIntentService";
WorkEnqueuer mCompatWorkEnqueuer;
CommandProcessor mCurProcessor;
CompatJobEngine mJobImpl;
static final Object sLock = new Object();
static final HashMap<ComponentName, WorkEnqueuer> sClassWorkEnqueuer = new HashMap<>();
boolean mInterruptIfStopped = false;
boolean mStopped = false;
boolean mDestroyed = false;
final ArrayList<CompatWorkItem> mCompatQueue = null;
public interface CompatJobEngine {
IBinder compatGetBinder();
GenericWorkItem dequeueWork();
}
public interface GenericWorkItem {
void complete();
Intent getIntent();
}
public boolean isStopped() {
return this.mStopped;
}
public abstract void onHandleWork(@NonNull Intent intent);
public boolean onStopCurrentWork() {
return true;
}
public void setInterruptIfStopped(boolean z) {
this.mInterruptIfStopped = z;
}
public static abstract class WorkEnqueuer {
final ComponentName mComponentName;
boolean mHasJobId;
int mJobId;
public abstract void enqueueWork(Intent intent);
public void serviceProcessingFinished() {
}
public void serviceProcessingStarted() {
}
public void serviceStartReceived() {
}
public WorkEnqueuer(ComponentName componentName) {
this.mComponentName = componentName;
}
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 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 // androidx.core.app.JobIntentService.WorkEnqueuer
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(ChunkedTrackBlacklistUtil.DEFAULT_TRACK_BLACKLIST_MS);
}
}
} finally {
}
}
}
}
@Override // androidx.core.app.JobIntentService.WorkEnqueuer
public void serviceStartReceived() {
synchronized (this) {
this.mLaunchingService = false;
}
}
@Override // androidx.core.app.JobIntentService.WorkEnqueuer
public void serviceProcessingStarted() {
synchronized (this) {
try {
if (!this.mServiceProcessing) {
this.mServiceProcessing = true;
this.mRunWakeLock.acquire(AuthenticationTokenClaims.MAX_TIME_SINCE_TOKEN_ISSUED);
this.mLaunchWakeLock.release();
}
} catch (Throwable th) {
throw th;
}
}
}
@Override // androidx.core.app.JobIntentService.WorkEnqueuer
public void serviceProcessingFinished() {
synchronized (this) {
try {
if (this.mServiceProcessing) {
if (this.mLaunchingService) {
this.mLaunchWakeLock.acquire(ChunkedTrackBlacklistUtil.DEFAULT_TRACK_BLACKLIST_MS);
}
this.mServiceProcessing = false;
this.mRunWakeLock.release();
}
} catch (Throwable th) {
throw th;
}
}
}
}
@RequiresApi(26)
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 // androidx.core.app.JobIntentService.GenericWorkItem
public Intent getIntent() {
return this.mJobWork.getIntent();
}
@Override // androidx.core.app.JobIntentService.GenericWorkItem
public void complete() {
synchronized (JobServiceEngineImpl.this.mLock) {
try {
JobParameters jobParameters = JobServiceEngineImpl.this.mParams;
if (jobParameters != null) {
jobParameters.completeWork(this.mJobWork);
}
} catch (Throwable th) {
throw th;
}
}
}
}
public JobServiceEngineImpl(JobIntentService jobIntentService) {
super(jobIntentService);
this.mLock = new Object();
this.mService = jobIntentService;
}
@Override // androidx.core.app.JobIntentService.CompatJobEngine
public IBinder compatGetBinder() {
return getBinder();
}
@Override // android.app.job.JobServiceEngine
public boolean onStartJob(JobParameters jobParameters) {
this.mParams = jobParameters;
this.mService.ensureProcessorRunningLocked(false);
return true;
}
@Override // android.app.job.JobServiceEngine
public boolean onStopJob(JobParameters jobParameters) {
boolean doStopCurrentWork = this.mService.doStopCurrentWork();
synchronized (this.mLock) {
this.mParams = null;
}
return doStopCurrentWork;
}
@Override // androidx.core.app.JobIntentService.CompatJobEngine
public GenericWorkItem dequeueWork() {
synchronized (this.mLock) {
try {
JobParameters jobParameters = this.mParams;
if (jobParameters == null) {
return null;
}
JobWorkItem dequeueWork = jobParameters.dequeueWork();
if (dequeueWork == null) {
return null;
}
dequeueWork.getIntent().setExtrasClassLoader(this.mService.getClassLoader());
return new WrapperWorkItem(dequeueWork);
} catch (Throwable th) {
throw th;
}
}
}
}
@RequiresApi(26)
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 // androidx.core.app.JobIntentService.WorkEnqueuer
public void enqueueWork(Intent intent) {
this.mJobScheduler.enqueue(this.mJobInfo, new JobWorkItem(intent));
}
}
public final class CompatWorkItem implements GenericWorkItem {
final Intent mIntent;
final int mStartId;
@Override // androidx.core.app.JobIntentService.GenericWorkItem
public Intent getIntent() {
return this.mIntent;
}
public CompatWorkItem(Intent intent, int i) {
this.mIntent = intent;
this.mStartId = i;
}
@Override // androidx.core.app.JobIntentService.GenericWorkItem
public void complete() {
JobIntentService.this.stopSelf(this.mStartId);
}
}
public final class CommandProcessor extends AsyncTask<Void, Void, Void> {
public CommandProcessor() {
}
@Override // android.os.AsyncTask
public Void doInBackground(Void... voidArr) {
while (true) {
GenericWorkItem dequeueWork = JobIntentService.this.dequeueWork();
if (dequeueWork == null) {
return null;
}
JobIntentService.this.onHandleWork(dequeueWork.getIntent());
dequeueWork.complete();
}
}
@Override // android.os.AsyncTask
public void onCancelled(Void r1) {
JobIntentService.this.processorFinished();
}
@Override // android.os.AsyncTask
public void onPostExecute(Void r1) {
JobIntentService.this.processorFinished();
}
}
@Override // android.app.Service
public void onCreate() {
super.onCreate();
this.mJobImpl = new JobServiceEngineImpl(this);
this.mCompatWorkEnqueuer = null;
}
@Override // android.app.Service
public int onStartCommand(@Nullable Intent intent, int i, int i2) {
if (this.mCompatQueue == null) {
return 2;
}
this.mCompatWorkEnqueuer.serviceStartReceived();
synchronized (this.mCompatQueue) {
ArrayList<CompatWorkItem> arrayList = this.mCompatQueue;
if (intent == null) {
intent = new Intent();
}
arrayList.add(new CompatWorkItem(intent, i2));
ensureProcessorRunningLocked(true);
}
return 3;
}
@Override // android.app.Service
public IBinder onBind(@NonNull Intent intent) {
CompatJobEngine compatJobEngine = this.mJobImpl;
if (compatJobEngine != null) {
return compatJobEngine.compatGetBinder();
}
return null;
}
@Override // android.app.Service
public void onDestroy() {
super.onDestroy();
ArrayList<CompatWorkItem> arrayList = this.mCompatQueue;
if (arrayList != null) {
synchronized (arrayList) {
this.mDestroyed = true;
this.mCompatWorkEnqueuer.serviceProcessingFinished();
}
}
}
public static void enqueueWork(@NonNull Context context, @NonNull Class<?> cls, int i, @NonNull Intent intent) {
enqueueWork(context, new ComponentName(context, cls), i, intent);
}
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 (sLock) {
WorkEnqueuer workEnqueuer = getWorkEnqueuer(context, componentName, true, i);
workEnqueuer.ensureJobId(i);
workEnqueuer.enqueueWork(intent);
}
}
public static WorkEnqueuer getWorkEnqueuer(Context context, ComponentName componentName, boolean z, int i) {
HashMap<ComponentName, WorkEnqueuer> hashMap = sClassWorkEnqueuer;
WorkEnqueuer workEnqueuer = hashMap.get(componentName);
if (workEnqueuer != null) {
return workEnqueuer;
}
if (!z) {
throw new IllegalArgumentException("Can't be here without a job id");
}
JobWorkEnqueuer jobWorkEnqueuer = new JobWorkEnqueuer(context, componentName, i);
hashMap.put(componentName, jobWorkEnqueuer);
return jobWorkEnqueuer;
}
public boolean doStopCurrentWork() {
CommandProcessor commandProcessor = this.mCurProcessor;
if (commandProcessor != null) {
commandProcessor.cancel(this.mInterruptIfStopped);
}
this.mStopped = true;
return onStopCurrentWork();
}
public void ensureProcessorRunningLocked(boolean z) {
if (this.mCurProcessor == null) {
this.mCurProcessor = new CommandProcessor();
WorkEnqueuer workEnqueuer = this.mCompatWorkEnqueuer;
if (workEnqueuer != null && z) {
workEnqueuer.serviceProcessingStarted();
}
this.mCurProcessor.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new Void[0]);
}
}
public void processorFinished() {
ArrayList<CompatWorkItem> arrayList = this.mCompatQueue;
if (arrayList != null) {
synchronized (arrayList) {
try {
this.mCurProcessor = null;
ArrayList<CompatWorkItem> arrayList2 = this.mCompatQueue;
if (arrayList2 != null && arrayList2.size() > 0) {
ensureProcessorRunningLocked(false);
} else if (!this.mDestroyed) {
this.mCompatWorkEnqueuer.serviceProcessingFinished();
}
} finally {
}
}
}
}
public GenericWorkItem dequeueWork() {
CompatJobEngine compatJobEngine = this.mJobImpl;
if (compatJobEngine != null) {
return compatJobEngine.dequeueWork();
}
synchronized (this.mCompatQueue) {
try {
if (this.mCompatQueue.size() <= 0) {
return null;
}
return this.mCompatQueue.remove(0);
} catch (Throwable th) {
throw th;
}
}
}
}