Loading Android.bp +139 −56 Original line number Diff line number Diff line Loading @@ -22,12 +22,12 @@ // / \ // +NetworkStackApiStableShims --> / \ <-- +NetworkStackApiCurrentShims // +NetworkStackReleaseApiLevel / \ +NetworkStackDevApiLevel // +jarjar apistub.api[latest].* / \ +module src/ // to apistub.* / \ // +jarjar apishim.api[latest].* / \ // to apishim.* / \ // / \ // / \ // NetworkStackApiStableDependencies \ // / \ android libs w/ all code // +module src/ --> / \ (also used in unit tests) // / <- +module src/ -> \ (also used in unit tests) // / \ | // NetworkStackApiStableLib NetworkStackApiCurrentLib <--* // | | Loading @@ -41,6 +41,14 @@ // TestNetworkStack // Common defaults to define SDK level package { default_applicable_licenses: ["Android-Apache-2.0"], } // Whether to enable the targets in this file that target current SDKs. // Set to false in branches like mainline-prod where API classes are too old to build current code. enable_current_sdk_targets = false java_defaults { name: "NetworkStackDevApiLevel", min_sdk_version: "29", Loading @@ -54,27 +62,116 @@ java_defaults { target_sdk_version: "30", } // Filegroups for the API shims filegroup { name: "NetworkStackApiCurrentShims", // Libraries for the API shims java_defaults { name: "NetworkStackShimsDefaults", libs: [ "androidx.annotation_annotation", "networkstack-client", ], apex_available: [ "com.android.tethering", "//apex_available:platform", // For InProcessNetworkStack and InProcessTethering ], min_sdk_version: "29", } // Common shim code. This includes the shim interface definitions themselves, and things like // ShimUtils and UnsupportedApiLevelException. Compiles against system_current because ShimUtils // needs access to all Build.VERSION_CODES.*, which by definition are only in the newest SDK. // TODO: consider moving ShimUtils into a library (or removing it in favour of SdkLevel) and compile // this target against the lowest-supported SDK (currently 29). java_library { name: "NetworkStackShimsCommon", defaults: ["NetworkStackShimsDefaults"], srcs: ["apishim/common/**/*.java"], sdk_version: "system_current", visibility: ["//visibility:private"], } // Each level of the shims (29, 30, ...) is its own java_library compiled against the corresponding // system_X SDK. this ensures that each shim can only use SDK classes that exist in its SDK level. java_library { name: "NetworkStackApi29Shims", defaults: ["NetworkStackShimsDefaults"], srcs: ["apishim/29/**/*.java"], libs: [ "NetworkStackShimsCommon", ], sdk_version: "system_29", visibility: ["//visibility:private"], } java_library { name: "NetworkStackApi30Shims", defaults: ["NetworkStackShimsDefaults"], srcs: [ "apishim/common/**/*.java", "apishim/29/**/*.java", "apishim/30/**/*.java", ], libs: [ "NetworkStackShimsCommon", "NetworkStackApi29Shims", ], sdk_version: "system_30", visibility: ["//visibility:private"], } // Shims for APIs being added to the current development version of Android. These APIs are not // stable and have no defined version number. These could be called 10000, but they use the next // integer so if the next SDK release happens to use that integer, we don't need to rename them. java_library { name: "NetworkStackApi31Shims", enabled: enable_current_sdk_targets, defaults: ["NetworkStackShimsDefaults"], srcs: [ "apishim/31/**/*.java", ":networkstack-module-utils-srcs", ], libs: [ "NetworkStackShimsCommon", "NetworkStackApi29Shims", "NetworkStackApi30Shims", "framework-connectivity", ], sdk_version: "module_current", visibility: ["//visibility:private"], } // API stable shims only include the compat package, but it is jarjared to replace the non-compat // package filegroup { // API current uses the API current shims directly. // The current (in-progress) shims are in the com.android.networkstack.apishim package and are // called directly by the networkstack code. java_library { name: "NetworkStackApiCurrentShims", enabled: enable_current_sdk_targets, defaults: ["NetworkStackShimsDefaults"], static_libs: [ "NetworkStackShimsCommon", "NetworkStackApi29Shims", "NetworkStackApi30Shims", "NetworkStackApi31Shims", ], sdk_version: "module_current", visibility: [ "//packages/modules/Connectivity/Tethering", "//packages/modules/Connectivity/tests/cts/net", ], } // API stable uses jarjar to rename the latest stable apishim package from // com.android.networkstack.apishim.apiXX to com.android.networkstack.apishim, which is called by // the networkstack code. java_library { name: "NetworkStackApiStableShims", srcs: [ "apishim/common/**/*.java", "apishim/29/**/*.java", "apishim/30/**/*.java", ":networkstack-module-utils-srcs", defaults: ["NetworkStackShimsDefaults"], static_libs: [ "NetworkStackShimsCommon", "NetworkStackApi29Shims", "NetworkStackApi30Shims", ], jarjar_rules: "apishim/jarjar-rules-compat.txt", sdk_version: "system_30", visibility: [ "//packages/modules/Connectivity/Tethering", "//packages/modules/Connectivity/tests/cts/net", ], } Loading @@ -84,11 +181,12 @@ java_defaults { name: "NetworkStackAndroidLibraryDefaults", srcs: [ ":framework-networkstack-shared-srcs", ":networkstack-module-utils-srcs", ], libs: ["unsupportedappusage"], static_libs: [ "androidx.annotation_annotation", "netd_aidl_interface-java", "netd_aidl_interface-lateststable-java", "netlink-client", "networkstack-client", "net-utils-framework-common", Loading @@ -101,43 +199,42 @@ java_defaults { plugins: ["java_api_finder"], } // The versions of the android library containing network stack code compiled for each SDK variant // API current uses the sources of the API current shims directly. // This allows API current code to be treated identically to code in src/ (it will be moved // there eventually), and to use the compat shim as fallback on older devices. // The versions of the android library containing network stack code compiled for each SDK variant. android_library { name: "NetworkStackApiCurrentLib", defaults: ["NetworkStackDevApiLevel", "NetworkStackAndroidLibraryDefaults"], srcs: [ ":NetworkStackApiCurrentShims", "src/**/*.java", ":statslog-networkstack-java-gen-current" ], static_libs: ["NetworkStackApiCurrentShims"], manifest: "AndroidManifestBase.xml", enabled: false, // Disabled in mainline-prod } // For API stable, first build the dependencies using jarjar compat rules, then build the sources // linking with the dependencies. java_library { name: "NetworkStackApiStableDependencies", defaults: ["NetworkStackReleaseApiLevel", "NetworkStackAndroidLibraryDefaults"], srcs: [":NetworkStackApiStableShims"], jarjar_rules: "apishim/jarjar-rules-compat.txt", enabled: enable_current_sdk_targets, visibility: [ "//frameworks/base/tests/net/integration", "//packages/modules/Connectivity/Tethering/tests/integration", "//packages/modules/Connectivity/tests/cts/net", "//packages/modules/NetworkStack/tests/unit", "//packages/modules/NetworkStack/tests/integration", ], } android_library { name: "NetworkStackApiStableLib", defaults: ["NetworkStackReleaseApiLevel"], defaults: ["NetworkStackReleaseApiLevel", "NetworkStackAndroidLibraryDefaults"], srcs: [ "src/**/*.java", ":statslog-networkstack-java-gen-stable", ], // API stable uses a jarjared version of the shims static_libs: [ "NetworkStackApiStableDependencies", ], static_libs: ["NetworkStackApiStableShims"], manifest: "AndroidManifestBase.xml", visibility: [ "//frameworks/base/tests/net/integration", "//packages/modules/Connectivity/Tethering/tests/integration", "//packages/modules/Connectivity/tests/cts/net", "//packages/modules/NetworkStack/tests/unit", "//packages/modules/NetworkStack/tests/integration", ], } filegroup { Loading @@ -146,7 +243,6 @@ filegroup { visibility: [ "//packages/modules/NetworkStack/tests/unit", "//packages/modules/NetworkStack/tests/integration", "//frameworks/base/packages/Tethering/tests/integration", "//packages/modules/Connectivity/Tethering/tests/integration", ] } Loading Loading @@ -181,7 +277,7 @@ android_app { // The InProcessNetworkStack goes together with the PlatformCaptivePortalLogin, which replaces // the default CaptivePortalLogin. required: ["PlatformNetworkPermissionConfig", "PlatformCaptivePortalLogin"], enabled: false, // Disabled in mainline-prod enabled: enable_current_sdk_targets, } // Pre-merge the AndroidManifest for NetworkStackNext, so that its manifest can be merged on top Loading @@ -190,7 +286,7 @@ android_library { defaults: ["NetworkStackAppDefaults", "NetworkStackDevApiLevel"], static_libs: ["NetworkStackApiCurrentLib"], manifest: "AndroidManifest.xml", enabled: false, // Disabled in mainline-prod enabled: enable_current_sdk_targets, } // NetworkStack build targeting the current API release, for testing on in-development SDK Loading @@ -202,7 +298,7 @@ android_app { manifest: "AndroidManifest_Next.xml", // The permission configuration *must* be included to ensure security of the device required: ["NetworkPermissionConfig"], enabled: false, // Disabled in mainline-prod enabled: enable_current_sdk_targets, } // Updatable network stack for finalized API Loading @@ -217,19 +313,6 @@ android_app { updatable: true, } // Android library to derive test APKs for integration tests android_library { name: "TestNetworkStackLib", defaults: ["NetworkStackAppDefaults", "NetworkStackReleaseApiLevel"], static_libs: ["NetworkStackApiStableLib"], manifest: "AndroidManifestBase.xml", visibility: [ "//frameworks/base/tests/net/integration", "//cts/tests/tests/net", "//packages/modules/Connectivity/tests/cts/net", ], } cc_library_shared { name: "libnetworkstackutilsjni", srcs: [ Loading apishim/29/com/android/networkstack/apishim/api29/CaptivePortalDataShimImpl.java +33 −6 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ package com.android.networkstack.apishim.api29; import android.net.CaptivePortalData; import android.net.Uri; import androidx.annotation.NonNull; import androidx.annotation.VisibleForTesting; Loading @@ -28,7 +28,7 @@ import org.json.JSONException; import org.json.JSONObject; /** * Compatibility implementation of {@link CaptivePortalDataShim}. * Compatibility implementation of {@link CaptivePortalData}. * * <p>Use {@link com.android.networkstack.apishim.CaptivePortalDataShimImpl} instead of this * fallback implementation. Loading @@ -37,7 +37,7 @@ public abstract class CaptivePortalDataShimImpl implements CaptivePortalDataShim protected CaptivePortalDataShimImpl() {} /** * Parse a {@link android.net.CaptivePortalData} from JSON. * Parse a {@link android.net.CaptivePortalDataShim} from JSON. * * <p>Use * {@link com.android.networkstack.apishim.CaptivePortalDataShimImpl#fromJson(JSONObject)} Loading @@ -56,19 +56,46 @@ public abstract class CaptivePortalDataShimImpl implements CaptivePortalDataShim return null; } @Override public int getUserPortalUrlSource() { // Not supported in API level 29 return ConstantsShim.CAPTIVE_PORTAL_DATA_SOURCE_OTHER; } @VisibleForTesting public static boolean isSupported() { return false; } /** * Generate a {@link CaptivePortalData} object with a friendly name set * Generate a {@link CaptivePortalDataShim} object with a friendly name set * * @param friendlyName The friendly name to set * @return a {@link CaptivePortalData} object with a friendly name set */ public CaptivePortalData withVenueFriendlyName(String friendlyName) { @Override public CaptivePortalDataShim withVenueFriendlyName(String friendlyName) throws UnsupportedApiLevelException { // Not supported in API level 29 return null; throw new UnsupportedApiLevelException("CaptivePortalData not supported on API 29"); } /** * Generate a {@link CaptivePortalDataShim} object with a friendly name and Passpoint external * URLs set * * @param friendlyName The friendly name to set * @param venueInfoUrl Venue information URL * @param termsAndConditionsUrl Terms and conditions URL * * @return a {@link CaptivePortalDataShim} object with friendly name, venue info URL and terms * and conditions URL set */ @Override public CaptivePortalDataShim withPasspointInfo(@NonNull String friendlyName, @NonNull Uri venueInfoUrl, @NonNull Uri termsAndConditionsUrl) throws UnsupportedApiLevelException { // Not supported in API level 29 throw new UnsupportedApiLevelException("CaptivePortalData not supported on API 29"); } } apishim/29/com/android/networkstack/apishim/api29/ConnectivityManagerShimImpl.java 0 → 100644 +64 −0 Original line number Diff line number Diff line /* * Copyright (C) 2021 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 com.android.networkstack.apishim.api29; import android.content.Context; import android.net.ConnectivityManager.NetworkCallback; import android.net.NetworkRequest; import android.os.Handler; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.android.networkstack.apishim.common.ConnectivityManagerShim; import com.android.networkstack.apishim.common.UnsupportedApiLevelException; /** * Implementation of {@link ConnectivityManagerShim} for API 29. */ public class ConnectivityManagerShimImpl implements ConnectivityManagerShim { protected ConnectivityManagerShimImpl(Context context) {} /** * Get a new instance of {@link ConnectivityManagerShim}. */ public static ConnectivityManagerShim newInstance(Context context) { return new ConnectivityManagerShimImpl(context); } /** * See android.net.ConnectivityManager#requestBackgroundNetwork * @throws UnsupportedApiLevelException if API is not available in this API level. */ @Override public void requestBackgroundNetwork(@NonNull NetworkRequest request, @Nullable Handler handler, @NonNull NetworkCallback networkCallback) throws UnsupportedApiLevelException { // Not supported for API 29. throw new UnsupportedApiLevelException("Not supported in API 29."); } /** * See android.net.ConnectivityManager#registerSystemDefaultNetworkCallback * @throws UnsupportedApiLevelException if API is not available in this API level. */ @Override public void registerSystemDefaultNetworkCallback(@NonNull NetworkCallback networkCallback, @NonNull Handler handler) throws UnsupportedApiLevelException { // Not supported for API 29. throw new UnsupportedApiLevelException("Not supported in API 29."); } } apishim/29/com/android/networkstack/apishim/api29/ConstantsShim.java +8 −0 Original line number Diff line number Diff line Loading @@ -34,4 +34,12 @@ public class ConstantsShim { // Constants defined in android.net.ConnectivityDiagnosticsManager. public static final int DETECTION_METHOD_DNS_EVENTS = 1; public static final int DETECTION_METHOD_TCP_METRICS = 2; // Constants defined in android.net.CaptivePortalData. public static final int CAPTIVE_PORTAL_DATA_SOURCE_OTHER = 0; public static final int CAPTIVE_PORTAL_DATA_SOURCE_PASSPOINT = 1; // Constants defined in android.net.NetworkCapabilities. public static final int NET_CAPABILITY_NOT_VCN_MANAGED = 28; } apishim/29/com/android/networkstack/apishim/api29/NetworkInformationShimImpl.java +2 −6 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ package com.android.networkstack.apishim.api29; import android.net.CaptivePortalData; import android.net.IpPrefix; import android.net.LinkProperties; import android.net.NetworkCapabilities; Loading Loading @@ -121,10 +120,7 @@ public class NetworkInformationShimImpl implements NetworkInformationShim { * @param captivePortalData Captive portal data to be used */ public void setCaptivePortalData(@NonNull LinkProperties lp, @Nullable CaptivePortalData captivePortalData) { if (lp == null) { return; } lp.setCaptivePortalData(captivePortalData); @Nullable CaptivePortalDataShim captivePortalData) { // Not supported on this API level: no-op } } Loading
Android.bp +139 −56 Original line number Diff line number Diff line Loading @@ -22,12 +22,12 @@ // / \ // +NetworkStackApiStableShims --> / \ <-- +NetworkStackApiCurrentShims // +NetworkStackReleaseApiLevel / \ +NetworkStackDevApiLevel // +jarjar apistub.api[latest].* / \ +module src/ // to apistub.* / \ // +jarjar apishim.api[latest].* / \ // to apishim.* / \ // / \ // / \ // NetworkStackApiStableDependencies \ // / \ android libs w/ all code // +module src/ --> / \ (also used in unit tests) // / <- +module src/ -> \ (also used in unit tests) // / \ | // NetworkStackApiStableLib NetworkStackApiCurrentLib <--* // | | Loading @@ -41,6 +41,14 @@ // TestNetworkStack // Common defaults to define SDK level package { default_applicable_licenses: ["Android-Apache-2.0"], } // Whether to enable the targets in this file that target current SDKs. // Set to false in branches like mainline-prod where API classes are too old to build current code. enable_current_sdk_targets = false java_defaults { name: "NetworkStackDevApiLevel", min_sdk_version: "29", Loading @@ -54,27 +62,116 @@ java_defaults { target_sdk_version: "30", } // Filegroups for the API shims filegroup { name: "NetworkStackApiCurrentShims", // Libraries for the API shims java_defaults { name: "NetworkStackShimsDefaults", libs: [ "androidx.annotation_annotation", "networkstack-client", ], apex_available: [ "com.android.tethering", "//apex_available:platform", // For InProcessNetworkStack and InProcessTethering ], min_sdk_version: "29", } // Common shim code. This includes the shim interface definitions themselves, and things like // ShimUtils and UnsupportedApiLevelException. Compiles against system_current because ShimUtils // needs access to all Build.VERSION_CODES.*, which by definition are only in the newest SDK. // TODO: consider moving ShimUtils into a library (or removing it in favour of SdkLevel) and compile // this target against the lowest-supported SDK (currently 29). java_library { name: "NetworkStackShimsCommon", defaults: ["NetworkStackShimsDefaults"], srcs: ["apishim/common/**/*.java"], sdk_version: "system_current", visibility: ["//visibility:private"], } // Each level of the shims (29, 30, ...) is its own java_library compiled against the corresponding // system_X SDK. this ensures that each shim can only use SDK classes that exist in its SDK level. java_library { name: "NetworkStackApi29Shims", defaults: ["NetworkStackShimsDefaults"], srcs: ["apishim/29/**/*.java"], libs: [ "NetworkStackShimsCommon", ], sdk_version: "system_29", visibility: ["//visibility:private"], } java_library { name: "NetworkStackApi30Shims", defaults: ["NetworkStackShimsDefaults"], srcs: [ "apishim/common/**/*.java", "apishim/29/**/*.java", "apishim/30/**/*.java", ], libs: [ "NetworkStackShimsCommon", "NetworkStackApi29Shims", ], sdk_version: "system_30", visibility: ["//visibility:private"], } // Shims for APIs being added to the current development version of Android. These APIs are not // stable and have no defined version number. These could be called 10000, but they use the next // integer so if the next SDK release happens to use that integer, we don't need to rename them. java_library { name: "NetworkStackApi31Shims", enabled: enable_current_sdk_targets, defaults: ["NetworkStackShimsDefaults"], srcs: [ "apishim/31/**/*.java", ":networkstack-module-utils-srcs", ], libs: [ "NetworkStackShimsCommon", "NetworkStackApi29Shims", "NetworkStackApi30Shims", "framework-connectivity", ], sdk_version: "module_current", visibility: ["//visibility:private"], } // API stable shims only include the compat package, but it is jarjared to replace the non-compat // package filegroup { // API current uses the API current shims directly. // The current (in-progress) shims are in the com.android.networkstack.apishim package and are // called directly by the networkstack code. java_library { name: "NetworkStackApiCurrentShims", enabled: enable_current_sdk_targets, defaults: ["NetworkStackShimsDefaults"], static_libs: [ "NetworkStackShimsCommon", "NetworkStackApi29Shims", "NetworkStackApi30Shims", "NetworkStackApi31Shims", ], sdk_version: "module_current", visibility: [ "//packages/modules/Connectivity/Tethering", "//packages/modules/Connectivity/tests/cts/net", ], } // API stable uses jarjar to rename the latest stable apishim package from // com.android.networkstack.apishim.apiXX to com.android.networkstack.apishim, which is called by // the networkstack code. java_library { name: "NetworkStackApiStableShims", srcs: [ "apishim/common/**/*.java", "apishim/29/**/*.java", "apishim/30/**/*.java", ":networkstack-module-utils-srcs", defaults: ["NetworkStackShimsDefaults"], static_libs: [ "NetworkStackShimsCommon", "NetworkStackApi29Shims", "NetworkStackApi30Shims", ], jarjar_rules: "apishim/jarjar-rules-compat.txt", sdk_version: "system_30", visibility: [ "//packages/modules/Connectivity/Tethering", "//packages/modules/Connectivity/tests/cts/net", ], } Loading @@ -84,11 +181,12 @@ java_defaults { name: "NetworkStackAndroidLibraryDefaults", srcs: [ ":framework-networkstack-shared-srcs", ":networkstack-module-utils-srcs", ], libs: ["unsupportedappusage"], static_libs: [ "androidx.annotation_annotation", "netd_aidl_interface-java", "netd_aidl_interface-lateststable-java", "netlink-client", "networkstack-client", "net-utils-framework-common", Loading @@ -101,43 +199,42 @@ java_defaults { plugins: ["java_api_finder"], } // The versions of the android library containing network stack code compiled for each SDK variant // API current uses the sources of the API current shims directly. // This allows API current code to be treated identically to code in src/ (it will be moved // there eventually), and to use the compat shim as fallback on older devices. // The versions of the android library containing network stack code compiled for each SDK variant. android_library { name: "NetworkStackApiCurrentLib", defaults: ["NetworkStackDevApiLevel", "NetworkStackAndroidLibraryDefaults"], srcs: [ ":NetworkStackApiCurrentShims", "src/**/*.java", ":statslog-networkstack-java-gen-current" ], static_libs: ["NetworkStackApiCurrentShims"], manifest: "AndroidManifestBase.xml", enabled: false, // Disabled in mainline-prod } // For API stable, first build the dependencies using jarjar compat rules, then build the sources // linking with the dependencies. java_library { name: "NetworkStackApiStableDependencies", defaults: ["NetworkStackReleaseApiLevel", "NetworkStackAndroidLibraryDefaults"], srcs: [":NetworkStackApiStableShims"], jarjar_rules: "apishim/jarjar-rules-compat.txt", enabled: enable_current_sdk_targets, visibility: [ "//frameworks/base/tests/net/integration", "//packages/modules/Connectivity/Tethering/tests/integration", "//packages/modules/Connectivity/tests/cts/net", "//packages/modules/NetworkStack/tests/unit", "//packages/modules/NetworkStack/tests/integration", ], } android_library { name: "NetworkStackApiStableLib", defaults: ["NetworkStackReleaseApiLevel"], defaults: ["NetworkStackReleaseApiLevel", "NetworkStackAndroidLibraryDefaults"], srcs: [ "src/**/*.java", ":statslog-networkstack-java-gen-stable", ], // API stable uses a jarjared version of the shims static_libs: [ "NetworkStackApiStableDependencies", ], static_libs: ["NetworkStackApiStableShims"], manifest: "AndroidManifestBase.xml", visibility: [ "//frameworks/base/tests/net/integration", "//packages/modules/Connectivity/Tethering/tests/integration", "//packages/modules/Connectivity/tests/cts/net", "//packages/modules/NetworkStack/tests/unit", "//packages/modules/NetworkStack/tests/integration", ], } filegroup { Loading @@ -146,7 +243,6 @@ filegroup { visibility: [ "//packages/modules/NetworkStack/tests/unit", "//packages/modules/NetworkStack/tests/integration", "//frameworks/base/packages/Tethering/tests/integration", "//packages/modules/Connectivity/Tethering/tests/integration", ] } Loading Loading @@ -181,7 +277,7 @@ android_app { // The InProcessNetworkStack goes together with the PlatformCaptivePortalLogin, which replaces // the default CaptivePortalLogin. required: ["PlatformNetworkPermissionConfig", "PlatformCaptivePortalLogin"], enabled: false, // Disabled in mainline-prod enabled: enable_current_sdk_targets, } // Pre-merge the AndroidManifest for NetworkStackNext, so that its manifest can be merged on top Loading @@ -190,7 +286,7 @@ android_library { defaults: ["NetworkStackAppDefaults", "NetworkStackDevApiLevel"], static_libs: ["NetworkStackApiCurrentLib"], manifest: "AndroidManifest.xml", enabled: false, // Disabled in mainline-prod enabled: enable_current_sdk_targets, } // NetworkStack build targeting the current API release, for testing on in-development SDK Loading @@ -202,7 +298,7 @@ android_app { manifest: "AndroidManifest_Next.xml", // The permission configuration *must* be included to ensure security of the device required: ["NetworkPermissionConfig"], enabled: false, // Disabled in mainline-prod enabled: enable_current_sdk_targets, } // Updatable network stack for finalized API Loading @@ -217,19 +313,6 @@ android_app { updatable: true, } // Android library to derive test APKs for integration tests android_library { name: "TestNetworkStackLib", defaults: ["NetworkStackAppDefaults", "NetworkStackReleaseApiLevel"], static_libs: ["NetworkStackApiStableLib"], manifest: "AndroidManifestBase.xml", visibility: [ "//frameworks/base/tests/net/integration", "//cts/tests/tests/net", "//packages/modules/Connectivity/tests/cts/net", ], } cc_library_shared { name: "libnetworkstackutilsjni", srcs: [ Loading
apishim/29/com/android/networkstack/apishim/api29/CaptivePortalDataShimImpl.java +33 −6 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ package com.android.networkstack.apishim.api29; import android.net.CaptivePortalData; import android.net.Uri; import androidx.annotation.NonNull; import androidx.annotation.VisibleForTesting; Loading @@ -28,7 +28,7 @@ import org.json.JSONException; import org.json.JSONObject; /** * Compatibility implementation of {@link CaptivePortalDataShim}. * Compatibility implementation of {@link CaptivePortalData}. * * <p>Use {@link com.android.networkstack.apishim.CaptivePortalDataShimImpl} instead of this * fallback implementation. Loading @@ -37,7 +37,7 @@ public abstract class CaptivePortalDataShimImpl implements CaptivePortalDataShim protected CaptivePortalDataShimImpl() {} /** * Parse a {@link android.net.CaptivePortalData} from JSON. * Parse a {@link android.net.CaptivePortalDataShim} from JSON. * * <p>Use * {@link com.android.networkstack.apishim.CaptivePortalDataShimImpl#fromJson(JSONObject)} Loading @@ -56,19 +56,46 @@ public abstract class CaptivePortalDataShimImpl implements CaptivePortalDataShim return null; } @Override public int getUserPortalUrlSource() { // Not supported in API level 29 return ConstantsShim.CAPTIVE_PORTAL_DATA_SOURCE_OTHER; } @VisibleForTesting public static boolean isSupported() { return false; } /** * Generate a {@link CaptivePortalData} object with a friendly name set * Generate a {@link CaptivePortalDataShim} object with a friendly name set * * @param friendlyName The friendly name to set * @return a {@link CaptivePortalData} object with a friendly name set */ public CaptivePortalData withVenueFriendlyName(String friendlyName) { @Override public CaptivePortalDataShim withVenueFriendlyName(String friendlyName) throws UnsupportedApiLevelException { // Not supported in API level 29 return null; throw new UnsupportedApiLevelException("CaptivePortalData not supported on API 29"); } /** * Generate a {@link CaptivePortalDataShim} object with a friendly name and Passpoint external * URLs set * * @param friendlyName The friendly name to set * @param venueInfoUrl Venue information URL * @param termsAndConditionsUrl Terms and conditions URL * * @return a {@link CaptivePortalDataShim} object with friendly name, venue info URL and terms * and conditions URL set */ @Override public CaptivePortalDataShim withPasspointInfo(@NonNull String friendlyName, @NonNull Uri venueInfoUrl, @NonNull Uri termsAndConditionsUrl) throws UnsupportedApiLevelException { // Not supported in API level 29 throw new UnsupportedApiLevelException("CaptivePortalData not supported on API 29"); } }
apishim/29/com/android/networkstack/apishim/api29/ConnectivityManagerShimImpl.java 0 → 100644 +64 −0 Original line number Diff line number Diff line /* * Copyright (C) 2021 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 com.android.networkstack.apishim.api29; import android.content.Context; import android.net.ConnectivityManager.NetworkCallback; import android.net.NetworkRequest; import android.os.Handler; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.android.networkstack.apishim.common.ConnectivityManagerShim; import com.android.networkstack.apishim.common.UnsupportedApiLevelException; /** * Implementation of {@link ConnectivityManagerShim} for API 29. */ public class ConnectivityManagerShimImpl implements ConnectivityManagerShim { protected ConnectivityManagerShimImpl(Context context) {} /** * Get a new instance of {@link ConnectivityManagerShim}. */ public static ConnectivityManagerShim newInstance(Context context) { return new ConnectivityManagerShimImpl(context); } /** * See android.net.ConnectivityManager#requestBackgroundNetwork * @throws UnsupportedApiLevelException if API is not available in this API level. */ @Override public void requestBackgroundNetwork(@NonNull NetworkRequest request, @Nullable Handler handler, @NonNull NetworkCallback networkCallback) throws UnsupportedApiLevelException { // Not supported for API 29. throw new UnsupportedApiLevelException("Not supported in API 29."); } /** * See android.net.ConnectivityManager#registerSystemDefaultNetworkCallback * @throws UnsupportedApiLevelException if API is not available in this API level. */ @Override public void registerSystemDefaultNetworkCallback(@NonNull NetworkCallback networkCallback, @NonNull Handler handler) throws UnsupportedApiLevelException { // Not supported for API 29. throw new UnsupportedApiLevelException("Not supported in API 29."); } }
apishim/29/com/android/networkstack/apishim/api29/ConstantsShim.java +8 −0 Original line number Diff line number Diff line Loading @@ -34,4 +34,12 @@ public class ConstantsShim { // Constants defined in android.net.ConnectivityDiagnosticsManager. public static final int DETECTION_METHOD_DNS_EVENTS = 1; public static final int DETECTION_METHOD_TCP_METRICS = 2; // Constants defined in android.net.CaptivePortalData. public static final int CAPTIVE_PORTAL_DATA_SOURCE_OTHER = 0; public static final int CAPTIVE_PORTAL_DATA_SOURCE_PASSPOINT = 1; // Constants defined in android.net.NetworkCapabilities. public static final int NET_CAPABILITY_NOT_VCN_MANAGED = 28; }
apishim/29/com/android/networkstack/apishim/api29/NetworkInformationShimImpl.java +2 −6 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ package com.android.networkstack.apishim.api29; import android.net.CaptivePortalData; import android.net.IpPrefix; import android.net.LinkProperties; import android.net.NetworkCapabilities; Loading Loading @@ -121,10 +120,7 @@ public class NetworkInformationShimImpl implements NetworkInformationShim { * @param captivePortalData Captive portal data to be used */ public void setCaptivePortalData(@NonNull LinkProperties lp, @Nullable CaptivePortalData captivePortalData) { if (lp == null) { return; } lp.setCaptivePortalData(captivePortalData); @Nullable CaptivePortalDataShim captivePortalData) { // Not supported on this API level: no-op } }