summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2018-01-19 07:58:35 +0900
committerJeff Sharkey <jsharkey@android.com>2018-01-19 15:50:12 +0900
commit9252b34065809731ea2f6d3ffad91f678f809c93 (patch)
treecd4e63c7ab82fd449f476cc6b4ae27e8a2828f39 /core/java
parentc694cde7bbb797699485b9df62c25f6e242852c6 (diff)
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
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/app/job/JobInfo.java27
-rw-r--r--core/java/android/content/pm/PackageManagerInternal.java5
-rw-r--r--core/java/android/net/INetworkPolicyManager.aidl1
3 files changed, 33 insertions, 0 deletions
diff --git a/core/java/android/app/job/JobInfo.java b/core/java/android/app/job/JobInfo.java
index 7c40b4eaf375..cba9dcc3c4cc 100644
--- a/core/java/android/app/job/JobInfo.java
+++ b/core/java/android/app/job/JobInfo.java
@@ -253,6 +253,11 @@ public class JobInfo implements Parcelable {
/**
* @hide
*/
+ public static final int FLAG_IS_PREFETCH = 1 << 2;
+
+ /**
+ * @hide
+ */
public static final int CONSTRAINT_FLAG_CHARGING = 1 << 0;
/**
@@ -1364,6 +1369,28 @@ public class JobInfo implements Parcelable {
}
/**
+ * 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.
*
* @param isPersisted True to indicate that the job will be written to
diff --git a/core/java/android/content/pm/PackageManagerInternal.java b/core/java/android/content/pm/PackageManagerInternal.java
index 2c45b8d8b30e..6f093ba8d005 100644
--- a/core/java/android/content/pm/PackageManagerInternal.java
+++ b/core/java/android/content/pm/PackageManagerInternal.java
@@ -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);
diff --git a/core/java/android/net/INetworkPolicyManager.aidl b/core/java/android/net/INetworkPolicyManager.aidl
index 7e37432fb06a..476e2f43649f 100644
--- a/core/java/android/net/INetworkPolicyManager.aidl
+++ b/core/java/android/net/INetworkPolicyManager.aidl
@@ -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);