Merge changes Ieef54d84,Ica3e88c2
am: 491f53523a
Change-Id: Ia60c1dd733a8de0e777dce78cde67738f6d466bd
This commit is contained in:
@@ -3270,6 +3270,7 @@ package android.net.metrics {
|
||||
public class IpConnectivityLog {
|
||||
method public boolean log(long, android.net.metrics.IpConnectivityLog.Event);
|
||||
method public boolean log(String, android.net.metrics.IpConnectivityLog.Event);
|
||||
method public boolean log(android.net.Network, int[], android.net.metrics.IpConnectivityLog.Event);
|
||||
method public boolean log(int, int[], android.net.metrics.IpConnectivityLog.Event);
|
||||
method public boolean log(android.net.metrics.IpConnectivityLog.Event);
|
||||
}
|
||||
@@ -4030,6 +4031,12 @@ package android.os {
|
||||
method public void onResult(android.os.Bundle);
|
||||
}
|
||||
|
||||
public class ServiceSpecificException extends java.lang.RuntimeException {
|
||||
ctor public ServiceSpecificException(int, String);
|
||||
ctor public ServiceSpecificException(int);
|
||||
field public final int errorCode;
|
||||
}
|
||||
|
||||
public final class StatsDimensionsValue implements android.os.Parcelable {
|
||||
method public int describeContents();
|
||||
method public boolean getBooleanValue();
|
||||
|
||||
@@ -738,6 +738,7 @@ package android.net.metrics {
|
||||
public class IpConnectivityLog {
|
||||
method public boolean log(long, android.net.metrics.IpConnectivityLog.Event);
|
||||
method public boolean log(String, android.net.metrics.IpConnectivityLog.Event);
|
||||
method public boolean log(android.net.Network, int[], android.net.metrics.IpConnectivityLog.Event);
|
||||
method public boolean log(int, int[], android.net.metrics.IpConnectivityLog.Event);
|
||||
method public boolean log(android.net.metrics.IpConnectivityLog.Event);
|
||||
}
|
||||
|
||||
@@ -1057,8 +1057,6 @@ Landroid/os/ServiceManager;->sServiceManager:Landroid/os/IServiceManager;
|
||||
Landroid/os/ServiceManagerNative;->asInterface(Landroid/os/IBinder;)Landroid/os/IServiceManager;
|
||||
Landroid/os/ServiceManagerProxy;->getService(Ljava/lang/String;)Landroid/os/IBinder;
|
||||
Landroid/os/ServiceManagerProxy;->mRemote:Landroid/os/IBinder;
|
||||
Landroid/os/ServiceSpecificException;-><init>(ILjava/lang/String;)V
|
||||
Landroid/os/ServiceSpecificException;->errorCode:I
|
||||
Landroid/os/SharedMemory;->getFd()I
|
||||
Landroid/os/ShellCommand;->peekNextArg()Ljava/lang/String;
|
||||
Landroid/os/StatFs;->mStat:Landroid/system/StructStatVfs;
|
||||
|
||||
@@ -21,6 +21,7 @@ import android.annotation.TestApi;
|
||||
import android.annotation.UnsupportedAppUsage;
|
||||
import android.net.ConnectivityMetricsEvent;
|
||||
import android.net.IIpConnectivityMetrics;
|
||||
import android.net.Network;
|
||||
import android.os.Parcelable;
|
||||
import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
@@ -126,6 +127,18 @@ public class IpConnectivityLog {
|
||||
return log(ev);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log an IpConnectivity event.
|
||||
* @param network the network associated with the event.
|
||||
* @param transports the current transports of the network associated with the event, as defined
|
||||
* in NetworkCapabilities.
|
||||
* @param data is a Parcelable instance representing the event.
|
||||
* @return true if the event was successfully logged.
|
||||
*/
|
||||
public boolean log(Network network, int[] transports, Event data) {
|
||||
return log(network.netId, transports, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log an IpConnectivity event.
|
||||
* @param netid the id of the network associated with the event.
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package android.os;
|
||||
|
||||
import android.annotation.SystemApi;
|
||||
|
||||
/**
|
||||
* An exception specific to a service.
|
||||
*
|
||||
@@ -28,6 +30,7 @@ package android.os;
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public class ServiceSpecificException extends RuntimeException {
|
||||
public final int errorCode;
|
||||
|
||||
|
||||
@@ -53,7 +53,6 @@ public class Protocol {
|
||||
public static final int BASE_WIFI_PASSPOINT_MANAGER = 0x00028000;
|
||||
public static final int BASE_WIFI_PASSPOINT_SERVICE = 0x00028100;
|
||||
public static final int BASE_WIFI_LOGGER = 0x00028300;
|
||||
public static final int BASE_DHCP = 0x00030000;
|
||||
public static final int BASE_DATA_CONNECTION = 0x00040000;
|
||||
public static final int BASE_DATA_CONNECTION_AC = 0x00041000;
|
||||
public static final int BASE_DATA_CONNECTION_TRACKER = 0x00042000;
|
||||
@@ -62,7 +61,6 @@ public class Protocol {
|
||||
public static final int BASE_NETWORK_STATE_TRACKER = 0x00070000;
|
||||
public static final int BASE_CONNECTIVITY_MANAGER = 0x00080000;
|
||||
public static final int BASE_NETWORK_AGENT = 0x00081000;
|
||||
public static final int BASE_NETWORK_MONITOR = 0x00082000;
|
||||
public static final int BASE_NETWORK_FACTORY = 0x00083000;
|
||||
public static final int BASE_ETHERNET = 0x00084000;
|
||||
public static final int BASE_LOWPAN = 0x00085000;
|
||||
|
||||
@@ -30,10 +30,10 @@ import android.annotation.Nullable;
|
||||
import android.net.IpPrefix;
|
||||
import android.net.LinkAddress;
|
||||
import android.net.NetworkUtils;
|
||||
|
||||
import com.google.android.collect.Sets;
|
||||
import android.util.ArraySet;
|
||||
|
||||
import java.net.Inet4Address;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
@@ -208,7 +208,7 @@ public class DhcpServingParams {
|
||||
* but it must always be set explicitly before building the {@link DhcpServingParams}.
|
||||
*/
|
||||
public Builder setDefaultRouters(@NonNull Inet4Address... defaultRouters) {
|
||||
return setDefaultRouters(Sets.newArraySet(defaultRouters));
|
||||
return setDefaultRouters(new ArraySet<>(Arrays.asList(defaultRouters)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -238,7 +238,7 @@ public class DhcpServingParams {
|
||||
* building the {@link DhcpServingParams}.
|
||||
*/
|
||||
public Builder setDnsServers(@NonNull Inet4Address... dnsServers) {
|
||||
return setDnsServers(Sets.newArraySet(dnsServers));
|
||||
return setDnsServers(new ArraySet<>(Arrays.asList(dnsServers)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -268,7 +268,7 @@ public class DhcpServingParams {
|
||||
* and do not need to be set here.
|
||||
*/
|
||||
public Builder setExcludedAddrs(@NonNull Inet4Address... excludedAddrs) {
|
||||
return setExcludedAddrs(Sets.newArraySet(excludedAddrs));
|
||||
return setExcludedAddrs(new ArraySet<>(Arrays.asList(excludedAddrs)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,6 +24,7 @@ import static android.net.ConnectivityManager.EXTRA_CAPTIVE_PORTAL_URL;
|
||||
import static android.net.ConnectivityManager.TYPE_MOBILE;
|
||||
import static android.net.ConnectivityManager.TYPE_WIFI;
|
||||
import static android.net.INetworkMonitor.NETWORK_TEST_RESULT_INVALID;
|
||||
import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_METERED;
|
||||
import static android.net.NetworkCapabilities.TRANSPORT_CELLULAR;
|
||||
import static android.net.NetworkCapabilities.TRANSPORT_WIFI;
|
||||
import static android.net.metrics.ValidationProbeEvent.DNS_FAILURE;
|
||||
@@ -80,7 +81,6 @@ import android.util.Log;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.util.ArrayUtils;
|
||||
import com.android.internal.util.Protocol;
|
||||
import com.android.internal.util.RingBufferIndices;
|
||||
import com.android.internal.util.State;
|
||||
import com.android.internal.util.StateMachine;
|
||||
@@ -150,29 +150,28 @@ public class NetworkMonitor extends StateMachine {
|
||||
}
|
||||
}
|
||||
|
||||
private static final int BASE = Protocol.BASE_NETWORK_MONITOR;
|
||||
/**
|
||||
* ConnectivityService has sent a notification to indicate that network has connected.
|
||||
* Initiates Network Validation.
|
||||
*/
|
||||
private static final int CMD_NETWORK_CONNECTED = BASE + 1;
|
||||
private static final int CMD_NETWORK_CONNECTED = 1;
|
||||
|
||||
/**
|
||||
* Message to self indicating it's time to evaluate a network's connectivity.
|
||||
* arg1 = Token to ignore old messages.
|
||||
*/
|
||||
private static final int CMD_REEVALUATE = BASE + 6;
|
||||
private static final int CMD_REEVALUATE = 6;
|
||||
|
||||
/**
|
||||
* ConnectivityService has sent a notification to indicate that network has disconnected.
|
||||
*/
|
||||
private static final int CMD_NETWORK_DISCONNECTED = BASE + 7;
|
||||
private static final int CMD_NETWORK_DISCONNECTED = 7;
|
||||
|
||||
/**
|
||||
* Force evaluation even if it has succeeded in the past.
|
||||
* arg1 = UID responsible for requesting this reeval. Will be billed for data.
|
||||
*/
|
||||
private static final int CMD_FORCE_REEVALUATION = BASE + 8;
|
||||
private static final int CMD_FORCE_REEVALUATION = 8;
|
||||
|
||||
/**
|
||||
* Message to self indicating captive portal app finished.
|
||||
@@ -181,7 +180,7 @@ public class NetworkMonitor extends StateMachine {
|
||||
* APP_RETURN_WANTED_AS_IS
|
||||
* obj = mCaptivePortalLoggedInResponseToken as String
|
||||
*/
|
||||
private static final int CMD_CAPTIVE_PORTAL_APP_FINISHED = BASE + 9;
|
||||
private static final int CMD_CAPTIVE_PORTAL_APP_FINISHED = 9;
|
||||
|
||||
/**
|
||||
* Message indicating sign-in app should be launched.
|
||||
@@ -190,14 +189,14 @@ public class NetworkMonitor extends StateMachine {
|
||||
* ConnectivityService when the user touches the "sign into
|
||||
* network" button in the wifi access point detail page.
|
||||
*/
|
||||
private static final int CMD_LAUNCH_CAPTIVE_PORTAL_APP = BASE + 11;
|
||||
private static final int CMD_LAUNCH_CAPTIVE_PORTAL_APP = 11;
|
||||
|
||||
/**
|
||||
* Retest network to see if captive portal is still in place.
|
||||
* arg1 = UID responsible for requesting this reeval. Will be billed for data.
|
||||
* 0 indicates self-initiated, so nobody to blame.
|
||||
*/
|
||||
private static final int CMD_CAPTIVE_PORTAL_RECHECK = BASE + 12;
|
||||
private static final int CMD_CAPTIVE_PORTAL_RECHECK = 12;
|
||||
|
||||
/**
|
||||
* ConnectivityService notifies NetworkMonitor of settings changes to
|
||||
@@ -210,20 +209,20 @@ public class NetworkMonitor extends StateMachine {
|
||||
* states, including being ignored until after an ongoing captive portal
|
||||
* validation phase is completed.
|
||||
*/
|
||||
private static final int CMD_PRIVATE_DNS_SETTINGS_CHANGED = BASE + 13;
|
||||
private static final int CMD_EVALUATE_PRIVATE_DNS = BASE + 15;
|
||||
private static final int CMD_PRIVATE_DNS_SETTINGS_CHANGED = 13;
|
||||
private static final int CMD_EVALUATE_PRIVATE_DNS = 15;
|
||||
|
||||
/**
|
||||
* Message to self indicating captive portal detection is completed.
|
||||
* obj = CaptivePortalProbeResult for detection result;
|
||||
*/
|
||||
public static final int CMD_PROBE_COMPLETE = BASE + 16;
|
||||
public static final int CMD_PROBE_COMPLETE = 16;
|
||||
|
||||
/**
|
||||
* ConnectivityService notifies NetworkMonitor of DNS query responses event.
|
||||
* arg1 = returncode in OnDnsEvent which indicates the response code for the DNS query.
|
||||
*/
|
||||
public static final int EVENT_DNS_NOTIFICATION = BASE + 17;
|
||||
public static final int EVENT_DNS_NOTIFICATION = 17;
|
||||
|
||||
// Start mReevaluateDelayMs at this value and double.
|
||||
private static final int INITIAL_REEVALUATE_DELAY_MS = 1000;
|
||||
@@ -245,7 +244,6 @@ public class NetworkMonitor extends StateMachine {
|
||||
private final INetworkMonitorCallbacks mCallback;
|
||||
private final Network mNetwork;
|
||||
private final Network mNonPrivateDnsBypassNetwork;
|
||||
private final int mNetId;
|
||||
private final TelephonyManager mTelephonyManager;
|
||||
private final WifiManager mWifiManager;
|
||||
private final ConnectivityManager mCm;
|
||||
@@ -322,7 +320,7 @@ public class NetworkMonitor extends StateMachine {
|
||||
NetworkRequest defaultRequest, IpConnectivityLog logger, SharedLog validationLogs,
|
||||
Dependencies deps) {
|
||||
// Add suffix indicating which NetworkMonitor we're talking about.
|
||||
super(TAG + "/" + network.netId);
|
||||
super(TAG + "/" + network.toString());
|
||||
|
||||
// Logs with a tag of the form given just above, e.g.
|
||||
// <timestamp> 862 2402 D NetworkMonitor/NetworkAgentInfo [WIFI () - 100]: ...
|
||||
@@ -335,7 +333,6 @@ public class NetworkMonitor extends StateMachine {
|
||||
mDependencies = deps;
|
||||
mNonPrivateDnsBypassNetwork = network;
|
||||
mNetwork = deps.getPrivateDnsBypassNetwork(network);
|
||||
mNetId = mNetwork.netId;
|
||||
mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
||||
mCm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
@@ -471,7 +468,7 @@ public class NetworkMonitor extends StateMachine {
|
||||
|
||||
@Override
|
||||
protected void log(String s) {
|
||||
if (DBG) Log.d(TAG + "/" + mNetwork.netId, s);
|
||||
if (DBG) Log.d(TAG + "/" + mNetwork.toString(), s);
|
||||
}
|
||||
|
||||
private void validationLog(int probeType, Object url, String msg) {
|
||||
@@ -795,7 +792,7 @@ public class NetworkMonitor extends StateMachine {
|
||||
CustomIntentReceiver(String action, int token, int what) {
|
||||
mToken = token;
|
||||
mWhat = what;
|
||||
mAction = action + "_" + mNetId + "_" + token;
|
||||
mAction = action + "_" + mNetwork.getNetworkHandle() + "_" + token;
|
||||
mContext.registerReceiver(this, new IntentFilter(mAction));
|
||||
}
|
||||
public PendingIntent getPendingIntent() {
|
||||
@@ -1088,11 +1085,6 @@ public class NetworkMonitor extends StateMachine {
|
||||
return mDependencies.getSetting(mContext, Settings.Global.CAPTIVE_PORTAL_USE_HTTPS, 1) == 1;
|
||||
}
|
||||
|
||||
private boolean getWifiScansAlwaysAvailableDisabled() {
|
||||
return mDependencies.getSetting(
|
||||
mContext, Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 0) == 0;
|
||||
}
|
||||
|
||||
private String getCaptivePortalServerHttpsUrl() {
|
||||
return mDependencies.getSetting(mContext,
|
||||
Settings.Global.CAPTIVE_PORTAL_HTTPS_URL, DEFAULT_HTTPS_URL);
|
||||
@@ -1484,7 +1476,7 @@ public class NetworkMonitor extends StateMachine {
|
||||
*/
|
||||
private void sendNetworkConditionsBroadcast(boolean responseReceived, boolean isCaptivePortal,
|
||||
long requestTimestampMs, long responseTimestampMs) {
|
||||
if (getWifiScansAlwaysAvailableDisabled()) {
|
||||
if (!mWifiManager.isScanAlwaysAvailable()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1568,7 +1560,7 @@ public class NetworkMonitor extends StateMachine {
|
||||
|
||||
private void logNetworkEvent(int evtype) {
|
||||
int[] transports = mNetworkCapabilities.getTransportTypes();
|
||||
mMetricsLog.log(mNetId, transports, new NetworkEvent(evtype));
|
||||
mMetricsLog.log(mNetwork, transports, new NetworkEvent(evtype));
|
||||
}
|
||||
|
||||
private int networkEventType(ValidationStage s, EvaluationResult r) {
|
||||
@@ -1590,7 +1582,8 @@ public class NetworkMonitor extends StateMachine {
|
||||
private void maybeLogEvaluationResult(int evtype) {
|
||||
if (mEvaluationTimer.isRunning()) {
|
||||
int[] transports = mNetworkCapabilities.getTransportTypes();
|
||||
mMetricsLog.log(mNetId, transports, new NetworkEvent(evtype, mEvaluationTimer.stop()));
|
||||
mMetricsLog.log(mNetwork, transports,
|
||||
new NetworkEvent(evtype, mEvaluationTimer.stop()));
|
||||
mEvaluationTimer.reset();
|
||||
}
|
||||
}
|
||||
@@ -1603,7 +1596,7 @@ public class NetworkMonitor extends StateMachine {
|
||||
.setReturnCode(probeResult)
|
||||
.setDurationMs(durationMs)
|
||||
.build();
|
||||
mMetricsLog.log(mNetId, transports, ev);
|
||||
mMetricsLog.log(mNetwork, transports, ev);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -1743,7 +1736,7 @@ public class NetworkMonitor extends StateMachine {
|
||||
boolean result = false;
|
||||
// Reevaluation will generate traffic. Thus, set a minimal reevaluation timer to limit the
|
||||
// possible traffic cost in metered network.
|
||||
if (mNetworkCapabilities.isMetered()
|
||||
if (!mNetworkCapabilities.hasCapability(NET_CAPABILITY_NOT_METERED)
|
||||
&& (SystemClock.elapsedRealtime() - getLastProbeTime()
|
||||
< mDataStallMinEvaluateTime)) {
|
||||
return false;
|
||||
|
||||
@@ -44,6 +44,7 @@ import android.content.Context;
|
||||
import android.net.DhcpResults;
|
||||
import android.net.NetworkUtils;
|
||||
import android.net.TrafficStats;
|
||||
import android.net.ip.IpClient;
|
||||
import android.net.metrics.DhcpClientEvent;
|
||||
import android.net.metrics.DhcpErrorEvent;
|
||||
import android.net.metrics.IpConnectivityLog;
|
||||
@@ -56,11 +57,9 @@ import android.system.Os;
|
||||
import android.util.EventLog;
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
import android.util.TimeUtils;
|
||||
|
||||
import com.android.internal.util.HexDump;
|
||||
import com.android.internal.util.MessageUtils;
|
||||
import com.android.internal.util.Protocol;
|
||||
import com.android.internal.util.State;
|
||||
import com.android.internal.util.StateMachine;
|
||||
import com.android.internal.util.WakeupMessage;
|
||||
@@ -118,7 +117,8 @@ public class DhcpClient extends StateMachine {
|
||||
// t=0, t=2, t=6, t=14, t=30, allowing for 10% jitter.
|
||||
private static final int DHCP_TIMEOUT_MS = 36 * SECONDS;
|
||||
|
||||
private static final int PUBLIC_BASE = Protocol.BASE_DHCP;
|
||||
// DhcpClient uses IpClient's handler.
|
||||
private static final int PUBLIC_BASE = IpClient.DHCPCLIENT_CMD_BASE;
|
||||
|
||||
/* Commands from controller to start/stop DHCP */
|
||||
public static final int CMD_START_DHCP = PUBLIC_BASE + 1;
|
||||
@@ -148,7 +148,7 @@ public class DhcpClient extends StateMachine {
|
||||
public static final int DHCP_FAILURE = 2;
|
||||
|
||||
// Internal messages.
|
||||
private static final int PRIVATE_BASE = Protocol.BASE_DHCP + 100;
|
||||
private static final int PRIVATE_BASE = IpClient.DHCPCLIENT_CMD_BASE + 100;
|
||||
private static final int CMD_KICK = PRIVATE_BASE + 1;
|
||||
private static final int CMD_RECEIVED_PACKET = PRIVATE_BASE + 2;
|
||||
private static final int CMD_TIMEOUT = PRIVATE_BASE + 3;
|
||||
@@ -544,13 +544,13 @@ public class DhcpClient extends StateMachine {
|
||||
|
||||
private String messageToString(Message message) {
|
||||
long now = SystemClock.uptimeMillis();
|
||||
StringBuilder b = new StringBuilder(" ");
|
||||
TimeUtils.formatDuration(message.getWhen() - now, b);
|
||||
b.append(" ").append(messageName(message.what))
|
||||
return new StringBuilder(" ")
|
||||
.append(message.getWhen() - now)
|
||||
.append(messageName(message.what))
|
||||
.append(" ").append(message.arg1)
|
||||
.append(" ").append(message.arg2)
|
||||
.append(" ").append(message.obj);
|
||||
return b.toString();
|
||||
.append(" ").append(message.obj)
|
||||
.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -358,6 +358,9 @@ public class IpClient extends StateMachine {
|
||||
private static final int CMD_JUMP_RUNNING_TO_STOPPING = 101;
|
||||
private static final int CMD_JUMP_STOPPING_TO_STOPPED = 102;
|
||||
|
||||
// IpClient shares a handler with DhcpClient: commands must not overlap
|
||||
public static final int DHCPCLIENT_CMD_BASE = 1000;
|
||||
|
||||
private static final int MAX_LOG_RECORDS = 500;
|
||||
private static final int MAX_PACKET_RECORDS = 100;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user