From 37c6b961f056a0686e06f70f854b9ea4824cb014 Mon Sep 17 00:00:00 2001 From: Paul Jensen Date: Mon, 19 May 2014 10:43:47 -0400 Subject: [PATCH] Add captive portal sign-in actions. Change-Id: I70a6c2efc4f3fa48d5b65e8d630682fe74abfe2c --- .../java/android/net/ConnectivityManager.java | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java index 05e179d7ca..5d66c090dc 100644 --- a/core/java/android/net/ConnectivityManager.java +++ b/core/java/android/net/ConnectivityManager.java @@ -283,6 +283,98 @@ public class ConnectivityManager { */ public static final String EXTRA_IS_CAPTIVE_PORTAL = "captivePortal"; + /** + * Broadcast Action: A connection has been established to a new network + * but a captive portal has been detected preventing internet connectivity. + * This broadcast is sent out prior to providing the user with a + * notification allowing them to sign into the network, as such it should + * only be used by apps that can automatically and silently (without user + * interaction) log into specific captive portals. It should not be used + * by apps that prompt the user to sign in, as the user has not yet + * indicated they want to proceed with signing in. + * The new network is not the default network so it can only be accessed via + * the {@link Network} extra {@link #EXTRA_NETWORK}. + * This is an ordered broadcast and so it is perfectly acceptable for + * multiple receivers to in turn consider whether they are best suited to + * address the captive portal. + * A receiver should abort the broadcast if they are sure they are the + * appropriate handler of the captive portal. If the broadcast is aborted, + * the result code must be set to one of the following: + * + */ + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String ACTION_CAPTIVE_PORTAL_DETECTED = + "android.net.conn.CAPTIVE_PORTAL_DETECTED"; + + /** + * Broadcast Action: A connection has been established to a new network, + * a captive portal has been detected preventing internet connectivity, + * the user was notified, and elected to sign into the captive portal. + * It may be used by apps that prompt the user to sign in. + * The new network is not the default network so it can only be accessed via + * the {@link Network} extra {@link #EXTRA_NETWORK}. + * This is an ordered broadcast and so it is perfectly acceptable for + * multiple receivers to in turn consider whether they are best suited to + * address the captive portal. + * A receiver should abort the broadcast if they are sure they are the + * appropriate handler of the captive portal. If the broadcast is aborted, + * the result code must be set to one of the following: + * + */ + @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) + public static final String ACTION_CAPTIVE_PORTAL_SIGN_IN = + "android.net.conn.CAPTIVE_PORTAL_SIGN_IN"; + + /** + * The lookup key for a {@link Network} object passed along with a + * {@link #ACTION_CAPTIVE_PORTAL_DETECTED} or + * {@link #ACTION_CAPTIVE_PORTAL_SIGN_IN} intent. This network is not the + * default network and must be accessed using this {@link Nework} object. + * Retrieve with {@link android.content.Intent#getParcelableExtra(String)}. + */ + public static final String EXTRA_NETWORK = "network"; + + /** + * Specified as a result code of a {@link #ACTION_CAPTIVE_PORTAL_DETECTED} or + * {@link #ACTION_CAPTIVE_PORTAL_SIGN_IN} receiver to indicate + * the receiver has signed into the + * captive portal. After being verified to provide internet + * connectivity, this network will be made the default (assuming + * it is preferred over all other active networks). + */ + public static final int CAPTIVE_PORTAL_SIGNED_IN = 1; + + /** + * Specified as a result code of a {@link #ACTION_CAPTIVE_PORTAL_DETECTED} or + * {@link #ACTION_CAPTIVE_PORTAL_SIGN_IN} receiver to indicate + * the receiver is familiar with + * this captive portal and knows sign-in is impossible or the user + * has indicated they do not want to pursue sign-in. No other apps will + * be given the option of signing in to the network. + */ + public static final int CAPTIVE_PORTAL_DISCONNECT = 2; + /** * The absence of a connection type. * @hide