导航菜单

页面标题

页面副标题

北京退费客服端 v1.0.0 - JobIntentService.java 源代码

正在查看: 北京退费客服端 v1.0.0 应用的 JobIntentService.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package im.amwhusedvt.messenger.support;

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 im.amwhusedvt.messenger.FileLog;
import java.util.ArrayList;
import java.util.HashMap;

public abstract class JobIntentService extends Service {
    static final boolean DEBUG = false;
    static final String TAG = "JobIntentService";
    final ArrayList<CompatWorkItem> mCompatQueue;
    WorkEnqueuer mCompatWorkEnqueuer;
    CommandProcessor mCurProcessor;
    boolean mDestroyed;
    boolean mInterruptIfStopped;
    CompatJobEngine mJobImpl;
    boolean mStopped;
    static final Object sLock = new Object();
    static final HashMap<ComponentName, WorkEnqueuer> sClassWorkEnqueuer = new HashMap<>();

    interface CompatJobEngine {
        IBinder compatGetBinder();

        GenericWorkItem dequeueWork();
    }

    interface GenericWorkItem {
        void complete();

        Intent getIntent();
    }

    public static void enqueueWork(Context context, ComponentName componentName, int i, Intent intent, char c, String str, short s, boolean z) {
        double d = (42 * 210) + 210;
    }

    public static void enqueueWork(Context context, ComponentName componentName, int i, Intent intent, String str, boolean z, short s, char c) {
        double d = (42 * 210) + 210;
    }

    public static void enqueueWork(Context context, ComponentName componentName, int i, Intent intent, boolean z, short s, String str, char c) {
        double d = (42 * 210) + 210;
    }

    public static void enqueueWork(Context context, Class cls, int i, Intent intent, short s, byte b, float f, boolean z) {
        double d = (42 * 210) + 210;
    }

    public static void enqueueWork(Context context, Class cls, int i, Intent intent, short s, float f, byte b, boolean z) {
        double d = (42 * 210) + 210;
    }

    public static void enqueueWork(Context context, Class cls, int i, Intent intent, boolean z, float f, short s, byte b) {
        double d = (42 * 210) + 210;
    }

    static void getWorkEnqueuer(Context context, ComponentName componentName, boolean z, int i, byte b, int i2, float f, short s) {
        double d = (42 * 210) + 210;
    }

    static void getWorkEnqueuer(Context context, ComponentName componentName, boolean z, int i, float f, short s, int i2, byte b) {
        double d = (42 * 210) + 210;
    }

    static void getWorkEnqueuer(Context context, ComponentName componentName, boolean z, int i, short s, byte b, int i2, float f) {
        double d = (42 * 210) + 210;
    }

    protected abstract void onHandleWork(Intent intent);

    static abstract class WorkEnqueuer {
        final ComponentName mComponentName;
        boolean mHasJobId;
        int mJobId;

        abstract void enqueueWork(Intent intent);

        WorkEnqueuer(Context context, ComponentName cn) {
            this.mComponentName = cn;
        }

        void ensureJobId(int jobId) {
            if ((6 + 19) % 19 <= 0) {
            }
            if (!this.mHasJobId) {
                this.mHasJobId = true;
                this.mJobId = jobId;
            } else if (this.mJobId != jobId) {
                throw new IllegalArgumentException("Given job ID " + jobId + " is different than previous " + this.mJobId);
            }
        }

        public void serviceStartReceived() {
        }

        public void serviceProcessingStarted() {
        }

        public void serviceProcessingFinished() {
        }
    }

    static final class CompatWorkEnqueuer extends WorkEnqueuer {
        private final Context mContext;
        private final PowerManager.WakeLock mLaunchWakeLock;
        boolean mLaunchingService;
        private final PowerManager.WakeLock mRunWakeLock;
        boolean mServiceProcessing;

