Loading apex/jobscheduler/framework/java/android/app/job/JobInfo.java +4 −1 Original line number Diff line number Diff line Loading @@ -1791,7 +1791,10 @@ public class JobInfo implements Parcelable { * <ol> * <li>Run as soon as possible</li> * <li>Be less restricted during Doze and battery saver</li> * <li>Bypass Doze, app standby, and battery saver network restrictions</li> * <li> * Bypass Doze, app standby, and battery saver network restrictions (if the job * has a {@link #setRequiredNetwork(NetworkRequest) connectivity constraint}) * </li> * <li>Be less likely to be killed than regular jobs</li> * <li>Be subject to background location throttling</li> * <li>Be exempt from delay to optimize job execution</li> Loading apex/jobscheduler/service/java/com/android/server/job/JobServiceContext.java +15 −19 Original line number Diff line number Diff line Loading @@ -427,34 +427,30 @@ public final class JobServiceContext implements ServiceConnection { boolean binding = false; boolean startedWithForegroundFlag = false; try { final Context.BindServiceFlags bindFlags; long bindFlags = Context.BIND_AUTO_CREATE | Context.BIND_NOT_APP_COMPONENT_USAGE; if (job.shouldTreatAsUserInitiatedJob() && !job.isUserBgRestricted()) { // If the user has bg restricted the app, don't give the job FG privileges // such as bypassing data saver or getting the higher foreground proc state. // If we've gotten to this point, the app is most likely in the foreground, // so the job will run just fine while the user keeps the app in the foreground. bindFlags = Context.BindServiceFlags.of( Context.BIND_AUTO_CREATE | Context.BIND_ALMOST_PERCEPTIBLE | Context.BIND_BYPASS_POWER_NETWORK_RESTRICTIONS | Context.BIND_BYPASS_USER_NETWORK_RESTRICTIONS | Context.BIND_NOT_APP_COMPONENT_USAGE); bindFlags |= Context.BIND_ALMOST_PERCEPTIBLE; if (job.hasConnectivityConstraint()) { // Only add network restriction bypass flags if the job requires network. bindFlags |= Context.BIND_BYPASS_POWER_NETWORK_RESTRICTIONS | Context.BIND_BYPASS_USER_NETWORK_RESTRICTIONS; } startedWithForegroundFlag = true; } else if (job.shouldTreatAsExpeditedJob() || job.shouldTreatAsUserInitiatedJob()) { bindFlags = Context.BindServiceFlags.of( Context.BIND_AUTO_CREATE | Context.BIND_NOT_FOREGROUND | Context.BIND_ALMOST_PERCEPTIBLE | Context.BIND_BYPASS_POWER_NETWORK_RESTRICTIONS | Context.BIND_NOT_APP_COMPONENT_USAGE); bindFlags |= Context.BIND_NOT_FOREGROUND | Context.BIND_ALMOST_PERCEPTIBLE; if (job.hasConnectivityConstraint()) { // Only add network restriction bypass flags if the job requires network. bindFlags |= Context.BIND_BYPASS_POWER_NETWORK_RESTRICTIONS; } } else { bindFlags = Context.BindServiceFlags.of( Context.BIND_AUTO_CREATE | Context.BIND_NOT_FOREGROUND | Context.BIND_NOT_PERCEPTIBLE | Context.BIND_NOT_APP_COMPONENT_USAGE); bindFlags |= Context.BIND_NOT_FOREGROUND | Context.BIND_NOT_PERCEPTIBLE; } binding = mContext.bindServiceAsUser(intent, this, bindFlags, binding = mContext.bindServiceAsUser(intent, this, Context.BindServiceFlags.of(bindFlags), UserHandle.of(job.getUserId())); } catch (SecurityException e) { // Some permission policy, for example INTERACT_ACROSS_USERS and Loading Loading
apex/jobscheduler/framework/java/android/app/job/JobInfo.java +4 −1 Original line number Diff line number Diff line Loading @@ -1791,7 +1791,10 @@ public class JobInfo implements Parcelable { * <ol> * <li>Run as soon as possible</li> * <li>Be less restricted during Doze and battery saver</li> * <li>Bypass Doze, app standby, and battery saver network restrictions</li> * <li> * Bypass Doze, app standby, and battery saver network restrictions (if the job * has a {@link #setRequiredNetwork(NetworkRequest) connectivity constraint}) * </li> * <li>Be less likely to be killed than regular jobs</li> * <li>Be subject to background location throttling</li> * <li>Be exempt from delay to optimize job execution</li> Loading
apex/jobscheduler/service/java/com/android/server/job/JobServiceContext.java +15 −19 Original line number Diff line number Diff line Loading @@ -427,34 +427,30 @@ public final class JobServiceContext implements ServiceConnection { boolean binding = false; boolean startedWithForegroundFlag = false; try { final Context.BindServiceFlags bindFlags; long bindFlags = Context.BIND_AUTO_CREATE | Context.BIND_NOT_APP_COMPONENT_USAGE; if (job.shouldTreatAsUserInitiatedJob() && !job.isUserBgRestricted()) { // If the user has bg restricted the app, don't give the job FG privileges // such as bypassing data saver or getting the higher foreground proc state. // If we've gotten to this point, the app is most likely in the foreground, // so the job will run just fine while the user keeps the app in the foreground. bindFlags = Context.BindServiceFlags.of( Context.BIND_AUTO_CREATE | Context.BIND_ALMOST_PERCEPTIBLE | Context.BIND_BYPASS_POWER_NETWORK_RESTRICTIONS | Context.BIND_BYPASS_USER_NETWORK_RESTRICTIONS | Context.BIND_NOT_APP_COMPONENT_USAGE); bindFlags |= Context.BIND_ALMOST_PERCEPTIBLE; if (job.hasConnectivityConstraint()) { // Only add network restriction bypass flags if the job requires network. bindFlags |= Context.BIND_BYPASS_POWER_NETWORK_RESTRICTIONS | Context.BIND_BYPASS_USER_NETWORK_RESTRICTIONS; } startedWithForegroundFlag = true; } else if (job.shouldTreatAsExpeditedJob() || job.shouldTreatAsUserInitiatedJob()) { bindFlags = Context.BindServiceFlags.of( Context.BIND_AUTO_CREATE | Context.BIND_NOT_FOREGROUND | Context.BIND_ALMOST_PERCEPTIBLE | Context.BIND_BYPASS_POWER_NETWORK_RESTRICTIONS | Context.BIND_NOT_APP_COMPONENT_USAGE); bindFlags |= Context.BIND_NOT_FOREGROUND | Context.BIND_ALMOST_PERCEPTIBLE; if (job.hasConnectivityConstraint()) { // Only add network restriction bypass flags if the job requires network. bindFlags |= Context.BIND_BYPASS_POWER_NETWORK_RESTRICTIONS; } } else { bindFlags = Context.BindServiceFlags.of( Context.BIND_AUTO_CREATE | Context.BIND_NOT_FOREGROUND | Context.BIND_NOT_PERCEPTIBLE | Context.BIND_NOT_APP_COMPONENT_USAGE); bindFlags |= Context.BIND_NOT_FOREGROUND | Context.BIND_NOT_PERCEPTIBLE; } binding = mContext.bindServiceAsUser(intent, this, bindFlags, binding = mContext.bindServiceAsUser(intent, this, Context.BindServiceFlags.of(bindFlags), UserHandle.of(job.getUserId())); } catch (SecurityException e) { // Some permission policy, for example INTERACT_ACROSS_USERS and Loading