Snap for 6282804 from 76182efa9fdc08d31a2f348932b6a2cfbc65fdbc to rvc-release
Change-Id: I3b38c8604044864ccc9958a3d769e12ad0689720
This commit is contained in:
@@ -273,9 +273,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
// connect anyway?" dialog after the user selects a network that doesn't validate.
|
// connect anyway?" dialog after the user selects a network that doesn't validate.
|
||||||
private static final int PROMPT_UNVALIDATED_DELAY_MS = 8 * 1000;
|
private static final int PROMPT_UNVALIDATED_DELAY_MS = 8 * 1000;
|
||||||
|
|
||||||
// How long to dismiss network notification.
|
|
||||||
private static final int TIMEOUT_NOTIFICATION_DELAY_MS = 20 * 1000;
|
|
||||||
|
|
||||||
// Default to 30s linger time-out. Modifiable only for testing.
|
// Default to 30s linger time-out. Modifiable only for testing.
|
||||||
private static final String LINGER_DELAY_PROPERTY = "persist.netmon.linger";
|
private static final String LINGER_DELAY_PROPERTY = "persist.netmon.linger";
|
||||||
private static final int DEFAULT_LINGER_DELAY_MS = 30_000;
|
private static final int DEFAULT_LINGER_DELAY_MS = 30_000;
|
||||||
@@ -522,11 +519,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
*/
|
*/
|
||||||
private static final int EVENT_PROVISIONING_NOTIFICATION = 43;
|
private static final int EVENT_PROVISIONING_NOTIFICATION = 43;
|
||||||
|
|
||||||
/**
|
|
||||||
* This event can handle dismissing notification by given network id.
|
|
||||||
*/
|
|
||||||
private static final int EVENT_TIMEOUT_NOTIFICATION = 44;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to specify whether a network should be used even if connectivity is partial.
|
* Used to specify whether a network should be used even if connectivity is partial.
|
||||||
* arg1 = whether to accept the network if its connectivity is partial (1 for true or 0 for
|
* arg1 = whether to accept the network if its connectivity is partial (1 for true or 0 for
|
||||||
@@ -534,7 +526,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
* arg2 = whether to remember this choice in the future (1 for true or 0 for false)
|
* arg2 = whether to remember this choice in the future (1 for true or 0 for false)
|
||||||
* obj = network
|
* obj = network
|
||||||
*/
|
*/
|
||||||
private static final int EVENT_SET_ACCEPT_PARTIAL_CONNECTIVITY = 45;
|
private static final int EVENT_SET_ACCEPT_PARTIAL_CONNECTIVITY = 44;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event for NetworkMonitor to inform ConnectivityService that the probe status has changed.
|
* Event for NetworkMonitor to inform ConnectivityService that the probe status has changed.
|
||||||
@@ -543,7 +535,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
* arg1 = A bitmask to describe which probes are completed.
|
* arg1 = A bitmask to describe which probes are completed.
|
||||||
* arg2 = A bitmask to describe which probes are successful.
|
* arg2 = A bitmask to describe which probes are successful.
|
||||||
*/
|
*/
|
||||||
public static final int EVENT_PROBE_STATUS_CHANGED = 46;
|
public static final int EVENT_PROBE_STATUS_CHANGED = 45;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event for NetworkMonitor to inform ConnectivityService that captive portal data has changed.
|
* Event for NetworkMonitor to inform ConnectivityService that captive portal data has changed.
|
||||||
@@ -551,7 +543,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
* arg2 = netId
|
* arg2 = netId
|
||||||
* obj = captive portal data
|
* obj = captive portal data
|
||||||
*/
|
*/
|
||||||
private static final int EVENT_CAPPORT_DATA_CHANGED = 47;
|
private static final int EVENT_CAPPORT_DATA_CHANGED = 46;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Argument for {@link #EVENT_PROVISIONING_NOTIFICATION} to indicate that the notification
|
* Argument for {@link #EVENT_PROVISIONING_NOTIFICATION} to indicate that the notification
|
||||||
@@ -2877,13 +2869,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
final boolean valid = ((testResult & NETWORK_VALIDATION_RESULT_VALID) != 0);
|
final boolean valid = ((testResult & NETWORK_VALIDATION_RESULT_VALID) != 0);
|
||||||
final boolean wasValidated = nai.lastValidated;
|
final boolean wasValidated = nai.lastValidated;
|
||||||
final boolean wasDefault = isDefaultNetwork(nai);
|
final boolean wasDefault = isDefaultNetwork(nai);
|
||||||
// Only show a connected notification if the network is pending validation
|
|
||||||
// after the captive portal app was open, and it has now validated.
|
|
||||||
if (nai.captivePortalValidationPending && valid) {
|
|
||||||
// User is now logged in, network validated.
|
|
||||||
nai.captivePortalValidationPending = false;
|
|
||||||
showNetworkNotification(nai, NotificationType.LOGGED_IN);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
final String logMsg = !TextUtils.isEmpty(redirectUrl)
|
final String logMsg = !TextUtils.isEmpty(redirectUrl)
|
||||||
@@ -3764,12 +3749,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
new CaptivePortal(new CaptivePortalImpl(network).asBinder()));
|
new CaptivePortal(new CaptivePortalImpl(network).asBinder()));
|
||||||
appIntent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK);
|
appIntent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
|
||||||
// This runs on a random binder thread, but getNetworkAgentInfoForNetwork is thread-safe,
|
|
||||||
// and captivePortalValidationPending is volatile.
|
|
||||||
final NetworkAgentInfo nai = getNetworkAgentInfoForNetwork(network);
|
|
||||||
if (nai != null) {
|
|
||||||
nai.captivePortalValidationPending = true;
|
|
||||||
}
|
|
||||||
Binder.withCleanCallingIdentity(() ->
|
Binder.withCleanCallingIdentity(() ->
|
||||||
mContext.startActivityAsUser(appIntent, UserHandle.CURRENT));
|
mContext.startActivityAsUser(appIntent, UserHandle.CURRENT));
|
||||||
}
|
}
|
||||||
@@ -3888,14 +3867,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
final String action;
|
final String action;
|
||||||
final boolean highPriority;
|
final boolean highPriority;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case LOGGED_IN:
|
|
||||||
action = Settings.ACTION_WIFI_SETTINGS;
|
|
||||||
mHandler.removeMessages(EVENT_TIMEOUT_NOTIFICATION);
|
|
||||||
mHandler.sendMessageDelayed(mHandler.obtainMessage(EVENT_TIMEOUT_NOTIFICATION,
|
|
||||||
nai.network.netId, 0), TIMEOUT_NOTIFICATION_DELAY_MS);
|
|
||||||
// High priority because it is a direct result of the user logging in to a portal.
|
|
||||||
highPriority = true;
|
|
||||||
break;
|
|
||||||
case NO_INTERNET:
|
case NO_INTERNET:
|
||||||
action = ConnectivityManager.ACTION_PROMPT_UNVALIDATED;
|
action = ConnectivityManager.ACTION_PROMPT_UNVALIDATED;
|
||||||
// High priority because it is only displayed for explicitly selected networks.
|
// High priority because it is only displayed for explicitly selected networks.
|
||||||
@@ -3923,7 +3894,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
Intent intent = new Intent(action);
|
Intent intent = new Intent(action);
|
||||||
if (type != NotificationType.LOGGED_IN && type != NotificationType.PRIVATE_DNS_BROKEN) {
|
if (type != NotificationType.PRIVATE_DNS_BROKEN) {
|
||||||
intent.setData(Uri.fromParts("netId", Integer.toString(nai.network.netId), null));
|
intent.setData(Uri.fromParts("netId", Integer.toString(nai.network.netId), null));
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
intent.setClassName("com.android.settings",
|
intent.setClassName("com.android.settings",
|
||||||
@@ -4139,9 +4110,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
case EVENT_DATA_SAVER_CHANGED:
|
case EVENT_DATA_SAVER_CHANGED:
|
||||||
handleRestrictBackgroundChanged(toBool(msg.arg1));
|
handleRestrictBackgroundChanged(toBool(msg.arg1));
|
||||||
break;
|
break;
|
||||||
case EVENT_TIMEOUT_NOTIFICATION:
|
|
||||||
mNotifier.clearNotification(msg.arg1, NotificationType.LOGGED_IN);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -160,10 +160,6 @@ public class NetworkAgentInfo implements Comparable<NetworkAgentInfo> {
|
|||||||
// Whether a captive portal was found during the last network validation attempt.
|
// Whether a captive portal was found during the last network validation attempt.
|
||||||
public boolean lastCaptivePortalDetected;
|
public boolean lastCaptivePortalDetected;
|
||||||
|
|
||||||
// Indicates the captive portal app was opened to show a login UI to the user, but the network
|
|
||||||
// has not validated yet.
|
|
||||||
public volatile boolean captivePortalValidationPending;
|
|
||||||
|
|
||||||
// Set to true when partial connectivity was detected.
|
// Set to true when partial connectivity was detected.
|
||||||
public boolean partialConnectivity;
|
public boolean partialConnectivity;
|
||||||
|
|
||||||
@@ -638,7 +634,6 @@ public class NetworkAgentInfo implements Comparable<NetworkAgentInfo> {
|
|||||||
+ "acceptUnvalidated{" + networkAgentConfig.acceptUnvalidated + "} "
|
+ "acceptUnvalidated{" + networkAgentConfig.acceptUnvalidated + "} "
|
||||||
+ "everCaptivePortalDetected{" + everCaptivePortalDetected + "} "
|
+ "everCaptivePortalDetected{" + everCaptivePortalDetected + "} "
|
||||||
+ "lastCaptivePortalDetected{" + lastCaptivePortalDetected + "} "
|
+ "lastCaptivePortalDetected{" + lastCaptivePortalDetected + "} "
|
||||||
+ "captivePortalValidationPending{" + captivePortalValidationPending + "} "
|
|
||||||
+ "partialConnectivity{" + partialConnectivity + "} "
|
+ "partialConnectivity{" + partialConnectivity + "} "
|
||||||
+ "acceptPartialConnectivity{" + networkAgentConfig.acceptPartialConnectivity + "} "
|
+ "acceptPartialConnectivity{" + networkAgentConfig.acceptPartialConnectivity + "} "
|
||||||
+ "clat{" + clatd + "} "
|
+ "clat{" + clatd + "} "
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ public class NetworkNotificationManager {
|
|||||||
LOST_INTERNET(SystemMessage.NOTE_NETWORK_LOST_INTERNET),
|
LOST_INTERNET(SystemMessage.NOTE_NETWORK_LOST_INTERNET),
|
||||||
NETWORK_SWITCH(SystemMessage.NOTE_NETWORK_SWITCH),
|
NETWORK_SWITCH(SystemMessage.NOTE_NETWORK_SWITCH),
|
||||||
NO_INTERNET(SystemMessage.NOTE_NETWORK_NO_INTERNET),
|
NO_INTERNET(SystemMessage.NOTE_NETWORK_NO_INTERNET),
|
||||||
LOGGED_IN(SystemMessage.NOTE_NETWORK_LOGGED_IN),
|
|
||||||
PARTIAL_CONNECTIVITY(SystemMessage.NOTE_NETWORK_PARTIAL_CONNECTIVITY),
|
PARTIAL_CONNECTIVITY(SystemMessage.NOTE_NETWORK_PARTIAL_CONNECTIVITY),
|
||||||
SIGN_IN(SystemMessage.NOTE_NETWORK_SIGN_IN),
|
SIGN_IN(SystemMessage.NOTE_NETWORK_SIGN_IN),
|
||||||
PRIVATE_DNS_BROKEN(SystemMessage.NOTE_NETWORK_PRIVATE_DNS_BROKEN);
|
PRIVATE_DNS_BROKEN(SystemMessage.NOTE_NETWORK_PRIVATE_DNS_BROKEN);
|
||||||
@@ -114,14 +113,10 @@ public class NetworkNotificationManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getIcon(int transportType, NotificationType notifyType) {
|
private static int getIcon(int transportType) {
|
||||||
if (transportType != TRANSPORT_WIFI) {
|
return (transportType == TRANSPORT_WIFI)
|
||||||
return R.drawable.stat_notify_rssi_in_range;
|
? R.drawable.stat_notify_wifi_in_range : // TODO: Distinguish ! from ?.
|
||||||
}
|
R.drawable.stat_notify_rssi_in_range;
|
||||||
|
|
||||||
return notifyType == NotificationType.LOGGED_IN
|
|
||||||
? R.drawable.ic_wifi_signal_4
|
|
||||||
: R.drawable.stat_notify_wifi_in_range; // TODO: Distinguish ! from ?.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -185,7 +180,7 @@ public class NetworkNotificationManager {
|
|||||||
Resources r = mContext.getResources();
|
Resources r = mContext.getResources();
|
||||||
final CharSequence title;
|
final CharSequence title;
|
||||||
final CharSequence details;
|
final CharSequence details;
|
||||||
int icon = getIcon(transportType, notifyType);
|
int icon = getIcon(transportType);
|
||||||
if (notifyType == NotificationType.NO_INTERNET && transportType == TRANSPORT_WIFI) {
|
if (notifyType == NotificationType.NO_INTERNET && transportType == TRANSPORT_WIFI) {
|
||||||
title = r.getString(R.string.wifi_no_internet,
|
title = r.getString(R.string.wifi_no_internet,
|
||||||
WifiInfo.sanitizeSsid(nai.networkCapabilities.getSSID()));
|
WifiInfo.sanitizeSsid(nai.networkCapabilities.getSSID()));
|
||||||
@@ -235,9 +230,6 @@ public class NetworkNotificationManager {
|
|||||||
details = r.getString(R.string.network_available_sign_in_detailed, name);
|
details = r.getString(R.string.network_available_sign_in_detailed, name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (notifyType == NotificationType.LOGGED_IN) {
|
|
||||||
title = WifiInfo.sanitizeSsid(nai.networkCapabilities.getSSID());
|
|
||||||
details = r.getString(R.string.captive_portal_logged_in_detailed);
|
|
||||||
} else if (notifyType == NotificationType.NETWORK_SWITCH) {
|
} else if (notifyType == NotificationType.NETWORK_SWITCH) {
|
||||||
String fromTransport = getTransportName(transportType);
|
String fromTransport = getTransportName(transportType);
|
||||||
String toTransport = getTransportName(approximateTransportType(switchToNai));
|
String toTransport = getTransportName(approximateTransportType(switchToNai));
|
||||||
@@ -379,7 +371,6 @@ public class NetworkNotificationManager {
|
|||||||
case NETWORK_SWITCH:
|
case NETWORK_SWITCH:
|
||||||
return 2;
|
return 2;
|
||||||
case LOST_INTERNET:
|
case LOST_INTERNET:
|
||||||
case LOGGED_IN:
|
|
||||||
return 1;
|
return 1;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -18,19 +18,26 @@ package android.net;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
import android.os.Build;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
|
|
||||||
import androidx.test.filters.SmallTest;
|
import androidx.test.filters.SmallTest;
|
||||||
import androidx.test.runner.AndroidJUnit4;
|
import androidx.test.runner.AndroidJUnit4;
|
||||||
|
|
||||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||||
|
import com.android.testutils.DevSdkIgnoreRule;
|
||||||
|
import com.android.testutils.DevSdkIgnoreRule.IgnoreUpTo;
|
||||||
|
|
||||||
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4.class)
|
@RunWith(AndroidJUnit4.class)
|
||||||
@SmallTest
|
@SmallTest
|
||||||
public class CaptivePortalTest {
|
public class CaptivePortalTest {
|
||||||
|
@Rule
|
||||||
|
public final DevSdkIgnoreRule ignoreRule = new DevSdkIgnoreRule();
|
||||||
|
|
||||||
private static final int DEFAULT_TIMEOUT_MS = 5000;
|
private static final int DEFAULT_TIMEOUT_MS = 5000;
|
||||||
private static final String TEST_PACKAGE_NAME = "com.google.android.test";
|
private static final String TEST_PACKAGE_NAME = "com.google.android.test";
|
||||||
|
|
||||||
@@ -84,6 +91,7 @@ public class CaptivePortalTest {
|
|||||||
assertEquals(result.mCode, CaptivePortal.APP_RETURN_WANTED_AS_IS);
|
assertEquals(result.mCode, CaptivePortal.APP_RETURN_WANTED_AS_IS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@IgnoreUpTo(Build.VERSION_CODES.Q)
|
||||||
@Test
|
@Test
|
||||||
public void testReevaluateNetwork() {
|
public void testReevaluateNetwork() {
|
||||||
final MyCaptivePortalImpl result = runCaptivePortalTest(c -> c.reevaluateNetwork());
|
final MyCaptivePortalImpl result = runCaptivePortalTest(c -> c.reevaluateNetwork());
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ import static android.system.OsConstants.RT_SCOPE_SITE;
|
|||||||
import static android.system.OsConstants.RT_SCOPE_UNIVERSE;
|
import static android.system.OsConstants.RT_SCOPE_UNIVERSE;
|
||||||
|
|
||||||
import static com.android.testutils.MiscAssertsKt.assertEqualBothWays;
|
import static com.android.testutils.MiscAssertsKt.assertEqualBothWays;
|
||||||
|
import static com.android.testutils.MiscAssertsKt.assertFieldCountEquals;
|
||||||
import static com.android.testutils.MiscAssertsKt.assertNotEqualEitherWay;
|
import static com.android.testutils.MiscAssertsKt.assertNotEqualEitherWay;
|
||||||
import static com.android.testutils.ParcelUtilsKt.assertParcelSane;
|
|
||||||
import static com.android.testutils.ParcelUtilsKt.assertParcelingIsLossless;
|
import static com.android.testutils.ParcelUtilsKt.assertParcelingIsLossless;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
@@ -38,11 +38,17 @@ import static org.junit.Assert.assertNotEquals;
|
|||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
|
import android.os.Build;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
|
|
||||||
import androidx.test.filters.SmallTest;
|
import androidx.test.filters.SmallTest;
|
||||||
import androidx.test.runner.AndroidJUnit4;
|
import androidx.test.runner.AndroidJUnit4;
|
||||||
|
|
||||||
|
import com.android.testutils.DevSdkIgnoreRule;
|
||||||
|
import com.android.testutils.DevSdkIgnoreRule.IgnoreAfter;
|
||||||
|
import com.android.testutils.DevSdkIgnoreRule.IgnoreUpTo;
|
||||||
|
|
||||||
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
@@ -57,6 +63,8 @@ import java.util.List;
|
|||||||
@RunWith(AndroidJUnit4.class)
|
@RunWith(AndroidJUnit4.class)
|
||||||
@SmallTest
|
@SmallTest
|
||||||
public class LinkAddressTest {
|
public class LinkAddressTest {
|
||||||
|
@Rule
|
||||||
|
public final DevSdkIgnoreRule ignoreRule = new DevSdkIgnoreRule();
|
||||||
|
|
||||||
private static final String V4 = "192.0.2.1";
|
private static final String V4 = "192.0.2.1";
|
||||||
private static final String V6 = "2001:db8::1";
|
private static final String V6 = "2001:db8::1";
|
||||||
@@ -318,15 +326,29 @@ public class LinkAddressTest {
|
|||||||
|
|
||||||
l = new LinkAddress(V6_ADDRESS, 64, 123, 456);
|
l = new LinkAddress(V6_ADDRESS, 64, 123, 456);
|
||||||
assertParcelingIsLossless(l);
|
assertParcelingIsLossless(l);
|
||||||
l = new LinkAddress(V6_ADDRESS, 64, 123, 456,
|
|
||||||
1L, 3600000L);
|
|
||||||
assertParcelingIsLossless(l);
|
|
||||||
|
|
||||||
l = new LinkAddress(V4 + "/28", IFA_F_PERMANENT, RT_SCOPE_LINK);
|
l = new LinkAddress(V4 + "/28", IFA_F_PERMANENT, RT_SCOPE_LINK);
|
||||||
assertParcelSane(l, 6);
|
assertParcelingIsLossless(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test @IgnoreUpTo(Build.VERSION_CODES.Q)
|
||||||
|
public void testLifetimeParceling() {
|
||||||
|
final LinkAddress l = new LinkAddress(V6_ADDRESS, 64, 123, 456, 1L, 3600000L);
|
||||||
|
assertParcelingIsLossless(l);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test @IgnoreAfter(Build.VERSION_CODES.Q)
|
||||||
|
public void testFieldCount_Q() {
|
||||||
|
assertFieldCountEquals(4, LinkAddress.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test @IgnoreUpTo(Build.VERSION_CODES.Q)
|
||||||
|
public void testFieldCount() {
|
||||||
|
// Make sure any new field is covered by the above parceling tests when changing this number
|
||||||
|
assertFieldCountEquals(6, LinkAddress.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test @IgnoreUpTo(Build.VERSION_CODES.Q)
|
||||||
public void testDeprecationTime() {
|
public void testDeprecationTime() {
|
||||||
try {
|
try {
|
||||||
new LinkAddress(V6_ADDRESS, 64, 0, 456,
|
new LinkAddress(V6_ADDRESS, 64, 0, 456,
|
||||||
@@ -347,7 +369,7 @@ public class LinkAddressTest {
|
|||||||
} catch (IllegalArgumentException expected) { }
|
} catch (IllegalArgumentException expected) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test @IgnoreUpTo(Build.VERSION_CODES.Q)
|
||||||
public void testExpirationTime() {
|
public void testExpirationTime() {
|
||||||
try {
|
try {
|
||||||
new LinkAddress(V6_ADDRESS, 64, 0, 456,
|
new LinkAddress(V6_ADDRESS, 64, 0, 456,
|
||||||
@@ -366,10 +388,13 @@ public class LinkAddressTest {
|
|||||||
public void testGetFlags() {
|
public void testGetFlags() {
|
||||||
LinkAddress l = new LinkAddress(V6_ADDRESS, 64, 123, RT_SCOPE_HOST);
|
LinkAddress l = new LinkAddress(V6_ADDRESS, 64, 123, RT_SCOPE_HOST);
|
||||||
assertEquals(123, l.getFlags());
|
assertEquals(123, l.getFlags());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test @IgnoreUpTo(Build.VERSION_CODES.Q)
|
||||||
|
public void testGetFlags_Deprecation() {
|
||||||
// Test if deprecated bit was added/remove automatically based on the provided deprecation
|
// Test if deprecated bit was added/remove automatically based on the provided deprecation
|
||||||
// time
|
// time
|
||||||
l = new LinkAddress(V6_ADDRESS, 64, 0, RT_SCOPE_HOST,
|
LinkAddress l = new LinkAddress(V6_ADDRESS, 64, 0, RT_SCOPE_HOST,
|
||||||
1L, LinkAddress.LIFETIME_PERMANENT);
|
1L, LinkAddress.LIFETIME_PERMANENT);
|
||||||
// Check if the flag is added automatically.
|
// Check if the flag is added automatically.
|
||||||
assertTrue((l.getFlags() & IFA_F_DEPRECATED) != 0);
|
assertTrue((l.getFlags() & IFA_F_DEPRECATED) != 0);
|
||||||
@@ -458,8 +483,11 @@ public class LinkAddressTest {
|
|||||||
(IFA_F_TEMPORARY|IFA_F_TENTATIVE|IFA_F_OPTIMISTIC),
|
(IFA_F_TEMPORARY|IFA_F_TENTATIVE|IFA_F_OPTIMISTIC),
|
||||||
RT_SCOPE_UNIVERSE);
|
RT_SCOPE_UNIVERSE);
|
||||||
assertGlobalPreferred(l, "v6,global,tempaddr+optimistic");
|
assertGlobalPreferred(l, "v6,global,tempaddr+optimistic");
|
||||||
|
}
|
||||||
|
|
||||||
l = new LinkAddress(V6_ADDRESS, 64, IFA_F_DEPRECATED,
|
@Test @IgnoreUpTo(Build.VERSION_CODES.Q)
|
||||||
|
public void testIsGlobalPreferred_DeprecatedInFuture() {
|
||||||
|
final LinkAddress l = new LinkAddress(V6_ADDRESS, 64, IFA_F_DEPRECATED,
|
||||||
RT_SCOPE_UNIVERSE, SystemClock.elapsedRealtime() + 100000,
|
RT_SCOPE_UNIVERSE, SystemClock.elapsedRealtime() + 100000,
|
||||||
SystemClock.elapsedRealtime() + 200000);
|
SystemClock.elapsedRealtime() + 200000);
|
||||||
// Although the deprecated bit is set, but the deprecation time is in the future, test
|
// Although the deprecated bit is set, but the deprecation time is in the future, test
|
||||||
|
|||||||
@@ -16,16 +16,23 @@
|
|||||||
|
|
||||||
package android.net
|
package android.net
|
||||||
|
|
||||||
|
import android.os.Build
|
||||||
import androidx.test.filters.SmallTest
|
import androidx.test.filters.SmallTest
|
||||||
import androidx.test.runner.AndroidJUnit4
|
import androidx.test.runner.AndroidJUnit4
|
||||||
|
import com.android.testutils.DevSdkIgnoreRule
|
||||||
|
import com.android.testutils.DevSdkIgnoreRule.IgnoreUpTo
|
||||||
import com.android.testutils.assertParcelSane
|
import com.android.testutils.assertParcelSane
|
||||||
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
@SmallTest
|
@SmallTest
|
||||||
class NetworkAgentConfigTest {
|
class NetworkAgentConfigTest {
|
||||||
@Test
|
@Rule @JvmField
|
||||||
|
val ignoreRule = DevSdkIgnoreRule()
|
||||||
|
|
||||||
|
@Test @IgnoreUpTo(Build.VERSION_CODES.Q)
|
||||||
fun testParcelNetworkAgentConfig() {
|
fun testParcelNetworkAgentConfig() {
|
||||||
val config = NetworkAgentConfig.Builder().apply {
|
val config = NetworkAgentConfig.Builder().apply {
|
||||||
setExplicitlySelected(true)
|
setExplicitlySelected(true)
|
||||||
|
|||||||
@@ -2751,9 +2751,6 @@ public class ConnectivityServiceTest {
|
|||||||
|
|
||||||
// Expect NET_CAPABILITY_VALIDATED onAvailable callback.
|
// Expect NET_CAPABILITY_VALIDATED onAvailable callback.
|
||||||
validatedCallback.expectAvailableDoubleValidatedCallbacks(mWiFiNetworkAgent);
|
validatedCallback.expectAvailableDoubleValidatedCallbacks(mWiFiNetworkAgent);
|
||||||
// Expect no notification to be shown when captive portal disappears by itself
|
|
||||||
verify(mNotificationManager, never()).notifyAsUser(
|
|
||||||
anyString(), eq(NotificationType.LOGGED_IN.eventId), any(), any());
|
|
||||||
|
|
||||||
// Break network connectivity.
|
// Break network connectivity.
|
||||||
// Expect NET_CAPABILITY_VALIDATED onLost callback.
|
// Expect NET_CAPABILITY_VALIDATED onLost callback.
|
||||||
@@ -2815,8 +2812,6 @@ public class ConnectivityServiceTest {
|
|||||||
mWiFiNetworkAgent.mNetworkMonitor.forceReevaluation(Process.myUid());
|
mWiFiNetworkAgent.mNetworkMonitor.forceReevaluation(Process.myUid());
|
||||||
validatedCallback.expectAvailableCallbacksValidated(mWiFiNetworkAgent);
|
validatedCallback.expectAvailableCallbacksValidated(mWiFiNetworkAgent);
|
||||||
captivePortalCallback.expectCallback(CallbackEntry.LOST, mWiFiNetworkAgent);
|
captivePortalCallback.expectCallback(CallbackEntry.LOST, mWiFiNetworkAgent);
|
||||||
verify(mNotificationManager, times(1)).notifyAsUser(anyString(),
|
|
||||||
eq(NotificationType.LOGGED_IN.eventId), any(), eq(UserHandle.ALL));
|
|
||||||
|
|
||||||
mCm.unregisterNetworkCallback(validatedCallback);
|
mCm.unregisterNetworkCallback(validatedCallback);
|
||||||
mCm.unregisterNetworkCallback(captivePortalCallback);
|
mCm.unregisterNetworkCallback(captivePortalCallback);
|
||||||
|
|||||||
@@ -237,20 +237,6 @@ public class NetworkNotificationManagerTest {
|
|||||||
verify(mNotificationManager, times(1)).cancelAsUser(eq(tag), eq(SIGN_IN.eventId), any());
|
verify(mNotificationManager, times(1)).cancelAsUser(eq(tag), eq(SIGN_IN.eventId), any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSameLevelNotifications() {
|
|
||||||
final int id = 101;
|
|
||||||
final String tag = NetworkNotificationManager.tagFor(id);
|
|
||||||
|
|
||||||
mManager.showNotification(id, LOGGED_IN, mWifiNai, mCellNai, null, false);
|
|
||||||
verify(mNotificationManager, times(1))
|
|
||||||
.notifyAsUser(eq(tag), eq(LOGGED_IN.eventId), any(), any());
|
|
||||||
|
|
||||||
mManager.showNotification(id, LOST_INTERNET, mWifiNai, mCellNai, null, false);
|
|
||||||
verify(mNotificationManager, times(1))
|
|
||||||
.notifyAsUser(eq(tag), eq(LOST_INTERNET.eventId), any(), any());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testClearNotificationByType() {
|
public void testClearNotificationByType() {
|
||||||
final int id = 101;
|
final int id = 101;
|
||||||
@@ -259,31 +245,25 @@ public class NetworkNotificationManagerTest {
|
|||||||
// clearNotification(int id, NotificationType notifyType) will check if given type is equal
|
// clearNotification(int id, NotificationType notifyType) will check if given type is equal
|
||||||
// to previous type or not. If they are equal then clear the notification; if they are not
|
// to previous type or not. If they are equal then clear the notification; if they are not
|
||||||
// equal then return.
|
// equal then return.
|
||||||
|
mManager.showNotification(id, NO_INTERNET, mWifiNai, mCellNai, null, false);
|
||||||
mManager.showNotification(id, LOGGED_IN, mWifiNai, mCellNai, null, false);
|
|
||||||
verify(mNotificationManager, times(1))
|
verify(mNotificationManager, times(1))
|
||||||
.notifyAsUser(eq(tag), eq(LOGGED_IN.eventId), any(), any());
|
.notifyAsUser(eq(tag), eq(NO_INTERNET.eventId), any(), any());
|
||||||
|
|
||||||
// Previous notification is LOGGED_IN and given type is LOGGED_IN too. The notification
|
// Previous notification is NO_INTERNET and given type is NO_INTERNET too. The notification
|
||||||
// should be cleared.
|
// should be cleared.
|
||||||
mManager.clearNotification(id, LOGGED_IN);
|
mManager.clearNotification(id, NO_INTERNET);
|
||||||
verify(mNotificationManager, times(1))
|
verify(mNotificationManager, times(1))
|
||||||
.cancelAsUser(eq(tag), eq(LOGGED_IN.eventId), any());
|
.cancelAsUser(eq(tag), eq(NO_INTERNET.eventId), any());
|
||||||
|
|
||||||
mManager.showNotification(id, LOGGED_IN, mWifiNai, mCellNai, null, false);
|
// SIGN_IN is popped-up.
|
||||||
verify(mNotificationManager, times(2))
|
mManager.showNotification(id, SIGN_IN, mWifiNai, mCellNai, null, false);
|
||||||
.notifyAsUser(eq(tag), eq(LOGGED_IN.eventId), any(), any());
|
|
||||||
|
|
||||||
// LOST_INTERNET notification popup after LOGGED_IN notification.
|
|
||||||
mManager.showNotification(id, LOST_INTERNET, mWifiNai, mCellNai, null, false);
|
|
||||||
verify(mNotificationManager, times(1))
|
verify(mNotificationManager, times(1))
|
||||||
.notifyAsUser(eq(tag), eq(LOST_INTERNET.eventId), any(), any());
|
.notifyAsUser(eq(tag), eq(SIGN_IN.eventId), any(), any());
|
||||||
|
|
||||||
// Previous notification is LOST_INTERNET and given type is LOGGED_IN. The notification
|
// The notification type is not matching previous one, PARTIAL_CONNECTIVITY won't be
|
||||||
// shouldn't be cleared.
|
// cleared.
|
||||||
mManager.clearNotification(id, LOGGED_IN);
|
mManager.clearNotification(id, PARTIAL_CONNECTIVITY);
|
||||||
// LOST_INTERNET shouldn't be cleared.
|
|
||||||
verify(mNotificationManager, never())
|
verify(mNotificationManager, never())
|
||||||
.cancelAsUser(eq(tag), eq(LOST_INTERNET.eventId), any());
|
.cancelAsUser(eq(tag), eq(PARTIAL_CONNECTIVITY.eventId), any());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user