Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9a654b28 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Clean up JS code."

parents 24e5b93c 70d7e4d9
Loading
Loading
Loading
Loading
+1 −5
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package android.app.job;

import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.os.IBinder;
@@ -26,8 +25,6 @@ import android.os.Message;
import android.os.RemoteException;
import android.util.Log;

import com.android.internal.annotations.GuardedBy;

import java.lang.ref.WeakReference;

/**
@@ -206,8 +203,7 @@ public abstract class JobServiceEngine {

    /**
     * Call in to engine to report that a job has finished executing.  See
     * {@link JobService#jobFinished(JobParameters, boolean)}  JobService.jobFinished} for more
     * information.
     * {@link JobService#jobFinished(JobParameters, boolean)} for more information.
     */
    public void jobFinished(JobParameters params, boolean needsReschedule) {
        if (params == null) {
+3 −3
Original line number Diff line number Diff line
@@ -1054,6 +1054,7 @@ public class JobSchedulerService extends com.android.server.SystemService

    public int scheduleAsPackage(JobInfo job, JobWorkItem work, int uId, String packageName,
            int userId, String tag) {
        // Rate limit excessive schedule() calls.
        final String servicePkg = job.getService().getPackageName();
        if (job.isPersisted() && (packageName == null || packageName.equals(servicePkg))) {
            // Only limit schedule calls for persisted jobs scheduled by the app itself.
@@ -1358,8 +1359,7 @@ public class JobSchedulerService extends com.android.server.SystemService
                for (int i=0; i<mActiveServices.size(); i++) {
                    JobServiceContext jsc = mActiveServices.get(i);
                    final JobStatus executing = jsc.getRunningJobLocked();
                    if (executing != null
                            && (executing.getFlags() & JobInfo.FLAG_WILL_BE_FOREGROUND) == 0) {
                    if (executing != null && !executing.canRunInDoze()) {
                        jsc.cancelExecutingJobLocked(JobParameters.REASON_DEVICE_IDLE,
                                "cancelled due to doze");
                    }
@@ -1411,7 +1411,7 @@ public class JobSchedulerService extends com.android.server.SystemService
                final JobServiceContext jsc = mActiveServices.get(i);
                final JobStatus job = jsc.getRunningJobLocked();
                if (job != null
                        && (job.getJob().getFlags() & JobInfo.FLAG_WILL_BE_FOREGROUND) == 0
                        && !job.canRunInDoze()
                        && !job.dozeWhitelisted
                        && !job.uidActive) {
                    // We will report active if we have a job running and it is not an exception
+1 −2
Original line number Diff line number Diff line
@@ -189,8 +189,7 @@ public final class BackgroundJobsController extends StateController {
        final String packageName = jobStatus.getSourcePackageName();

        final boolean canRun = !mAppStateTracker.areJobsRestricted(uid, packageName,
                (jobStatus.getInternalFlags() & JobStatus.INTERNAL_FLAG_HAS_FOREGROUND_EXEMPTION)
                        != 0);
                jobStatus.canRunInBatterySaver());

        final boolean isActive;
        if (activeState == UNKNOWN) {
+1 −1
Original line number Diff line number Diff line
@@ -464,7 +464,7 @@ public final class ConnectivityController extends RestrictingController implemen
            NetworkCapabilities capabilities) {
        // TODO: consider matching against non-active networks

        final boolean ignoreBlocked = (jobStatus.getFlags() & JobInfo.FLAG_WILL_BE_FOREGROUND) != 0;
        final boolean ignoreBlocked = jobStatus.shouldIgnoreNetworkBlocking();
        final NetworkInfo info = mConnManager.getNetworkInfoForUid(network,
                jobStatus.getSourceUid(), ignoreBlocked);

+23 −5
Original line number Diff line number Diff line
@@ -470,7 +470,7 @@ public final class JobStatus {
        }
        this.requiredConstraints = requiredConstraints;
        mRequiredConstraintsOfInterest = requiredConstraints & CONSTRAINTS_OF_INTEREST;
        mReadyNotDozing = (job.getFlags() & JobInfo.FLAG_WILL_BE_FOREGROUND) != 0;
        mReadyNotDozing = canRunInDoze();
        if (standbyBucket == RESTRICTED_INDEX) {
            addDynamicConstraints(DYNAMIC_RESTRICTED_CONSTRAINTS);
        } else {
@@ -1036,6 +1036,22 @@ public final class JobStatus {
        mPersistedUtcTimes = null;
    }

    /**
     * @return true if the job is exempted from Doze restrictions and therefore allowed to run
     * in Doze.
     */
    public boolean canRunInDoze() {
        return (getFlags() & JobInfo.FLAG_WILL_BE_FOREGROUND) != 0;
    }

    boolean canRunInBatterySaver() {
        return (getInternalFlags() & INTERNAL_FLAG_HAS_FOREGROUND_EXEMPTION) != 0;
    }

    boolean shouldIgnoreNetworkBlocking() {
        return (getFlags() & JobInfo.FLAG_WILL_BE_FOREGROUND) != 0;
    }

    /** @return true if the constraint was changed, false otherwise. */
    boolean setChargingConstraintSatisfied(boolean state) {
        return setConstraintSatisfied(CONSTRAINT_CHARGING, state);
@@ -1086,7 +1102,7 @@ public final class JobStatus {
        dozeWhitelisted = whitelisted;
        if (setConstraintSatisfied(CONSTRAINT_DEVICE_NOT_DOZING, state)) {
            // The constraint was changed. Update the ready flag.
            mReadyNotDozing = state || (job.getFlags() & JobInfo.FLAG_WILL_BE_FOREGROUND) != 0;
            mReadyNotDozing = state || canRunInDoze();
            return true;
        }
        return false;
@@ -1771,9 +1787,11 @@ public final class JobStatus {
            pw.print(prefix); pw.print("  readyDeadlineSatisfied: ");
            pw.println(mReadyDeadlineSatisfied);
        }
        if (mDynamicConstraints != 0) {
            pw.print(prefix);
            pw.print("  readyDynamicSatisfied: ");
            pw.println(mReadyDynamicSatisfied);
        }
        pw.print(prefix);
        pw.print("  readyComponentEnabled: ");
        pw.println(serviceInfo != null);