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

Commit 9252b340 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Use data plans for better job scheduling.

Now that we have data plan information from the carrier, we can start
using it to influence when we schedule jobs.  As a first pass
algorithm:

-- If the network is congested, and a job is less than 50% through
its runnable window, then we'll defer it for awhile.
-- If the network has a surplus of data, we'll consider using some
of it to improve the user experience by running prefetching jobs.

Provider APIs for carrier apps to override their connections to be
temporarily marked as either "unmetered" or "congested", along with
automatic timeouts if desired.

Flag for developers to indicate which jobs will have a material
positive impact on end users.  (We don't want to promote jobs that
are simply doing logs upload; for example.)  Glue code to quickly
return targetSdk of a specific package.

More tweaking to the exact algorithms will come in future CLs.

Test: bit FrameworksServicesTests:com.android.server.job.
Bug: 64133169
Change-Id: Iabb9f90a7a65958ad648b091edec378fc3bf785a
parent c694cde7
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -6992,6 +6992,7 @@ package android.app.job {
    method public android.app.job.JobInfo.Builder setEstimatedNetworkBytes(long);
    method public android.app.job.JobInfo.Builder setExtras(android.os.PersistableBundle);
    method public android.app.job.JobInfo.Builder setImportantWhileForeground(boolean);
    method public android.app.job.JobInfo.Builder setIsPrefetch(boolean);
    method public android.app.job.JobInfo.Builder setMinimumLatency(long);
    method public android.app.job.JobInfo.Builder setOverrideDeadline(long);
    method public android.app.job.JobInfo.Builder setPeriodic(long);
+2 −0
Original line number Diff line number Diff line
@@ -4381,6 +4381,8 @@ package android.telephony {

  public class SubscriptionManager {
    method public java.util.List<android.telephony.SubscriptionPlan> getSubscriptionPlans(int);
    method public void setSubscriptionOverrideCongested(int, boolean, long);
    method public void setSubscriptionOverrideUnmetered(int, boolean, long);
    method public void setSubscriptionPlans(int, java.util.List<android.telephony.SubscriptionPlan>);
    field public static final java.lang.String ACTION_MANAGE_SUBSCRIPTION_PLANS = "android.telephony.action.MANAGE_SUBSCRIPTION_PLANS";
    field public static final java.lang.String ACTION_REFRESH_SUBSCRIPTION_PLANS = "android.telephony.action.REFRESH_SUBSCRIPTION_PLANS";
+27 −0
Original line number Diff line number Diff line
@@ -250,6 +250,11 @@ public class JobInfo implements Parcelable {
     */
    public static final int FLAG_IMPORTANT_WHILE_FOREGROUND = 1 << 1;

    /**
     * @hide
     */
    public static final int FLAG_IS_PREFETCH = 1 << 2;

    /**
     * @hide
     */
@@ -1363,6 +1368,28 @@ public class JobInfo implements Parcelable {
            return this;
        }

        /**
         * Setting this to true indicates that this job is designed to prefetch
         * content that will make a material improvement to the experience of
         * the specific user of this device. For example, fetching top headlines
         * of interest to the current user.
         * <p>
         * The system may use this signal to relax the network constraints you
         * originally requested, such as allowing a
         * {@link JobInfo#NETWORK_TYPE_UNMETERED} job to run over a metered
         * network when there is a surplus of metered data available. The system
         * may also use this signal in combination with end user usage patterns
         * to ensure data is prefetched before the user launches your app.
         */
        public Builder setIsPrefetch(boolean isPrefetch) {
            if (isPrefetch) {
                mFlags |= FLAG_IS_PREFETCH;
            } else {
                mFlags &= (~FLAG_IS_PREFETCH);
            }
            return this;
        }

        /**
         * Set whether or not to persist this job across device reboots.
         *
+5 −0
Original line number Diff line number Diff line
@@ -436,6 +436,11 @@ public abstract class PackageManagerInternal {
     */
    public abstract int getUidTargetSdkVersion(int uid);

    /**
     * Return the taget SDK version for the app with the given package name.
     */
    public abstract int getPackageTargetSdkVersion(String packageName);

    /** Whether the binder caller can access instant apps. */
    public abstract boolean canAccessInstantApps(int callingUid, int userId);

+1 −0
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ interface INetworkPolicyManager {
    SubscriptionPlan[] getSubscriptionPlans(int subId, String callingPackage);
    void setSubscriptionPlans(int subId, in SubscriptionPlan[] plans, String callingPackage);
    String getSubscriptionPlansOwner(int subId);
    void setSubscriptionOverride(int subId, int overrideMask, int overrideValue, long timeoutMillis, String callingPackage);

    void factoryReset(String subscriber);

Loading