Snap for 7744644 from eafcccbfecdb38f21c2fb0c8ad2d75e067d85386 to mainline-extservices-release Change-Id: I9d5573e0f098ce5de0205dafce4775b347b46a78
diff --git a/TEST_MAPPING b/TEST_MAPPING index 2bb0e61..ed6a1a8 100644 --- a/TEST_MAPPING +++ b/TEST_MAPPING
@@ -40,8 +40,7 @@ // We must specify at least one module here or the tests won't run. Use the same set as CTS // so in theory the infra would not need to reinstall/reboot devices to run both. { - // TODO: add back tethering when it is updatable in this branch - "name": "NetworkStackTests[CaptivePortalLoginGoogle.apk+NetworkStackGoogle.apk+com.google.android.resolv.apex]" + "name": "NetworkStackTests[CaptivePortalLoginGoogle.apk+NetworkStackGoogle.apk+com.google.android.resolv.apex+com.google.android.tethering.apex]" } ], "mainline-postsubmit": [
diff --git a/common/networkstackclient/Android.bp b/common/networkstackclient/Android.bp index 02a39f6..c344d07 100644 --- a/common/networkstackclient/Android.bp +++ b/common/networkstackclient/Android.bp
@@ -121,7 +121,7 @@ enabled: false, }, }, - imports: ["ipmemorystore-aidl-interfaces"], + imports: ["ipmemorystore-aidl-interfaces-V10"], versions: [ "1", "2",
diff --git a/res/values-da/strings.xml b/res/values-da/strings.xml index e54f11c..706f174 100644 --- a/res/values-da/strings.xml +++ b/res/values-da/strings.xml
@@ -19,7 +19,7 @@ <string name="notification_channel_name_connected" msgid="1795068343200033922">"Godkendelse til loginportal"</string> <string name="notification_channel_description_connected" msgid="7239184168268014518">"De notifikationer, der vises, når enheden er blevet godkendt til et netværk via en loginportal"</string> <string name="notification_channel_name_network_venue_info" msgid="6526543187249265733">"Oplysninger om netværksplacering"</string> - <string name="notification_channel_description_network_venue_info" msgid="5131499595382733605">"Notifikationer, der vises for at indikere, at netværket har en side med oplysninger om placeringen"</string> + <string name="notification_channel_description_network_venue_info" msgid="5131499595382733605">"Notifikationer, der vises for at indikere, at netværket har en side med oplysninger om lokationen"</string> <string name="connected" msgid="4563643884927480998">"Der er oprettet forbindelse"</string> <string name="tap_for_info" msgid="6849746325626883711">"Der er oprettet forbindelse/tryk for at se website"</string> <string name="application_label" msgid="1322847171305285454">"Netværksadministrator"</string>
diff --git a/src/android/net/ip/IpClient.java b/src/android/net/ip/IpClient.java index 4de9393..6746680 100644 --- a/src/android/net/ip/IpClient.java +++ b/src/android/net/ip/IpClient.java
@@ -715,7 +715,7 @@ (ifaceUp) -> sendMessage(EVENT_NETLINK_LINKPROPERTIES_CHANGED, ifaceUp ? ARG_LINKPROP_CHANGED_LINKSTATE_UP : ARG_LINKPROP_CHANGED_LINKSTATE_DOWN), - config, mLog) { + config, mLog, mDependencies) { @Override public void onInterfaceAdded(String iface) { super.onInterfaceAdded(iface);
diff --git a/src/android/net/ip/IpClientLinkObserver.java b/src/android/net/ip/IpClientLinkObserver.java index 3702674..ff0aafe 100644 --- a/src/android/net/ip/IpClientLinkObserver.java +++ b/src/android/net/ip/IpClientLinkObserver.java
@@ -16,6 +16,7 @@ package android.net.ip; +import static android.net.util.NetworkStackUtils.IPCLIENT_PARSE_NETLINK_EVENTS_VERSION; import static android.system.OsConstants.AF_INET6; import static com.android.net.module.util.NetworkStackConstants.ICMPV6_ROUTER_ADVERTISEMENT; @@ -37,6 +38,7 @@ import com.android.net.module.util.netlink.NetlinkConstants; import com.android.net.module.util.netlink.NetlinkMessage; import com.android.net.module.util.netlink.StructNdOptPref64; +import com.android.net.module.util.netlink.StructNdOptRdnss; import com.android.networkstack.apishim.NetworkInformationShimImpl; import com.android.networkstack.apishim.common.NetworkInformationShim; import com.android.server.NetworkObserver; @@ -107,6 +109,7 @@ } } + private final Context mContext; private final String mInterfaceName; private final Callback mCallback; private final LinkProperties mLinkProperties; @@ -115,13 +118,15 @@ private final AlarmManager mAlarmManager; private final Configuration mConfig; private final Handler mHandler; + private final IpClient.Dependencies mDependencies; private final MyNetlinkMonitor mNetlinkMonitor; private static final boolean DBG = false; public IpClientLinkObserver(Context context, Handler h, String iface, Callback callback, - Configuration config, SharedLog log) { + Configuration config, SharedLog log, IpClient.Dependencies deps) { + mContext = context; mInterfaceName = iface; mTag = "NetlinkTracker/" + mInterfaceName; mCallback = callback; @@ -134,6 +139,7 @@ mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); mNetlinkMonitor = new MyNetlinkMonitor(h, log, mTag); mHandler.post(mNetlinkMonitor::start); + mDependencies = deps; } public void shutdown() { @@ -153,6 +159,11 @@ } } + private boolean isNetlinkEventParsingEnabled() { + return mDependencies.isFeatureEnabled(mContext, IPCLIENT_PARSE_NETLINK_EVENTS_VERSION, + false /* default value */); + } + @Override public void onInterfaceRemoved(String iface) { maybeLog("interfaceRemoved", iface); @@ -246,17 +257,21 @@ @Override public void onInterfaceDnsServerInfo(String iface, long lifetime, String[] addresses) { - if (mInterfaceName.equals(iface)) { - maybeLog("interfaceDnsServerInfo", Arrays.toString(addresses)); - final boolean changed = mDnsServerRepository.addServers(lifetime, addresses); - final boolean linkState; - if (changed) { - synchronized (this) { - mDnsServerRepository.setDnsServersOn(mLinkProperties); - linkState = getInterfaceLinkStateLocked(); - } - mCallback.update(linkState); + if (isNetlinkEventParsingEnabled()) return; + if (!mInterfaceName.equals(iface)) return; + maybeLog("interfaceDnsServerInfo", Arrays.toString(addresses)); + updateInterfaceDnsServerInfo(lifetime, addresses); + } + + private void updateInterfaceDnsServerInfo(long lifetime, final String[] addresses) { + final boolean changed = mDnsServerRepository.addServers(lifetime, addresses); + final boolean linkState; + if (changed) { + synchronized (this) { + mDnsServerRepository.setDnsServersOn(mLinkProperties); + linkState = getInterfaceLinkStateLocked(); } + mCallback.update(linkState); } } @@ -408,6 +423,15 @@ updatePref64(opt.prefix, now, expiry); } + private void processRdnssOption(StructNdOptRdnss opt) { + if (!isNetlinkEventParsingEnabled()) return; + final String[] addresses = new String[opt.servers.length]; + for (int i = 0; i < opt.servers.length; i++) { + addresses[i] = opt.servers[i].getHostAddress(); + } + updateInterfaceDnsServerInfo(opt.header.lifetime, addresses); + } + private void processNduseroptMessage(NduseroptMessage msg, final long whenMs) { if (msg.family != AF_INET6 || msg.option == null || msg.ifindex != mIfindex) return; if (msg.icmp_type != (byte) ICMPV6_ROUTER_ADVERTISEMENT) return; @@ -417,8 +441,12 @@ processPref64Option((StructNdOptPref64) msg.option, whenMs); break; + case StructNdOptRdnss.TYPE: + processRdnssOption((StructNdOptRdnss) msg.option); + break; + default: - // TODO: implement RDNSS and DNSSL. + // TODO: implement DNSSL. break; } }
diff --git a/src/android/net/util/NetworkStackUtils.java b/src/android/net/util/NetworkStackUtils.java index e06cdca..6dc2a5b 100755 --- a/src/android/net/util/NetworkStackUtils.java +++ b/src/android/net/util/NetworkStackUtils.java
@@ -250,6 +250,13 @@ "ipclient_garp_na_roaming_version"; /** + * Experiment flag to enable parsing netlink events from kernel directly instead from netd aidl + * interface. + */ + public static final String IPCLIENT_PARSE_NETLINK_EVENTS_VERSION = + "ipclient_parse_netlink_events_version"; + + /** * Experiment flag to disable accept_ra parameter when IPv6 provisioning loss happens due to * the default route has gone. */
diff --git a/src/com/android/server/connectivity/NetworkMonitor.java b/src/com/android/server/connectivity/NetworkMonitor.java index 131b3b2..cb0ee18 100755 --- a/src/com/android/server/connectivity/NetworkMonitor.java +++ b/src/com/android/server/connectivity/NetworkMonitor.java
@@ -623,6 +623,10 @@ // even before notifyNetworkConnected. mLinkProperties = new LinkProperties(); mNetworkCapabilities = new NetworkCapabilities(null); + + Log.d(TAG, "Starting on network " + mNetwork + + " with capport HTTPS URL " + Arrays.toString(mCaptivePortalHttpsUrls) + + " and HTTP URL " + Arrays.toString(mCaptivePortalHttpUrls)); } /** @@ -1982,11 +1986,17 @@ } final long now = System.currentTimeMillis(); - if (expTime < now || (expTime - now) > TEST_URL_EXPIRATION_MS) return null; + if (expTime < now || (expTime - now) > TEST_URL_EXPIRATION_MS) { + logw("Skipping test URL with expiration " + expTime + ", now " + now); + return null; + } final String strUrl = mDependencies.getDeviceConfigProperty(NAMESPACE_CONNECTIVITY, key, null /* defaultValue */); - if (!isValidTestUrl(strUrl)) return null; + if (!isValidTestUrl(strUrl)) { + logw("Skipping invalid test URL " + strUrl); + return null; + } return makeURL(strUrl); }
diff --git a/tests/integration/src/android/net/ip/IpClientIntegrationTestCommon.java b/tests/integration/src/android/net/ip/IpClientIntegrationTestCommon.java index bbbe0ba..6ade54f 100644 --- a/tests/integration/src/android/net/ip/IpClientIntegrationTestCommon.java +++ b/tests/integration/src/android/net/ip/IpClientIntegrationTestCommon.java
@@ -146,7 +146,6 @@ import androidx.annotation.NonNull; import androidx.test.InstrumentationRegistry; import androidx.test.filters.SmallTest; -import androidx.test.runner.AndroidJUnit4; import com.android.internal.util.HexDump; import com.android.internal.util.StateMachine; @@ -181,6 +180,7 @@ import org.junit.Test; import org.junit.rules.TestName; import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; import org.mockito.ArgumentCaptor; import org.mockito.InOrder; import org.mockito.Mock; @@ -224,7 +224,7 @@ * * Tests in this class can either be run with signature permissions, or with root access. */ -@RunWith(AndroidJUnit4.class) +@RunWith(Parameterized.class) @SmallTest public abstract class IpClientIntegrationTestCommon { private static final int DATA_BUFFER_LEN = 4096; @@ -247,6 +247,17 @@ @Rule public final TestName mTestNameRule = new TestName(); + // Indicate whether the flag of parsing netlink event is enabled or not. If it's disabled, + // integration test still covers the old codepath(i.e. using NetworkObserver), otherwise, + // test goes through the new codepath(i.e. processRtNetlinkxxx). + @Parameterized.Parameter(0) + public boolean mIsNetlinkEventParseEnabled; + + @Parameterized.Parameters + public static Iterable<? extends Object> data() { + return Arrays.asList(Boolean.valueOf("false"), Boolean.valueOf("true")); + } + /** * Indicates that a test requires signature permissions to run. * @@ -553,8 +564,14 @@ @Before public void setUp() throws Exception { - final Method testMethod = IpClientIntegrationTestCommon.class.getMethod( - mTestNameRule.getMethodName()); + // Suffix "[0]" or "[1]" is added to the end of test method name after running with + // Parameterized.class, that's intended behavior, to iterate each test method with the + // parameterize value. However, Class#getMethod() throws NoSuchMethodException when + // searching the target test method name due to this change. Just keep the original test + // method name to fix NoSuchMethodException, and find the correct annotation associated + // to test method. + final String testMethodName = mTestNameRule.getMethodName().split("\\[")[0]; + final Method testMethod = IpClientIntegrationTestCommon.class.getMethod(testMethodName); mIsSignatureRequiredTest = testMethod.getAnnotation(SignatureRequiredTest.class) != null; assumeFalse(testSkipped()); @@ -567,6 +584,12 @@ } mIIpClient = makeIIpClient(mIfaceName, mCb); + + // Depend on the parameterized value to enable/disable netlink message refactor flag. + // Make sure both of the old codepath(rely on the INetdUnsolicitedEventListener aidl) + // and new codepath(parse netlink event from kernel) will be executed. + setFeatureEnabled(NetworkStackUtils.IPCLIENT_PARSE_NETLINK_EVENTS_VERSION, + mIsNetlinkEventParseEnabled /* default value */); } protected void setUpMocks() throws Exception {
diff --git a/tests/unit/Android.bp b/tests/unit/Android.bp index a74d018..fa054fe 100644 --- a/tests/unit/Android.bp +++ b/tests/unit/Android.bp
@@ -56,10 +56,7 @@ min_sdk_version: "29", srcs: [], // TODO: tests that only apply to the current, non-stable API can be added here test_suites: ["general-tests"], - test_mainline_modules: [ - "CaptivePortalLoginGoogle.apk+NetworkStackGoogle.apk+com.google.android.resolv.apex", - "CaptivePortalLoginGoogle.apk+NetworkStackGoogle.apk+com.google.android.resolv.apex+com.google.android.tethering.apex" - ], + test_mainline_modules: ["CaptivePortalLoginGoogle.apk+NetworkStackGoogle.apk+com.google.android.resolv.apex+com.google.android.tethering.apex"], defaults: ["NetworkStackTestsDefaults"], static_libs: ["NetworkStackApiCurrentLib"], compile_multilib: "both", // Workaround for b/147785146 for mainline-presubmit @@ -86,10 +83,7 @@ min_sdk_version: "29", target_sdk_version: "30", test_suites: ["general-tests", "mts"], - test_mainline_modules: [ - "CaptivePortalLoginGoogle.apk+NetworkStackGoogle.apk+com.google.android.resolv.apex", - "CaptivePortalLoginGoogle.apk+NetworkStackGoogle.apk+com.google.android.resolv.apex+com.google.android.tethering.apex" - ], + test_mainline_modules: ["CaptivePortalLoginGoogle.apk+NetworkStackGoogle.apk+com.google.android.resolv.apex+com.google.android.tethering.apex"], defaults: ["NetworkStackTestsDefaults"], static_libs: ["NetworkStackApiStableLib"], compile_multilib: "both",