diff options
author | Steve Kondik <steve@cyngn.com> | 2015-12-07 17:15:21 -0800 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2015-12-07 17:15:21 -0800 |
commit | b625fb6993c5f10ba8b68f824e3d344d65dae525 (patch) | |
tree | 8e0254975e39d8bd1b6f8c71d0e2b8b7238c3691 /service | |
parent | 3b56a6aba71e7d666b3f2d6c44389e1187904d73 (diff) | |
parent | 78ca9b3d6fb28abc6d52a31791f4b4084af76e65 (diff) | |
download | frameworks_opt_net_wifi-b625fb6993c5f10ba8b68f824e3d344d65dae525.tar.gz frameworks_opt_net_wifi-b625fb6993c5f10ba8b68f824e3d344d65dae525.tar.bz2 frameworks_opt_net_wifi-b625fb6993c5f10ba8b68f824e3d344d65dae525.zip |
Merge tag 'android-6.0.1_r3' of https://android.googlesource.com/platform/frameworks/opt/net/wifi into base
Android 6.0.1 release 3
Change-Id: I81ecfc8e6509fe6d76a0d5fd0bfaa3dcc11c3a08
Diffstat (limited to 'service')
6 files changed, 121 insertions, 58 deletions
diff --git a/service/java/com/android/server/wifi/WifiConfigStore.java b/service/java/com/android/server/wifi/WifiConfigStore.java index 53f11a6..a7c645b 100644 --- a/service/java/com/android/server/wifi/WifiConfigStore.java +++ b/service/java/com/android/server/wifi/WifiConfigStore.java @@ -395,8 +395,8 @@ public class WifiConfigStore extends IpConfigStore { public static final int maxNumScanCacheEntries = 128; - public final AtomicBoolean enableHalBasedPno = new AtomicBoolean(true); - public final AtomicBoolean enableSsidWhitelist = new AtomicBoolean(true); + public final AtomicBoolean enableHalBasedPno = new AtomicBoolean(false); + public final AtomicBoolean enableSsidWhitelist = new AtomicBoolean(false); public final AtomicBoolean enableAutoJoinWhenAssociated = new AtomicBoolean(true); public final AtomicBoolean enableFullBandScanWhenAssociated = new AtomicBoolean(true); public final AtomicBoolean enableChipWakeUpWhenAssociated = new AtomicBoolean(true); @@ -472,7 +472,7 @@ public class WifiConfigStore extends IpConfigStore { WifiEnterpriseConfig.CA_CERT_KEY, WifiEnterpriseConfig.SUBJECT_MATCH_KEY, WifiEnterpriseConfig.ENGINE_KEY, WifiEnterpriseConfig.ENGINE_ID_KEY, WifiEnterpriseConfig.PRIVATE_KEY_ID_KEY, WifiEnterpriseConfig.ALTSUBJECT_MATCH_KEY, - WifiEnterpriseConfig.DOM_SUFFIX_MATCH_KEY + WifiEnterpriseConfig.DOM_SUFFIX_MATCH_KEY, WifiEnterpriseConfig.PHASE1_KEY }; @@ -1043,6 +1043,8 @@ public class WifiConfigStore extends IpConfigStore { } } + mWifiNative.setHs20(config.isPasspoint()); + if (updatePriorities) mWifiNative.saveConfig(); else @@ -1811,7 +1813,7 @@ public class WifiConfigStore extends IpConfigStore { mLastPriority = 0; mConfiguredNetworks.clear(); - + List<WifiConfiguration> configTlsResetList = new ArrayList<WifiConfiguration>(); int last_id = -1; boolean done = false; while (!done) { @@ -1880,6 +1882,14 @@ public class WifiConfigStore extends IpConfigStore { if (showNetworks) log("Ignoring loaded configured for network " + config.networkId + " because config are not valid"); } + + if (config != null && config.enterpriseConfig != null && + config.enterpriseConfig.getEapMethod() < WifiEnterpriseConfig.Eap.PWD) { + if (!config.enterpriseConfig.getTls12Enable()) { + //re-enable the TLS1.2 every time when load the network + configTlsResetList.add(config); + } + } } done = (lines.length == 1); @@ -1903,6 +1913,12 @@ public class WifiConfigStore extends IpConfigStore { logContents(SUPPLICANT_CONFIG_FILE_BACKUP); logContents(networkHistoryConfigFile); } + + //reset TLS default to 1.2 + for (WifiConfiguration config : configTlsResetList) { + config.enterpriseConfig.setTls12Enable(true); + addOrUpdateNetwork(config, WifiConfiguration.UNKNOWN_UID); + } } private void logContents(String file) { diff --git a/service/java/com/android/server/wifi/WifiController.java b/service/java/com/android/server/wifi/WifiController.java index 92fc562..58e4882 100644 --- a/service/java/com/android/server/wifi/WifiController.java +++ b/service/java/com/android/server/wifi/WifiController.java @@ -652,6 +652,12 @@ class WifiController extends StateMachine { } } break; + case CMD_EMERGENCY_MODE_CHANGED: + if (msg.arg1 == 1) { + mWifiStateMachine.setHostApRunning(null, false); + transitionTo(mEcmState); + break; + } case CMD_AP_START_FAILURE: if(!mSettingsStore.isScanAlwaysAvailable()) { transitionTo(mApStaDisabledState); @@ -669,6 +675,7 @@ class WifiController extends StateMachine { @Override public void enter() { mWifiStateMachine.setSupplicantRunning(false); + mWifiStateMachine.clearANQPCache(); } @Override diff --git a/service/java/com/android/server/wifi/WifiMonitor.java b/service/java/com/android/server/wifi/WifiMonitor.java index 2b67a8d..cd324b4 100644 --- a/service/java/com/android/server/wifi/WifiMonitor.java +++ b/service/java/com/android/server/wifi/WifiMonitor.java @@ -231,6 +231,10 @@ public class WifiMonitor { private static final String BSS_REMOVED_STR = "BSS-REMOVED"; /** + * This indicate supplicant encounter RSN PMKID mismatch error + */ + private static final String RSN_PMKID_STR = "RSN: PMKID mismatch"; + /** * Regex pattern for extracting an Ethernet-style MAC address from a string. * Matches a strings like the following:<pre> * CTRL-EVENT-CONNECTED - Connection to 00:1e:58:ec:d5:6d completed (reauth) [id=1 id_str=]</pre> @@ -510,6 +514,7 @@ public class WifiMonitor { public static final int HS20_REMEDIATION_EVENT = BASE + 61; public static final int HS20_DEAUTH_EVENT = BASE + 62; + public static final int RSN_PMKID_MISMATCH_EVENT = BASE + 63; /** * This indicates a read error on the monitor socket conenction */ @@ -848,6 +853,8 @@ public class WifiMonitor { } else if (eventStr.startsWith(AUTH_EVENT_PREFIX_STR) && eventStr.endsWith(AUTH_TIMEOUT_STR)) { mStateMachine.sendMessage(AUTHENTICATION_FAILURE_EVENT); + } else if (eventStr.startsWith(RSN_PMKID_STR)) { + mStateMachine.sendMessage(RSN_PMKID_MISMATCH_EVENT); } else { if (DBG) Log.w(TAG, "couldn't identify event type - " + eventStr); } diff --git a/service/java/com/android/server/wifi/WifiNative.java b/service/java/com/android/server/wifi/WifiNative.java index b4c19fb..14af922 100644 --- a/service/java/com/android/server/wifi/WifiNative.java +++ b/service/java/com/android/server/wifi/WifiNative.java @@ -678,6 +678,14 @@ public class WifiNative { doBooleanCommand("SCAN_INTERVAL " + scanInterval); } + public void setHs20(boolean hs20) { + if (hs20) { + doBooleanCommand("SET HS20 1"); + } else { + doBooleanCommand("SET HS20 0"); + } + } + public void startTdls(String macAddr, boolean enable) { if (enable) { doBooleanCommand("TDLS_DISCOVER " + macAddr); @@ -1482,8 +1490,8 @@ public class WifiNative { int secondChanelOffset = 0; byte channelMode = 0; - byte centerFreqIndex1 = 0; - byte centerFreqIndex2 = 0; + int centerFreqIndex1 = 0; + int centerFreqIndex2 = 0; boolean is80211McRTTResponder = false; @@ -1506,8 +1514,8 @@ public class WifiNative { secondChanelOffset = bytes[inforStart + 1] & 0x3; } else if(type == EID_VHT_OPERATION) { channelMode = bytes[inforStart]; - centerFreqIndex1 = bytes[inforStart + 1]; - centerFreqIndex2 = bytes[inforStart + 2]; + centerFreqIndex1 = bytes[inforStart + 1] & 0xFF; + centerFreqIndex2 = bytes[inforStart + 2] & 0xFF; } else if (type == EID_EXTENDED_CAPS) { int tempIndex = RTT_RESP_ENABLE_BIT / 8; byte offset = RTT_RESP_ENABLE_BIT % 8; diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java index cfcecad..7b9556c 100644 --- a/service/java/com/android/server/wifi/WifiServiceImpl.java +++ b/service/java/com/android/server/wifi/WifiServiceImpl.java @@ -996,7 +996,7 @@ public final class WifiServiceImpl extends IWifiManager.Stub { long ident = Binder.clearCallingIdentity(); try { if (!canReadPeerMacAddresses && !isActiveNetworkScorer - && !isLocationEnabled()) { + && !isLocationEnabled(callingPackage)) { return new ArrayList<ScanResult>(); } if (!canReadPeerMacAddresses && !isActiveNetworkScorer @@ -1016,9 +1016,12 @@ public final class WifiServiceImpl extends IWifiManager.Stub { } } - private boolean isLocationEnabled() { - return Settings.Secure.getInt(mContext.getContentResolver(), Settings.Secure.LOCATION_MODE, - Settings.Secure.LOCATION_MODE_OFF) != Settings.Secure.LOCATION_MODE_OFF; + private boolean isLocationEnabled(String callingPackage) { + boolean legacyForegroundApp = !isMApp(mContext, callingPackage) + && isForegroundApp(callingPackage); + return legacyForegroundApp || Settings.Secure.getInt(mContext.getContentResolver(), + Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_OFF) + != Settings.Secure.LOCATION_MODE_OFF; } /** @@ -1976,7 +1979,7 @@ public final class WifiServiceImpl extends IWifiManager.Stub { return mWifiStateMachine.getEnableAutoJoinWhenAssociated(); } public void setHalBasedAutojoinOffload(int enabled) { - enforceChangePermission(); + enforceConnectivityInternalPermission(); mWifiStateMachine.setHalBasedAutojoinOffload(enabled); } @@ -2109,29 +2112,18 @@ public final class WifiServiceImpl extends IWifiManager.Stub { private boolean checkCallerCanAccessScanResults(String callingPackage, int uid) { if (ActivityManager.checkUidPermission(Manifest.permission.ACCESS_FINE_LOCATION, uid) == PackageManager.PERMISSION_GRANTED - && isAppOppAllowed(AppOpsManager.OP_FINE_LOCATION, callingPackage, uid)) { + && checkAppOppAllowed(AppOpsManager.OP_FINE_LOCATION, callingPackage, uid)) { return true; } if (ActivityManager.checkUidPermission(Manifest.permission.ACCESS_COARSE_LOCATION, uid) == PackageManager.PERMISSION_GRANTED - && isAppOppAllowed(AppOpsManager.OP_COARSE_LOCATION, callingPackage, uid)) { + && checkAppOppAllowed(AppOpsManager.OP_COARSE_LOCATION, callingPackage, uid)) { return true; } - // Enforce location permission for apps targeting M and later versions - boolean enforceLocationPermission = true; - try { - enforceLocationPermission = mContext.getPackageManager().getApplicationInfo( - callingPackage, 0).targetSdkVersion >= Build.VERSION_CODES.M; - } catch (PackageManager.NameNotFoundException e) { - // In case of exception, enforce permission anyway - } - if (enforceLocationPermission) { - throw new SecurityException("Need ACCESS_COARSE_LOCATION or " - + "ACCESS_FINE_LOCATION permission to get scan results"); - } + boolean apiLevel23App = isMApp(mContext, callingPackage); // Pre-M apps running in the foreground should continue getting scan results - if (isForegroundApp(callingPackage)) { + if (!apiLevel23App && isForegroundApp(callingPackage)) { return true; } Log.e(TAG, "Permission denial: Need ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION " @@ -2139,10 +2131,20 @@ public final class WifiServiceImpl extends IWifiManager.Stub { return false; } - private boolean isAppOppAllowed(int op, String callingPackage, int uid) { + private boolean checkAppOppAllowed(int op, String callingPackage, int uid) { return mAppOps.noteOp(op, uid, callingPackage) == AppOpsManager.MODE_ALLOWED; } + private static boolean isMApp(Context context, String pkgName) { + try { + return context.getPackageManager().getApplicationInfo(pkgName, 0) + .targetSdkVersion >= Build.VERSION_CODES.M; + } catch (PackageManager.NameNotFoundException e) { + // In case of exception, assume M app (more strict checking) + } + return true; + } + /** * Return true if the specified package name is a foreground app. * diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java index ee3cacd..66422a5 100644 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -216,6 +216,8 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno private boolean mIsWiFiIpReachabilityEnabled ; + private int mCurrentAssociateNetworkId = -1; + /* Chipset supports background scan */ private final boolean mBackgroundScanSupported; @@ -1398,7 +1400,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno PendingIntent getPrivateBroadcast(String action, int requestCode) { Intent intent = new Intent(action, null); intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); - //intent.setPackage(this.getClass().getPackage().getName()); + // TODO: Find the correct value so this is not hard coded intent.setPackage("android"); return PendingIntent.getBroadcast(mContext, requestCode, intent, 0); } @@ -1947,6 +1949,9 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno // If workSource is not null, blame is given to it, otherwise blame is given to callingUid. private void noteScanStart(int callingUid, WorkSource workSource) { + if (lastStartScanTimeStamp != 0) { + noteScanEnd(); + } long now = System.currentTimeMillis(); lastStartScanTimeStamp = now; lastScanDuration = 0; @@ -1981,6 +1986,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno } private void noteScanEnd() { + closeRadioScanStats(); long now = System.currentTimeMillis(); if (lastStartScanTimeStamp != 0) { lastScanDuration = now - lastStartScanTimeStamp; @@ -4039,8 +4045,6 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno private static final String DELIMITER_STR = "===="; private static final String END_STR = "####"; - int emptyScanResultCount = 0; - // Used for matching BSSID strings, at least one characteer must be a non-zero number private static Pattern mNotZero = Pattern.compile("[1-9a-fA-F]"); @@ -4100,23 +4104,13 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno if (sid == -1) break; } - // Age out scan results, we return all scan results found in the last 12 seconds, - // and NOT all scan results since last scan. - // ageOutScanResults(12000); - scanResults = scanResultsBuf.toString(); + if (TextUtils.isEmpty(scanResults)) { - emptyScanResultCount++; - if (emptyScanResultCount > 10) { - // If we got too many empty scan results, the current scan cache is stale, - // hence clear it. - mScanResults = new ArrayList<>(); - } + mScanResults = new ArrayList<>(); return; } - emptyScanResultCount = 0; - mWifiConfigStore.trimANQPCache(false); // note that all these splits and substrings keep references to the original @@ -4242,7 +4236,8 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno || state == SupplicantState.GROUP_HANDSHAKE || (/* keep autojoin enabled if user has manually selected a wifi network, so as to make sure we reliably remain connected to this network */ - mConnectionRequests == 0 && selection == null)) { + mConnectionRequests == 0 && selection == null) + || mInDelayedStop) { // Dont attempt auto-joining again while we are already attempting to join // and/or obtaining Ip address attemptAutoJoin = false; @@ -4291,9 +4286,9 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno * Fetch RSSI, linkspeed, and frequency on current connection */ private void fetchRssiLinkSpeedAndFrequencyNative() { - int newRssi = -1; - int newLinkSpeed = -1; - int newFrequency = -1; + Integer newRssi = null; + Integer newLinkSpeed = null; + Integer newFrequency = null; String signalPoll = mWifiNative.signalPoll(); @@ -4317,12 +4312,11 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno } if (PDBG) { - logd("fetchRssiLinkSpeedAndFrequencyNative rssi=" - + Integer.toString(newRssi) + " linkspeed=" - + Integer.toString(newLinkSpeed)); + logd("fetchRssiLinkSpeedAndFrequencyNative rssi=" + newRssi + + " linkspeed=" + newLinkSpeed + " freq=" + newFrequency); } - if (newRssi > WifiInfo.INVALID_RSSI && newRssi < WifiInfo.MAX_RSSI) { + if (newRssi != null && newRssi > WifiInfo.INVALID_RSSI && newRssi < WifiInfo.MAX_RSSI) { // screen out invalid values /* some implementations avoid negative values by adding 256 * so we need to adjust for that here. @@ -4350,10 +4344,10 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno updateCapabilities(getCurrentWifiConfiguration()); } - if (newLinkSpeed != -1) { + if (newLinkSpeed != null) { mWifiInfo.setLinkSpeed(newLinkSpeed); } - if (newFrequency > 0) { + if (newFrequency != null && newFrequency > 0) { if (ScanResult.is5GHz(newFrequency)) { mWifiConnectionStatistics.num5GhzConnected++; } @@ -6256,7 +6250,6 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno case WifiMonitor.SCAN_RESULTS_EVENT: case WifiMonitor.SCAN_FAILED_EVENT: maybeRegisterNetworkFactory(); // Make sure our NetworkFactory is registered - closeRadioScanStats(); noteScanEnd(); setScanResults(); if (mIsFullScanOngoing || mSendScanResultsBroadcast) { @@ -6639,7 +6632,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno /* send regular delayed shut down */ Intent driverStopIntent = new Intent(ACTION_DELAYED_DRIVER_STOP, null); - driverStopIntent.setPackage(mContext.getPackageName()); + driverStopIntent.setPackage("android"); driverStopIntent.putExtra(DELAYED_STOP_COUNTER, mDelayedStopCounter); mDriverStopIntent = PendingIntent.getBroadcast(mContext, DRIVER_STOP_REQUEST, driverStopIntent, @@ -6928,6 +6921,10 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno case CMD_START_SCAN: handleScanRequest(WifiNative.SCAN_WITHOUT_CONNECTION_SETUP, message); break; + case WifiMonitor.SUPPLICANT_STATE_CHANGE_EVENT: + SupplicantState state = handleSupplicantStateChange(message); + if(DBG) log("SupplicantState= " + state); + break; default: return NOT_HANDLED; } @@ -7183,6 +7180,9 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno case WifiMonitor.GAS_QUERY_START_EVENT: s = "WifiMonitor.GAS_QUERY_START_EVENT"; break; + case WifiMonitor.RSN_PMKID_MISMATCH_EVENT: + s = "WifiMonitor.RSN_PMKID_MISMATCH_EVENT"; + break; case CMD_SET_OPERATIONAL_MODE: s = "CMD_SET_OPERATIONAL_MODE"; break; @@ -7514,6 +7514,13 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno mIpReachabilityMonitor.probeAll(); } } + + if (state == SupplicantState.ASSOCIATED) { + StateChangeResult stateChangeResult = (StateChangeResult) message.obj; + if (stateChangeResult != null) { + mCurrentAssociateNetworkId = stateChangeResult.networkId; + } + } break; case WifiP2pServiceImpl.DISCONNECT_WIFI_REQUEST: if (message.arg1 == 1) { @@ -9593,9 +9600,9 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno } else { if (mScreenOn) { /** - * screen lit and => delayed timer + * screen lit and => start scan immediately */ - startDelayedScan(500, null, null); + startScan(UNKNOWN_SCAN_SOURCE, 0, null, null); } else { /** * screen dark and PNO supported => scan alarm disabled @@ -9865,6 +9872,22 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno case CMD_SCREEN_STATE_CHANGED: handleScreenStateChanged(message.arg1 != 0); break; + case WifiMonitor.RSN_PMKID_MISMATCH_EVENT: + //WAR: In release M, there is a TLS bugs for some radius. M upgrade the TLS to + // 1.2. However,some old radius can not support it. So if possibly disconnected + // due to TLS failure, we will toggler the TLS version between 1.1 and 1.2 for + // next retry connection + int nid = mCurrentAssociateNetworkId; + WifiConfiguration currentNet = mWifiConfigStore.getWifiConfiguration(nid); + if (currentNet != null && currentNet.enterpriseConfig != null) { + currentNet.enterpriseConfig.setTls12Enable( + !currentNet.enterpriseConfig.getTls12Enable()); + mWifiConfigStore.saveNetwork(currentNet, WifiConfiguration.UNKNOWN_UID); + Log.e(TAG, "NetWork ID =" + nid + " switch to TLS1.2: " + + currentNet.enterpriseConfig.getTls12Enable()); + } + + break; default: ret = NOT_HANDLED; } |