@@ -92,6 +92,14 @@ public class WifiWatchdogStateMachine extends StateMachine {
9292 private static final String DEFAULT_WALLED_GARDEN_URL =
9393 "http://clients3.google.com/generate_204" ;
9494 private static final int WALLED_GARDEN_SOCKET_TIMEOUT_MS = 10000 ;
95+
96+ /* Some carrier apps might have support captive portal handling. Add some delay to allow
97+ app authentication to be done before our test.
98+ TODO: This should go away once we provide an API to apps to disable walled garden test
99+ for certain SSIDs
100+ */
101+ private static final int WALLED_GARDEN_START_DELAY_MS = 3000 ;
102+
95103 private static final int DNS_INTRATEST_PING_INTERVAL_MS = 200 ;
96104 /* With some router setups, it takes a few hunder milli-seconds before connection is active */
97105 private static final int DNS_START_DELAY_MS = 1000 ;
@@ -101,29 +109,30 @@ public class WifiWatchdogStateMachine extends StateMachine {
101109 /**
102110 * Indicates the enable setting of WWS may have changed
103111 */
104- private static final int EVENT_WATCHDOG_TOGGLED = BASE + 1 ;
112+ private static final int EVENT_WATCHDOG_TOGGLED = BASE + 1 ;
105113
106114 /**
107115 * Indicates the wifi network state has changed. Passed w/ original intent
108116 * which has a non-null networkInfo object
109117 */
110- private static final int EVENT_NETWORK_STATE_CHANGE = BASE + 2 ;
118+ private static final int EVENT_NETWORK_STATE_CHANGE = BASE + 2 ;
111119 /**
112120 * Indicates the signal has changed. Passed with arg1
113121 * {@link #mNetEventCounter} and arg2 [raw signal strength]
114122 */
115- private static final int EVENT_RSSI_CHANGE = BASE + 3 ;
116- private static final int EVENT_SCAN_RESULTS_AVAILABLE = BASE + 4 ;
117- private static final int EVENT_WIFI_RADIO_STATE_CHANGE = BASE + 5 ;
118- private static final int EVENT_WATCHDOG_SETTINGS_CHANGE = BASE + 6 ;
123+ private static final int EVENT_RSSI_CHANGE = BASE + 3 ;
124+ private static final int EVENT_SCAN_RESULTS_AVAILABLE = BASE + 4 ;
125+ private static final int EVENT_WIFI_RADIO_STATE_CHANGE = BASE + 5 ;
126+ private static final int EVENT_WATCHDOG_SETTINGS_CHANGE = BASE + 6 ;
119127
120- private static final int MESSAGE_HANDLE_WALLED_GARDEN = BASE + 100 ;
121- private static final int MESSAGE_HANDLE_BAD_AP = BASE + 101 ;
128+ private static final int MESSAGE_HANDLE_WALLED_GARDEN = BASE + 100 ;
129+ private static final int MESSAGE_HANDLE_BAD_AP = BASE + 101 ;
122130 /**
123131 * arg1 == mOnlineWatchState.checkCount
124132 */
125- private static final int MESSAGE_SINGLE_DNS_CHECK = BASE + 103 ;
126- private static final int MESSAGE_NETWORK_FOLLOWUP = BASE + 104 ;
133+ private static final int MESSAGE_SINGLE_DNS_CHECK = BASE + 102 ;
134+ private static final int MESSAGE_NETWORK_FOLLOWUP = BASE + 103 ;
135+ private static final int MESSAGE_DELAYED_WALLED_GARDEN_CHECK = BASE + 104 ;
127136
128137 private Context mContext ;
129138 private ContentResolver mContentResolver ;
@@ -140,6 +149,7 @@ public class WifiWatchdogStateMachine extends StateMachine {
140149 private DnsCheckingState mDnsCheckingState = new DnsCheckingState ();
141150 private OnlineWatchState mOnlineWatchState = new OnlineWatchState ();
142151 private DnsCheckFailureState mDnsCheckFailureState = new DnsCheckFailureState ();
152+ private DelayWalledGardenState mDelayWalledGardenState = new DelayWalledGardenState ();
143153 private WalledGardenState mWalledGardenState = new WalledGardenState ();
144154 private BlacklistedApState mBlacklistedApState = new BlacklistedApState ();
145155
@@ -209,6 +219,7 @@ private WifiWatchdogStateMachine(Context context) {
209219 addState (mConnectedState , mWatchdogEnabledState );
210220 addState (mDnsCheckingState , mConnectedState );
211221 addState (mDnsCheckFailureState , mConnectedState );
222+ addState (mDelayWalledGardenState , mConnectedState );
212223 addState (mWalledGardenState , mConnectedState );
213224 addState (mBlacklistedApState , mConnectedState );
214225 addState (mOnlineWatchState , mConnectedState );
@@ -727,14 +738,7 @@ public boolean processMessage(Message msg) {
727738 return HANDLED ;
728739 }
729740
730- mLastWalledGardenCheckTime = SystemClock .elapsedRealtime ();
731- if (isWalledGardenConnection ()) {
732- if (DBG ) log ("Walled garden test complete - walled garden detected" );
733- transitionTo (mWalledGardenState );
734- } else {
735- if (DBG ) log ("Walled garden test complete - online" );
736- transitionTo (mOnlineWatchState );
737- }
741+ transitionTo (mDelayWalledGardenState );
738742 return HANDLED ;
739743 }
740744
@@ -780,6 +784,31 @@ private boolean shouldCheckWalledGarden() {
780784 }
781785 }
782786
787+ class DelayWalledGardenState extends State {
788+ @ Override
789+ public void enter () {
790+ sendMessageDelayed (MESSAGE_DELAYED_WALLED_GARDEN_CHECK , WALLED_GARDEN_START_DELAY_MS );
791+ }
792+
793+ @ Override
794+ public boolean processMessage (Message msg ) {
795+ switch (msg .what ) {
796+ case MESSAGE_DELAYED_WALLED_GARDEN_CHECK :
797+ mLastWalledGardenCheckTime = SystemClock .elapsedRealtime ();
798+ if (isWalledGardenConnection ()) {
799+ if (DBG ) log ("Walled garden test complete - walled garden detected" );
800+ transitionTo (mWalledGardenState );
801+ } else {
802+ if (DBG ) log ("Walled garden test complete - online" );
803+ transitionTo (mOnlineWatchState );
804+ }
805+ return HANDLED ;
806+ default :
807+ return NOT_HANDLED ;
808+ }
809+ }
810+ }
811+
783812 class OnlineWatchState extends State {
784813 /**
785814 * Signals a short-wait message is enqueued for the current 'guard' counter
0 commit comments