Merge "Add maxTargetSdk restriction to unused APIs."

This commit is contained in:
Mathew Inwood
2020-11-09 14:41:20 +00:00
committed by Gerrit Code Review
11 changed files with 46 additions and 42 deletions

View File

@@ -354,7 +354,7 @@ public class ConnectivityManager {
* @hide * @hide
*/ */
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public static final String ACTION_TETHER_STATE_CHANGED = public static final String ACTION_TETHER_STATE_CHANGED =
TetheringManager.ACTION_TETHER_STATE_CHANGED; TetheringManager.ACTION_TETHER_STATE_CHANGED;
@@ -363,7 +363,7 @@ public class ConnectivityManager {
* gives a String[] listing all the interfaces configured for * gives a String[] listing all the interfaces configured for
* tethering and currently available for tethering. * tethering and currently available for tethering.
*/ */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public static final String EXTRA_AVAILABLE_TETHER = TetheringManager.EXTRA_AVAILABLE_TETHER; public static final String EXTRA_AVAILABLE_TETHER = TetheringManager.EXTRA_AVAILABLE_TETHER;
/** /**
@@ -378,7 +378,7 @@ public class ConnectivityManager {
* gives a String[] listing all the interfaces currently tethered * gives a String[] listing all the interfaces currently tethered
* (ie, has DHCPv4 support and packets potentially forwarded/NATed) * (ie, has DHCPv4 support and packets potentially forwarded/NATed)
*/ */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public static final String EXTRA_ACTIVE_TETHER = TetheringManager.EXTRA_ACTIVE_TETHER; public static final String EXTRA_ACTIVE_TETHER = TetheringManager.EXTRA_ACTIVE_TETHER;
/** /**
@@ -387,7 +387,7 @@ public class ConnectivityManager {
* failed. Use {@link #getLastTetherError} to find the error code * failed. Use {@link #getLastTetherError} to find the error code
* for any interfaces listed here. * for any interfaces listed here.
*/ */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public static final String EXTRA_ERRORED_TETHER = TetheringManager.EXTRA_ERRORED_TETHER; public static final String EXTRA_ERRORED_TETHER = TetheringManager.EXTRA_ERRORED_TETHER;
/** /**
@@ -850,7 +850,7 @@ public class ConnectivityManager {
* {@hide} * {@hide}
*/ */
@Deprecated @Deprecated
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public static String getNetworkTypeName(int type) { public static String getNetworkTypeName(int type) {
switch (type) { switch (type) {
case TYPE_NONE: case TYPE_NONE:
@@ -1173,7 +1173,7 @@ public class ConnectivityManager {
* {@hide} * {@hide}
*/ */
@RequiresPermission(android.Manifest.permission.NETWORK_STACK) @RequiresPermission(android.Manifest.permission.NETWORK_STACK)
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public NetworkInfo getActiveNetworkInfoForUid(int uid) { public NetworkInfo getActiveNetworkInfoForUid(int uid) {
return getActiveNetworkInfoForUid(uid, false); return getActiveNetworkInfoForUid(uid, false);
} }
@@ -1520,7 +1520,7 @@ public class ConnectivityManager {
return 1; return 1;
} }
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
private NetworkCapabilities networkCapabilitiesForFeature(int networkType, String feature) { private NetworkCapabilities networkCapabilitiesForFeature(int networkType, String feature) {
if (networkType == TYPE_MOBILE) { if (networkType == TYPE_MOBILE) {
switch (feature) { switch (feature) {
@@ -1606,7 +1606,7 @@ public class ConnectivityManager {
}; };
} }
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
private static final HashMap<NetworkCapabilities, LegacyRequest> sLegacyRequests = private static final HashMap<NetworkCapabilities, LegacyRequest> sLegacyRequests =
new HashMap<>(); new HashMap<>();
@@ -1635,7 +1635,7 @@ public class ConnectivityManager {
Log.d(TAG, "expireRequest with " + ourSeqNum + ", " + sequenceNum); Log.d(TAG, "expireRequest with " + ourSeqNum + ", " + sequenceNum);
} }
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
private NetworkRequest requestNetworkForFeatureLocked(NetworkCapabilities netCap) { private NetworkRequest requestNetworkForFeatureLocked(NetworkCapabilities netCap) {
int delay = -1; int delay = -1;
int type = legacyTypeForNetworkCapabilities(netCap); int type = legacyTypeForNetworkCapabilities(netCap);
@@ -1665,7 +1665,7 @@ public class ConnectivityManager {
} }
} }
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
private boolean removeRequestForFeature(NetworkCapabilities netCap) { private boolean removeRequestForFeature(NetworkCapabilities netCap) {
final LegacyRequest l; final LegacyRequest l;
synchronized (sLegacyRequests) { synchronized (sLegacyRequests) {
@@ -1732,17 +1732,17 @@ public class ConnectivityManager {
/** @hide */ /** @hide */
public static class PacketKeepaliveCallback { public static class PacketKeepaliveCallback {
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public PacketKeepaliveCallback() { public PacketKeepaliveCallback() {
} }
/** The requested keepalive was successfully started. */ /** The requested keepalive was successfully started. */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public void onStarted() {} public void onStarted() {}
/** The keepalive was successfully stopped. */ /** The keepalive was successfully stopped. */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public void onStopped() {} public void onStopped() {}
/** An error occurred. */ /** An error occurred. */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public void onError(int error) {} public void onError(int error) {}
} }
@@ -1806,7 +1806,7 @@ public class ConnectivityManager {
private volatile Integer mSlot; private volatile Integer mSlot;
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public void stop() { public void stop() {
try { try {
mExecutor.execute(() -> { mExecutor.execute(() -> {
@@ -1875,7 +1875,7 @@ public class ConnectivityManager {
* *
* @hide * @hide
*/ */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public PacketKeepalive startNattKeepalive( public PacketKeepalive startNattKeepalive(
Network network, int intervalSeconds, PacketKeepaliveCallback callback, Network network, int intervalSeconds, PacketKeepaliveCallback callback,
InetAddress srcAddr, int srcPort, InetAddress dstAddr) { InetAddress srcAddr, int srcPort, InetAddress dstAddr) {
@@ -2110,7 +2110,7 @@ public class ConnectivityManager {
/** {@hide} */ /** {@hide} */
@Deprecated @Deprecated
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public NetworkQuotaInfo getActiveNetworkQuotaInfo() { public NetworkQuotaInfo getActiveNetworkQuotaInfo() {
try { try {
return mService.getActiveNetworkQuotaInfo(); return mService.getActiveNetworkQuotaInfo();
@@ -2408,7 +2408,7 @@ public class ConnectivityManager {
* *
* {@hide} * {@hide}
*/ */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
@Deprecated @Deprecated
public int tether(String iface) { public int tether(String iface) {
return mTetheringManager.tether(iface); return mTetheringManager.tether(iface);
@@ -2849,7 +2849,7 @@ public class ConnectivityManager {
* {@hide} * {@hide}
*/ */
@RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE) @RequiresPermission(android.Manifest.permission.ACCESS_NETWORK_STATE)
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
@Deprecated @Deprecated
public int getLastTetherError(String iface) { public int getLastTetherError(String iface) {
int error = mTetheringManager.getLastTetherError(iface); int error = mTetheringManager.getLastTetherError(iface);
@@ -4659,7 +4659,7 @@ public class ConnectivityManager {
* @deprecated This is strictly for legacy usage to support {@link #startUsingNetworkFeature}. * @deprecated This is strictly for legacy usage to support {@link #startUsingNetworkFeature}.
*/ */
@Deprecated @Deprecated
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public static boolean setProcessDefaultNetworkForHostResolution(Network network) { public static boolean setProcessDefaultNetworkForHostResolution(Network network) {
return NetworkUtils.bindProcessToNetworkForHostResolution( return NetworkUtils.bindProcessToNetworkForHostResolution(
(network == null) ? NETID_UNSET : network.getNetIdForResolv()); (network == null) ? NETID_UNSET : network.getNetIdForResolv());

View File

@@ -73,7 +73,7 @@ interface IConnectivityManager
NetworkCapabilities getNetworkCapabilities(in Network network, String callingPackageName); NetworkCapabilities getNetworkCapabilities(in Network network, String callingPackageName);
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
NetworkState[] getAllNetworkState(); NetworkState[] getAllNetworkState();
NetworkQuotaInfo getActiveNetworkQuotaInfo(); NetworkQuotaInfo getActiveNetworkQuotaInfo();
@@ -134,7 +134,7 @@ interface IConnectivityManager
VpnConfig getVpnConfig(int userId); VpnConfig getVpnConfig(int userId);
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
void startLegacyVpn(in VpnProfile profile); void startLegacyVpn(in VpnProfile profile);
LegacyVpnInfo getLegacyVpnInfo(int userId); LegacyVpnInfo getLegacyVpnInfo(int userId);

View File

@@ -21,6 +21,7 @@ import android.annotation.Nullable;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.annotation.SystemApi; import android.annotation.SystemApi;
import android.compat.annotation.UnsupportedAppUsage; import android.compat.annotation.UnsupportedAppUsage;
import android.os.Build;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
@@ -98,7 +99,7 @@ public final class IpConfiguration implements Parcelable {
} }
/** @hide */ /** @hide */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public IpConfiguration(IpAssignment ipAssignment, public IpConfiguration(IpAssignment ipAssignment,
ProxySettings proxySettings, ProxySettings proxySettings,
StaticIpConfiguration staticIpConfiguration, StaticIpConfiguration staticIpConfiguration,

View File

@@ -111,7 +111,7 @@ public final class LinkProperties implements Parcelable {
* *
* @hide * @hide
*/ */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public static ProvisioningChange compareProvisioning( public static ProvisioningChange compareProvisioning(
LinkProperties before, LinkProperties after) { LinkProperties before, LinkProperties after) {
if (before.isProvisioned() && after.isProvisioned()) { if (before.isProvisioned() && after.isProvisioned()) {
@@ -849,7 +849,7 @@ public final class LinkProperties implements Parcelable {
* Returns all the links stacked on top of this link. * Returns all the links stacked on top of this link.
* @hide * @hide
*/ */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public @NonNull List<LinkProperties> getStackedLinks() { public @NonNull List<LinkProperties> getStackedLinks() {
if (mStackedLinks.isEmpty()) { if (mStackedLinks.isEmpty()) {
return Collections.emptyList(); return Collections.emptyList();
@@ -1448,7 +1448,7 @@ public final class LinkProperties implements Parcelable {
* @return {@code true} if both are identical, {@code false} otherwise. * @return {@code true} if both are identical, {@code false} otherwise.
* @hide * @hide
*/ */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public boolean isIdenticalStackedLinks(@NonNull LinkProperties target) { public boolean isIdenticalStackedLinks(@NonNull LinkProperties target) {
if (!mStackedLinks.keySet().equals(target.mStackedLinks.keySet())) { if (!mStackedLinks.keySet().equals(target.mStackedLinks.keySet())) {
return false; return false;

View File

@@ -22,6 +22,7 @@ import android.annotation.Nullable;
import android.compat.annotation.UnsupportedAppUsage; import android.compat.annotation.UnsupportedAppUsage;
import android.net.util.MacAddressUtils; import android.net.util.MacAddressUtils;
import android.net.wifi.WifiInfo; import android.net.wifi.WifiInfo;
import android.os.Build;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
@@ -58,7 +59,7 @@ public final class MacAddress implements Parcelable {
* <p>Not publicly exposed or treated specially since the OUI 00:00:00 is registered. * <p>Not publicly exposed or treated specially since the OUI 00:00:00 is registered.
* @hide * @hide
*/ */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public static final MacAddress ALL_ZEROS_ADDRESS = new MacAddress(0); public static final MacAddress ALL_ZEROS_ADDRESS = new MacAddress(0);
/** @hide */ /** @hide */

View File

@@ -19,6 +19,7 @@ package android.net;
import android.annotation.NonNull; import android.annotation.NonNull;
import android.annotation.SystemApi; import android.annotation.SystemApi;
import android.compat.annotation.UnsupportedAppUsage; import android.compat.annotation.UnsupportedAppUsage;
import android.os.Build;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import android.system.ErrnoException; import android.system.ErrnoException;
@@ -109,7 +110,7 @@ public class Network implements Parcelable {
/** /**
* @hide * @hide
*/ */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public Network(int netId) { public Network(int netId) {
this(netId, false); this(netId, false);
} }

View File

@@ -133,7 +133,7 @@ public final class NetworkCapabilities implements Parcelable {
* Represents the network's capabilities. If any are specified they will be satisfied * Represents the network's capabilities. If any are specified they will be satisfied
* by any Network that matches all of them. * by any Network that matches all of them.
*/ */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
private long mNetworkCapabilities; private long mNetworkCapabilities;
/** /**
@@ -1288,7 +1288,7 @@ public final class NetworkCapabilities implements Parcelable {
* *
* @hide * @hide
*/ */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public boolean hasSignalStrength() { public boolean hasSignalStrength() {
return mSignalStrength > SIGNAL_STRENGTH_UNSPECIFIED; return mSignalStrength > SIGNAL_STRENGTH_UNSPECIFIED;
} }
@@ -1927,7 +1927,7 @@ public final class NetworkCapabilities implements Parcelable {
/** /**
* @hide * @hide
*/ */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public static @NonNull String transportNamesOf(@Nullable @Transport int[] types) { public static @NonNull String transportNamesOf(@Nullable @Transport int[] types) {
StringJoiner joiner = new StringJoiner("|"); StringJoiner joiner = new StringJoiner("|");
if (types != null) { if (types != null) {

View File

@@ -43,7 +43,7 @@ public class NetworkRequest implements Parcelable {
* The {@link NetworkCapabilities} that define this request. * The {@link NetworkCapabilities} that define this request.
* @hide * @hide
*/ */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public final @NonNull NetworkCapabilities networkCapabilities; public final @NonNull NetworkCapabilities networkCapabilities;
/** /**
@@ -52,7 +52,7 @@ public class NetworkRequest implements Parcelable {
* the request. * the request.
* @hide * @hide
*/ */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public final int requestId; public final int requestId;
/** /**

View File

@@ -98,7 +98,7 @@ public class NetworkUtils {
* this socket will go directly to the underlying network, so its traffic will not be * this socket will go directly to the underlying network, so its traffic will not be
* forwarded through the VPN. * forwarded through the VPN.
*/ */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public static boolean protectFromVpn(FileDescriptor fd) { public static boolean protectFromVpn(FileDescriptor fd) {
return protectFromVpn(fd.getInt$()); return protectFromVpn(fd.getInt$());
} }
@@ -223,7 +223,7 @@ public class NetworkUtils {
* @hide * @hide
* @deprecated use {@link Inet4AddressUtils#netmaskToPrefixLength(Inet4Address)} * @deprecated use {@link Inet4AddressUtils#netmaskToPrefixLength(Inet4Address)}
*/ */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
@Deprecated @Deprecated
public static int netmaskToPrefixLength(Inet4Address netmask) { public static int netmaskToPrefixLength(Inet4Address netmask) {
// This is only here because some apps seem to be using it (@UnsupportedAppUsage). // This is only here because some apps seem to be using it (@UnsupportedAppUsage).
@@ -290,7 +290,7 @@ public class NetworkUtils {
/** /**
* Returns the implicit netmask of an IPv4 address, as was the custom before 1993. * Returns the implicit netmask of an IPv4 address, as was the custom before 1993.
*/ */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public static int getImplicitNetmask(Inet4Address address) { public static int getImplicitNetmask(Inet4Address address) {
// Only here because it seems to be used by apps // Only here because it seems to be used by apps
return Inet4AddressUtils.getImplicitNetmask(address); return Inet4AddressUtils.getImplicitNetmask(address);

View File

@@ -232,7 +232,7 @@ public final class RouteInfo implements Parcelable {
* *
* @hide * @hide
*/ */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public RouteInfo(@Nullable IpPrefix destination, @Nullable InetAddress gateway, public RouteInfo(@Nullable IpPrefix destination, @Nullable InetAddress gateway,
@Nullable String iface) { @Nullable String iface) {
this(destination, gateway, iface, RTN_UNICAST); this(destination, gateway, iface, RTN_UNICAST);
@@ -501,7 +501,7 @@ public final class RouteInfo implements Parcelable {
* *
* @hide * @hide
*/ */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
@Nullable @Nullable
public static RouteInfo selectBestRoute(Collection<RouteInfo> routes, InetAddress dest) { public static RouteInfo selectBestRoute(Collection<RouteInfo> routes, InetAddress dest) {
return NetUtils.selectBestRoute(routes, dest); return NetUtils.selectBestRoute(routes, dest);

View File

@@ -20,6 +20,7 @@ import android.annotation.NonNull;
import android.annotation.Nullable; import android.annotation.Nullable;
import android.annotation.SystemApi; import android.annotation.SystemApi;
import android.compat.annotation.UnsupportedAppUsage; import android.compat.annotation.UnsupportedAppUsage;
import android.os.Build;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
@@ -53,19 +54,19 @@ import java.util.Objects;
@SystemApi @SystemApi
public final class StaticIpConfiguration implements Parcelable { public final class StaticIpConfiguration implements Parcelable {
/** @hide */ /** @hide */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
@Nullable @Nullable
public LinkAddress ipAddress; public LinkAddress ipAddress;
/** @hide */ /** @hide */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
@Nullable @Nullable
public InetAddress gateway; public InetAddress gateway;
/** @hide */ /** @hide */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
@NonNull @NonNull
public final ArrayList<InetAddress> dnsServers; public final ArrayList<InetAddress> dnsServers;
/** @hide */ /** @hide */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
@Nullable @Nullable
public String domains; public String domains;