diff options
Diffstat (limited to 'service/java/com/android/server/wifi/WifiStateMachine.java')
-rw-r--r-- | service/java/com/android/server/wifi/WifiStateMachine.java | 93 |
1 files changed, 80 insertions, 13 deletions
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java index 5d1906aca..f34d0b1e9 100644 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -663,6 +663,8 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss static final int CMD_GET_PRIVILEGED_CONFIGURED_NETWORKS = BASE + 62; /* Get Link Layer Stats thru HAL */ static final int CMD_GET_LINK_LAYER_STATS = BASE + 63; + /* Has Carrier configured networks */ + static final int CMD_HAS_CARRIER_CONFIGURED_NETWORKS = BASE + 64; /* Supplicant commands after driver start*/ /* Initiate a scan */ static final int CMD_START_SCAN = BASE + 71; @@ -1071,7 +1073,6 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss mP2pSupported = mContext.getPackageManager().hasSystemFeature( PackageManager.FEATURE_WIFI_DIRECT); - mWifiConfigManager = mFacade.makeWifiConfigManager(context, mWifiNative, facade, mWifiInjector.getClock(), userManager, mWifiInjector.getKeyStore()); @@ -2151,6 +2152,21 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss return result; } + /** + * Check if Carrier networks have been configured synchronously + * + * @param channel + * @return + */ + public boolean syncHasCarrierConfiguredNetworks( + int uuid, AsyncChannel channel) { + Message resultMsg = channel.sendMessageSynchronously( + CMD_HAS_CARRIER_CONFIGURED_NETWORKS, uuid); + boolean result = resultMsg.obj != null && (boolean) resultMsg.obj; + resultMsg.recycle(); + return result; + } + public List<WifiConfiguration> syncGetPrivilegedConfiguredNetwork(AsyncChannel channel) { Message resultMsg = channel.sendMessageSynchronously( CMD_GET_PRIVILEGED_CONFIGURED_NETWORKS); @@ -2186,6 +2202,14 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss Message resultMsg = channel.sendMessageSynchronously(CMD_GET_SUPPORTED_FEATURES); int supportedFeatureSet = resultMsg.arg1; resultMsg.recycle(); + + // Mask the feature set against system properties. + boolean disableRtt = mPropertyService.getBoolean("config.disable_rtt", false); + if (disableRtt) { + supportedFeatureSet &= + ~(WifiManager.WIFI_FEATURE_D2D_RTT | WifiManager.WIFI_FEATURE_D2AP_RTT); + } + return supportedFeatureSet; } @@ -2911,6 +2935,13 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss sb.append(Integer.toString(msg.arg2)); sb.append(" num=").append(mWifiConfigManager.getConfiguredNetworksSize()); break; + case CMD_HAS_CARRIER_CONFIGURED_NETWORKS: + sb.append(" "); + sb.append(Integer.toString(msg.arg1)); + sb.append(" "); + sb.append(Integer.toString(msg.arg2)); + sb.append(" hasCarrierNetworks=").append(mWifiConfigManager.hasCarrierNetworks()); + break; case DhcpClient.CMD_PRE_DHCP_ACTION: sb.append(" "); sb.append(Integer.toString(msg.arg1)); @@ -4196,6 +4227,9 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss case CMD_GET_CONFIGURED_NETWORKS: replyToMessage(message, message.what, (List<WifiConfiguration>) null); break; + case CMD_HAS_CARRIER_CONFIGURED_NETWORKS: + replyToMessage(message, message.what, null); + break; case CMD_GET_PRIVILEGED_CONFIGURED_NETWORKS: replyToMessage(message, message.what, (List<WifiConfiguration>) null); break; @@ -4562,7 +4596,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss switch(message.what) { case WifiMonitor.SUP_CONNECTION_EVENT: if (DBG) log("Supplicant connection established"); - setWifiState(WIFI_STATE_ENABLED); + mSupplicantRestartCount = 0; /* Reset the supplicant state to indicate the supplicant * state is not known at this time */ @@ -4627,10 +4661,6 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss class SupplicantStartedState extends State { @Override public void enter() { - /* Wifi is available as long as we have a connection to supplicant */ - mNetworkInfo.setIsAvailable(true); - if (mNetworkAgent != null) mNetworkAgent.sendNetworkInfo(mNetworkInfo); - int defaultInterval = mContext.getResources().getInteger( R.integer.config_wifi_supplicant_scan_interval); @@ -5518,18 +5548,30 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss @Override public void enter() { + // Let the system know that wifi is enabled + setWifiState(WIFI_STATE_ENABLED); + + mNetworkInfo.setIsAvailable(true); + if (mNetworkAgent != null) mNetworkAgent.sendNetworkInfo(mNetworkInfo); + + // initialize network state + setNetworkDetailedState(DetailedState.DISCONNECTED); + // Inform WifiConnectivityManager that Wifi is enabled if (mWifiConnectivityManager != null) { mWifiConnectivityManager.setWifiEnabled(true); } // Inform metrics that Wifi is Enabled (but not yet connected) mWifiMetrics.setWifiState(WifiMetricsProto.WifiLog.WIFI_DISCONNECTED); - - } @Override public void exit() { + // Let the system know that wifi is not available since we are exiting client mode. + setWifiState(WIFI_STATE_DISABLED); + mNetworkInfo.setIsAvailable(false); + if (mNetworkAgent != null) mNetworkAgent.sendNetworkInfo(mNetworkInfo); + // Inform WifiConnectivityManager that Wifi is disabled if (mWifiConnectivityManager != null) { mWifiConnectivityManager.setWifiEnabled(false); @@ -5547,6 +5589,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss String bssid; String ssid; NetworkUpdateResult result; + Set<Integer> removedNetworkIds; logStateAndMessage(message, this); switch (message.what) { @@ -5830,6 +5873,10 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss replyToMessage(message, message.what, mWifiConfigManager.getSavedNetworks()); break; + case CMD_HAS_CARRIER_CONFIGURED_NETWORKS: + replyToMessage(message, message.what, + (Boolean)mWifiConfigManager.hasCarrierNetworks()); + break; case WifiMonitor.SUP_REQUEST_IDENTITY: int networkId = message.arg2; boolean identitySent = false; @@ -5843,8 +5890,10 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss // For SIM & AKA/AKA' EAP method Only, get identity from ICC if (targetWificonfiguration != null && targetWificonfiguration.networkId == networkId - && targetWificonfiguration.allowedKeyManagement + && (targetWificonfiguration.allowedKeyManagement .get(WifiConfiguration.KeyMgmt.IEEE8021X) + || targetWificonfiguration.allowedKeyManagement + .get(WifiConfiguration.KeyMgmt.WPA_EAP)) && TelephonyUtil.isSimEapMethod(eapMethod)) { String identity = TelephonyUtil.getSimIdentity(mContext, eapMethod); if (identity != null) { @@ -5994,7 +6043,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss //Determine if this CONNECTION is for a user selection if (mWifiConfigManager.isLastSelectedConfiguration(config) && mWifiConfigManager.isCurrentUserProfile( - UserHandle.getUserId(config.lastConnectUid))) { + UserHandle.getUserId(config.lastConnectUid))) { lastConnectUid = config.lastConnectUid; mWifiMetrics.setConnectionEventRoamType( WifiMetricsProto.ConnectionEvent.ROAM_USER_SELECTED); @@ -6039,10 +6088,22 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss } break; case CMD_REMOVE_APP_CONFIGURATIONS: - mWifiConfigManager.removeNetworksForApp((ApplicationInfo) message.obj); + removedNetworkIds = + mWifiConfigManager.removeNetworksForApp((ApplicationInfo) message.obj); + if (removedNetworkIds.contains(mTargetNetworkId) || + removedNetworkIds.contains(mLastNetworkId)) { + // Disconnect and let autojoin reselect a new network. + sendMessage(CMD_DISCONNECT); + } break; case CMD_REMOVE_USER_CONFIGURATIONS: - mWifiConfigManager.removeNetworksForUser(message.arg1); + removedNetworkIds = + mWifiConfigManager.removeNetworksForUser((Integer) message.arg1); + if (removedNetworkIds.contains(mTargetNetworkId) || + removedNetworkIds.contains(mLastNetworkId)) { + // Disconnect and let autojoin reselect a new network. + sendMessage(CMD_DISCONNECT); + } break; case WifiManager.CONNECT_NETWORK: // Only the current foreground user and System UI (which runs as user 0 but acts @@ -6473,7 +6534,9 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss private void updateCapabilities(WifiConfiguration config) { NetworkCapabilities networkCapabilities = new NetworkCapabilities(mDfltNetworkCapabilities); if (config != null) { - if (config.ephemeral) { + Log.d(TAG, "updateCapabilities for config:" + config.getPrintableSsid() + config.ephemeral + + "," + config.isCarrierNetwork); + if (config.ephemeral && !config.isCarrierNetwork) { networkCapabilities.removeCapability( NetworkCapabilities.NET_CAPABILITY_TRUSTED); } else { @@ -7460,6 +7523,10 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss break; } else { config = mWifiConfigManager.getWifiConfiguration(netId); + if (config == null) { + loge("AUTO_ROAM and invalid netowrk ID, bail out..."); + break; + } } setTargetBssid(config, bssid); |