Merge "Add @UnsupportedAppUsage annotations"

am: 90660f8990

Change-Id: I8f8c9106b494caa6dc5ad405111f2a285a01e49f
This commit is contained in:
Mathew Inwood
2018-08-15 10:12:01 -07:00
committed by android-build-merger
6 changed files with 83 additions and 0 deletions

View File

@@ -17,6 +17,7 @@
package android.net;
import android.annotation.SystemService;
import android.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.os.Handler;
import android.os.Message;
@@ -66,6 +67,7 @@ public class EthernetManager {
* @param iface Ethernet interface name
* @param isAvailable {@code true} if Ethernet port exists.
*/
@UnsupportedAppUsage
void onAvailabilityChanged(String iface, boolean isAvailable);
}
@@ -84,6 +86,7 @@ public class EthernetManager {
* Get Ethernet configuration.
* @return the Ethernet Configuration, contained in {@link IpConfiguration}.
*/
@UnsupportedAppUsage
public IpConfiguration getConfiguration(String iface) {
try {
return mService.getConfiguration(iface);
@@ -95,6 +98,7 @@ public class EthernetManager {
/**
* Set Ethernet configuration.
*/
@UnsupportedAppUsage
public void setConfiguration(String iface, IpConfiguration config) {
try {
mService.setConfiguration(iface, config);
@@ -106,6 +110,7 @@ public class EthernetManager {
/**
* Indicates whether the system currently has one or more Ethernet interfaces.
*/
@UnsupportedAppUsage
public boolean isAvailable() {
return getAvailableInterfaces().length > 0;
}
@@ -115,6 +120,7 @@ public class EthernetManager {
*
* @param iface Ethernet interface name
*/
@UnsupportedAppUsage
public boolean isAvailable(String iface) {
try {
return mService.isAvailable(iface);
@@ -128,6 +134,7 @@ public class EthernetManager {
* @param listener A {@link Listener} to add.
* @throws IllegalArgumentException If the listener is null.
*/
@UnsupportedAppUsage
public void addListener(Listener listener) {
if (listener == null) {
throw new IllegalArgumentException("listener must not be null");
@@ -145,6 +152,7 @@ public class EthernetManager {
/**
* Returns an array of available Ethernet interface names.
*/
@UnsupportedAppUsage
public String[] getAvailableInterfaces() {
try {
return mService.getAvailableInterfaces();
@@ -158,6 +166,7 @@ public class EthernetManager {
* @param listener A {@link Listener} to remove.
* @throws IllegalArgumentException If the listener is null.
*/
@UnsupportedAppUsage
public void removeListener(Listener listener) {
if (listener == null) {
throw new IllegalArgumentException("listener must not be null");

View File

@@ -16,6 +16,7 @@
package android.net;
import android.annotation.UnsupportedAppUsage;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.SystemClock;
@@ -110,25 +111,43 @@ public class NetworkStats implements Parcelable {
* generated.
*/
private long elapsedRealtime;
@UnsupportedAppUsage
private int size;
@UnsupportedAppUsage
private int capacity;
@UnsupportedAppUsage
private String[] iface;
@UnsupportedAppUsage
private int[] uid;
@UnsupportedAppUsage
private int[] set;
@UnsupportedAppUsage
private int[] tag;
@UnsupportedAppUsage
private int[] metered;
@UnsupportedAppUsage
private int[] roaming;
@UnsupportedAppUsage
private int[] defaultNetwork;
@UnsupportedAppUsage
private long[] rxBytes;
@UnsupportedAppUsage
private long[] rxPackets;
@UnsupportedAppUsage
private long[] txBytes;
@UnsupportedAppUsage
private long[] txPackets;
@UnsupportedAppUsage
private long[] operations;
public static class Entry {
@UnsupportedAppUsage
public String iface;
@UnsupportedAppUsage
public int uid;
@UnsupportedAppUsage
public int set;
@UnsupportedAppUsage
public int tag;
/**
* Note that this is only populated w/ the default value when read from /proc or written
@@ -148,12 +167,17 @@ public class NetworkStats implements Parcelable {
* getSummary().
*/
public int defaultNetwork;
@UnsupportedAppUsage
public long rxBytes;
@UnsupportedAppUsage
public long rxPackets;
@UnsupportedAppUsage
public long txBytes;
@UnsupportedAppUsage
public long txPackets;
public long operations;
@UnsupportedAppUsage
public Entry() {
this(IFACE_ALL, UID_ALL, SET_DEFAULT, TAG_NONE, 0L, 0L, 0L, 0L, 0L);
}
@@ -240,6 +264,7 @@ public class NetworkStats implements Parcelable {
}
}
@UnsupportedAppUsage
public NetworkStats(long elapsedRealtime, int initialSize) {
this.elapsedRealtime = elapsedRealtime;
this.size = 0;
@@ -263,6 +288,7 @@ public class NetworkStats implements Parcelable {
}
}
@UnsupportedAppUsage
public NetworkStats(Parcel parcel) {
elapsedRealtime = parcel.readLong();
size = parcel.readInt();
@@ -399,6 +425,7 @@ public class NetworkStats implements Parcelable {
/**
* Return specific stats entry.
*/
@UnsupportedAppUsage
public Entry getValues(int i, Entry recycle) {
final Entry entry = recycle != null ? recycle : new Entry();
entry.iface = iface[i];
@@ -432,6 +459,7 @@ public class NetworkStats implements Parcelable {
return SystemClock.elapsedRealtime() - elapsedRealtime;
}
@UnsupportedAppUsage
public int size() {
return size;
}
@@ -460,6 +488,7 @@ public class NetworkStats implements Parcelable {
* {@link #findIndex(String, int, int, int, int)} is unable to find match. Can
* also be used to subtract values from existing rows.
*/
@UnsupportedAppUsage
public NetworkStats combineValues(Entry entry) {
final int i = findIndex(entry.iface, entry.uid, entry.set, entry.tag, entry.metered,
entry.roaming, entry.defaultNetwork);
@@ -479,6 +508,7 @@ public class NetworkStats implements Parcelable {
/**
* Combine all values from another {@link NetworkStats} into this object.
*/
@UnsupportedAppUsage
public void combineAllValues(NetworkStats another) {
NetworkStats.Entry entry = null;
for (int i = 0; i < another.size; i++) {
@@ -564,6 +594,7 @@ public class NetworkStats implements Parcelable {
/**
* Return list of unique UIDs known by this data structure.
*/
@UnsupportedAppUsage
public int[] getUniqueUids() {
final SparseBooleanArray uids = new SparseBooleanArray();
for (int uid : this.uid) {
@@ -582,6 +613,7 @@ public class NetworkStats implements Parcelable {
* Return total bytes represented by this snapshot object, usually used when
* checking if a {@link #subtract(NetworkStats)} delta passes a threshold.
*/
@UnsupportedAppUsage
public long getTotalBytes() {
final Entry entry = getTotal(null);
return entry.rxBytes + entry.txBytes;
@@ -590,6 +622,7 @@ public class NetworkStats implements Parcelable {
/**
* Return total of all fields represented by this snapshot object.
*/
@UnsupportedAppUsage
public Entry getTotal(Entry recycle) {
return getTotal(recycle, null, UID_ALL, false);
}
@@ -598,6 +631,7 @@ public class NetworkStats implements Parcelable {
* Return total of all fields represented by this snapshot object matching
* the requested {@link #uid}.
*/
@UnsupportedAppUsage
public Entry getTotal(Entry recycle, int limitUid) {
return getTotal(recycle, null, limitUid, false);
}
@@ -610,6 +644,7 @@ public class NetworkStats implements Parcelable {
return getTotal(recycle, limitIface, UID_ALL, false);
}
@UnsupportedAppUsage
public Entry getTotalIncludingTags(Entry recycle) {
return getTotal(recycle, null, UID_ALL, true);
}
@@ -1085,6 +1120,7 @@ public class NetworkStats implements Parcelable {
return 0;
}
@UnsupportedAppUsage
public static final Creator<NetworkStats> CREATOR = new Creator<NetworkStats>() {
@Override
public NetworkStats createFromParcel(Parcel in) {

View File

@@ -30,6 +30,7 @@ import static android.text.format.DateUtils.SECOND_IN_MILLIS;
import static com.android.internal.util.ArrayUtils.total;
import android.annotation.UnsupportedAppUsage;
import android.os.Parcel;
import android.os.Parcelable;
import android.service.NetworkStatsHistoryBucketProto;
@@ -89,16 +90,23 @@ public class NetworkStatsHistory implements Parcelable {
public static class Entry {
public static final long UNKNOWN = -1;
@UnsupportedAppUsage
public long bucketDuration;
@UnsupportedAppUsage
public long bucketStart;
public long activeTime;
@UnsupportedAppUsage
public long rxBytes;
@UnsupportedAppUsage
public long rxPackets;
@UnsupportedAppUsage
public long txBytes;
@UnsupportedAppUsage
public long txPackets;
public long operations;
}
@UnsupportedAppUsage
public NetworkStatsHistory(long bucketDuration) {
this(bucketDuration, 10, FIELD_ALL);
}
@@ -125,6 +133,7 @@ public class NetworkStatsHistory implements Parcelable {
recordEntireHistory(existing);
}
@UnsupportedAppUsage
public NetworkStatsHistory(Parcel in) {
bucketDuration = in.readLong();
bucketStart = readLongArray(in);
@@ -210,6 +219,7 @@ public class NetworkStatsHistory implements Parcelable {
return 0;
}
@UnsupportedAppUsage
public int size() {
return bucketCount;
}
@@ -218,6 +228,7 @@ public class NetworkStatsHistory implements Parcelable {
return bucketDuration;
}
@UnsupportedAppUsage
public long getStart() {
if (bucketCount > 0) {
return bucketStart[0];
@@ -226,6 +237,7 @@ public class NetworkStatsHistory implements Parcelable {
}
}
@UnsupportedAppUsage
public long getEnd() {
if (bucketCount > 0) {
return bucketStart[bucketCount - 1] + bucketDuration;
@@ -245,6 +257,7 @@ public class NetworkStatsHistory implements Parcelable {
* Return index of bucket that contains or is immediately before the
* requested time.
*/
@UnsupportedAppUsage
public int getIndexBefore(long time) {
int index = Arrays.binarySearch(bucketStart, 0, bucketCount, time);
if (index < 0) {
@@ -272,6 +285,7 @@ public class NetworkStatsHistory implements Parcelable {
/**
* Return specific stats entry.
*/
@UnsupportedAppUsage
public Entry getValues(int i, Entry recycle) {
final Entry entry = recycle != null ? recycle : new Entry();
entry.bucketStart = bucketStart[i];
@@ -373,6 +387,7 @@ public class NetworkStatsHistory implements Parcelable {
* Record an entire {@link NetworkStatsHistory} into this history. Usually
* for combining together stats for external reporting.
*/
@UnsupportedAppUsage
public void recordEntireHistory(NetworkStatsHistory input) {
recordHistory(input, Long.MIN_VALUE, Long.MAX_VALUE);
}
@@ -509,6 +524,7 @@ public class NetworkStatsHistory implements Parcelable {
* Return interpolated data usage across the requested range. Interpolates
* across buckets, so values may be rounded slightly.
*/
@UnsupportedAppUsage
public Entry getValues(long start, long end, Entry recycle) {
return getValues(start, end, Long.MAX_VALUE, recycle);
}
@@ -517,6 +533,7 @@ public class NetworkStatsHistory implements Parcelable {
* Return interpolated data usage across the requested range. Interpolates
* across buckets, so values may be rounded slightly.
*/
@UnsupportedAppUsage
public Entry getValues(long start, long end, long now, Entry recycle) {
final Entry entry = recycle != null ? recycle : new Entry();
entry.bucketDuration = end - start;
@@ -701,6 +718,7 @@ public class NetworkStatsHistory implements Parcelable {
return writer.toString();
}
@UnsupportedAppUsage
public static final Creator<NetworkStatsHistory> CREATOR = new Creator<NetworkStatsHistory>() {
@Override
public NetworkStatsHistory createFromParcel(Parcel in) {

View File

@@ -34,6 +34,7 @@ import static android.net.NetworkStats.ROAMING_NO;
import static android.net.NetworkStats.ROAMING_YES;
import static android.net.wifi.WifiInfo.removeDoubleQuotes;
import android.annotation.UnsupportedAppUsage;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.BackupUtils;
@@ -96,6 +97,7 @@ public class NetworkTemplate implements Parcelable {
* Template to match {@link ConnectivityManager#TYPE_MOBILE} networks with
* the given IMSI.
*/
@UnsupportedAppUsage
public static NetworkTemplate buildTemplateMobileAll(String subscriberId) {
return new NetworkTemplate(MATCH_MOBILE, subscriberId, null);
}
@@ -104,6 +106,7 @@ public class NetworkTemplate implements Parcelable {
* Template to match {@link ConnectivityManager#TYPE_MOBILE} networks,
* regardless of IMSI.
*/
@UnsupportedAppUsage
public static NetworkTemplate buildTemplateMobileWildcard() {
return new NetworkTemplate(MATCH_MOBILE_WILDCARD, null, null);
}
@@ -112,11 +115,13 @@ public class NetworkTemplate implements Parcelable {
* Template to match all {@link ConnectivityManager#TYPE_WIFI} networks,
* regardless of SSID.
*/
@UnsupportedAppUsage
public static NetworkTemplate buildTemplateWifiWildcard() {
return new NetworkTemplate(MATCH_WIFI_WILDCARD, null, null);
}
@Deprecated
@UnsupportedAppUsage
public static NetworkTemplate buildTemplateWifi() {
return buildTemplateWifiWildcard();
}
@@ -133,6 +138,7 @@ public class NetworkTemplate implements Parcelable {
* Template to combine all {@link ConnectivityManager#TYPE_ETHERNET} style
* networks together.
*/
@UnsupportedAppUsage
public static NetworkTemplate buildTemplateEthernet() {
return new NetworkTemplate(MATCH_ETHERNET, null, null);
}
@@ -173,6 +179,7 @@ public class NetworkTemplate implements Parcelable {
private final int mRoaming;
private final int mDefaultNetwork;
@UnsupportedAppUsage
public NetworkTemplate(int matchRule, String subscriberId, String networkId) {
this(matchRule, subscriberId, new String[] { subscriberId }, networkId);
}
@@ -293,10 +300,12 @@ public class NetworkTemplate implements Parcelable {
}
}
@UnsupportedAppUsage
public int getMatchRule() {
return mMatchRule;
}
@UnsupportedAppUsage
public String getSubscriberId() {
return mSubscriberId;
}
@@ -460,6 +469,7 @@ public class NetworkTemplate implements Parcelable {
* active merge set [A,B], we'd return a new template that primarily matches
* A, but also matches B.
*/
@UnsupportedAppUsage
public static NetworkTemplate normalize(NetworkTemplate template, String[] merged) {
if (template.isMatchRuleMobile() && ArrayUtils.contains(merged, template.mSubscriberId)) {
// Requested template subscriber is part of the merge group; return
@@ -471,6 +481,7 @@ public class NetworkTemplate implements Parcelable {
}
}
@UnsupportedAppUsage
public static final Creator<NetworkTemplate> CREATOR = new Creator<NetworkTemplate>() {
@Override
public NetworkTemplate createFromParcel(Parcel in) {

View File

@@ -19,6 +19,7 @@ package android.net;
import android.annotation.SuppressLint;
import android.annotation.SystemApi;
import android.annotation.TestApi;
import android.annotation.UnsupportedAppUsage;
import android.app.DownloadManager;
import android.app.backup.BackupManager;
import android.app.usage.NetworkStatsManager;
@@ -141,6 +142,7 @@ public class TrafficStats {
private static INetworkStatsService sStatsService;
@UnsupportedAppUsage
private synchronized static INetworkStatsService getStatsService() {
if (sStatsService == null) {
sStatsService = INetworkStatsService.Stub.asInterface(
@@ -528,6 +530,7 @@ public class TrafficStats {
}
/** {@hide} */
@UnsupportedAppUsage
public static long getMobileTcpRxPackets() {
long total = 0;
for (String iface : getMobileIfaces()) {
@@ -543,6 +546,7 @@ public class TrafficStats {
}
/** {@hide} */
@UnsupportedAppUsage
public static long getMobileTcpTxPackets() {
long total = 0;
for (String iface : getMobileIfaces()) {
@@ -576,6 +580,7 @@ public class TrafficStats {
}
/** {@hide} */
@UnsupportedAppUsage
public static long getTxBytes(String iface) {
try {
return getStatsService().getIfaceStats(iface, TYPE_TX_BYTES);
@@ -585,6 +590,7 @@ public class TrafficStats {
}
/** {@hide} */
@UnsupportedAppUsage
public static long getRxBytes(String iface) {
try {
return getStatsService().getIfaceStats(iface, TYPE_RX_BYTES);
@@ -940,6 +946,7 @@ public class TrafficStats {
* Interfaces are never removed from this list, so counters should always be
* monotonic.
*/
@UnsupportedAppUsage
private static String[] getMobileIfaces() {
try {
return getStatsService().getMobileIfaces();

View File

@@ -17,6 +17,7 @@
package android.net.nsd;
import android.annotation.NonNull;
import android.annotation.UnsupportedAppUsage;
import android.os.Parcelable;
import android.os.Parcel;
import android.text.TextUtils;
@@ -185,6 +186,7 @@ public final class NsdServiceInfo implements Parcelable {
}
/** @hide */
@UnsupportedAppUsage
public void setAttribute(String key, byte[] value) {
if (TextUtils.isEmpty(key)) {
throw new IllegalArgumentException("Key cannot be empty");