Loading api/system-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -24219,6 +24219,7 @@ package android.net { method public android.net.Network[] getAllNetworks(); method public deprecated boolean getBackgroundDataSetting(); method public android.net.Network getBoundNetworkForProcess(); method public java.lang.String getCaptivePortalServerUrl(); method public android.net.ProxyInfo getDefaultProxy(); method public android.net.LinkProperties getLinkProperties(android.net.Network); method public android.net.NetworkCapabilities getNetworkCapabilities(android.net.Network); core/java/android/net/ConnectivityManager.java +19 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ import static com.android.internal.util.Preconditions.checkNotNull; import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; import android.annotation.SystemApi; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; Loading Loading @@ -896,6 +897,24 @@ public class ConnectivityManager { } } /** * Gets the URL that should be used for resolving whether a captive portal is present. * 1. This URL should respond with a 204 response to a GET request to indicate no captive * portal is present. * 2. This URL must be HTTP as redirect responses are used to find captive portal * sign-in pages. Captive portals cannot respond to HTTPS requests with redirects. * * @hide */ @SystemApi public String getCaptivePortalServerUrl() { try { return mService.getCaptivePortalServerUrl(); } catch (RemoteException e) { return null; } } /** * Tells the underlying networking system that the caller wants to * begin using the named feature. The interpretation of {@code feature} Loading core/java/android/net/IConnectivityManager.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -165,4 +165,6 @@ interface IConnectivityManager in IBinder binder, String srcAddr, int srcPort, String dstAddr); void stopKeepalive(in Network network, int slot); String getCaptivePortalServerUrl(); } packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java +3 −6 Original line number Diff line number Diff line Loading @@ -56,7 +56,6 @@ import java.util.Random; public class CaptivePortalLoginActivity extends Activity { private static final String TAG = "CaptivePortalLogin"; private static final String DEFAULT_SERVER = "connectivitycheck.gstatic.com"; private static final int SOCKET_TIMEOUT_MS = 10000; private enum Result { DISMISSED, UNWANTED, WANTED_AS_IS }; Loading @@ -72,16 +71,14 @@ public class CaptivePortalLoginActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); String server = Settings.Global.getString(getContentResolver(), "captive_portal_server"); if (server == null) server = DEFAULT_SERVER; mCm = ConnectivityManager.from(this); String url = getIntent().getStringExtra(ConnectivityManager.EXTRA_CAPTIVE_PORTAL_URL); if (url == null) url = mCm.getCaptivePortalServerUrl(); try { mURL = url != null ? new URL(url) : new URL("http", server, "/generate_204"); mURL = new URL(url); } catch (MalformedURLException e) { // System misconfigured, bail out in a way that at least provides network access. Log.e(TAG, "Invalid captive portal URL, server=" + server); Log.e(TAG, "Invalid captive portal URL, url=" + url); done(Result.WANTED_AS_IS); } mNetwork = getIntent().getParcelableExtra(ConnectivityManager.EXTRA_NETWORK); Loading services/core/java/com/android/server/ConnectivityService.java +5 −0 Original line number Diff line number Diff line Loading @@ -4847,6 +4847,11 @@ public class ConnectivityService extends IConnectivityManager.Stub return success; } @Override public String getCaptivePortalServerUrl() { return NetworkMonitor.getCaptivePortalServerUrl(mContext); } @Override public void startNattKeepalive(Network network, int intervalSeconds, Messenger messenger, IBinder binder, String srcAddr, int srcPort, String dstAddr) { Loading Loading
api/system-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -24219,6 +24219,7 @@ package android.net { method public android.net.Network[] getAllNetworks(); method public deprecated boolean getBackgroundDataSetting(); method public android.net.Network getBoundNetworkForProcess(); method public java.lang.String getCaptivePortalServerUrl(); method public android.net.ProxyInfo getDefaultProxy(); method public android.net.LinkProperties getLinkProperties(android.net.Network); method public android.net.NetworkCapabilities getNetworkCapabilities(android.net.Network);
core/java/android/net/ConnectivityManager.java +19 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ import static com.android.internal.util.Preconditions.checkNotNull; import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; import android.annotation.SystemApi; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; Loading Loading @@ -896,6 +897,24 @@ public class ConnectivityManager { } } /** * Gets the URL that should be used for resolving whether a captive portal is present. * 1. This URL should respond with a 204 response to a GET request to indicate no captive * portal is present. * 2. This URL must be HTTP as redirect responses are used to find captive portal * sign-in pages. Captive portals cannot respond to HTTPS requests with redirects. * * @hide */ @SystemApi public String getCaptivePortalServerUrl() { try { return mService.getCaptivePortalServerUrl(); } catch (RemoteException e) { return null; } } /** * Tells the underlying networking system that the caller wants to * begin using the named feature. The interpretation of {@code feature} Loading
core/java/android/net/IConnectivityManager.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -165,4 +165,6 @@ interface IConnectivityManager in IBinder binder, String srcAddr, int srcPort, String dstAddr); void stopKeepalive(in Network network, int slot); String getCaptivePortalServerUrl(); }
packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java +3 −6 Original line number Diff line number Diff line Loading @@ -56,7 +56,6 @@ import java.util.Random; public class CaptivePortalLoginActivity extends Activity { private static final String TAG = "CaptivePortalLogin"; private static final String DEFAULT_SERVER = "connectivitycheck.gstatic.com"; private static final int SOCKET_TIMEOUT_MS = 10000; private enum Result { DISMISSED, UNWANTED, WANTED_AS_IS }; Loading @@ -72,16 +71,14 @@ public class CaptivePortalLoginActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); String server = Settings.Global.getString(getContentResolver(), "captive_portal_server"); if (server == null) server = DEFAULT_SERVER; mCm = ConnectivityManager.from(this); String url = getIntent().getStringExtra(ConnectivityManager.EXTRA_CAPTIVE_PORTAL_URL); if (url == null) url = mCm.getCaptivePortalServerUrl(); try { mURL = url != null ? new URL(url) : new URL("http", server, "/generate_204"); mURL = new URL(url); } catch (MalformedURLException e) { // System misconfigured, bail out in a way that at least provides network access. Log.e(TAG, "Invalid captive portal URL, server=" + server); Log.e(TAG, "Invalid captive portal URL, url=" + url); done(Result.WANTED_AS_IS); } mNetwork = getIntent().getParcelableExtra(ConnectivityManager.EXTRA_NETWORK); Loading
services/core/java/com/android/server/ConnectivityService.java +5 −0 Original line number Diff line number Diff line Loading @@ -4847,6 +4847,11 @@ public class ConnectivityService extends IConnectivityManager.Stub return success; } @Override public String getCaptivePortalServerUrl() { return NetworkMonitor.getCaptivePortalServerUrl(mContext); } @Override public void startNattKeepalive(Network network, int intervalSeconds, Messenger messenger, IBinder binder, String srcAddr, int srcPort, String dstAddr) { Loading