1 /*
2  * Copyright (C) 2022 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package android.net.connectivity;
17 
18 import android.compat.annotation.ChangeId;
19 import android.compat.annotation.EnabledAfter;
20 import android.compat.annotation.EnabledSince;
21 import android.os.Build;
22 
23 /**
24  * The class contains all CompatChanges for the Connectivity module.
25  *
26  * <p>This is the centralized place for the CompatChanges used in the Connectivity module.
27  * Putting all the CompatChanges in single place makes it possible to manage them under a single
28  * platform_compat_config.
29  * @hide
30  */
31 public final class ConnectivityCompatChanges {
32 
33     /**
34      * The {@link android.net.LinkProperties#getRoutes()} now can contain excluded as well as
35      * included routes. Use {@link android.net.RouteInfo#getType()} to determine route type.
36      *
37      * @hide
38      */
39     @ChangeId
40     @EnabledAfter(targetSdkVersion = Build.VERSION_CODES.S_V2)
41     public static final long EXCLUDED_ROUTES = 186082280;
42 
43     /**
44      * When enabled, apps targeting < Android 12 are considered legacy for
45      * the NSD native daemon.
46      * The platform will only keep the daemon running as long as there are
47      * any legacy apps connected.
48      *
49      * After Android 12, direct communication with the native daemon might not work since the native
50      * daemon won't always stay alive. Using the NSD APIs from NsdManager as the replacement is
51      * recommended.
52      * Another alternative could be bundling your own mdns solutions instead of
53      * depending on the system mdns native daemon.
54      *
55      * This compatibility change applies to Android 13 and later only. To toggle behavior on
56      * Android 12 and Android 12L, use RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS.
57      *
58      * @hide
59      */
60     @ChangeId
61     @EnabledSince(targetSdkVersion = android.os.Build.VERSION_CODES.S)
62     // This was a platform change ID with value 191844585L before T
63     public static final long RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER = 235355681L;
64 
65     /**
66      * The self certified capabilities check should be enabled after android 13.
67      *
68      * <p> See {@link android.net.NetworkCapabilities} for more details.
69      *
70      * @hide
71      */
72     @ChangeId
73     @EnabledAfter(targetSdkVersion = Build.VERSION_CODES.TIRAMISU)
74     public static final long ENABLE_SELF_CERTIFIED_CAPABILITIES_DECLARATION = 266524688;
75 
76     /**
77      * Apps targeting < Android 14 use a legacy NSD backend.
78      *
79      * The legacy apps use a legacy native daemon as NsdManager backend, but other apps use a
80      * platform-integrated mDNS implementation as backend.
81      *
82      * @hide
83      */
84     @ChangeId
85     @EnabledAfter(targetSdkVersion = Build.VERSION_CODES.TIRAMISU)
86     public static final long ENABLE_PLATFORM_MDNS_BACKEND = 270306772L;
87 
88     /**
89      * Apps targeting Android V or higher receive network callbacks from local networks as default
90      *
91      * Apps targeting lower than {@link android.os.Build.VERSION_CODES.VANILLA_ICE_CREAM} need
92      * to add {@link android.net.NetworkCapabilities#NET_CAPABILITY_LOCAL_NETWORK} to the
93      * {@link android.net.NetworkCapabilities} of the {@link android.net.NetworkRequest} to receive
94      * {@link android.net.ConnectivityManager.NetworkCallback} from local networks.
95      *
96      * @hide
97      */
98     @ChangeId
99     @EnabledAfter(targetSdkVersion = Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
100     public static final long ENABLE_MATCH_LOCAL_NETWORK = 319212206L;
101 
102     /**
103      * On Android {@link android.os.Build.VERSION_CODES.VANILLA_ICE_CREAM} or higher releases,
104      * network access from apps targeting Android 36 or higher that do not have the
105      * {@link android.Manifest.permission#INTERNET} permission is considered blocked.
106      * This results in API behaviors change for apps without
107      * {@link android.Manifest.permission#INTERNET} permission.
108      * {@link android.net.NetworkInfo} returned from {@link android.net.ConnectivityManager} APIs
109      * always has {@link android.net.NetworkInfo.DetailedState#BLOCKED}.
110      * {@link android.net.ConnectivityManager#getActiveNetwork()} always returns null.
111      * {@link android.net.ConnectivityManager.NetworkCallback#onBlockedStatusChanged()} is always
112      * called with blocked=true.
113      * <p>
114      * For backwards compatibility, apps running on older releases, or targeting older SDK levels,
115      * network access from apps without {@link android.Manifest.permission#INTERNET} permission is
116      * considered not blocked even though apps cannot access any networks.
117      *
118      * @hide
119      */
120     @ChangeId
121     @EnabledAfter(targetSdkVersion = Build.VERSION_CODES.VANILLA_ICE_CREAM)
122     public static final long NETWORK_BLOCKED_WITHOUT_INTERNET_PERMISSION = 333340911L;
123 
124     /**
125      * Enable caching for TrafficStats#get* APIs.
126      *
127      * Apps targeting Android V or later or running on Android V or later may take up to several
128      * seconds to see the updated results.
129      * Apps targeting lower android SDKs do not see cached result for backward compatibility,
130      * results of TrafficStats#get* APIs are reflecting network statistics immediately.
131      *
132      * @hide
133      */
134     @ChangeId
135     @EnabledAfter(targetSdkVersion = Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
136     public static final long ENABLE_TRAFFICSTATS_RATE_LIMIT_CACHE = 74210811L;
137 
ConnectivityCompatChanges()138     private ConnectivityCompatChanges() {
139     }
140 }
141