Merge "Add maxTargetSdk restriction to unused APIs." am: db3bb00d7b

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1468245

Change-Id: I35f65987f7f9287cf03418e9feb27c81f4fd1878
This commit is contained in:
Mathew Inwood
2020-11-09 15:09:11 +00:00
committed by Automerger Merge Worker
8 changed files with 44 additions and 39 deletions

View File

@@ -34,6 +34,7 @@ import android.net.NetworkTemplate;
import android.net.netstats.provider.INetworkStatsProviderCallback; import android.net.netstats.provider.INetworkStatsProviderCallback;
import android.net.netstats.provider.NetworkStatsProvider; import android.net.netstats.provider.NetworkStatsProvider;
import android.os.Binder; import android.os.Binder;
import android.os.Build;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.os.Message; import android.os.Message;
@@ -129,7 +130,7 @@ public class NetworkStatsManager {
/** /**
* {@hide} * {@hide}
*/ */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public NetworkStatsManager(Context context) throws ServiceNotFoundException { public NetworkStatsManager(Context context) throws ServiceNotFoundException {
this(context, INetworkStatsService.Stub.asInterface( this(context, INetworkStatsService.Stub.asInterface(
ServiceManager.getServiceOrThrow(Context.NETWORK_STATS_SERVICE))); ServiceManager.getServiceOrThrow(Context.NETWORK_STATS_SERVICE)));
@@ -153,7 +154,7 @@ public class NetworkStatsManager {
} }
/** @hide */ /** @hide */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
@TestApi @TestApi
public void setPollForce(boolean pollForce) { public void setPollForce(boolean pollForce) {
if (pollForce) { if (pollForce) {

View File

@@ -23,6 +23,7 @@ import android.annotation.SystemService;
import android.annotation.TestApi; import android.annotation.TestApi;
import android.compat.annotation.UnsupportedAppUsage; import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context; import android.content.Context;
import android.os.Build;
import android.os.Handler; import android.os.Handler;
import android.os.Message; import android.os.Message;
import android.os.RemoteException; import android.os.RemoteException;
@@ -76,7 +77,7 @@ public class EthernetManager {
* @param isAvailable {@code true} if Ethernet port exists. * @param isAvailable {@code true} if Ethernet port exists.
* @hide * @hide
*/ */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
void onAvailabilityChanged(String iface, boolean isAvailable); void onAvailabilityChanged(String iface, boolean isAvailable);
} }
@@ -97,7 +98,7 @@ public class EthernetManager {
* @return the Ethernet Configuration, contained in {@link IpConfiguration}. * @return the Ethernet Configuration, contained in {@link IpConfiguration}.
* @hide * @hide
*/ */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public IpConfiguration getConfiguration(String iface) { public IpConfiguration getConfiguration(String iface) {
try { try {
return mService.getConfiguration(iface); return mService.getConfiguration(iface);
@@ -110,7 +111,7 @@ public class EthernetManager {
* Set Ethernet configuration. * Set Ethernet configuration.
* @hide * @hide
*/ */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public void setConfiguration(String iface, IpConfiguration config) { public void setConfiguration(String iface, IpConfiguration config) {
try { try {
mService.setConfiguration(iface, config); mService.setConfiguration(iface, config);
@@ -123,7 +124,7 @@ public class EthernetManager {
* Indicates whether the system currently has one or more Ethernet interfaces. * Indicates whether the system currently has one or more Ethernet interfaces.
* @hide * @hide
*/ */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public boolean isAvailable() { public boolean isAvailable() {
return getAvailableInterfaces().length > 0; return getAvailableInterfaces().length > 0;
} }
@@ -134,7 +135,7 @@ public class EthernetManager {
* @param iface Ethernet interface name * @param iface Ethernet interface name
* @hide * @hide
*/ */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public boolean isAvailable(String iface) { public boolean isAvailable(String iface) {
try { try {
return mService.isAvailable(iface); return mService.isAvailable(iface);
@@ -149,7 +150,7 @@ public class EthernetManager {
* @throws IllegalArgumentException If the listener is null. * @throws IllegalArgumentException If the listener is null.
* @hide * @hide
*/ */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public void addListener(Listener listener) { public void addListener(Listener listener) {
if (listener == null) { if (listener == null) {
throw new IllegalArgumentException("listener must not be null"); throw new IllegalArgumentException("listener must not be null");
@@ -168,7 +169,7 @@ public class EthernetManager {
* Returns an array of available Ethernet interface names. * Returns an array of available Ethernet interface names.
* @hide * @hide
*/ */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public String[] getAvailableInterfaces() { public String[] getAvailableInterfaces() {
try { try {
return mService.getAvailableInterfaces(); return mService.getAvailableInterfaces();
@@ -183,7 +184,7 @@ public class EthernetManager {
* @throws IllegalArgumentException If the listener is null. * @throws IllegalArgumentException If the listener is null.
* @hide * @hide
*/ */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public void removeListener(Listener listener) { public void removeListener(Listener listener) {
if (listener == null) { if (listener == null) {
throw new IllegalArgumentException("listener must not be null"); throw new IllegalArgumentException("listener must not be null");

View File

@@ -42,7 +42,7 @@ interface INetworkStatsService {
* PACKAGE_USAGE_STATS permission is always checked. If PACKAGE_USAGE_STATS is not granted * PACKAGE_USAGE_STATS permission is always checked. If PACKAGE_USAGE_STATS is not granted
* READ_NETWORK_USAGE_STATS is checked for. * READ_NETWORK_USAGE_STATS is checked for.
*/ */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
INetworkStatsSession openSessionForUsageStats(int flags, String callingPackage); INetworkStatsSession openSessionForUsageStats(int flags, String callingPackage);
/** Return data layer snapshot of UID network usage. */ /** Return data layer snapshot of UID network usage. */

View File

@@ -21,6 +21,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;
import android.os.SystemClock; import android.os.SystemClock;
@@ -219,11 +220,11 @@ public final class NetworkStats implements Parcelable {
* generated. * generated.
*/ */
private long elapsedRealtime; private long elapsedRealtime;
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
private int size; private int size;
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
private int capacity; private int capacity;
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
private String[] iface; private String[] iface;
@UnsupportedAppUsage @UnsupportedAppUsage
private int[] uid; private int[] uid;
@@ -231,21 +232,21 @@ public final class NetworkStats implements Parcelable {
private int[] set; private int[] set;
@UnsupportedAppUsage @UnsupportedAppUsage
private int[] tag; private int[] tag;
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
private int[] metered; private int[] metered;
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
private int[] roaming; private int[] roaming;
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
private int[] defaultNetwork; private int[] defaultNetwork;
@UnsupportedAppUsage @UnsupportedAppUsage
private long[] rxBytes; private long[] rxBytes;
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
private long[] rxPackets; private long[] rxPackets;
@UnsupportedAppUsage @UnsupportedAppUsage
private long[] txBytes; private long[] txBytes;
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
private long[] txPackets; private long[] txPackets;
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
private long[] operations; private long[] operations;
/** /**
@@ -258,7 +259,7 @@ public final class NetworkStats implements Parcelable {
@SystemApi @SystemApi
public static class Entry { public static class Entry {
/** @hide */ /** @hide */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public String iface; public String iface;
/** @hide */ /** @hide */
@UnsupportedAppUsage @UnsupportedAppUsage
@@ -267,7 +268,7 @@ public final class NetworkStats implements Parcelable {
@UnsupportedAppUsage @UnsupportedAppUsage
public int set; public int set;
/** @hide */ /** @hide */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public int tag; public int tag;
/** /**
* Note that this is only populated w/ the default value when read from /proc or written * Note that this is only populated w/ the default value when read from /proc or written
@@ -294,20 +295,20 @@ public final class NetworkStats implements Parcelable {
@UnsupportedAppUsage @UnsupportedAppUsage
public long rxBytes; public long rxBytes;
/** @hide */ /** @hide */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public long rxPackets; public long rxPackets;
/** @hide */ /** @hide */
@UnsupportedAppUsage @UnsupportedAppUsage
public long txBytes; public long txBytes;
/** @hide */ /** @hide */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public long txPackets; public long txPackets;
/** @hide */ /** @hide */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public long operations; public long operations;
/** @hide */ /** @hide */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public Entry() { public Entry() {
this(IFACE_ALL, UID_ALL, SET_DEFAULT, TAG_NONE, 0L, 0L, 0L, 0L, 0L); this(IFACE_ALL, UID_ALL, SET_DEFAULT, TAG_NONE, 0L, 0L, 0L, 0L, 0L);
} }
@@ -454,7 +455,7 @@ public final class NetworkStats implements Parcelable {
} }
/** @hide */ /** @hide */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public NetworkStats(Parcel parcel) { public NetworkStats(Parcel parcel) {
elapsedRealtime = parcel.readLong(); elapsedRealtime = parcel.readLong();
size = parcel.readInt(); size = parcel.readInt();

View File

@@ -32,6 +32,7 @@ import static android.text.format.DateUtils.SECOND_IN_MILLIS;
import static com.android.internal.util.ArrayUtils.total; import static com.android.internal.util.ArrayUtils.total;
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.service.NetworkStatsHistoryBucketProto; import android.service.NetworkStatsHistoryBucketProto;
@@ -91,18 +92,18 @@ public class NetworkStatsHistory implements Parcelable {
public static class Entry { public static class Entry {
public static final long UNKNOWN = -1; public static final long UNKNOWN = -1;
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public long bucketDuration; public long bucketDuration;
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public long bucketStart; public long bucketStart;
public long activeTime; public long activeTime;
@UnsupportedAppUsage @UnsupportedAppUsage
public long rxBytes; public long rxBytes;
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public long rxPackets; public long rxPackets;
@UnsupportedAppUsage @UnsupportedAppUsage
public long txBytes; public long txBytes;
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public long txPackets; public long txPackets;
public long operations; public long operations;
} }
@@ -134,7 +135,7 @@ public class NetworkStatsHistory implements Parcelable {
recordEntireHistory(existing); recordEntireHistory(existing);
} }
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public NetworkStatsHistory(Parcel in) { public NetworkStatsHistory(Parcel in) {
bucketDuration = in.readLong(); bucketDuration = in.readLong();
bucketStart = readLongArray(in); bucketStart = readLongArray(in);
@@ -220,7 +221,7 @@ public class NetworkStatsHistory implements Parcelable {
return 0; return 0;
} }
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public int size() { public int size() {
return bucketCount; return bucketCount;
} }
@@ -258,7 +259,7 @@ public class NetworkStatsHistory implements Parcelable {
* Return index of bucket that contains or is immediately before the * Return index of bucket that contains or is immediately before the
* requested time. * requested time.
*/ */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public int getIndexBefore(long time) { public int getIndexBefore(long time) {
int index = Arrays.binarySearch(bucketStart, 0, bucketCount, time); int index = Arrays.binarySearch(bucketStart, 0, bucketCount, time);
if (index < 0) { if (index < 0) {
@@ -286,7 +287,7 @@ public class NetworkStatsHistory implements Parcelable {
/** /**
* Return specific stats entry. * Return specific stats entry.
*/ */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public Entry getValues(int i, Entry recycle) { public Entry getValues(int i, Entry recycle) {
final Entry entry = recycle != null ? recycle : new Entry(); final Entry entry = recycle != null ? recycle : new Entry();
entry.bucketStart = bucketStart[i]; entry.bucketStart = bucketStart[i];

View File

@@ -37,6 +37,7 @@ import static android.net.wifi.WifiInfo.sanitizeSsid;
import android.annotation.NonNull; import android.annotation.NonNull;
import android.annotation.Nullable; import android.annotation.Nullable;
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.telephony.Annotation.NetworkType; import android.telephony.Annotation.NetworkType;
@@ -159,7 +160,7 @@ public class NetworkTemplate implements Parcelable {
* Template to match metered {@link ConnectivityManager#TYPE_MOBILE} networks, * Template to match metered {@link ConnectivityManager#TYPE_MOBILE} networks,
* regardless of IMSI. * regardless of IMSI.
*/ */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public static NetworkTemplate buildTemplateMobileWildcard() { public static NetworkTemplate buildTemplateMobileWildcard() {
return new NetworkTemplate(MATCH_MOBILE_WILDCARD, null, null); return new NetworkTemplate(MATCH_MOBILE_WILDCARD, null, null);
} }

View File

@@ -565,7 +565,7 @@ public class TrafficStats {
} }
/** {@hide} */ /** {@hide} */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public static long getMobileTcpRxPackets() { public static long getMobileTcpRxPackets() {
long total = 0; long total = 0;
for (String iface : getMobileIfaces()) { for (String iface : getMobileIfaces()) {
@@ -581,7 +581,7 @@ public class TrafficStats {
} }
/** {@hide} */ /** {@hide} */
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
public static long getMobileTcpTxPackets() { public static long getMobileTcpTxPackets() {
long total = 0; long total = 0;
for (String iface : getMobileIfaces()) { for (String iface : getMobileIfaces()) {

View File

@@ -25,7 +25,7 @@ import android.os.Messenger;
*/ */
interface INsdManager interface INsdManager
{ {
@UnsupportedAppUsage @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
Messenger getMessenger(); Messenger getMessenger();
void setEnabled(boolean enable); void setEnabled(boolean enable);
} }