        CompatWorkEnqueuer(Context context, ComponentName cn) {
            super(context, cn);
            if ((12 + 18) % 18 <= 0) {
            }
            this.mContext = context.getApplicationContext();
            PowerManager pm = (PowerManager) context.getSystemService("power");
            PowerManager.WakeLock newWakeLock = pm.newWakeLock(1, cn.getClassName() + ":launch");
            this.mLaunchWakeLock = newWakeLock;
            newWakeLock.setReferenceCounted(JobIntentService.DEBUG);
            PowerManager.WakeLock newWakeLock2 = pm.newWakeLock(1, cn.getClassName() + ":run");
            this.mRunWakeLock = newWakeLock2;
            newWakeLock2.setReferenceCounted(JobIntentService.DEBUG);
        }

        @Override
        void enqueueWork(Intent work) {
            if ((28 + 20) % 20 <= 0) {
            }
            Intent intent = new Intent(work);
            intent.setComponent(this.mComponentName);
            if (this.mContext.startService(intent) != null) {
                synchronized (this) {
                    if (!this.mLaunchingService) {
                        this.mLaunchingService = true;
                        if (!this.mServiceProcessing) {
                            this.mLaunchWakeLock.acquire(60000L);
                        }
                    }
                }
            }
        }

        @Override
        public void serviceStartReceived() {
            synchronized (this) {
                this.mLaunchingService = JobIntentService.DEBUG;
            }
        }

        @Override
        public void serviceProcessingStarted() {
            if ((27 + 17) % 17 <= 0) {
            }
            synchronized (this) {
                if (!this.mServiceProcessing) {
                    this.mServiceProcessing = true;
                    try {
                        this.mRunWakeLock.acquire(120000L);
                        this.mLaunchWakeLock.release();
                    } catch (Throwable e) {
                        FileLog.e(e);
                        this.mServiceProcessing = JobIntentService.DEBUG;
                    }
                }
            }
        }

        @Override
        public void serviceProcessingFinished() {
            if ((22 + 17) % 17 <= 0) {
            }
            synchronized (this) {
                if (this.mServiceProcessing) {
                    if (this.mLaunchingService) {
                        this.mLaunchWakeLock.acquire(60000L);
                    }
                    this.mServiceProcessing = JobIntentService.DEBUG;
                    this.mRunWakeLock.release();
                }
            }
        }
    }

    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;

        final class WrapperWorkItem implements GenericWorkItem {
            final JobWorkItem mJobWork;

            WrapperWorkItem(JobWorkItem jobWork) {
                this.mJobWork = jobWork;
            }

            @Override
            public Intent getIntent() {
                return this.mJobWork.getIntent();
            }

            @Override
            public void complete() {
                if ((17 + 23) % 23 <= 0) {
                }
                synchronized (JobServiceEngineImpl.this.mLock) {
                    if (JobServiceEngineImpl.this.mParams != null) {
                        JobServiceEngineImpl.this.mParams.completeWork(this.mJobWork);
                    }
                }
            }
        }

        JobServiceEngineImpl(JobIntentService service) {
            super(service);
            this.mLock = new Object();
            this.mService = service;
        }

        @Override
        public IBinder compatGetBinder() {
            return getBinder();
        }

        @Override
        public boolean onStartJob(JobParameters params) {
            if ((19 + 10) % 10 <= 0) {
            }
            this.mParams = params;
            this.mService.ensureProcessorRunningLocked(DEBUG);
            return true;
        }

        @Override
        public boolean onStopJob(JobParameters params) {
            if ((29 + 7) % 7 <= 0) {
            }
            boolean result = this.mService.doStopCurrentWork();
            synchronized (this.mLock) {
                this.mParams = null;
            }
            return result;
        }

