• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.Disabled;
20 import android.compat.annotation.EnabledAfter;
21 import android.compat.annotation.EnabledSince;
22 import android.os.Build;
23 
24 /**
25  * The class contains all CompatChanges for the Connectivity module.
26  *
27  * <p>This is the centralized place for the CompatChanges used in the Connectivity module.
28  * Putting all the CompatChanges in single place makes it possible to manage them under a single
29  * platform_compat_config.
30  * @hide
31  */
32 public final class ConnectivityCompatChanges {
33 
34     /**
35      * The {@link android.net.LinkProperties#getRoutes()} now can contain excluded as well as
36      * included routes. Use {@link android.net.RouteInfo#getType()} to determine route type.
37      *
38      * @hide
39      */
40     @ChangeId
41     @EnabledAfter(targetSdkVersion = Build.VERSION_CODES.S_V2)
42     public static final long EXCLUDED_ROUTES = 186082280;
43 
44     /**
45      * When enabled, apps targeting < Android 12 are considered legacy for
46      * the NSD native daemon.
47      * The platform will only keep the daemon running as long as there are
48      * any legacy apps connected.
49      *
50      * After Android 12, direct communication with the native daemon might not work since the native
51      * daemon won't always stay alive. Using the NSD APIs from NsdManager as the replacement is
52      * recommended.
53      * Another alternative could be bundling your own mdns solutions instead of
54      * depending on the system mdns native daemon.
55      *
56      * This compatibility change applies to Android 13 and later only. To toggle behavior on
57      * Android 12 and Android 12L, use RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS.
58      *
59      * @hide
60      */
61     @ChangeId
62     @EnabledSince(targetSdkVersion = android.os.Build.VERSION_CODES.S)
63     // This was a platform change ID with value 191844585L before T
64     public static final long RUN_NATIVE_NSD_ONLY_IF_LEGACY_APPS_T_AND_LATER = 235355681L;
65 
66     /**
67      * The self certified capabilities check should be enabled after android 13.
68      *
69      * <p> See {@link android.net.NetworkCapabilities} for more details.
70      *
71      * @hide
72      */
73     @ChangeId
74     @EnabledAfter(targetSdkVersion = Build.VERSION_CODES.TIRAMISU)
75     public static final long ENABLE_SELF_CERTIFIED_CAPABILITIES_DECLARATION = 266524688;
76 
77     /**
78      * Apps targeting < Android 14 use a legacy NSD backend.
79      *
80      * The legacy apps use a legacy native daemon as NsdManager backend, but other apps use a
81      * platform-integrated mDNS implementation as backend.
82      *
83      * @hide
84      */
85     @ChangeId
86     @EnabledAfter(targetSdkVersion = Build.VERSION_CODES.TIRAMISU)
87     public static final long ENABLE_PLATFORM_MDNS_BACKEND = 270306772L;
88 
89     /**
90      * Apps targeting Android V or higher receive network callbacks from local networks as default
91      *
92      * Apps targeting lower than {@link android.os.Build.VERSION_CODES.VANILLA_ICE_CREAM} need
93      * to add {@link android.net.NetworkCapabilities#NET_CAPABILITY_LOCAL_NETWORK} to the
94      * {@link android.net.NetworkCapabilities} of the {@link android.net.NetworkRequest} to receive
95      * {@link android.net.ConnectivityManager.NetworkCallback} from local networks.
96      *
97      * @hide
98      */
99     @ChangeId
100     @EnabledAfter(targetSdkVersion = Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
101     public static final long ENABLE_MATCH_LOCAL_NETWORK = 319212206L;
102 
103     /**
104      * On Android versions starting from 37, network access from apps targeting
105      * Android 37 or higher, that do not have the {@link android.Manifest.permission#INTERNET}
106      * permission, is considered blocked.
107      * This results in API behaviors change for apps without
108      * {@link android.Manifest.permission#INTERNET} permission.
109      * {@link android.net.NetworkInfo} returned from {@link android.net.ConnectivityManager} APIs
110      * always has {@link android.net.NetworkInfo.DetailedState#BLOCKED}.
111      * {@link android.net.ConnectivityManager#getActiveNetwork()} always returns null.
112      * {@link android.net.ConnectivityManager.NetworkCallback#onBlockedStatusChanged()} is always
113      * called with blocked=true.
114      * <p>
115      * For backwards compatibility, apps running on older releases, or targeting older SDK levels,
116      * network access from apps without {@link android.Manifest.permission#INTERNET} permission is
117      * considered not blocked even though apps cannot access any networks.
118      *
119      * TODO: b/400903101 - Update the target SDK version once it's finalized.
120      *
121      * @hide
122      */
123     @ChangeId
124     @EnabledAfter(targetSdkVersion = 36)
125     public static final long NETWORK_BLOCKED_WITHOUT_INTERNET_PERMISSION = 333340911L;
126 
127     /**
128      * Enable caching for TrafficStats#get* APIs.
129      *
130      * Apps targeting Android V or later or running on Android V or later may take up to several
131      * seconds to see the updated results.
132      * Apps targeting lower android SDKs do not see cached result for backward compatibility,
133      * results of TrafficStats#get* APIs are reflecting network statistics immediately.
134      *
135      * @hide
136      */
137     @ChangeId
138     @EnabledAfter(targetSdkVersion = Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
139     public static final long ENABLE_TRAFFICSTATS_RATE_LIMIT_CACHE = 74210811L;
140 
141     /**
142      * Restrict local network access.
143      * Apps targeting a release after V will require permissions to access the local network.
144      *
145      * ToDo: Update the target SDK version once it's finalized.
146      * @hide
147      */
148     @ChangeId
149     @Disabled
150     public static final long RESTRICT_LOCAL_NETWORK = 365139289L;
151 
152     /**
153      * Enable match non-threads local networks.
154      *
155      * Apps targeting a release after V can have NetworkRequests matches non-thread local networks.
156      *
157      * @hide
158      */
159     @ChangeId
160     @EnabledAfter(targetSdkVersion = Build.VERSION_CODES.VANILLA_ICE_CREAM)
161     public static final long ENABLE_MATCH_NON_THREAD_LOCAL_NETWORKS = 349487600L;
162 
ConnectivityCompatChanges()163     private ConnectivityCompatChanges() {
164     }
165 }
166