Merge "Fix testRegisterUsageCallback failure in setUp"
diff --git a/core/java/android/app/usage/NetworkStatsManager.java b/core/java/android/app/usage/NetworkStatsManager.java
index 9f46f20..59ae334 100644
--- a/core/java/android/app/usage/NetworkStatsManager.java
+++ b/core/java/android/app/usage/NetworkStatsManager.java
@@ -21,6 +21,7 @@
import android.annotation.Nullable;
import android.annotation.SystemService;
import android.annotation.TestApi;
+import android.annotation.UnsupportedAppUsage;
import android.app.usage.NetworkStats.Bucket;
import android.content.Context;
import android.net.ConnectivityManager;
@@ -121,6 +122,7 @@
/**
* {@hide}
*/
+ @UnsupportedAppUsage
public NetworkStatsManager(Context context) throws ServiceNotFoundException {
this(context, INetworkStatsService.Stub.asInterface(
ServiceManager.getServiceOrThrow(Context.NETWORK_STATS_SERVICE)));
diff --git a/core/java/android/net/EthernetManager.java b/core/java/android/net/EthernetManager.java
index ecccda5..7256502 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 @@
* @param iface Ethernet interface name
* @param isAvailable {@code true} if Ethernet port exists.
*/
+ @UnsupportedAppUsage
void onAvailabilityChanged(String iface, boolean isAvailable);
}
@@ -84,6 +86,7 @@
* 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 @@
/**
* Set Ethernet configuration.
*/
+ @UnsupportedAppUsage
public void setConfiguration(String iface, IpConfiguration config) {
try {
mService.setConfiguration(iface, config);
@@ -106,6 +110,7 @@
/**
* Indicates whether the system currently has one or more Ethernet interfaces.
*/
+ @UnsupportedAppUsage
public boolean isAvailable() {
return getAvailableInterfaces().length > 0;
}
@@ -115,6 +120,7 @@
*
* @param iface Ethernet interface name
*/
+ @UnsupportedAppUsage
public boolean isAvailable(String iface) {
try {
return mService.isAvailable(iface);
@@ -128,6 +134,7 @@
* @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 @@
/**
* Returns an array of available Ethernet interface names.
*/
+ @UnsupportedAppUsage
public String[] getAvailableInterfaces() {
try {
return mService.getAvailableInterfaces();
@@ -158,6 +166,7 @@
* @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 edf9bc1..e270fc2 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 @@
* 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 @@
* 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 @@
}
}
+ @UnsupportedAppUsage
public NetworkStats(long elapsedRealtime, int initialSize) {
this.elapsedRealtime = elapsedRealtime;
this.size = 0;
@@ -263,6 +288,7 @@
}
}
+ @UnsupportedAppUsage
public NetworkStats(Parcel parcel) {
elapsedRealtime = parcel.readLong();
size = parcel.readInt();
@@ -399,6 +425,7 @@
/**
* 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 @@
return SystemClock.elapsedRealtime() - elapsedRealtime;
}
+ @UnsupportedAppUsage
public int size() {
return size;
}
@@ -460,6 +488,7 @@
* {@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 @@
/**
* 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 @@
/**
* 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 @@
* 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 @@
/**
* 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 @@
* 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 @@
return getTotal(recycle, limitIface, UID_ALL, false);
}
+ @UnsupportedAppUsage
public Entry getTotalIncludingTags(Entry recycle) {
return getTotal(recycle, null, UID_ALL, true);
}
@@ -1085,6 +1120,7 @@
return 0;
}
+ @UnsupportedAppUsage
public static final Creator<NetworkStats> CREATOR = new Creator<NetworkStats>() {
@Override
public NetworkStats createFromParcel(Parcel in) {
diff --git a/core/java/android/net/NetworkStatsHistory.java b/core/java/android/net/NetworkStatsHistory.java
index a13ad65..d53e032 100644
--- a/core/java/android/net/NetworkStatsHistory.java
+++ b/core/java/android/net/NetworkStatsHistory.java
@@ -30,6 +30,7 @@
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 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 @@
recordEntireHistory(existing);
}
+ @UnsupportedAppUsage
public NetworkStatsHistory(Parcel in) {
bucketDuration = in.readLong();
bucketStart = readLongArray(in);
@@ -210,6 +219,7 @@
return 0;
}
+ @UnsupportedAppUsage
public int size() {
return bucketCount;
}
@@ -218,6 +228,7 @@
return bucketDuration;
}
+ @UnsupportedAppUsage
public long getStart() {
if (bucketCount > 0) {
return bucketStart[0];
@@ -226,6 +237,7 @@
}
}
+ @UnsupportedAppUsage
public long getEnd() {
if (bucketCount > 0) {
return bucketStart[bucketCount - 1] + bucketDuration;
@@ -245,6 +257,7 @@
* 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 @@
/**
* 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 @@
* 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 @@
* 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 @@
* 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 @@
return writer.toString();
}
+ @UnsupportedAppUsage
public static final Creator<NetworkStatsHistory> CREATOR = new Creator<NetworkStatsHistory>() {
@Override
public NetworkStatsHistory createFromParcel(Parcel in) {
diff --git a/core/java/android/net/NetworkTemplate.java b/core/java/android/net/NetworkTemplate.java
index 74233fd..bb75c63 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_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 @@
* 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 @@
* 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 @@
* 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 @@
* 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 @@
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 @@
}
}
+ @UnsupportedAppUsage
public int getMatchRule() {
return mMatchRule;
}
+ @UnsupportedAppUsage
public String getSubscriberId() {
return mSubscriberId;
}
@@ -460,6 +469,7 @@
* 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 @@
}
}
+ @UnsupportedAppUsage
public static final Creator<NetworkTemplate> CREATOR = new Creator<NetworkTemplate>() {
@Override
public NetworkTemplate createFromParcel(Parcel in) {
diff --git a/core/java/android/net/TrafficStats.java b/core/java/android/net/TrafficStats.java
index 40d53b7..44f7e48 100644
--- a/core/java/android/net/TrafficStats.java
+++ b/core/java/android/net/TrafficStats.java
@@ -19,6 +19,7 @@
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 @@
private static INetworkStatsService sStatsService;
+ @UnsupportedAppUsage
private synchronized static INetworkStatsService getStatsService() {
if (sStatsService == null) {
sStatsService = INetworkStatsService.Stub.asInterface(
@@ -528,6 +530,7 @@
}
/** {@hide} */
+ @UnsupportedAppUsage
public static long getMobileTcpRxPackets() {
long total = 0;
for (String iface : getMobileIfaces()) {
@@ -543,6 +546,7 @@
}
/** {@hide} */
+ @UnsupportedAppUsage
public static long getMobileTcpTxPackets() {
long total = 0;
for (String iface : getMobileIfaces()) {
@@ -576,6 +580,7 @@
}
/** {@hide} */
+ @UnsupportedAppUsage
public static long getTxBytes(String iface) {
try {
return getStatsService().getIfaceStats(iface, TYPE_TX_BYTES);
@@ -585,6 +590,7 @@
}
/** {@hide} */
+ @UnsupportedAppUsage
public static long getRxBytes(String iface) {
try {
return getStatsService().getIfaceStats(iface, TYPE_RX_BYTES);
@@ -940,6 +946,7 @@
* 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 bccaf60..9ba17ed 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 @@
}
/** @hide */
+ @UnsupportedAppUsage
public void setAttribute(String key, byte[] value) {
if (TextUtils.isEmpty(key)) {
throw new IllegalArgumentException("Key cannot be empty");