Add ConnectivitySettingsManagerTest

- Add tests for ConnectivitySettingsManager.
- Also address leftover javadoc comments.

Bug: 182538166
Test: atest FrameworksNetTests
Test: atest CtsNetTestCases
Change-Id: I8161c1bca84b41964578d59ee5d6ab07b2380707
This commit is contained in:
paulhu
2021-03-29 10:50:36 +08:00
parent 5440e0b8e8
commit 236a992cd0
2 changed files with 303 additions and 5 deletions

View File

@@ -562,7 +562,7 @@ public class ConnectivitySettingsManager {
public static void setNetworkSwitchNotificationMaximumDailyCount(@NonNull Context context,
@IntRange(from = 0) int count) {
if (count < 0) {
throw new IllegalArgumentException("Count must be 0~10.");
throw new IllegalArgumentException("Count must be more than 0.");
}
Settings.Global.putInt(
context.getContentResolver(), NETWORK_SWITCH_NOTIFICATION_DAILY_LIMIT, count);
@@ -585,6 +585,7 @@ public class ConnectivitySettingsManager {
/**
* Set minimum duration (to {@link Settings}) between each switching network notifications.
* The duration will be rounded down to the next millisecond, and must be positive.
*
* @param context The {@link Context} to set the setting.
* @param duration The minimum duration between notifications when switching networks.
@@ -612,10 +613,11 @@ public class ConnectivitySettingsManager {
/**
* Set URL (to {@link Settings}) used for HTTP captive portal detection upon a new connection.
* This URL should respond with a 204 response to a GET request to indicate no captive portal is
* present. And this URL must be HTTP as redirect responses are used to find captive portal
* sign-in pages. If the URL set to null or be incorrect, it will result in captive portal
* detection failed and lost the connection.
* The URL is accessed to check for connectivity and presence of a captive portal on a network.
* The URL should respond with HTTP status 204 to a GET request, and the stack will use
* redirection status as a signal for captive portal detection.
* If the URL is set to null or is otherwise incorrect or inaccessible, the stack will fail to
* detect connectivity and portals. This will often result in loss of connectivity.
*
* @param context The {@link Context} to set the setting.
* @param url The URL used for HTTP captive portal detection upon a new connection.
@@ -819,6 +821,7 @@ public class ConnectivitySettingsManager {
/**
* Set duration (to {@link Settings}) to keep a PendingIntent-based request.
* The duration will be rounded down to the next millisecond, and must be positive.
*
* @param context The {@link Context} to set the setting.
* @param duration The duration to keep a PendingIntent-based request.