Prioritize FGS jobs over BFGS jobs

Also improve dumpsys output for priorities.

Also now "evaluated priority" is always printed, for easier debugging.

Bug: 111360323
Test: atest CtsJobSchedulerTestCases

Change-Id: Iee74eda5fb290cf46e7c8fdd74a0804d03328d29
This commit is contained in:
Makoto Onuki
2018-12-05 13:22:24 -08:00
parent 5d2308b3e9
commit ec8b14d02e
3 changed files with 53 additions and 19 deletions

View File

@@ -200,12 +200,23 @@ public class JobInfo implements Parcelable {
public static final int PRIORITY_SYNC_INITIALIZATION = 20;
/**
* Value of {@link #getPriority} for a foreground app (overrides the supplied
* Value of {@link #getPriority} for a BFGS app (overrides the supplied
* JobInfo priority if it is smaller).
* @hide
*/
public static final int PRIORITY_BOUND_FOREGROUND_SERVICE = 30;
/** @hide For backward compatibility. */
@UnsupportedAppUsage
public static final int PRIORITY_FOREGROUND_APP = PRIORITY_BOUND_FOREGROUND_SERVICE;
/**
* Value of {@link #getPriority} for a FG service app (overrides the supplied
* JobInfo priority if it is smaller).
* @hide
*/
@UnsupportedAppUsage
public static final int PRIORITY_FOREGROUND_APP = 30;
public static final int PRIORITY_FOREGROUND_SERVICE = 35;
/**
* Value of {@link #getPriority} for the current top app (overrides the supplied
@@ -1593,4 +1604,29 @@ public class JobInfo implements Parcelable {
return new JobInfo(this);
}
}
/**
* Convert a priority integer into a human readable string for debugging.
* @hide
*/
public static String getPriorityString(int priority) {
switch (priority) {
case PRIORITY_DEFAULT:
return PRIORITY_DEFAULT + " [DEFAULT]";
case PRIORITY_SYNC_EXPEDITED:
return PRIORITY_SYNC_EXPEDITED + " [SYNC_EXPEDITED]";
case PRIORITY_SYNC_INITIALIZATION:
return PRIORITY_SYNC_INITIALIZATION + " [SYNC_INITIALIZATION]";
case PRIORITY_BOUND_FOREGROUND_SERVICE:
return PRIORITY_BOUND_FOREGROUND_SERVICE + " [BFGS_APP]";
case PRIORITY_FOREGROUND_SERVICE:
return PRIORITY_FOREGROUND_SERVICE + " [FGS_APP]";
case PRIORITY_TOP_APP:
return PRIORITY_TOP_APP + " [TOP_APP]";
// PRIORITY_ADJ_* are adjustments and not used as real priorities.
// No need to convert to strings.
}
return priority + " [UNKNOWN]";
}
}