Commit 5fb697d1 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 7920115 from 7afca1af to mainline-tzdata3-release

Change-Id: Ie93cb51113cb9d8a3d11d1d512c486b76b4a37c5
parents c9119d6b 7afca1af
......@@ -45,6 +45,17 @@ package {
default_applicable_licenses: ["Android-Apache-2.0"],
}
// Defaults to enable/disable java targets that depend on
// NetworkStackNext, which uses development APIs. "enabled" may
// have a different value depending on the branch.
java_defaults {
name: "NetworkStackNextEnableDefaults",
enabled: true,
}
// This is a placeholder comment to avoid merge conflicts
// as the above target may have different "enabled" values
// depending on the branch
java_defaults {
name: "NetworkStackDevApiLevel",
min_sdk_version: "29",
......@@ -68,7 +79,7 @@ java_defaults {
name: "NetworkStackShimsDefaults",
libs: [
"androidx.annotation_annotation",
"networkstack-client",
"networkstack-aidl-latest",
],
static_libs : [
"modules-utils-build_system"
......@@ -215,6 +226,8 @@ java_defaults {
static_libs: [
"androidx.annotation_annotation",
"modules-utils-build_system",
"modules-utils-preconditions",
"modules-utils-statemachine",
"netd_aidl_interface-lateststable-java",
"networkstack-client",
"net-utils-framework-common",
......@@ -231,7 +244,11 @@ java_defaults {
// The versions of the android library containing network stack code compiled for each SDK variant.
android_library {
name: "NetworkStackApiCurrentLib",
defaults: ["NetworkStackDevApiLevel", "NetworkStackAndroidLibraryDefaults"],
defaults: [
"NetworkStackDevApiLevel",
"NetworkStackAndroidLibraryDefaults",
"NetworkStackNextEnableDefaults",
],
srcs: [
"src/**/*.java",
":statslog-networkstack-java-gen-current"
......@@ -245,9 +262,7 @@ android_library {
"//packages/modules/NetworkStack/tests/unit",
"//packages/modules/NetworkStack/tests/integration",
],
lint: {
baseline_filename: "lint-baseline-current-lib.xml",
},
lint: { strict_updatability_linting: true },
}
android_library {
......@@ -268,9 +283,7 @@ android_library {
"//packages/modules/NetworkStack/tests/unit",
"//packages/modules/NetworkStack/tests/integration",
],
lint: {
baseline_filename: "lint-baseline-stable-lib.xml",
},
lint: { strict_updatability_linting: true },
}
filegroup {
......@@ -304,7 +317,11 @@ java_defaults {
// Non-updatable network stack running in the system server process for devices not using the module
android_app {
name: "InProcessNetworkStack",
defaults: [ "NetworkStackAppDefaults", "NetworkStackDevApiLevel"],
defaults: [
"NetworkStackAppDefaults",
"NetworkStackDevApiLevel",
"NetworkStackNextEnableDefaults",
],
static_libs: ["NetworkStackApiCurrentLib"],
certificate: "platform",
manifest: "AndroidManifest_InProcess.xml",
......@@ -322,7 +339,11 @@ android_app {
// Pre-merge the AndroidManifest for NetworkStackNext, so that its manifest can be merged on top
android_library {
name: "NetworkStackNextManifestBase",
defaults: ["NetworkStackAppDefaults", "NetworkStackDevApiLevel"],
defaults: [
"NetworkStackAppDefaults",
"NetworkStackDevApiLevel",
"NetworkStackNextEnableDefaults",
],
static_libs: ["NetworkStackApiCurrentLib"],
manifest: "AndroidManifest.xml"
}
......@@ -330,7 +351,11 @@ android_library {
// NetworkStack build targeting the current API release, for testing on in-development SDK
android_app {
name: "NetworkStackNext",
defaults: ["NetworkStackAppDefaults", "NetworkStackDevApiLevel"],
defaults: [
"NetworkStackAppDefaults",
"NetworkStackDevApiLevel",
"NetworkStackNextEnableDefaults",
],
static_libs: ["NetworkStackNextManifestBase"],
certificate: "networkstack",
manifest: "AndroidManifest_Next.xml",
......@@ -339,6 +364,7 @@ android_app {
"NetworkPermissionConfig",
"privapp_whitelist_com.android.networkstack",
],
lint: { strict_updatability_linting: true },
}
// Updatable network stack for finalized API
......@@ -354,6 +380,7 @@ android_app {
"privapp_whitelist_com.android.networkstack",
],
updatable: true,
lint: { strict_updatability_linting: true },
}
cc_library_shared {
......
......@@ -17,8 +17,10 @@
package com.android.networkstack.apishim.api29;
import android.net.Uri;
import android.os.Build;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.annotation.VisibleForTesting;
import com.android.networkstack.apishim.common.CaptivePortalDataShim;
......@@ -33,6 +35,7 @@ import org.json.JSONObject;
* <p>Use {@link com.android.networkstack.apishim.CaptivePortalDataShimImpl} instead of this
* fallback implementation.
*/
@RequiresApi(Build.VERSION_CODES.Q)
public abstract class CaptivePortalDataShimImpl implements CaptivePortalDataShim {
protected CaptivePortalDataShimImpl() {}
......
......@@ -25,9 +25,11 @@ import android.net.ConnectivityManager;
import android.net.ConnectivityManager.NetworkCallback;
import android.net.NetworkCapabilities;
import android.net.NetworkRequest;
import android.os.Build;
import android.os.Handler;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import com.android.networkstack.apishim.common.ConnectivityManagerShim;
import com.android.networkstack.apishim.common.UnsupportedApiLevelException;
......@@ -35,6 +37,7 @@ import com.android.networkstack.apishim.common.UnsupportedApiLevelException;
/**
* Implementation of {@link ConnectivityManagerShim} for API 29.
*/
@RequiresApi(Build.VERSION_CODES.Q)
public class ConnectivityManagerShimImpl implements ConnectivityManagerShim {
protected final ConnectivityManager mCm;
protected ConnectivityManagerShimImpl(Context context) {
......
......@@ -20,10 +20,11 @@ import android.net.IpPrefix;
import android.net.LinkProperties;
import android.net.NetworkCapabilities;
import android.net.Uri;
import android.os.Build;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.annotation.RequiresApi;
import com.android.networkstack.apishim.common.CaptivePortalDataShim;
import com.android.networkstack.apishim.common.NetworkInformationShim;
......@@ -36,6 +37,7 @@ import java.net.Inet4Address;
* <p>Use {@link com.android.networkstack.apishim.NetworkInformationShimImpl} instead of this
* fallback implementation.
*/
@RequiresApi(Build.VERSION_CODES.Q)
public class NetworkInformationShimImpl implements NetworkInformationShim {
protected NetworkInformationShimImpl() {}
......@@ -49,22 +51,6 @@ public class NetworkInformationShimImpl implements NetworkInformationShim {
return new NetworkInformationShimImpl();
}
/**
* Indicates whether the shim can use APIs above the Q SDK.
*/
@VisibleForTesting
public static boolean useApiAboveQ() {
return false;
}
/**
* Indicates whether the shim can use APIs above the R SDK.
*/
@VisibleForTesting
public static boolean useApiAboveR() {
return false;
}
@Nullable
@Override
public Uri getCaptivePortalApiUrl(@Nullable LinkProperties lp) {
......
......@@ -17,10 +17,12 @@
package com.android.networkstack.apishim.api29;
import android.net.NetworkRequest;
import android.os.Build;
import android.util.Range;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import com.android.networkstack.apishim.common.NetworkRequestShim;
import com.android.networkstack.apishim.common.UnsupportedApiLevelException;
......@@ -30,6 +32,7 @@ import java.util.Set;
/**
* Implementation of {@link NetworkRequestShim} for API 29.
*/
@RequiresApi(Build.VERSION_CODES.Q)
public class NetworkRequestShimImpl implements NetworkRequestShim {
protected NetworkRequestShimImpl() {}
......
......@@ -17,14 +17,17 @@
package com.android.networkstack.apishim.api29;
import android.net.Network;
import android.os.Build;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import com.android.networkstack.apishim.common.NetworkShim;
import com.android.networkstack.apishim.common.UnsupportedApiLevelException;
/**
* Implementation of NetworkShim for API 29.
*/
@RequiresApi(Build.VERSION_CODES.Q)
public class NetworkShimImpl implements NetworkShim {
@NonNull
protected final Network mNetwork;
......
/*
* 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.os.Build;
import androidx.annotation.RequiresApi;
import com.android.networkstack.apishim.common.SettingsShim;
/**
* Implementation of {@link SettingsShim} for API 29.
*/
@RequiresApi(Build.VERSION_CODES.Q)
public class SettingsShimImpl implements SettingsShim {
protected SettingsShimImpl() {}
/**
* Get a new instance of {@link SettingsShimImpl}.
*
* Use com.android.networkstack.apishim.SettingsShim#newInstance()
* (non-API29 version) instead, to use the correct shims depending on build SDK.
*/
public static SettingsShim newInstance() {
return new SettingsShimImpl();
}
}
......@@ -17,8 +17,10 @@
package com.android.networkstack.apishim.api29;
import android.net.util.SocketUtils;
import android.os.Build;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import com.android.networkstack.apishim.common.SocketUtilsShim;
......@@ -27,6 +29,7 @@ import java.net.SocketAddress;
/**
* Implementation of SocketUtilsShim for API 29.
*/
@RequiresApi(Build.VERSION_CODES.Q)
public class SocketUtilsShimImpl implements SocketUtilsShim {
protected SocketUtilsShimImpl() {}
......
......@@ -22,7 +22,9 @@ import android.net.Uri;
import android.os.Build;
import android.os.RemoteException;
import androidx.annotation.ChecksSdkIntAtLeast;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import com.android.networkstack.apishim.common.CaptivePortalDataShim;
import com.android.networkstack.apishim.common.ShimUtils;
......@@ -34,6 +36,7 @@ import org.json.JSONObject;
/**
* Compatibility implementation of {@link CaptivePortalDataShim}.
*/
@RequiresApi(Build.VERSION_CODES.R)
public class CaptivePortalDataShimImpl
extends com.android.networkstack.apishim.api29.CaptivePortalDataShimImpl {
@NonNull
......@@ -52,6 +55,7 @@ public class CaptivePortalDataShimImpl
* @throws JSONException The JSON is not a representation of correct captive portal data.
* @throws UnsupportedApiLevelException CaptivePortalData is not available on this API level.
*/
@RequiresApi(Build.VERSION_CODES.Q)
@NonNull
public static CaptivePortalDataShim fromJson(JSONObject obj) throws JSONException,
UnsupportedApiLevelException {
......@@ -77,6 +81,8 @@ public class CaptivePortalDataShimImpl
.build());
}
@RequiresApi(Build.VERSION_CODES.Q)
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.R)
public static boolean isSupported() {
return ShimUtils.isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.Q);
}
......
......@@ -16,14 +16,18 @@
package com.android.networkstack.apishim.api30;
import static com.android.modules.utils.build.SdkLevel.isAtLeastR;
import android.os.Build;
import androidx.annotation.RequiresApi;
import com.android.networkstack.apishim.common.NetworkRequestShim;
import com.android.networkstack.apishim.common.ShimUtils;
/**
* Implementation of {@link NetworkRequestShim} for API 30.
*/
@RequiresApi(Build.VERSION_CODES.R)
public class NetworkRequestShimImpl
extends com.android.networkstack.apishim.api29.NetworkRequestShimImpl {
protected NetworkRequestShimImpl() {
......@@ -33,8 +37,9 @@ public class NetworkRequestShimImpl
/**
* Get a new instance of {@link NetworkRequestShim}.
*/
@RequiresApi(Build.VERSION_CODES.Q)
public static NetworkRequestShim newInstance() {
if (!ShimUtils.isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.Q)) {
if (!isAtLeastR()) {
return com.android.networkstack.apishim.api29.NetworkRequestShimImpl
.newInstance();
}
......
......@@ -16,17 +16,20 @@
package com.android.networkstack.apishim.api30;
import static com.android.modules.utils.build.SdkLevel.isAtLeastR;
import android.net.Network;
import android.os.Build;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import com.android.networkstack.apishim.common.NetworkShim;
import com.android.networkstack.apishim.common.ShimUtils;
/**
* Implementation of {@link NetworkShim} for API 30.
*/
@RequiresApi(Build.VERSION_CODES.R)
public class NetworkShimImpl extends com.android.networkstack.apishim.api29.NetworkShimImpl {
protected NetworkShimImpl(@NonNull Network network) {
super(network);
......@@ -35,8 +38,9 @@ public class NetworkShimImpl extends com.android.networkstack.apishim.api29.Netw
/**
* Get a new instance of {@link NetworkShim}.
*/
@RequiresApi(Build.VERSION_CODES.Q)
public static NetworkShim newInstance(@NonNull Network network) {
if (!ShimUtils.isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.Q)) {
if (!isAtLeastR()) {
return com.android.networkstack.apishim.api29.NetworkShimImpl.newInstance(network);
}
return new NetworkShimImpl(network);
......
......@@ -16,27 +16,33 @@
package com.android.networkstack.apishim.api30;
import static com.android.modules.utils.build.SdkLevel.isAtLeastR;
import android.content.Context;
import android.os.Build;
import android.provider.Settings;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import com.android.networkstack.apishim.common.SettingsShim;
/**
* Implementation of {@link SettingsShim} for API 30.
*/
public class SettingsShimImpl implements SettingsShim {
@RequiresApi(Build.VERSION_CODES.R)
public class SettingsShimImpl extends com.android.networkstack.apishim.api29.SettingsShimImpl {
protected SettingsShimImpl() { }
/**
* Get a new instance of {@link SettingsShim}.
*
* Use com.android.networkstack.apishim.SeetingsShim#newInstance()
* (non-API30 version) instead, to use the correct shims depending on build SDK.
*/
@RequiresApi(Build.VERSION_CODES.Q)
public static SettingsShim newInstance() {
if (!isAtLeastR()) {
return com.android.networkstack.apishim.api29.SettingsShimImpl.newInstance();
}
return new SettingsShimImpl();
}
......
......@@ -16,12 +16,14 @@
package com.android.networkstack.apishim.api30;
import static com.android.modules.utils.build.SdkLevel.isAtLeastR;
import android.net.util.SocketUtils;
import android.os.Build;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import com.android.networkstack.apishim.common.ShimUtils;
import com.android.networkstack.apishim.common.SocketUtilsShim;
import java.net.SocketAddress;
......@@ -29,6 +31,7 @@ import java.net.SocketAddress;
/**
* Implementation of {@link SocketUtilsShim} for API 30.
*/
@RequiresApi(Build.VERSION_CODES.R)
public class SocketUtilsShimImpl
extends com.android.networkstack.apishim.api29.SocketUtilsShimImpl {
protected SocketUtilsShimImpl() {}
......@@ -36,8 +39,9 @@ public class SocketUtilsShimImpl
/**
* Get a new instance of {@link SocketUtilsShim}.
*/
@RequiresApi(Build.VERSION_CODES.Q)
public static SocketUtilsShim newInstance() {
if (!ShimUtils.isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.Q)) {
if (!isAtLeastR()) {
return com.android.networkstack.apishim.api29.SocketUtilsShimImpl.newInstance();
}
return new SocketUtilsShimImpl();
......
......@@ -18,14 +18,17 @@ package com.android.networkstack.apishim.api31;
import android.net.CaptivePortalData;
import android.net.Uri;
import android.os.Build;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import com.android.networkstack.apishim.common.CaptivePortalDataShim;
/**
* Compatibility implementation of {@link CaptivePortalDataShim}.
*/
@RequiresApi(Build.VERSION_CODES.S)
public class CaptivePortalDataShimImpl
extends com.android.networkstack.apishim.api30.CaptivePortalDataShimImpl {
public CaptivePortalDataShimImpl(@NonNull CaptivePortalData data) {
......
......@@ -16,38 +16,32 @@
package com.android.networkstack.apishim.api31;
import static com.android.modules.utils.build.SdkLevel.isAtLeastS;
import android.net.LinkProperties;
import android.net.NetworkCapabilities;
import android.os.Build;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.VisibleForTesting;
import com.android.networkstack.apishim.common.CaptivePortalDataShim;
import com.android.networkstack.apishim.common.NetworkInformationShim;
import com.android.networkstack.apishim.common.ShimUtils;
/**
* Compatibility implementation of {@link NetworkInformationShim}.
*/
@RequiresApi(Build.VERSION_CODES.S)
public class NetworkInformationShimImpl
extends com.android.networkstack.apishim.api30.NetworkInformationShimImpl {
protected NetworkInformationShimImpl() {}
/**
* Indicates whether the shim can use APIs above the R SDK.
*/
@VisibleForTesting
public static boolean useApiAboveR() {
return ShimUtils.isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.R);
}
/**
* Get a new instance of {@link NetworkInformationShim}.
*/
@RequiresApi(Build.VERSION_CODES.Q)
public static NetworkInformationShim newInstance() {
if (!useApiAboveR()) {
if (!isAtLeastS()) {
return com.android.networkstack.apishim.api30.NetworkInformationShimImpl.newInstance();
}
return new NetworkInformationShimImpl();
......@@ -60,7 +54,6 @@ public class NetworkInformationShimImpl
return new CaptivePortalDataShimImpl(lp.getCaptivePortalData());
}
@RequiresApi(Build.VERSION_CODES.S)
@Nullable
@Override
public String getCapabilityCarrierName(int capability) {
......
......@@ -17,12 +17,15 @@
package com.android.networkstack.apishim.api31;
import android.net.Network;
import android.os.Build;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
/**
* Implementation of {@link NetworkShim} for API 30.
* Implementation of {@link NetworkShim} for API 31.
*/
@RequiresApi(Build.VERSION_CODES.S)
public class NetworkShimImpl extends com.android.networkstack.apishim.api30.NetworkShimImpl {
// Currently, this is the same as the API 30 shim, so inherit everything from that.
protected NetworkShimImpl(@NonNull Network network) {
......
......@@ -16,19 +16,22 @@
package com.android.networkstack.apishim.api31;
import static com.android.modules.utils.build.SdkLevel.isAtLeastS;
import android.content.Context;
import android.os.Build;
import android.provider.Settings;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import com.android.networkstack.apishim.common.SettingsShim;
import com.android.networkstack.apishim.common.ShimUtils;
/**
* Implementation of {@link SettingsShim} for API 31.
*/
@RequiresApi(Build.VERSION_CODES.S)
public class SettingsShimImpl
extends com.android.networkstack.apishim.api30.SettingsShimImpl {
protected SettingsShimImpl() { }
......@@ -36,10 +39,10 @@ public class SettingsShimImpl
/**
* Get a new instance of {@link SettingsShim}.
*/
@RequiresApi(Build.VERSION_CODES.Q)
public static SettingsShim newInstance() {
if (!ShimUtils.isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.R)) {
return com.android.networkstack.apishim.api30.SettingsShimImpl
.newInstance();