Snap for 12455219 from bc2755e0dbd9dcffcb5df23b7bf373f28bad920f to mainline-healthfitness-release Change-Id: I5a74ede95360dde8766957f140a13291a2165469
diff --git a/apishim/common/com/android/networkstack/apishim/common/ShimUtils.java b/apishim/common/com/android/networkstack/apishim/common/ShimUtils.java index 648751b..a7bf921 100644 --- a/apishim/common/com/android/networkstack/apishim/common/ShimUtils.java +++ b/apishim/common/com/android/networkstack/apishim/common/ShimUtils.java
@@ -44,13 +44,6 @@ } /** - * Check whether the device supports in-development or final R networking APIs. - */ - public static boolean isAtLeastR() { - return isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.Q); - } - - /** * Check whether the device supports in-development or final S networking APIs. */ public static boolean isAtLeastS() {
diff --git a/src/android/net/ip/IpClient.java b/src/android/net/ip/IpClient.java index 868c63b..0106d59 100644 --- a/src/android/net/ip/IpClient.java +++ b/src/android/net/ip/IpClient.java
@@ -44,7 +44,6 @@ import static android.net.ip.IpClient.IpClientCommands.CMD_UPDATE_APF_DATA_SNAPSHOT; import static android.net.ip.IpClient.IpClientCommands.CMD_UPDATE_HTTP_PROXY; import static android.net.ip.IpClient.IpClientCommands.CMD_UPDATE_L2INFORMATION; -import static android.net.ip.IpClient.IpClientCommands.CMD_UPDATE_L2KEY_CLUSTER; import static android.net.ip.IpClient.IpClientCommands.CMD_UPDATE_TCP_BUFFER_SIZES; import static android.net.ip.IpClient.IpClientCommands.EVENT_DHCPACTION_TIMEOUT; import static android.net.ip.IpClient.IpClientCommands.EVENT_IPV6_AUTOCONF_TIMEOUT; @@ -134,7 +133,6 @@ import android.net.shared.ProvisioningConfiguration; import android.net.shared.ProvisioningConfiguration.ScanResultInfo; import android.net.shared.ProvisioningConfiguration.ScanResultInfo.InformationElement; -import android.os.Build; import android.os.ConditionVariable; import android.os.Handler; import android.os.IBinder; @@ -152,7 +150,6 @@ import android.text.format.DateUtils; import android.util.LocalLog; import android.util.Log; -import android.util.Pair; import android.util.SparseArray; import androidx.annotation.NonNull; @@ -601,16 +598,15 @@ static final int EVENT_READ_PACKET_FILTER_COMPLETE = 12; static final int CMD_ADD_KEEPALIVE_PACKET_FILTER_TO_APF = 13; static final int CMD_REMOVE_KEEPALIVE_PACKET_FILTER_FROM_APF = 14; - static final int CMD_UPDATE_L2KEY_CLUSTER = 15; - static final int CMD_COMPLETE_PRECONNECTION = 16; - static final int CMD_UPDATE_L2INFORMATION = 17; - static final int CMD_SET_DTIM_MULTIPLIER_AFTER_DELAY = 18; - static final int CMD_UPDATE_APF_CAPABILITIES = 19; - static final int EVENT_IPV6_AUTOCONF_TIMEOUT = 20; - static final int CMD_UPDATE_APF_DATA_SNAPSHOT = 21; - static final int EVENT_NUD_FAILURE_QUERY_TIMEOUT = 22; - static final int EVENT_NUD_FAILURE_QUERY_SUCCESS = 23; - static final int EVENT_NUD_FAILURE_QUERY_FAILURE = 24; + static final int CMD_COMPLETE_PRECONNECTION = 15; + static final int CMD_UPDATE_L2INFORMATION = 16; + static final int CMD_SET_DTIM_MULTIPLIER_AFTER_DELAY = 17; + static final int CMD_UPDATE_APF_CAPABILITIES = 18; + static final int EVENT_IPV6_AUTOCONF_TIMEOUT = 19; + static final int CMD_UPDATE_APF_DATA_SNAPSHOT = 20; + static final int EVENT_NUD_FAILURE_QUERY_TIMEOUT = 21; + static final int EVENT_NUD_FAILURE_QUERY_SUCCESS = 22; + static final int EVENT_NUD_FAILURE_QUERY_FAILURE = 23; // Internal commands to use instead of trying to call transitionTo() inside // a given State's enter() method. Calling transitionTo() from enter/exit // encounters a Log.wtf() that can cause trouble on eng builds. @@ -635,11 +631,6 @@ private static final int MAX_PACKET_RECORDS = 100; @VisibleForTesting - static final String CONFIG_MIN_RDNSS_LIFETIME = "ipclient_min_rdnss_lifetime"; - private static final int DEFAULT_MIN_RDNSS_LIFETIME = - ShimUtils.isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.Q) ? 120 : 0; - - @VisibleForTesting static final String CONFIG_ACCEPT_RA_MIN_LFT = "ipclient_accept_ra_min_lft"; @VisibleForTesting static final int DEFAULT_ACCEPT_RA_MIN_LFT = 180; @@ -799,9 +790,6 @@ @Nullable private final DevicePolicyManager mDevicePolicyManager; - // Ignore nonzero RDNSS option lifetimes below this value. 0 = disabled. - private final int mMinRdnssLifetimeSec; - // Ignore any nonzero RA section with lifetime below this value. private final int mAcceptRaMinLft; @@ -1063,8 +1051,6 @@ mDhcp6PrefixDelegationEnabled = mDependencies.isFeatureEnabled(mContext, IPCLIENT_DHCPV6_PREFIX_DELEGATION_VERSION); - mMinRdnssLifetimeSec = mDependencies.getDeviceConfigPropertyInt( - CONFIG_MIN_RDNSS_LIFETIME, DEFAULT_MIN_RDNSS_LIFETIME); mAcceptRaMinLft = mDependencies.getDeviceConfigPropertyInt(CONFIG_ACCEPT_RA_MIN_LFT, DEFAULT_ACCEPT_RA_MIN_LFT); mApfCounterPollingIntervalMs = mDependencies.getDeviceConfigPropertyInt( @@ -1095,7 +1081,7 @@ DEFAULT_NUD_FAILURE_COUNT_WEEKLY_THRESHOLD); IpClientLinkObserver.Configuration config = new IpClientLinkObserver.Configuration( - mMinRdnssLifetimeSec, mPopulateLinkAddressLifetime); + mAcceptRaMinLft, mPopulateLinkAddressLifetime); mLinkObserver = new IpClientLinkObserver( mContext, getHandler(), @@ -1205,7 +1191,8 @@ @Override public void setL2KeyAndGroupHint(String l2Key, String cluster) { enforceNetworkStackCallingPermission(); - IpClient.this.setL2KeyAndCluster(l2Key, cluster); + // This method is not supported anymore. The caller should call + // #updateLayer2Information() instead. } @Override public void setTcpBufferSizes(String tcpBufferSizes) { @@ -1399,18 +1386,6 @@ } /** - * Set the L2 key and cluster for storing info into the memory store. - * - * This method is only supported on Q devices. For R or above releases, - * caller should call #updateLayer2Information() instead. - */ - public void setL2KeyAndCluster(String l2Key, String cluster) { - if (!ShimUtils.isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.Q)) { - sendMessage(CMD_UPDATE_L2KEY_CLUSTER, new Pair<>(l2Key, cluster)); - } - } - - /** * Set the HTTP Proxy configuration to use. * * This may be called, repeatedly, at any time before or after a call to @@ -2748,7 +2723,7 @@ apfConfig.multicastFilter = mMulticastFiltering; // Get the Configuration for ApfFilter from Context // Resource settings were moved from ApfCapabilities APIs to NetworkStack resources in S - if (ShimUtils.isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.R)) { + if (ShimUtils.isAtLeastS()) { final Resources res = mContext.getResources(); apfConfig.ieee802_3Filter = res.getBoolean(R.bool.config_apfDrop802_3Frames); apfConfig.ethTypeBlackList = res.getIntArray(R.array.config_apfEthTypeDenyList); @@ -2757,7 +2732,9 @@ apfConfig.ethTypeBlackList = ApfCapabilities.getApfEtherTypeBlackList(); } - apfConfig.minRdnssLifetimeSec = mMinRdnssLifetimeSec; + // The RDNSS option is not processed by the kernel, so lifetime filtering + // can occur independent of kernel support for accept_ra_min_lft. + apfConfig.minRdnssLifetimeSec = mAcceptRaMinLft; // Check the feature flag first before reading IPv6 sysctl, which can prevent from // triggering a potential kernel bug about the sysctl. // TODO: add unit test to check if the setIpv6Sysctl() is called or not. @@ -2848,13 +2825,6 @@ handleLinkPropertiesUpdate(NO_CALLBACKS); break; - case CMD_UPDATE_L2KEY_CLUSTER: { - final Pair<String, String> args = (Pair<String, String>) msg.obj; - mL2Key = args.first; - mCluster = args.second; - break; - } - case CMD_SET_MULTICAST_FILTER: mMulticastFiltering = (boolean) msg.obj; break; @@ -3212,20 +3182,6 @@ transitionToStoppingState(DisconnectCode.forNumber(msg.arg1)); break; - case CMD_UPDATE_L2KEY_CLUSTER: { - final Pair<String, String> args = (Pair<String, String>) msg.obj; - mL2Key = args.first; - mCluster = args.second; - // TODO : attributes should be saved to the memory store with - // these new values if they differ from the previous ones. - // If the state machine is in pure StartedState, then the values to input - // are not known yet and should be updated when the LinkProperties are updated. - // If the state machine is in RunningState (which is a child of StartedState) - // then the next NUD check should be used to store the new values to avoid - // inputting current values for what may be a different L3 network. - break; - } - case CMD_UPDATE_L2INFORMATION: handleUpdateL2Information((Layer2InformationParcelable) msg.obj); break;
diff --git a/src/com/android/server/NetworkStackService.java b/src/com/android/server/NetworkStackService.java index 76b5e38..686a399 100644 --- a/src/com/android/server/NetworkStackService.java +++ b/src/com/android/server/NetworkStackService.java
@@ -53,7 +53,6 @@ import android.net.shared.PrivateDnsConfig; import android.net.util.RawPacketTracker; import android.net.util.RawSocketUtils; -import android.os.Build; import android.os.HandlerThread; import android.os.IBinder; import android.os.Looper; @@ -74,7 +73,6 @@ import com.android.net.module.util.SharedLog; import com.android.networkstack.NetworkStackNotifier; import com.android.networkstack.R; -import com.android.networkstack.apishim.common.ShimUtils; import com.android.networkstack.ipmemorystore.IpMemoryStoreService; import com.android.server.connectivity.NetworkMonitor; import com.android.server.util.PermissionUtil; @@ -208,7 +206,6 @@ @GuardedBy("mIpClients") private final ArrayList<WeakReference<IpClient>> mIpClients = new ArrayList<>(); private final IpMemoryStoreService mIpMemoryStoreService; - @Nullable private final NetworkStackNotifier mNotifier; private static final int MAX_VALIDATION_LOGS = 10; @@ -303,15 +300,10 @@ mNetd = INetd.Stub.asInterface( (IBinder) context.getSystemService(Context.NETD_SERVICE)); mIpMemoryStoreService = mDeps.makeIpMemoryStoreService(context); - // NetworkStackNotifier only shows notifications relevant for API level > Q - if (ShimUtils.isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.Q)) { - final HandlerThread notifierThread = new HandlerThread( - NetworkStackNotifier.class.getSimpleName()); - notifierThread.start(); - mNotifier = mDeps.makeNotifier(context, notifierThread.getLooper()); - } else { - mNotifier = null; - } + final HandlerThread notifierThread = new HandlerThread( + NetworkStackNotifier.class.getSimpleName()); + notifierThread.start(); + mNotifier = mDeps.makeNotifier(context, notifierThread.getLooper()); int netdVersion; String netdHash; @@ -730,11 +722,6 @@ * Dump version information of the module and detected system version. */ private void dumpVersion(@NonNull PrintWriter fout) { - if (!ShimUtils.isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.Q)) { - dumpVersionNumberOnly(fout); - return; - } - fout.println("LocalInterface:" + this.VERSION + ":" + this.HASH); synchronized (mAidlVersions) { // Sort versions for deterministic order in output
diff --git a/src/com/android/server/connectivity/NetworkMonitor.java b/src/com/android/server/connectivity/NetworkMonitor.java index 1a36f25..659e911 100755 --- a/src/com/android/server/connectivity/NetworkMonitor.java +++ b/src/com/android/server/connectivity/NetworkMonitor.java
@@ -125,7 +125,6 @@ import android.net.util.Stopwatch; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; -import android.os.Build; import android.os.Bundle; import android.os.CancellationSignal; import android.os.Message; @@ -476,7 +475,6 @@ private final TelephonyManager mTelephonyManager; private final WifiManager mWifiManager; private final ConnectivityManager mCm; - @Nullable private final NetworkStackNotifier mNotifier; private final IpConnectivityLog mMetricsLog; private final Dependencies mDependencies; @@ -1439,7 +1437,7 @@ final CaptivePortalProbeResult probeRes = mLastPortalProbeResult; // Use redirect URL from AP if exists. final String portalUrl = - (useRedirectUrlForPortal() && makeURL(probeRes.redirectUrl) != null) + (makeURL(probeRes.redirectUrl) != null) ? probeRes.redirectUrl : probeRes.detectUrl; appExtras.putString(EXTRA_CAPTIVE_PORTAL_URL, portalUrl); if (probeRes.probeSpec != null) { @@ -1448,9 +1446,7 @@ } appExtras.putString(ConnectivityManager.EXTRA_CAPTIVE_PORTAL_USER_AGENT, mCaptivePortalUserAgent); - if (mNotifier != null) { - mNotifier.notifyCaptivePortalValidationPending(network); - } + mNotifier.notifyCaptivePortalValidationPending(network); mCm.startCaptivePortalApp(network, appExtras); return HANDLED; default: @@ -1458,12 +1454,6 @@ } } - private boolean useRedirectUrlForPortal() { - // It must match the conditions in CaptivePortalLogin in which the redirect URL is not - // used to validate that the portal is gone. - return ShimUtils.isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.Q); - } - @Override public void exit() { if (mLaunchCaptivePortalAppBroadcastReceiver != null) {
diff --git a/tests/integration/common/android/net/ip/IpClientIntegrationTestCommon.java b/tests/integration/common/android/net/ip/IpClientIntegrationTestCommon.java index 469a944..ff402dc 100644 --- a/tests/integration/common/android/net/ip/IpClientIntegrationTestCommon.java +++ b/tests/integration/common/android/net/ip/IpClientIntegrationTestCommon.java
@@ -43,7 +43,6 @@ import static android.net.ip.IpClient.CONFIG_APF_COUNTER_POLLING_INTERVAL_SECS; import static android.net.ip.IpClient.CONFIG_NUD_FAILURE_COUNT_DAILY_THRESHOLD; import static android.net.ip.IpClient.CONFIG_NUD_FAILURE_COUNT_WEEKLY_THRESHOLD; -import static android.net.ip.IpClient.DEFAULT_ACCEPT_RA_MIN_LFT; import static android.net.ip.IpClient.DEFAULT_APF_COUNTER_POLLING_INTERVAL_SECS; import static android.net.ip.IpClient.DEFAULT_NUD_FAILURE_COUNT_DAILY_THRESHOLD; import static android.net.ip.IpClient.DEFAULT_NUD_FAILURE_COUNT_WEEKLY_THRESHOLD; @@ -195,7 +194,6 @@ import android.os.PowerManager; import android.os.RemoteException; import android.os.SystemClock; -import android.os.SystemProperties; import android.provider.Settings; import android.stats.connectivity.NudEventType; import android.system.ErrnoException; @@ -230,8 +228,6 @@ import com.android.net.module.util.structs.RdnssOption; import com.android.networkstack.R; import com.android.networkstack.apishim.CaptivePortalDataShimImpl; -import com.android.networkstack.apishim.ConstantsShim; -import com.android.networkstack.apishim.common.ShimUtils; import com.android.networkstack.ipmemorystore.IpMemoryStoreService; import com.android.networkstack.metrics.IpProvisioningMetrics; import com.android.networkstack.metrics.IpReachabilityMonitorMetrics; @@ -854,7 +850,6 @@ return null; }).when(mIpMemoryStore).retrieveNetworkEventCount(eq(TEST_CLUSTER), any(), any(), any()); - setDeviceConfigProperty(IpClient.CONFIG_MIN_RDNSS_LIFETIME, 67); setDeviceConfigProperty(DhcpClient.DHCP_RESTART_CONFIG_DELAY, 10); setDeviceConfigProperty(DhcpClient.ARP_FIRST_PROBE_DELAY_MS, 10); setDeviceConfigProperty(DhcpClient.ARP_PROBE_MIN_MS, 10); @@ -872,7 +867,7 @@ // Set the minimal RA lifetime value, any RA section with liftime below this value will be // ignored. - setDeviceConfigProperty(CONFIG_ACCEPT_RA_MIN_LFT, DEFAULT_ACCEPT_RA_MIN_LFT); + setDeviceConfigProperty(CONFIG_ACCEPT_RA_MIN_LFT, 67); // Set the polling interval to update APF data snapshot. setDeviceConfigProperty(CONFIG_APF_COUNTER_POLLING_INTERVAL_SECS, @@ -1303,23 +1298,13 @@ final List<DhcpPacket> packetList) throws Exception { for (DhcpPacket packet : packetList) { if (!expectSendHostname || hostname == null) { - assertNoHostname(packet.getHostname()); + assertNull(packet.getHostname()); } else { assertEquals(hostnameAfterTransliteration, packet.getHostname()); } } } - private void assertNoHostname(String hostname) { - if (ShimUtils.isAtLeastR()) { - assertNull(hostname); - } else { - // Until Q, if no hostname is set, the device falls back to the hostname set via - // system property, to avoid breaking Q devices already launched with that setup. - assertEquals(SystemProperties.get("net.hostname"), hostname); - } - } - // Helper method to complete DHCP 2-way or 4-way handshake private List<DhcpPacket> performDhcpHandshake(final boolean isSuccessLease, final Integer leaseTimeSec, final boolean shouldReplyRapidCommitAck, final int mtu, @@ -1770,7 +1755,7 @@ assertIpMemoryStoreNetworkAttributes(TEST_LEASE_DURATION_S, currentTime, TEST_DEFAULT_MTU); } - @Test @IgnoreUpTo(Build.VERSION_CODES.Q) + @Test public void testRollbackFromRapidCommitOption() throws Exception { startIpClientProvisioning(true /* isDhcpRapidCommitEnabled */, false /* isPreConnectionEnabled */, @@ -1856,10 +1841,8 @@ assertTrue(packet instanceof DhcpDiscoverPacket); } - @Test @IgnoreUpTo(Build.VERSION_CODES.Q) + @Test public void testDhcpServerInLinkProperties() throws Exception { - assumeTrue(ConstantsShim.VERSION > Build.VERSION_CODES.Q); - performDhcpHandshake(); ArgumentCaptor<LinkProperties> captor = ArgumentCaptor.forClass(LinkProperties.class); verify(mCb, timeout(TEST_TIMEOUT_MS)).onProvisioningSuccess(captor.capture()); @@ -2267,13 +2250,13 @@ LinkProperties lp = doIpv6OnlyProvisioning(inOrder, ra); - // Expect that DNS servers with lifetimes below CONFIG_MIN_RDNSS_LIFETIME are not accepted. + // Expect that DNS servers with lifetimes below CONFIG_ACCEPT_RA_MIN_LFT are not accepted. assertNotNull(lp); assertEquals(1, lp.getDnsServers().size()); assertTrue(lp.getDnsServers().contains(InetAddress.getByName(dnsServer))); // If the RDNSS lifetime is above the minimum, the DNS server is accepted. - rdnss1 = buildRdnssOption(68, lowlifeDnsServer); + rdnss1 = buildRdnssOption(67, lowlifeDnsServer); ra = buildRaPacket(pio, rdnss1, rdnss2); mPacketReader.sendResponse(ra); inOrder.verify(mCb, timeout(TEST_TIMEOUT_MS)).onLinkPropertiesChange(captor.capture()); @@ -2338,11 +2321,9 @@ } - @Test @IgnoreUpTo(Build.VERSION_CODES.Q) + @Test @SignatureRequiredTest(reason = "TODO: evaluate whether signature perms are required") public void testPref64Option() throws Exception { - assumeTrue(ConstantsShim.VERSION > Build.VERSION_CODES.Q); - ProvisioningConfiguration config = new ProvisioningConfiguration.Builder() .withoutIpReachabilityMonitor() .withoutIPv4() @@ -2815,8 +2796,6 @@ argThat(lp -> lp.getMtu() == testMtu)); // Ensure that the URL was set as expected in the callbacks. - // Can't verify the URL up to Q as there is no such attribute in LinkProperties. - if (!ShimUtils.isAtLeastR()) return null; verify(mCb, atLeastOnce()).onLinkPropertiesChange(captor.capture()); final LinkProperties expectedLp = captor.getAllValues().stream().findFirst().get(); assertNotNull(expectedLp);
diff --git a/tests/unit/src/android/net/ip/IpClientTest.java b/tests/unit/src/android/net/ip/IpClientTest.java index 3fc843e..2fb0a7f 100644 --- a/tests/unit/src/android/net/ip/IpClientTest.java +++ b/tests/unit/src/android/net/ip/IpClientTest.java
@@ -531,19 +531,20 @@ final IpClient ipc = makeIpClient(iface); final String l2Key = TEST_L2KEY; final String cluster = TEST_CLUSTER; + final MacAddress bssid = MacAddress.fromString(TEST_BSSID); ProvisioningConfiguration config = new ProvisioningConfiguration.Builder() .withoutIPv4() .withoutIpReachabilityMonitor() .withInitialConfiguration( conf(links(TEST_LOCAL_ADDRESSES), prefixes(TEST_PREFIXES), ips())) + .withLayer2Information(new Layer2Information(l2Key, cluster, bssid)) .build(); ipc.startProvisioning(config); verify(mCb, timeout(TEST_TIMEOUT_MS).times(1)).setNeighborDiscoveryOffload(true); verify(mCb, timeout(TEST_TIMEOUT_MS).times(1)).setFallbackMulticastFilter(false); verify(mCb, never()).onProvisioningFailure(any()); - ipc.setL2KeyAndCluster(l2Key, cluster); for (String addr : TEST_LOCAL_ADDRESSES) { String[] parts = addr.split("/");