Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
Make isCaptivePortal perform both HTTP and HTTPS probes.
Browse files Browse the repository at this point in the history
Also a couple of minor cleanups and logging tweaks.

Bug: 26075613
Change-Id: I67b09e96d72764179339b616072bb2ce06aabf33
  • Loading branch information
lcolitti committed Apr 28, 2016
1 parent 7461032 commit c5be12e
Show file tree
Hide file tree
Showing 4 changed files with 227 additions and 65 deletions.
8 changes: 6 additions & 2 deletions api/system-current.txt
Expand Up @@ -26170,8 +26170,12 @@ package android.net.metrics {
method public static void logEvent(int, long, int, int);
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<android.net.metrics.ValidationProbeEvent> CREATOR;
field public static final int PROBE_HTTP = 0; // 0x0
field public static final int PROBE_HTTPS = 1; // 0x1
field public static final int DNS_FAILURE = 0; // 0x0
field public static final int DNS_SUCCESS = 1; // 0x1
field public static final int PROBE_DNS = 0; // 0x0
field public static final int PROBE_HTTP = 1; // 0x1
field public static final int PROBE_HTTPS = 2; // 0x2
field public static final int PROBE_PAC = 3; // 0x3
field public final long durationMs;
field public final int netId;
field public final int probeType;
Expand Down
16 changes: 13 additions & 3 deletions core/java/android/net/metrics/ValidationProbeEvent.java
Expand Up @@ -29,8 +29,13 @@
@SystemApi
public final class ValidationProbeEvent extends IpConnectivityEvent implements Parcelable {

public static final int PROBE_HTTP = 0;
public static final int PROBE_HTTPS = 1;
public static final int PROBE_DNS = 0;
public static final int PROBE_HTTP = 1;
public static final int PROBE_HTTPS = 2;
public static final int PROBE_PAC = 3;

public static final int DNS_FAILURE = 0;
public static final int DNS_SUCCESS = 1;

public final int netId;
public final long durationMs;
Expand Down Expand Up @@ -73,14 +78,19 @@ public ValidationProbeEvent[] newArray(int size) {
}
};

/** @hide */
public static String getProbeName(int probeType) {
return Decoder.constants.get(probeType, "PROBE_???");
}

public static void logEvent(int netId, long durationMs, int probeType, int returnCode) {
logEvent(new ValidationProbeEvent(netId, durationMs, probeType, returnCode));
}

@Override
public String toString() {
return String.format("ValidationProbeEvent(%d, %s:%d, %dms)",
netId, Decoder.constants.get(probeType), returnCode, durationMs);
netId, getProbeName(probeType), returnCode, durationMs);
}

final static class Decoder {
Expand Down
9 changes: 9 additions & 0 deletions core/java/android/provider/Settings.java
Expand Up @@ -7705,6 +7705,15 @@ public static final class Global extends NameValueTable {
*/
public static final String CAPTIVE_PORTAL_SERVER = "captive_portal_server";

/**
* Whether to use HTTPS for network validation. This is enabled by default and the setting
* needs to be set to 0 to disable it. This setting is a misnomer because captive portals
* don't actually use HTTPS, but it's consistent with the other settings.
*
* @hide
*/
public static final String CAPTIVE_PORTAL_USE_HTTPS = "captive_portal_use_https";

/**
* Whether network service discovery is enabled.
*
Expand Down

0 comments on commit c5be12e

Please sign in to comment.