Merge "Move TrafficStats tags for the network stack constants" into qt-dev
This commit is contained in:
@@ -920,6 +920,7 @@ filegroup {
|
||||
"core/java/com/android/internal/util/RingBufferIndices.java",
|
||||
"core/java/com/android/internal/util/State.java",
|
||||
"core/java/com/android/internal/util/StateMachine.java",
|
||||
"core/java/com/android/internal/util/TrafficStatsConstants.java",
|
||||
"core/java/com/android/internal/util/WakeupMessage.java",
|
||||
"core/java/android/net/shared/*.java",
|
||||
]
|
||||
|
||||
@@ -4225,9 +4225,12 @@ package android.net {
|
||||
method public static void setThreadStatsTagApp();
|
||||
method public static void setThreadStatsTagBackup();
|
||||
method public static void setThreadStatsTagRestore();
|
||||
field public static final int TAG_SYSTEM_DHCP = -192; // 0xffffff40
|
||||
field public static final int TAG_SYSTEM_DHCP_SERVER = -186; // 0xffffff46
|
||||
field public static final int TAG_SYSTEM_PROBE = -190; // 0xffffff42
|
||||
field public static final int TAG_NETWORK_STACK_IMPERSONATION_RANGE_END = -113; // 0xffffff8f
|
||||
field public static final int TAG_NETWORK_STACK_IMPERSONATION_RANGE_START = -128; // 0xffffff80
|
||||
field public static final int TAG_NETWORK_STACK_RANGE_END = -257; // 0xfffffeff
|
||||
field public static final int TAG_NETWORK_STACK_RANGE_START = -768; // 0xfffffd00
|
||||
field public static final int TAG_SYSTEM_IMPERSONATION_RANGE_END = -241; // 0xffffff0f
|
||||
field public static final int TAG_SYSTEM_IMPERSONATION_RANGE_START = -256; // 0xffffff00
|
||||
}
|
||||
|
||||
public abstract class Uri implements java.lang.Comparable<android.net.Uri> android.os.Parcelable {
|
||||
|
||||
@@ -1459,9 +1459,6 @@ package android.net {
|
||||
method public static long getLoopbackRxPackets();
|
||||
method public static long getLoopbackTxBytes();
|
||||
method public static long getLoopbackTxPackets();
|
||||
field public static final int TAG_SYSTEM_DHCP = -192; // 0xffffff40
|
||||
field public static final int TAG_SYSTEM_DHCP_SERVER = -186; // 0xffffff46
|
||||
field public static final int TAG_SYSTEM_PROBE = -190; // 0xffffff42
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ import android.annotation.UnsupportedAppUsage;
|
||||
import android.os.SystemClock;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.internal.util.TrafficStatsConstants;
|
||||
|
||||
import java.net.DatagramPacket;
|
||||
import java.net.DatagramSocket;
|
||||
import java.net.InetAddress;
|
||||
@@ -99,7 +101,8 @@ public class SntpClient {
|
||||
|
||||
public boolean requestTime(InetAddress address, int port, int timeout, Network network) {
|
||||
DatagramSocket socket = null;
|
||||
final int oldTag = TrafficStats.getAndSetThreadStatsTag(TrafficStats.TAG_SYSTEM_NTP);
|
||||
final int oldTag = TrafficStats.getAndSetThreadStatsTag(
|
||||
TrafficStatsConstants.TAG_SYSTEM_NTP);
|
||||
try {
|
||||
socket = new DatagramSocket();
|
||||
network.bindSocket(socket);
|
||||
|
||||
@@ -89,6 +89,42 @@ public class TrafficStats {
|
||||
*/
|
||||
public static final int UID_TETHERING = -5;
|
||||
|
||||
/**
|
||||
* Tag values in this range are reserved for the network stack. The network stack is
|
||||
* running as UID {@link android.os.Process.NETWORK_STACK_UID} when in the mainline
|
||||
* module separate process, and as the system UID otherwise.
|
||||
*/
|
||||
/** @hide */
|
||||
@SystemApi
|
||||
public static final int TAG_NETWORK_STACK_RANGE_START = 0xFFFFFD00;
|
||||
/** @hide */
|
||||
@SystemApi
|
||||
public static final int TAG_NETWORK_STACK_RANGE_END = 0xFFFFFEFF;
|
||||
|
||||
/**
|
||||
* Tags between 0xFFFFFF00 and 0xFFFFFFFF are reserved and used internally by system services
|
||||
* like DownloadManager when performing traffic on behalf of an application.
|
||||
*/
|
||||
// Please note there is no enforcement of these constants, so do not rely on them to
|
||||
// determine that the caller is a system caller.
|
||||
/** @hide */
|
||||
@SystemApi
|
||||
public static final int TAG_SYSTEM_IMPERSONATION_RANGE_START = 0xFFFFFF00;
|
||||
/** @hide */
|
||||
@SystemApi
|
||||
public static final int TAG_SYSTEM_IMPERSONATION_RANGE_END = 0xFFFFFF0F;
|
||||
|
||||
/**
|
||||
* Tag values between these ranges are reserved for the network stack to do traffic
|
||||
* on behalf of applications. It is a subrange of the range above.
|
||||
*/
|
||||
/** @hide */
|
||||
@SystemApi
|
||||
public static final int TAG_NETWORK_STACK_IMPERSONATION_RANGE_START = 0xFFFFFF80;
|
||||
/** @hide */
|
||||
@SystemApi
|
||||
public static final int TAG_NETWORK_STACK_IMPERSONATION_RANGE_END = 0xFFFFFF8F;
|
||||
|
||||
/**
|
||||
* Default tag value for {@link DownloadManager} traffic.
|
||||
*
|
||||
@@ -127,26 +163,9 @@ public class TrafficStats {
|
||||
*/
|
||||
public static final int TAG_SYSTEM_APP = 0xFFFFFF05;
|
||||
|
||||
// TODO : remove this constant when Wifi code is updated
|
||||
/** @hide */
|
||||
@SystemApi
|
||||
@TestApi
|
||||
public static final int TAG_SYSTEM_DHCP = 0xFFFFFF40;
|
||||
/** @hide */
|
||||
public static final int TAG_SYSTEM_NTP = 0xFFFFFF41;
|
||||
/** @hide */
|
||||
@SystemApi
|
||||
@TestApi
|
||||
public static final int TAG_SYSTEM_PROBE = 0xFFFFFF42;
|
||||
/** @hide */
|
||||
public static final int TAG_SYSTEM_NEIGHBOR = 0xFFFFFF43;
|
||||
/** @hide */
|
||||
public static final int TAG_SYSTEM_GPS = 0xFFFFFF44;
|
||||
/** @hide */
|
||||
public static final int TAG_SYSTEM_PAC = 0xFFFFFF45;
|
||||
/** @hide */
|
||||
@SystemApi
|
||||
@TestApi
|
||||
public static final int TAG_SYSTEM_DHCP_SERVER = 0xFFFFFF46;
|
||||
|
||||
private static INetworkStatsService sStatsService;
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.internal.util;
|
||||
|
||||
/**
|
||||
* Constants for traffic stats.
|
||||
* @hide
|
||||
*/
|
||||
public class TrafficStatsConstants {
|
||||
// These tags are used by the network stack to do traffic for its own purposes. Traffic
|
||||
// tagged with these will be counted toward the network stack and must stay inside the
|
||||
// range defined by
|
||||
// {@link android.net.TrafficStats#TAG_NETWORK_STACK_RANGE_START} and
|
||||
// {@link android.net.TrafficStats#TAG_NETWORK_STACK_RANGE_END}.
|
||||
public static final int TAG_SYSTEM_DHCP = 0xFFFFFE01;
|
||||
public static final int TAG_SYSTEM_NEIGHBOR = 0xFFFFFE02;
|
||||
public static final int TAG_SYSTEM_DHCP_SERVER = 0xFFFFFE03;
|
||||
|
||||
public static final int TAG_SYSTEM_NTP = 0xFFFFFF41;
|
||||
public static final int TAG_SYSTEM_GPS = 0xFFFFFF44;
|
||||
public static final int TAG_SYSTEM_PAC = 0xFFFFFF45;
|
||||
|
||||
// These tags are used by the network stack to do traffic on behalf of apps. Traffic
|
||||
// tagged with these will be counted toward the app on behalf of which the network
|
||||
// stack is doing this traffic. These values must stay inside the range defined by
|
||||
// {@link android.net.TrafficStats#TAG_NETWORK_STACK_IMPERSONATION_RANGE_START} and
|
||||
// {@link android.net.TrafficStats#TAG_NETWORK_STACK_IMPERSONATION_RANGE_END}.
|
||||
public static final int TAG_SYSTEM_PROBE = 0xFFFFFF81;
|
||||
}
|
||||
@@ -52,6 +52,7 @@ import android.widget.TextView;
|
||||
import com.android.internal.telephony.PhoneConstants;
|
||||
import com.android.internal.telephony.TelephonyIntents;
|
||||
import com.android.internal.util.ArrayUtils;
|
||||
import com.android.internal.util.TrafficStatsConstants;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
@@ -238,7 +239,8 @@ public class CaptivePortalLoginActivity extends Activity {
|
||||
if (isFinishing() || isDestroyed()) return;
|
||||
HttpURLConnection urlConnection = null;
|
||||
int httpResponseCode = 500;
|
||||
int oldTag = TrafficStats.getAndSetThreadStatsTag(TrafficStats.TAG_SYSTEM_PROBE);
|
||||
int oldTag = TrafficStats.getAndSetThreadStatsTag(
|
||||
TrafficStatsConstants.TAG_SYSTEM_PROBE);
|
||||
try {
|
||||
urlConnection = (HttpURLConnection) mNetwork.openConnection(
|
||||
new URL(mCm.getCaptivePortalServerUrl()));
|
||||
|
||||
@@ -65,6 +65,7 @@ import com.android.internal.util.HexDump;
|
||||
import com.android.internal.util.MessageUtils;
|
||||
import com.android.internal.util.State;
|
||||
import com.android.internal.util.StateMachine;
|
||||
import com.android.internal.util.TrafficStatsConstants;
|
||||
import com.android.internal.util.WakeupMessage;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
@@ -329,7 +330,8 @@ public class DhcpClient extends StateMachine {
|
||||
}
|
||||
|
||||
private boolean initUdpSocket() {
|
||||
final int oldTag = TrafficStats.getAndSetThreadStatsTag(TrafficStats.TAG_SYSTEM_DHCP);
|
||||
final int oldTag = TrafficStats.getAndSetThreadStatsTag(
|
||||
TrafficStatsConstants.TAG_SYSTEM_DHCP);
|
||||
try {
|
||||
mUdpSock = Os.socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||
SocketUtils.bindSocketToInterface(mUdpSock, mIfaceName);
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package android.net.dhcp;
|
||||
|
||||
import static android.net.TrafficStats.TAG_SYSTEM_DHCP_SERVER;
|
||||
import static android.net.dhcp.DhcpPacket.DHCP_CLIENT;
|
||||
import static android.net.dhcp.DhcpPacket.DHCP_HOST_NAME;
|
||||
import static android.net.dhcp.DhcpPacket.DHCP_SERVER;
|
||||
@@ -33,6 +32,7 @@ import static android.system.OsConstants.SOL_SOCKET;
|
||||
import static android.system.OsConstants.SO_BROADCAST;
|
||||
import static android.system.OsConstants.SO_REUSEADDR;
|
||||
|
||||
import static com.android.internal.util.TrafficStatsConstants.TAG_SYSTEM_DHCP_SERVER;
|
||||
import static com.android.server.util.NetworkStackConstants.INFINITE_LEASE;
|
||||
import static com.android.server.util.NetworkStackConstants.IPV4_ADDR_ALL;
|
||||
import static com.android.server.util.NetworkStackConstants.IPV4_ADDR_ANY;
|
||||
|
||||
@@ -98,6 +98,7 @@ import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.util.RingBufferIndices;
|
||||
import com.android.internal.util.State;
|
||||
import com.android.internal.util.StateMachine;
|
||||
import com.android.internal.util.TrafficStatsConstants;
|
||||
import com.android.networkstack.R;
|
||||
import com.android.networkstack.metrics.DataStallDetectionStats;
|
||||
import com.android.networkstack.metrics.DataStallStatsUtils;
|
||||
@@ -1478,7 +1479,8 @@ public class NetworkMonitor extends StateMachine {
|
||||
int httpResponseCode = CaptivePortalProbeResult.FAILED_CODE;
|
||||
String redirectUrl = null;
|
||||
final Stopwatch probeTimer = new Stopwatch().start();
|
||||
final int oldTag = TrafficStats.getAndSetThreadStatsTag(TrafficStats.TAG_SYSTEM_PROBE);
|
||||
final int oldTag = TrafficStats.getAndSetThreadStatsTag(
|
||||
TrafficStatsConstants.TAG_SYSTEM_PROBE);
|
||||
try {
|
||||
urlConnection = (HttpURLConnection) mNetwork.openConnection(url);
|
||||
urlConnection.setInstanceFollowRedirects(probeType == ValidationProbeEvent.PROBE_PAC);
|
||||
|
||||
@@ -33,6 +33,7 @@ import android.text.TextUtils;
|
||||
import android.util.Pair;
|
||||
|
||||
import com.android.internal.util.IndentingPrintWriter;
|
||||
import com.android.internal.util.TrafficStatsConstants;
|
||||
|
||||
import libcore.io.IoUtils;
|
||||
|
||||
@@ -381,7 +382,8 @@ public class NetworkDiagnostics {
|
||||
protected void setupSocket(
|
||||
int sockType, int protocol, long writeTimeout, long readTimeout, int dstPort)
|
||||
throws ErrnoException, IOException {
|
||||
final int oldTag = TrafficStats.getAndSetThreadStatsTag(TrafficStats.TAG_SYSTEM_PROBE);
|
||||
final int oldTag = TrafficStats.getAndSetThreadStatsTag(
|
||||
TrafficStatsConstants.TAG_SYSTEM_PROBE);
|
||||
try {
|
||||
mFileDescriptor = Os.socket(mAddressFamily, sockType, protocol);
|
||||
} finally {
|
||||
|
||||
@@ -39,6 +39,7 @@ import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.internal.annotations.GuardedBy;
|
||||
import com.android.internal.util.TrafficStatsConstants;
|
||||
import com.android.net.IProxyCallback;
|
||||
import com.android.net.IProxyPortListener;
|
||||
import com.android.net.IProxyService;
|
||||
@@ -111,7 +112,8 @@ public class PacManager {
|
||||
String file;
|
||||
final Uri pacUrl = mPacUrl;
|
||||
if (Uri.EMPTY.equals(pacUrl)) return;
|
||||
final int oldTag = TrafficStats.getAndSetThreadStatsTag(TrafficStats.TAG_SYSTEM_PAC);
|
||||
final int oldTag = TrafficStats.getAndSetThreadStatsTag(
|
||||
TrafficStatsConstants.TAG_SYSTEM_PAC);
|
||||
try {
|
||||
file = get(pacUrl);
|
||||
} catch (IOException ioe) {
|
||||
|
||||
@@ -20,6 +20,8 @@ import android.net.TrafficStats;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.internal.util.TrafficStatsConstants;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -92,7 +94,8 @@ public class GpsXtraDownloader {
|
||||
|
||||
// load balance our requests among the available servers
|
||||
while (result == null) {
|
||||
final int oldTag = TrafficStats.getAndSetThreadStatsTag(TrafficStats.TAG_SYSTEM_GPS);
|
||||
final int oldTag = TrafficStats.getAndSetThreadStatsTag(
|
||||
TrafficStatsConstants.TAG_SYSTEM_GPS);
|
||||
try {
|
||||
result = doDownload(mXtraServers[mNextServerIndex]);
|
||||
} finally {
|
||||
|
||||
@@ -36,6 +36,7 @@ import android.system.StructTimeval;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.internal.annotations.GuardedBy;
|
||||
import com.android.internal.util.TrafficStatsConstants;
|
||||
|
||||
import libcore.io.IoBridge;
|
||||
|
||||
@@ -586,7 +587,8 @@ public class RouterAdvertisementDaemon {
|
||||
private boolean createSocket() {
|
||||
final int SEND_TIMEOUT_MS = 300;
|
||||
|
||||
final int oldTag = TrafficStats.getAndSetThreadStatsTag(TrafficStats.TAG_SYSTEM_NEIGHBOR);
|
||||
final int oldTag = TrafficStats.getAndSetThreadStatsTag(
|
||||
TrafficStatsConstants.TAG_SYSTEM_NEIGHBOR);
|
||||
try {
|
||||
mSocket = Os.socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6);
|
||||
// Setting SNDTIMEO is purely for defensive purposes.
|
||||
|
||||
Reference in New Issue
Block a user