diff --git a/api/current.txt b/api/current.txt index 869d148142a70..ba9b1cce79fa7 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24604,6 +24604,7 @@ package android.net { method public android.net.Network getBoundNetworkForProcess(); method public android.net.ProxyInfo getDefaultProxy(); method public android.net.LinkProperties getLinkProperties(android.net.Network); + method public int getMultipathPreference(android.net.Network); method public android.net.NetworkCapabilities getNetworkCapabilities(android.net.Network); method public deprecated android.net.NetworkInfo getNetworkInfo(int); method public android.net.NetworkInfo getNetworkInfo(android.net.Network); @@ -24643,6 +24644,9 @@ package android.net { field public static final java.lang.String EXTRA_NO_CONNECTIVITY = "noConnectivity"; field public static final java.lang.String EXTRA_OTHER_NETWORK_INFO = "otherNetwork"; field public static final java.lang.String EXTRA_REASON = "reason"; + field public static final int MULTIPATH_PREFERENCE_HANDOVER = 1; // 0x1 + field public static final int MULTIPATH_PREFERENCE_PERFORMANCE = 4; // 0x4 + field public static final int MULTIPATH_PREFERENCE_RELIABILITY = 2; // 0x2 field public static final int RESTRICT_BACKGROUND_STATUS_DISABLED = 1; // 0x1 field public static final int RESTRICT_BACKGROUND_STATUS_ENABLED = 3; // 0x3 field public static final int RESTRICT_BACKGROUND_STATUS_WHITELISTED = 2; // 0x2 diff --git a/api/system-current.txt b/api/system-current.txt index aa49f23ed8a31..a0b95006054a7 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -26524,6 +26524,7 @@ package android.net { method public java.lang.String getCaptivePortalServerUrl(); method public android.net.ProxyInfo getDefaultProxy(); method public android.net.LinkProperties getLinkProperties(android.net.Network); + method public int getMultipathPreference(android.net.Network); method public android.net.NetworkCapabilities getNetworkCapabilities(android.net.Network); method public deprecated android.net.NetworkInfo getNetworkInfo(int); method public android.net.NetworkInfo getNetworkInfo(android.net.Network); @@ -26567,6 +26568,9 @@ package android.net { field public static final java.lang.String EXTRA_NO_CONNECTIVITY = "noConnectivity"; field public static final java.lang.String EXTRA_OTHER_NETWORK_INFO = "otherNetwork"; field public static final java.lang.String EXTRA_REASON = "reason"; + field public static final int MULTIPATH_PREFERENCE_HANDOVER = 1; // 0x1 + field public static final int MULTIPATH_PREFERENCE_PERFORMANCE = 4; // 0x4 + field public static final int MULTIPATH_PREFERENCE_RELIABILITY = 2; // 0x2 field public static final int RESTRICT_BACKGROUND_STATUS_DISABLED = 1; // 0x1 field public static final int RESTRICT_BACKGROUND_STATUS_ENABLED = 3; // 0x3 field public static final int RESTRICT_BACKGROUND_STATUS_WHITELISTED = 2; // 0x2 diff --git a/api/test-current.txt b/api/test-current.txt index 86936d3d753fa..682c0297426d9 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -24696,6 +24696,7 @@ package android.net { method public android.net.Network getBoundNetworkForProcess(); method public android.net.ProxyInfo getDefaultProxy(); method public android.net.LinkProperties getLinkProperties(android.net.Network); + method public int getMultipathPreference(android.net.Network); method public android.net.NetworkCapabilities getNetworkCapabilities(android.net.Network); method public deprecated android.net.NetworkInfo getNetworkInfo(int); method public android.net.NetworkInfo getNetworkInfo(android.net.Network); @@ -24735,6 +24736,9 @@ package android.net { field public static final java.lang.String EXTRA_NO_CONNECTIVITY = "noConnectivity"; field public static final java.lang.String EXTRA_OTHER_NETWORK_INFO = "otherNetwork"; field public static final java.lang.String EXTRA_REASON = "reason"; + field public static final int MULTIPATH_PREFERENCE_HANDOVER = 1; // 0x1 + field public static final int MULTIPATH_PREFERENCE_PERFORMANCE = 4; // 0x4 + field public static final int MULTIPATH_PREFERENCE_RELIABILITY = 2; // 0x2 field public static final int RESTRICT_BACKGROUND_STATUS_DISABLED = 1; // 0x1 field public static final int RESTRICT_BACKGROUND_STATUS_ENABLED = 3; // 0x3 field public static final int RESTRICT_BACKGROUND_STATUS_WHITELISTED = 2; // 0x2 diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java index ac0c0dc5a9166..222953e3ae6c9 100644 --- a/core/java/android/net/ConnectivityManager.java +++ b/core/java/android/net/ConnectivityManager.java @@ -3263,6 +3263,75 @@ public class ConnectivityManager { } } + /** + * It is acceptable to briefly use multipath data to provide seamless connectivity for + * time-sensitive user-facing operations when the system default network is temporarily + * unresponsive. The amount of data should be limited (less than one megabyte), and the + * operation should be infrequent to ensure that data usage is limited. + * + * An example of such an operation might be a time-sensitive foreground activity, such as a + * voice command, that the user is performing while walking out of range of a Wi-Fi network. + */ + public static final int MULTIPATH_PREFERENCE_HANDOVER = 1 << 0; + + /** + * It is acceptable to use small amounts of multipath data on an ongoing basis to provide + * a backup channel for traffic that is primarily going over another network. + * + * An example might be maintaining backup connections to peers or servers for the purpose of + * fast fallback if the default network is temporarily unresponsive or disconnects. The traffic + * on backup paths should be negligible compared to the traffic on the main path. + */ + public static final int MULTIPATH_PREFERENCE_RELIABILITY = 1 << 1; + + /** + * It is acceptable to use metered data to improve network latency and performance. + */ + public static final int MULTIPATH_PREFERENCE_PERFORMANCE = 1 << 2; + + /** + * Return value to use for unmetered networks. On such networks we currently set all the flags + * to true. + * @hide + */ + public static final int MULTIPATH_PREFERENCE_UNMETERED = + MULTIPATH_PREFERENCE_HANDOVER | + MULTIPATH_PREFERENCE_RELIABILITY | + MULTIPATH_PREFERENCE_PERFORMANCE; + + /** @hide */ + @Retention(RetentionPolicy.SOURCE) + @IntDef(flag = true, value = { + MULTIPATH_PREFERENCE_HANDOVER, + MULTIPATH_PREFERENCE_RELIABILITY, + MULTIPATH_PREFERENCE_PERFORMANCE, + }) + public @interface MultipathPreference { + } + + /** + * Provides a hint to the calling application on whether it is desirable to use the + * multinetwork APIs (e.g., {@link Network#openConnection}, {@link Network#bindSocket}, etc.) + * for multipath data transfer on this network when it is not the system default network. + * Applications desiring to use multipath network protocols should call this method before + * each such operation. + *
+ * This method requires the caller to hold the permission
+ * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
+ *
+ * @param network The network on which the application desires to use multipath data.
+ * If {@code null}, this method will return the a preference that will generally
+ * apply to metered networks.
+ * @return a bitwise OR of zero or more of the {@code MULTIPATH_PREFERENCE_*} constants.
+ */
+ public @MultipathPreference int getMultipathPreference(Network network) {
+ try {
+ return mService.getMultipathPreference(network);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
/**
* Resets all connectivity manager settings back to factory defaults.
* @hide
diff --git a/core/java/android/net/IConnectivityManager.aidl b/core/java/android/net/IConnectivityManager.aidl
index 4aabda9eb09d2..117fa0b476f4a 100644
--- a/core/java/android/net/IConnectivityManager.aidl
+++ b/core/java/android/net/IConnectivityManager.aidl
@@ -163,6 +163,8 @@ interface IConnectivityManager
void setAcceptUnvalidated(in Network network, boolean accept, boolean always);
void setAvoidUnvalidated(in Network network);
+ int getMultipathPreference(in Network Network);
+
int getRestoreDefaultNetworkDelay(int networkType);
boolean addVpnAddress(String address, int prefixLength);
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index d71ce346c0cee..d83f2cbf13bdb 100755
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -8081,6 +8081,16 @@ public final class Settings {
*/
public static final String NETWORK_AVOID_BAD_WIFI = "network_avoid_bad_wifi";
+ /**
+ * User setting for ConnectivityManager.getMeteredMultipathPreference(). This value may be
+ * overridden by the system based on device or application state. If null, the value
+ * specified by config_networkMeteredMultipathPreference is used.
+ *
+ * @hide
+ */
+ public static final String NETWORK_METERED_MULTIPATH_PREFERENCE =
+ "network_metered_multipath_preference";
+
/**
* The thresholds of the wifi throughput badging (SD, HD etc.) as a comma-delimited list of
* colon-delimited key-value pairs. The key is the badging enum value defined in
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 98737622bb3e8..fa1c7a1034326 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -283,6 +283,11 @@
Settings.Global.NETWORK_AVOID_BAD_WIFI. This is the default value of that setting. -->