Merge "Remove captive portal sign-in actions." into lmp-dev
This commit is contained in:
@@ -17054,15 +17054,10 @@ package android.net {
|
||||
method public void unregisterDefaultNetworkActiveListener(android.net.ConnectivityManager.OnNetworkActiveListener);
|
||||
method public void unregisterNetworkCallback(android.net.ConnectivityManager.NetworkCallback);
|
||||
field public static final deprecated java.lang.String ACTION_BACKGROUND_DATA_SETTING_CHANGED = "android.net.conn.BACKGROUND_DATA_SETTING_CHANGED";
|
||||
field public static final java.lang.String ACTION_CAPTIVE_PORTAL_DETECTED = "android.net.conn.CAPTIVE_PORTAL_DETECTED";
|
||||
field public static final java.lang.String ACTION_CAPTIVE_PORTAL_SIGN_IN = "android.net.conn.CAPTIVE_PORTAL_SIGN_IN";
|
||||
field public static final int CAPTIVE_PORTAL_DISCONNECT = 2; // 0x2
|
||||
field public static final int CAPTIVE_PORTAL_SIGNED_IN = 1; // 0x1
|
||||
field public static final java.lang.String CONNECTIVITY_ACTION = "android.net.conn.CONNECTIVITY_CHANGE";
|
||||
field public static final deprecated int DEFAULT_NETWORK_PREFERENCE = 1; // 0x1
|
||||
field public static final java.lang.String EXTRA_EXTRA_INFO = "extraInfo";
|
||||
field public static final java.lang.String EXTRA_IS_FAILOVER = "isFailover";
|
||||
field public static final java.lang.String EXTRA_NETWORK = "network";
|
||||
field public static final deprecated java.lang.String EXTRA_NETWORK_INFO = "networkInfo";
|
||||
field public static final java.lang.String EXTRA_NETWORK_TYPE = "networkType";
|
||||
field public static final java.lang.String EXTRA_NO_CONNECTIVITY = "noConnectivity";
|
||||
|
||||
@@ -283,98 +283,6 @@ 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:
|
||||
* <ul>
|
||||
* <li>{@link #CAPTIVE_PORTAL_SIGNED_IN} 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).
|
||||
* </li>
|
||||
* <li>{@link #CAPTIVE_PORTAL_DISCONNECT} 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.
|
||||
* </li>
|
||||
* </ul>
|
||||
*/
|
||||
@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:
|
||||
* <ul>
|
||||
* <li>{@link #CAPTIVE_PORTAL_SIGNED_IN} 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).
|
||||
* </li>
|
||||
* <li>{@link #CAPTIVE_PORTAL_DISCONNECT} 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.
|
||||
* </li>
|
||||
* </ul>
|
||||
*/
|
||||
@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 Network} 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
|
||||
|
||||
@@ -223,9 +223,7 @@ public class NetworkMonitor extends StateMachine {
|
||||
private State mOfflineState = new OfflineState();
|
||||
private State mValidatedState = new ValidatedState();
|
||||
private State mEvaluatingState = new EvaluatingState();
|
||||
private State mUninteractiveAppsPromptedState = new UninteractiveAppsPromptedState();
|
||||
private State mUserPromptedState = new UserPromptedState();
|
||||
private State mInteractiveAppsPromptedState = new InteractiveAppsPromptedState();
|
||||
private State mCaptivePortalState = new CaptivePortalState();
|
||||
private State mLingeringState = new LingeringState();
|
||||
|
||||
@@ -243,9 +241,7 @@ public class NetworkMonitor extends StateMachine {
|
||||
addState(mOfflineState, mDefaultState);
|
||||
addState(mValidatedState, mDefaultState);
|
||||
addState(mEvaluatingState, mDefaultState);
|
||||
addState(mUninteractiveAppsPromptedState, mDefaultState);
|
||||
addState(mUserPromptedState, mDefaultState);
|
||||
addState(mInteractiveAppsPromptedState, mDefaultState);
|
||||
addState(mCaptivePortalState, mDefaultState);
|
||||
addState(mLingeringState, mDefaultState);
|
||||
setInitialState(mOfflineState);
|
||||
@@ -368,7 +364,7 @@ public class NetworkMonitor extends StateMachine {
|
||||
if (httpResponseCode == 204) {
|
||||
transitionTo(mValidatedState);
|
||||
} else if (httpResponseCode >= 200 && httpResponseCode <= 399) {
|
||||
transitionTo(mUninteractiveAppsPromptedState);
|
||||
transitionTo(mUserPromptedState);
|
||||
} else if (++mRetries > MAX_RETRIES) {
|
||||
transitionTo(mOfflineState);
|
||||
} else if (mReevaluateDelayMs >= 0) {
|
||||
@@ -382,71 +378,6 @@ public class NetworkMonitor extends StateMachine {
|
||||
}
|
||||
}
|
||||
|
||||
private class AppRespondedBroadcastReceiver extends BroadcastReceiver {
|
||||
private static final int CAPTIVE_PORTAL_UNINITIALIZED_RETURN_CODE = 0;
|
||||
private boolean mCanceled;
|
||||
AppRespondedBroadcastReceiver() {
|
||||
mCanceled = false;
|
||||
}
|
||||
public void send(String action) {
|
||||
Intent intent = new Intent(action);
|
||||
intent.putExtra(ConnectivityManager.EXTRA_NETWORK, mNetworkAgentInfo.network);
|
||||
mContext.sendOrderedBroadcastAsUser(intent, UserHandle.ALL, null, this, getHandler(),
|
||||
CAPTIVE_PORTAL_UNINITIALIZED_RETURN_CODE, null, null);
|
||||
}
|
||||
public void cancel() {
|
||||
mCanceled = true;
|
||||
}
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (!mCanceled) {
|
||||
cancel();
|
||||
switch (getResultCode()) {
|
||||
case ConnectivityManager.CAPTIVE_PORTAL_SIGNED_IN:
|
||||
sendMessage(EVENT_APP_BYPASSED_CAPTIVE_PORTAL);
|
||||
break;
|
||||
case ConnectivityManager.CAPTIVE_PORTAL_DISCONNECT:
|
||||
sendMessage(EVENT_APP_INDICATES_SIGN_IN_IMPOSSIBLE);
|
||||
break;
|
||||
// NOTE: This case label makes compiler enforce no overlap between result codes.
|
||||
case CAPTIVE_PORTAL_UNINITIALIZED_RETURN_CODE:
|
||||
default:
|
||||
sendMessage(EVENT_NO_APP_RESPONSE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class UninteractiveAppsPromptedState extends State {
|
||||
private AppRespondedBroadcastReceiver mReceiver;
|
||||
@Override
|
||||
public void enter() {
|
||||
mReceiver = new AppRespondedBroadcastReceiver();
|
||||
mReceiver.send(ConnectivityManager.ACTION_CAPTIVE_PORTAL_DETECTED);
|
||||
}
|
||||
@Override
|
||||
public boolean processMessage(Message message) {
|
||||
if (DBG) log(getName() + message.toString());
|
||||
switch (message.what) {
|
||||
case EVENT_APP_BYPASSED_CAPTIVE_PORTAL:
|
||||
transitionTo(mValidatedState);
|
||||
return HANDLED;
|
||||
case EVENT_APP_INDICATES_SIGN_IN_IMPOSSIBLE:
|
||||
transitionTo(mOfflineState);
|
||||
return HANDLED;
|
||||
case EVENT_NO_APP_RESPONSE:
|
||||
transitionTo(mUserPromptedState);
|
||||
return HANDLED;
|
||||
default:
|
||||
return NOT_HANDLED;
|
||||
}
|
||||
}
|
||||
public void exit() {
|
||||
mReceiver.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
private class UserPromptedState extends State {
|
||||
private class UserRespondedBroadcastReceiver extends BroadcastReceiver {
|
||||
private final int mToken;
|
||||
@@ -487,7 +418,7 @@ public class NetworkMonitor extends StateMachine {
|
||||
case CMD_USER_WANTS_SIGN_IN:
|
||||
if (message.arg1 != mUserPromptedToken)
|
||||
return HANDLED;
|
||||
transitionTo(mInteractiveAppsPromptedState);
|
||||
transitionTo(mCaptivePortalState);
|
||||
return HANDLED;
|
||||
default:
|
||||
return NOT_HANDLED;
|
||||
@@ -504,35 +435,6 @@ public class NetworkMonitor extends StateMachine {
|
||||
}
|
||||
}
|
||||
|
||||
private class InteractiveAppsPromptedState extends State {
|
||||
private AppRespondedBroadcastReceiver mReceiver;
|
||||
@Override
|
||||
public void enter() {
|
||||
mReceiver = new AppRespondedBroadcastReceiver();
|
||||
mReceiver.send(ConnectivityManager.ACTION_CAPTIVE_PORTAL_SIGN_IN);
|
||||
}
|
||||
@Override
|
||||
public boolean processMessage(Message message) {
|
||||
if (DBG) log(getName() + message.toString());
|
||||
switch (message.what) {
|
||||
case EVENT_APP_BYPASSED_CAPTIVE_PORTAL:
|
||||
transitionTo(mValidatedState);
|
||||
return HANDLED;
|
||||
case EVENT_APP_INDICATES_SIGN_IN_IMPOSSIBLE:
|
||||
transitionTo(mOfflineState);
|
||||
return HANDLED;
|
||||
case EVENT_NO_APP_RESPONSE:
|
||||
transitionTo(mCaptivePortalState);
|
||||
return HANDLED;
|
||||
default:
|
||||
return NOT_HANDLED;
|
||||
}
|
||||
}
|
||||
public void exit() {
|
||||
mReceiver.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
private class CaptivePortalState extends State {
|
||||
private class CaptivePortalLoggedInBroadcastReceiver extends BroadcastReceiver {
|
||||
private final int mToken;
|
||||
|
||||
Reference in New Issue
Block a user