Merge "Moves all compatibility flags to ConnectivityCompatChanges.java" am: 985534c95b
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2428795 Change-Id: I66949aeedb6eb24539df51f5918c4f8b48551ef4 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -144,7 +144,6 @@ apex {
|
||||
|
||||
compat_configs: [
|
||||
"connectivity-platform-compat-config",
|
||||
"connectivity-t-platform-compat-config",
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
@@ -164,6 +164,7 @@ java_sdk_library {
|
||||
],
|
||||
}
|
||||
|
||||
// This rule is not used anymore(b/268440216).
|
||||
platform_compat_config {
|
||||
name: "connectivity-t-platform-compat-config",
|
||||
src: ":framework-connectivity-t",
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package android.net.nsd;
|
||||
|
||||
import static android.net.connectivity.ConnectivityCompatChanges.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER;
|
||||
|
||||
import android.annotation.IntDef;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
@@ -24,8 +26,6 @@ import android.annotation.SdkConstant;
|
||||
import android.annotation.SdkConstant.SdkConstantType;
|
||||
import android.annotation.SystemService;
|
||||
import android.app.compat.CompatChanges;
|
||||
import android.compat.annotation.ChangeId;
|
||||
import android.compat.annotation.EnabledSince;
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.ConnectivityManager.NetworkCallback;
|
||||
@@ -136,28 +136,6 @@ public final class NsdManager {
|
||||
private static final String TAG = NsdManager.class.getSimpleName();
|
||||
private static final boolean DBG = false;
|
||||
|
||||
/**
|
||||
* When enabled, apps targeting < Android 12 are considered legacy for
|
||||
* the NSD native daemon.
|
||||
* The platform will only keep the daemon running as long as there are
|
||||
* any legacy apps connected.
|
||||
*
|
||||
* After Android 12, direct communication with the native daemon might not work since the native
|
||||
* daemon won't always stay alive. Using the NSD APIs from NsdManager as the replacement is
|
||||
* recommended.
|
||||
* Another alternative could be bundling your own mdns solutions instead of
|
||||
* depending on the system mdns native daemon.
|
||||
*
|
||||
* This compatibility change applies to Android 13 and later only. To toggle behavior on
|
||||
* Android 12 and Android 12L, use RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@ChangeId
|
||||
@EnabledSince(targetSdkVersion = android.os.Build.VERSION_CODES.S)
|
||||
// This was a platform change ID with value 191844585L before T
|
||||
public static final long RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER = 235355681L;
|
||||
|
||||
/**
|
||||
* Broadcast intent action to indicate whether network service discovery is
|
||||
* enabled or disabled. An extra {@link #EXTRA_NSD_STATE} provides the state
|
||||
|
||||
@@ -16,19 +16,18 @@
|
||||
|
||||
package android.net;
|
||||
|
||||
import static android.net.connectivity.ConnectivityCompatChanges.EXCLUDED_ROUTES;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.SystemApi;
|
||||
import android.app.compat.CompatChanges;
|
||||
import android.compat.annotation.ChangeId;
|
||||
import android.compat.annotation.EnabledAfter;
|
||||
import android.compat.annotation.UnsupportedAppUsage;
|
||||
import android.os.Build;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.modules.utils.build.SdkLevel;
|
||||
import com.android.net.module.util.CollectionUtils;
|
||||
import com.android.net.module.util.LinkPropertiesUtils;
|
||||
@@ -58,17 +57,6 @@ import java.util.StringJoiner;
|
||||
*
|
||||
*/
|
||||
public final class LinkProperties implements Parcelable {
|
||||
/**
|
||||
* The {@link #getRoutes()} now can contain excluded as well as included routes. Use
|
||||
* {@link RouteInfo#getType()} to determine route type.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@ChangeId
|
||||
@EnabledAfter(targetSdkVersion = Build.VERSION_CODES.S_V2)
|
||||
@VisibleForTesting
|
||||
public static final long EXCLUDED_ROUTES = 186082280;
|
||||
|
||||
// The interface described by the network link.
|
||||
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
|
||||
private String mIfaceName;
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (C) 2022 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package android.net.connectivity;
|
||||
|
||||
import android.compat.annotation.ChangeId;
|
||||
import android.compat.annotation.EnabledAfter;
|
||||
import android.compat.annotation.EnabledSince;
|
||||
import android.os.Build;
|
||||
|
||||
/**
|
||||
* The class contains all CompatChanges for the Connectivity module.
|
||||
*
|
||||
* <p>This is the centralized place for the CompatChanges used in the Connectivity module.
|
||||
* Putting all the CompatChanges in single place makes it possible to manage them under a single
|
||||
* platform_compat_config.
|
||||
* @hide
|
||||
*/
|
||||
public final class ConnectivityCompatChanges {
|
||||
|
||||
/**
|
||||
* The {@link android.net.LinkProperties#getRoutes()} now can contain excluded as well as
|
||||
* included routes. Use {@link android.net.RouteInfo#getType()} to determine route type.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@ChangeId
|
||||
@EnabledAfter(targetSdkVersion = Build.VERSION_CODES.S_V2)
|
||||
public static final long EXCLUDED_ROUTES = 186082280;
|
||||
|
||||
/**
|
||||
* When enabled, apps targeting < Android 12 are considered legacy for
|
||||
* the NSD native daemon.
|
||||
* The platform will only keep the daemon running as long as there are
|
||||
* any legacy apps connected.
|
||||
*
|
||||
* After Android 12, direct communication with the native daemon might not work since the native
|
||||
* daemon won't always stay alive. Using the NSD APIs from NsdManager as the replacement is
|
||||
* recommended.
|
||||
* Another alternative could be bundling your own mdns solutions instead of
|
||||
* depending on the system mdns native daemon.
|
||||
*
|
||||
* This compatibility change applies to Android 13 and later only. To toggle behavior on
|
||||
* Android 12 and Android 12L, use RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@ChangeId
|
||||
@EnabledSince(targetSdkVersion = android.os.Build.VERSION_CODES.S)
|
||||
// This was a platform change ID with value 191844585L before T
|
||||
public static final long RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER = 235355681L;
|
||||
|
||||
private ConnectivityCompatChanges() {
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,7 @@ import static org.junit.Assert.fail;
|
||||
|
||||
import android.compat.testing.PlatformCompatChangeRule;
|
||||
import android.net.LinkProperties.ProvisioningChange;
|
||||
import android.net.connectivity.ConnectivityCompatChanges;
|
||||
import android.os.Build;
|
||||
import android.system.OsConstants;
|
||||
import android.util.ArraySet;
|
||||
@@ -1261,7 +1262,7 @@ public class LinkPropertiesTest {
|
||||
|
||||
@Test @IgnoreUpTo(Build.VERSION_CODES.R)
|
||||
@CtsNetTestCasesMaxTargetSdk31(reason = "Compat change cannot be overridden when targeting T+")
|
||||
@EnableCompatChanges({LinkProperties.EXCLUDED_ROUTES})
|
||||
@EnableCompatChanges({ConnectivityCompatChanges.EXCLUDED_ROUTES})
|
||||
public void testHasExcludeRoute() {
|
||||
LinkProperties lp = new LinkProperties();
|
||||
lp.setInterfaceName("tun0");
|
||||
@@ -1274,7 +1275,7 @@ public class LinkPropertiesTest {
|
||||
|
||||
@Test @IgnoreUpTo(Build.VERSION_CODES.R)
|
||||
@CtsNetTestCasesMaxTargetSdk31(reason = "Compat change cannot be overridden when targeting T+")
|
||||
@EnableCompatChanges({LinkProperties.EXCLUDED_ROUTES})
|
||||
@EnableCompatChanges({ConnectivityCompatChanges.EXCLUDED_ROUTES})
|
||||
public void testRouteAddWithSameKey() throws Exception {
|
||||
LinkProperties lp = new LinkProperties();
|
||||
lp.setInterfaceName("wlan0");
|
||||
@@ -1348,14 +1349,14 @@ public class LinkPropertiesTest {
|
||||
|
||||
@Test @IgnoreUpTo(Build.VERSION_CODES.R)
|
||||
@CtsNetTestCasesMaxTargetSdk31(reason = "Compat change cannot be overridden when targeting T+")
|
||||
@EnableCompatChanges({LinkProperties.EXCLUDED_ROUTES})
|
||||
@EnableCompatChanges({ConnectivityCompatChanges.EXCLUDED_ROUTES})
|
||||
public void testExcludedRoutesEnabledByCompatChange() {
|
||||
assertExcludeRoutesVisible();
|
||||
}
|
||||
|
||||
@Test @IgnoreUpTo(Build.VERSION_CODES.R)
|
||||
@CtsNetTestCasesMaxTargetSdk31(reason = "Compat change cannot be overridden when targeting T+")
|
||||
@DisableCompatChanges({LinkProperties.EXCLUDED_ROUTES})
|
||||
@DisableCompatChanges({ConnectivityCompatChanges.EXCLUDED_ROUTES})
|
||||
public void testExcludedRoutesDisabledByCompatChange() {
|
||||
checkExcludeRoutesNotVisibleAfterS();
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import android.net.NetworkRequest
|
||||
import android.net.TestNetworkInterface
|
||||
import android.net.TestNetworkManager
|
||||
import android.net.TestNetworkSpecifier
|
||||
import android.net.connectivity.ConnectivityCompatChanges
|
||||
import android.net.cts.NsdManagerTest.NsdDiscoveryRecord.DiscoveryEvent.DiscoveryStarted
|
||||
import android.net.cts.NsdManagerTest.NsdDiscoveryRecord.DiscoveryEvent.DiscoveryStopped
|
||||
import android.net.cts.NsdManagerTest.NsdDiscoveryRecord.DiscoveryEvent.ServiceFound
|
||||
@@ -40,8 +41,8 @@ import android.net.cts.NsdManagerTest.NsdRegistrationRecord.RegistrationEvent.Re
|
||||
import android.net.cts.NsdManagerTest.NsdRegistrationRecord.RegistrationEvent.ServiceRegistered
|
||||
import android.net.cts.NsdManagerTest.NsdRegistrationRecord.RegistrationEvent.ServiceUnregistered
|
||||
import android.net.cts.NsdManagerTest.NsdRegistrationRecord.RegistrationEvent.UnregistrationFailed
|
||||
import android.net.cts.NsdManagerTest.NsdResolveRecord.ResolveEvent.ResolveFailed
|
||||
import android.net.cts.NsdManagerTest.NsdResolveRecord.ResolveEvent.ResolutionStopped
|
||||
import android.net.cts.NsdManagerTest.NsdResolveRecord.ResolveEvent.ResolveFailed
|
||||
import android.net.cts.NsdManagerTest.NsdResolveRecord.ResolveEvent.ServiceResolved
|
||||
import android.net.cts.NsdManagerTest.NsdResolveRecord.ResolveEvent.StopResolutionFailed
|
||||
import android.net.cts.NsdManagerTest.NsdServiceInfoCallbackRecord.ServiceInfoCallbackEvent.RegisterCallbackFailed
|
||||
@@ -783,7 +784,7 @@ class NsdManagerTest {
|
||||
// when the compat change is disabled.
|
||||
// Note that before T the compat constant had a different int value.
|
||||
assertFalse(CompatChanges.isChangeEnabled(
|
||||
NsdManager.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER))
|
||||
ConnectivityCompatChanges.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER))
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -32,6 +32,7 @@ import static org.mockito.Mockito.verify;
|
||||
|
||||
import android.compat.testing.PlatformCompatChangeRule;
|
||||
import android.content.Context;
|
||||
import android.net.connectivity.ConnectivityCompatChanges;
|
||||
import android.os.Build;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
@@ -81,70 +82,70 @@ public class NsdManagerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableCompatChanges(NsdManager.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
|
||||
@EnableCompatChanges(ConnectivityCompatChanges.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
|
||||
public void testResolveServiceS() throws Exception {
|
||||
verify(mServiceConn, never()).startDaemon();
|
||||
doTestResolveService();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableCompatChanges(NsdManager.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
|
||||
@DisableCompatChanges(ConnectivityCompatChanges.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
|
||||
public void testResolveServicePreS() throws Exception {
|
||||
verify(mServiceConn).startDaemon();
|
||||
doTestResolveService();
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableCompatChanges(NsdManager.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
|
||||
@EnableCompatChanges(ConnectivityCompatChanges.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
|
||||
public void testDiscoverServiceS() throws Exception {
|
||||
verify(mServiceConn, never()).startDaemon();
|
||||
doTestDiscoverService();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableCompatChanges(NsdManager.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
|
||||
@DisableCompatChanges(ConnectivityCompatChanges.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
|
||||
public void testDiscoverServicePreS() throws Exception {
|
||||
verify(mServiceConn).startDaemon();
|
||||
doTestDiscoverService();
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableCompatChanges(NsdManager.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
|
||||
@EnableCompatChanges(ConnectivityCompatChanges.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
|
||||
public void testParallelResolveServiceS() throws Exception {
|
||||
verify(mServiceConn, never()).startDaemon();
|
||||
doTestParallelResolveService();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableCompatChanges(NsdManager.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
|
||||
@DisableCompatChanges(ConnectivityCompatChanges.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
|
||||
public void testParallelResolveServicePreS() throws Exception {
|
||||
verify(mServiceConn).startDaemon();
|
||||
doTestParallelResolveService();
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableCompatChanges(NsdManager.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
|
||||
@EnableCompatChanges(ConnectivityCompatChanges.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
|
||||
public void testInvalidCallsS() throws Exception {
|
||||
verify(mServiceConn, never()).startDaemon();
|
||||
doTestInvalidCalls();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableCompatChanges(NsdManager.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
|
||||
@DisableCompatChanges(ConnectivityCompatChanges.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
|
||||
public void testInvalidCallsPreS() throws Exception {
|
||||
verify(mServiceConn).startDaemon();
|
||||
doTestInvalidCalls();
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableCompatChanges(NsdManager.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
|
||||
@EnableCompatChanges(ConnectivityCompatChanges.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
|
||||
public void testRegisterServiceS() throws Exception {
|
||||
verify(mServiceConn, never()).startDaemon();
|
||||
doTestRegisterService();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableCompatChanges(NsdManager.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
|
||||
@DisableCompatChanges(ConnectivityCompatChanges.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
|
||||
public void testRegisterServicePreS() throws Exception {
|
||||
verify(mServiceConn).startDaemon();
|
||||
doTestRegisterService();
|
||||
|
||||
@@ -53,6 +53,7 @@ import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.net.INetd;
|
||||
import android.net.Network;
|
||||
import android.net.connectivity.ConnectivityCompatChanges;
|
||||
import android.net.mdns.aidl.DiscoveryInfo;
|
||||
import android.net.mdns.aidl.GetAddressInfo;
|
||||
import android.net.mdns.aidl.IMDnsEventListener;
|
||||
@@ -187,7 +188,7 @@ public class NsdServiceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisableCompatChanges(NsdManager.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
|
||||
@DisableCompatChanges(ConnectivityCompatChanges.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
|
||||
public void testPreSClients() throws Exception {
|
||||
// Pre S client connected, the daemon should be started.
|
||||
connectClient(mService);
|
||||
@@ -214,7 +215,7 @@ public class NsdServiceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableCompatChanges(NsdManager.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
|
||||
@EnableCompatChanges(ConnectivityCompatChanges.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
|
||||
public void testNoDaemonStartedWhenClientsConnect() throws Exception {
|
||||
// Creating an NsdManager will not cause daemon startup.
|
||||
connectClient(mService);
|
||||
@@ -248,7 +249,7 @@ public class NsdServiceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableCompatChanges(NsdManager.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
|
||||
@EnableCompatChanges(ConnectivityCompatChanges.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
|
||||
public void testClientRequestsAreGCedAtDisconnection() throws Exception {
|
||||
final NsdManager client = connectClient(mService);
|
||||
final INsdManagerCallback cb1 = getCallback();
|
||||
@@ -291,7 +292,7 @@ public class NsdServiceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnableCompatChanges(NsdManager.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
|
||||
@EnableCompatChanges(ConnectivityCompatChanges.RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER)
|
||||
public void testCleanupDelayNoRequestActive() throws Exception {
|
||||
final NsdManager client = connectClient(mService);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user