diff options
| author | 2021-03-25 15:01:30 +0000 | |
|---|---|---|
| committer | 2021-03-25 15:01:30 +0000 | |
| commit | 241dd6ef0ec3ae7cb2aebd74778b4428bc1b00ff (patch) | |
| tree | 8f73aed83f127a45f53709d6f4993c573bb05411 | |
| parent | 40b4495f8eeb29150bee968c58634cc70c4a2460 (diff) | |
| parent | 45515ca16966793bc0c6e2e807b6e64f6606cfa8 (diff) | |
Merge "Add MOBILE_DATA_PREFERRED_APPS setting" into sc-dev
| -rw-r--r-- | packages/Connectivity/framework/api/module-lib-current.txt | 2 | ||||
| -rw-r--r-- | packages/Connectivity/framework/src/android/net/ConnectivitySettingsManager.java | 33 |
2 files changed, 35 insertions, 0 deletions
diff --git a/packages/Connectivity/framework/api/module-lib-current.txt b/packages/Connectivity/framework/api/module-lib-current.txt index 94845bf590c7..0cc8c239cb94 100644 --- a/packages/Connectivity/framework/api/module-lib-current.txt +++ b/packages/Connectivity/framework/api/module-lib-current.txt @@ -55,6 +55,7 @@ package android.net { method @Nullable public static android.net.ProxyInfo getGlobalProxy(@NonNull android.content.Context); method @NonNull public static java.time.Duration getMobileDataActivityTimeout(@NonNull android.content.Context, @NonNull java.time.Duration); method public static boolean getMobileDataAlwaysOn(@NonNull android.content.Context, boolean); + method @Nullable public static String getMobileDataPreferredApps(@NonNull android.content.Context); method public static int getNetworkAvoidBadWifi(@NonNull android.content.Context); method @Nullable public static String getNetworkMeteredMultipathPreference(@NonNull android.content.Context); method public static int getNetworkSwitchNotificationMaximumDailyCount(@NonNull android.content.Context, int); @@ -72,6 +73,7 @@ package android.net { method public static void setGlobalProxy(@NonNull android.content.Context, @NonNull android.net.ProxyInfo); method public static void setMobileDataActivityTimeout(@NonNull android.content.Context, @NonNull java.time.Duration); method public static void setMobileDataAlwaysOn(@NonNull android.content.Context, boolean); + method public static void setMobileDataPreferredApps(@NonNull android.content.Context, @Nullable String); method public static void setNetworkAvoidBadWifi(@NonNull android.content.Context, int); method public static void setNetworkMeteredMultipathPreference(@NonNull android.content.Context, @NonNull String); method public static void setNetworkSwitchNotificationMaximumDailyCount(@NonNull android.content.Context, @IntRange(from=0) int); diff --git a/packages/Connectivity/framework/src/android/net/ConnectivitySettingsManager.java b/packages/Connectivity/framework/src/android/net/ConnectivitySettingsManager.java index e133d5e53f42..9a00055e0079 100644 --- a/packages/Connectivity/framework/src/android/net/ConnectivitySettingsManager.java +++ b/packages/Connectivity/framework/src/android/net/ConnectivitySettingsManager.java @@ -333,6 +333,14 @@ public class ConnectivitySettingsManager { "network_metered_multipath_preference"; /** + * A list of apps that should go on cellular networks in preference even when higher-priority + * networks are connected. + * + * @hide + */ + public static final String MOBILE_DATA_PREFERRED_APPS = "mobile_data_preferred_apps"; + + /** * Get mobile data activity timeout from {@link Settings}. * * @param context The {@link Context} to query the setting. @@ -893,4 +901,29 @@ public class ConnectivitySettingsManager { Settings.Global.putString( context.getContentResolver(), NETWORK_METERED_MULTIPATH_PREFERENCE, preference); } + + /** + * Get the list of apps(from {@link Settings}) that should go on cellular networks in preference + * even when higher-priority networks are connected. + * + * @param context The {@link Context} to query the setting. + * @return A list of apps that should go on cellular networks in preference even when + * higher-priority networks are connected or null if no setting value. + */ + @Nullable + public static String getMobileDataPreferredApps(@NonNull Context context) { + return Settings.Secure.getString(context.getContentResolver(), MOBILE_DATA_PREFERRED_APPS); + } + + /** + * Set the list of apps(to {@link Settings}) that should go on cellular networks in preference + * even when higher-priority networks are connected. + * + * @param context The {@link Context} to set the setting. + * @param list A list of apps that should go on cellular networks in preference even when + * higher-priority networks are connected. + */ + public static void setMobileDataPreferredApps(@NonNull Context context, @Nullable String list) { + Settings.Secure.putString(context.getContentResolver(), MOBILE_DATA_PREFERRED_APPS, list); + } } |