Merge "Revert "Calc job standby runnability based on last job execution...""
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.android.server.job;
|
||||
|
||||
import android.annotation.UserIdInt;
|
||||
import android.app.job.JobInfo;
|
||||
|
||||
import java.util.List;
|
||||
@@ -39,14 +38,6 @@ public interface JobSchedulerInternal {
|
||||
*/
|
||||
long nextHeartbeatForBucket(int bucket);
|
||||
|
||||
/**
|
||||
* Heartbeat ordinal for the given app. This is typically the heartbeat at which
|
||||
* the app last ran jobs, so that a newly-scheduled job in an app that hasn't run
|
||||
* jobs in a long time is immediately runnable even if the app is bucketed into
|
||||
* an infrequent time allocation.
|
||||
*/
|
||||
public long baseHeartbeatForApp(String packageName, @UserIdInt int userId, int appBucket);
|
||||
|
||||
/**
|
||||
* Returns a list of pending jobs scheduled by the system service.
|
||||
*/
|
||||
|
||||
@@ -19,7 +19,6 @@ package com.android.server.job;
|
||||
import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
|
||||
import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER;
|
||||
|
||||
import android.annotation.UserIdInt;
|
||||
import android.app.Activity;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.AppGlobals;
|
||||
@@ -39,7 +38,6 @@ import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.Intent.UriFlags;
|
||||
import android.content.pm.IPackageManager;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManagerInternal;
|
||||
@@ -2021,29 +2019,6 @@ public final class JobSchedulerService extends com.android.server.SystemService
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Heartbeat ordinal for the given app. This is typically the heartbeat at which
|
||||
* the app last ran jobs, so that a newly-scheduled job in an app that hasn't run
|
||||
* jobs in a long time is immediately runnable even if the app is bucketed into
|
||||
* an infrequent time allocation.
|
||||
*/
|
||||
public long baseHeartbeatForApp(String packageName, @UserIdInt int userId,
|
||||
final int appStandbyBucket) {
|
||||
if (appStandbyBucket == 0) {
|
||||
// Active => everything can be run right away
|
||||
return 0;
|
||||
}
|
||||
final long timeSinceLastJob = mStandbyTracker.getTimeSinceLastJobRun(
|
||||
packageName, userId);
|
||||
final long bucketLength = mConstants.STANDBY_BEATS[appStandbyBucket];
|
||||
final long bucketsAgo = timeSinceLastJob / bucketLength;
|
||||
|
||||
// If we haven't run any jobs for more than the app's current bucket period, just
|
||||
// consider anything new to be immediately runnable. Otherwise, base it on the
|
||||
// bucket at which we last ran jobs.
|
||||
return (bucketsAgo > bucketLength) ? 0 : (getCurrentHeartbeat() - bucketsAgo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of all pending jobs. A running job is not considered pending. Periodic
|
||||
* jobs are always considered pending.
|
||||
@@ -2119,14 +2094,10 @@ public final class JobSchedulerService extends com.android.server.SystemService
|
||||
mUsageStats = usageStats;
|
||||
}
|
||||
|
||||
public long getTimeSinceLastJobRun(String packageName, final @UserIdInt int userId) {
|
||||
return mUsageStats.getTimeSinceLastJobRun(packageName, userId);
|
||||
}
|
||||
|
||||
// AppIdleStateChangeListener interface for live updates
|
||||
|
||||
@Override
|
||||
public void onAppIdleStateChanged(final String packageName, final @UserIdInt int userId,
|
||||
public void onAppIdleStateChanged(final String packageName, final int userId,
|
||||
boolean idle, int bucket) {
|
||||
final int uid = mLocalPM.getPackageUid(packageName,
|
||||
PackageManager.MATCH_UNINSTALLED_PACKAGES, userId);
|
||||
|
||||
@@ -394,9 +394,7 @@ public final class JobStatus {
|
||||
int standbyBucket = JobSchedulerService.standbyBucketForPackage(jobPackage,
|
||||
sourceUserId, elapsedNow);
|
||||
JobSchedulerInternal js = LocalServices.getService(JobSchedulerInternal.class);
|
||||
long currentHeartbeat = js != null
|
||||
? js.baseHeartbeatForApp(jobPackage, sourceUserId, standbyBucket)
|
||||
: 0;
|
||||
long currentHeartbeat = js != null ? js.currentHeartbeat() : 0;
|
||||
return new JobStatus(job, callingUid, resolveTargetSdkVersion(job), sourcePkg, sourceUserId,
|
||||
standbyBucket, currentHeartbeat, tag, 0,
|
||||
earliestRunTimeElapsedMillis, latestRunTimeElapsedMillis,
|
||||
|
||||
Reference in New Issue
Block a user