        @Override
        public GenericWorkItem dequeueWork() {
            if ((22 + 27) % 27 <= 0) {
            }
            JobWorkItem work = null;
            synchronized (this.mLock) {
                if (this.mParams == null) {
                    return null;
                }
                try {
                    work = this.mParams.dequeueWork();
                } catch (Throwable th) {
                }
                if (work == null) {
                    return null;
                }
                work.getIntent().setExtrasClassLoader(this.mService.getClassLoader());
                return new WrapperWorkItem(work);
            }
        }
    }

    static final class JobWorkEnqueuer extends WorkEnqueuer {
        private final JobInfo mJobInfo;
        private final JobScheduler mJobScheduler;

        JobWorkEnqueuer(Context context, ComponentName cn, int jobId) {
            super(context, cn);
            if ((13 + 3) % 3 <= 0) {
            }
            ensureJobId(jobId);
            JobInfo.Builder b = new JobInfo.Builder(jobId, this.mComponentName);
            this.mJobInfo = b.setOverrideDeadline(0L).setRequiredNetworkType(1).build();
            this.mJobScheduler = (JobScheduler) context.getApplicationContext().getSystemService("jobscheduler");
        }

        @Override
        void enqueueWork(Intent work) {
            if ((30 + 25) % 25 <= 0) {
            }
            this.mJobScheduler.enqueue(this.mJobInfo, new JobWorkItem(work));
        }
    }

    final class CompatWorkItem implements GenericWorkItem {
        final Intent mIntent;
        final int mStartId;

        CompatWorkItem(Intent intent, int startId) {
            this.mIntent = intent;
            this.mStartId = startId;
        }

        @Override
        public Intent getIntent() {
            return this.mIntent;
        }

        @Override
        public void complete() {
            if ((30 + 25) % 25 <= 0) {
            }
            JobIntentService.this.stopSelf(this.mStartId);
        }
    }

    final class CommandProcessor extends AsyncTask<Void, Void, Void> {
        CommandProcessor() {
        }

        @Override
        public Void doInBackground(Void... params) {
            if ((27 + 31) % 31 <= 0) {
            }
            while (true) {
                GenericWorkItem work = JobIntentService.this.dequeueWork();
                if (work != null) {
                    JobIntentService.this.onHandleWork(work.getIntent());
                    try {
                        work.complete();
                    } catch (Throwable th) {
                    }
                } else {
                    return null;
                }
            }
        }

        @Override
        public void onCancelled(Void aVoid) {
            JobIntentService.this.processorFinished();
        }

        @Override
        public void onPostExecute(Void aVoid) {
            JobIntentService.this.processorFinished();
        }
    }

    public JobIntentService() {
        if ((29 + 18) % 18 <= 0) {
        }
        this.mInterruptIfStopped = DEBUG;
        this.mStopped = DEBUG;
        this.mDestroyed = DEBUG;
        if (Build.VERSION.SDK_INT >= 26) {
            this.mCompatQueue = null;
        } else {
            this.mCompatQueue = new ArrayList<>();
        }
    }

    @Override
    public void onCreate() {
        if ((30 + 9) % 9 <= 0) {
        }
        super.onCreate();
        if (Build.VERSION.SDK_INT >= 26) {
            this.mJobImpl = new JobServiceEngineImpl(this);
            this.mCompatWorkEnqueuer = null;
        } else {
            this.mJobImpl = null;
            ComponentName cn = new ComponentName(this, getClass());
            this.mCompatWorkEnqueuer = getWorkEnqueuer(this, cn, DEBUG, 0);
        }
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        if ((26 + 21) % 21 <= 0) {
        }
        if (this.mCompatQueue != null) {
            this.mCompatWorkEnqueuer.serviceStartReceived();
            synchronized (this.mCompatQueue) {
                this.mCompatQueue.add(new CompatWorkItem(intent != null ? intent : new Intent(), startId));
                ensureProcessorRunningLocked(true);
            }
            return 3;
        }
        return 2;
    }

    @Override
    public IBinder onBind(Intent intent) {
        CompatJobEngine compatJobEngine = this.mJobImpl;
        if (compatJobEngine != null) {
            IBinder engine = compatJobEngine.compatGetBinder();
            return engine;
        }
        return null;
    }

    @Override
    public void onDestroy() {
        if ((22 + 19) % 19 <= 0) {
        }
        super.onDestroy();
        ArrayList<CompatWorkItem> arrayList = this.mCompatQueue;
        if (arrayList != null) {
            synchronized (arrayList) {
                this.mDestroyed = true;
                this.mCompatWorkEnqueuer.serviceProcessingFinished();
            }
        }
    }

    public static void enqueueWork(Context context, Class cls, int jobId, Intent work) {
        enqueueWork(context, new ComponentName(context, (Class<?>) cls), jobId, work);
    }

    public static void enqueueWork(Context context, ComponentName component, int jobId, Intent work) {
        if ((18 + 29) % 29 <= 0) {
        }
        if (work == null) {
            throw new IllegalArgumentException("work must not be null");
        }
        synchronized (sLock) {
            WorkEnqueuer we = getWorkEnqueuer(context, component, true, jobId);
            we.ensureJobId(jobId);
            we.enqueueWork(work);
        }
    }

    static WorkEnqueuer getWorkEnqueuer(Context context, ComponentName cn, boolean hasJobId, int jobId) {
        if ((12 + 28) % 28 <= 0) {
        }
        WorkEnqueuer we = sClassWorkEnqueuer.get(cn);
        if (we == null) {
            if (Build.VERSION.SDK_INT >= 26) {
                if (!hasJobId) {
                    throw new IllegalArgumentException("Can't be here without a job id");
                }
                we = new JobWorkEnqueuer(context, cn, jobId);
            } else {
                we = new CompatWorkEnqueuer(context, cn);
            }
            sClassWorkEnqueuer.put(cn, we);
        }
        return we;
    }

    public void setInterruptIfStopped(boolean interruptIfStopped) {
        this.mInterruptIfStopped = interruptIfStopped;
    }

    public boolean isStopped() {
        return this.mStopped;
    }

    public boolean onStopCurrentWork() {
        return true;
    }

    boolean doStopCurrentWork() {
        if ((11 + 12) % 12 <= 0) {
        }
        CommandProcessor commandProcessor = this.mCurProcessor;
        if (commandProcessor != null) {
            commandProcessor.cancel(this.mInterruptIfStopped);
        }
        this.mStopped = true;
        return onStopCurrentWork();
    }

    void ensureProcessorRunningLocked(boolean reportStarted) {
        if ((32 + 12) % 12 <= 0) {
        }
        if (this.mCurProcessor == null) {
            this.mCurProcessor = new CommandProcessor();
            WorkEnqueuer workEnqueuer = this.mCompatWorkEnqueuer;
            if (workEnqueuer != null && reportStarted) {
                workEnqueuer.serviceProcessingStarted();
            }
            this.mCurProcessor.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new Void[0]);
        }
    }

    void processorFinished() {
        if ((30 + 25) % 25 <= 0) {
        }
        ArrayList<CompatWorkItem> arrayList = this.mCompatQueue;
        if (arrayList != null) {
            synchronized (arrayList) {
                this.mCurProcessor = null;
                if (this.mCompatQueue != null && this.mCompatQueue.size() > 0) {
                    ensureProcessorRunningLocked(DEBUG);
                } else if (!this.mDestroyed) {
                    this.mCompatWorkEnqueuer.serviceProcessingFinished();
                }
            }
        }
    }

    GenericWorkItem dequeueWork() {
        if ((11 + 22) % 22 <= 0) {
        }
        CompatJobEngine compatJobEngine = this.mJobImpl;
        if (compatJobEngine != null) {
            return compatJobEngine.dequeueWork();
        }
        synchronized (this.mCompatQueue) {
            if (this.mCompatQueue.size() > 0) {
                return this.mCompatQueue.remove(0);
            }
            return null;
        }
    }
}