From ac005192eaba6433b64d092ed764851de31f404e Mon Sep 17 00:00:00 2001 From: Mathew Inwood Date: Wed, 8 Aug 2018 14:44:44 +0100 Subject: [PATCH] Add @UnsupportedAppUsage annotations For packages: android.net.wimax android.net.wifi.p2p.nsd android.net.wifi.p2p android.net.wifi.hotspot2.pps android.net.wifi.hotspot2.omadm android.net.wifi.hotspot2 android.net.wifi.aware android.net.wifi android.net.util android.net.sip android.net.rtp android.net.nsd android.net.metrics android.net.lowpan android.net.http android.net.captiveportal android.net This is an automatically generated CL. See go/UnsupportedAppUsage for more details. Exempted-From-Owner-Approval: Mechanical changes to the codebase which have been approved by Android API council and announced on android-eng@ Bug: 110868826 Test: m Change-Id: I520be7a4c79e68310c12e4f55bf66acaa94145a1 --- core/java/android/net/EthernetManager.java | 9 +++++ core/java/android/net/NetworkStats.java | 36 +++++++++++++++++++ .../java/android/net/NetworkStatsHistory.java | 18 ++++++++++ core/java/android/net/NetworkTemplate.java | 11 ++++++ core/java/android/net/TrafficStats.java | 7 ++++ core/java/android/net/nsd/NsdServiceInfo.java | 2 ++ 6 files changed, 83 insertions(+) diff --git a/core/java/android/net/EthernetManager.java b/core/java/android/net/EthernetManager.java index ecccda588a..72565024d3 100644 --- a/core/java/android/net/EthernetManager.java +++ b/core/java/android/net/EthernetManager.java @@ -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"); diff --git a/core/java/android/net/NetworkStats.java b/core/java/android/net/NetworkStats.java index edf9bc1c6b..e270fc2e39 100644 --- a/core/java/android/net/NetworkStats.java +++ b/core/java/android/net/NetworkStats.java @@ -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 CREATOR = new Creator() { @Override public NetworkStats createFromParcel(Parcel in) { diff --git a/core/java/android/net/NetworkStatsHistory.java b/core/java/android/net/NetworkStatsHistory.java index a13ad659e7..d53e0326ae 100644 --- a/core/java/android/net/NetworkStatsHistory.java +++ b/core/java/android/net/NetworkStatsHistory.java @@ -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 CREATOR = new Creator() { @Override public NetworkStatsHistory createFromParcel(Parcel in) { diff --git a/core/java/android/net/NetworkTemplate.java b/core/java/android/net/NetworkTemplate.java index 74233fd990..bb75c63436 100644 --- a/core/java/android/net/NetworkTemplate.java +++ b/core/java/android/net/NetworkTemplate.java @@ -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 CREATOR = new Creator() { @Override public NetworkTemplate createFromParcel(Parcel in) { diff --git a/core/java/android/net/TrafficStats.java b/core/java/android/net/TrafficStats.java index f033268698..a463afa2e1 100644 --- a/core/java/android/net/TrafficStats.java +++ b/core/java/android/net/TrafficStats.java @@ -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( @@ -536,6 +538,7 @@ public class TrafficStats { } /** {@hide} */ + @UnsupportedAppUsage public static long getMobileTcpRxPackets() { long total = 0; for (String iface : getMobileIfaces()) { @@ -551,6 +554,7 @@ public class TrafficStats { } /** {@hide} */ + @UnsupportedAppUsage public static long getMobileTcpTxPackets() { long total = 0; for (String iface : getMobileIfaces()) { @@ -584,6 +588,7 @@ public class TrafficStats { } /** {@hide} */ + @UnsupportedAppUsage public static long getTxBytes(String iface) { try { return getStatsService().getIfaceStats(iface, TYPE_TX_BYTES); @@ -593,6 +598,7 @@ public class TrafficStats { } /** {@hide} */ + @UnsupportedAppUsage public static long getRxBytes(String iface) { try { return getStatsService().getIfaceStats(iface, TYPE_RX_BYTES); @@ -948,6 +954,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(); diff --git a/core/java/android/net/nsd/NsdServiceInfo.java b/core/java/android/net/nsd/NsdServiceInfo.java index bccaf60e69..9ba17edfb9 100644 --- a/core/java/android/net/nsd/NsdServiceInfo.java +++ b/core/java/android/net/nsd/NsdServiceInfo.java @@ -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");