[高通SDM450][Android9.0]设备默认支持连接WPA3-SAE加密协议的WIFI

news/2024/11/29 13:40:25/

文章目录

    • 开发平台基本信息
    • 问题描述
    • 问题分析
    • 解决方法

开发平台基本信息

芯片: SDM450
版本: Android 9.0
kernel: msm-4.9

问题描述

前段时间,有个医院的客户反馈我们的设备无法连接上他们医院路由器的WIFI,并且设备显示wifi已保存,但就是连接不上。而且,连接手机的热点却是能正常连接并且能够上网的。

问题分析

  1. 首先,基本可以排除硬件问题,因为能够连接手机热点并且能够上网;
  2. 其次,因为显示已保存,所以猜想会不会是WIFI的状态是保存了,但是,实际上WIFI的密码等参数没有写到本地文件,但是,客户忘记WIFI密码、恢复出厂设置,也都无法连接。
  3. 硬件跟软件操作流程都没问题,那就只能对比WIFI的差异性了,让客户把机器的WIFI信息保存的文件导出来,对比一下路由WIFI跟热点有什么区别。

注:WIFI信息保存的路径:/data/misc/wifi/WifiConfigStore.xml

在这里插入图片描述

从上图,可以看出来热点的加密方式是WPA_PSK;而路由器WIFI的加密方式是SAE;所以,猜想是不是我们的设备不支持SAE加密方式WIFI。果然,移植相关补丁之后,客户反馈能够正常连接他们的WIFI了,下面给出具体的补丁。

解决方法

路径:frameworks/base/diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 5bbfcee..c9655a5 100755
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -673,6 +673,8 @@<!-- Wifi driver supports IEEE80211AC for softap --><bool translatable="false" name="config_wifi_softap_ieee80211ac_supported">false</bool>+    <bool translatable="false" name="config_wifi_wpa3_supported">false</bool>
+<!-- Flag indicating whether we should enable the automatic brightness.Software implementation will be used if config_hardware_auto_brightness_available is not set --><bool name="config_automatic_brightness_available">false</bool>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 4a40131..6aa7750 100755
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -319,6 +319,7 @@<java-symbol type="bool" name="config_wifi_batched_scan_supported" /><java-symbol type="bool" name="config_wifi_softap_acs_supported" /><java-symbol type="bool" name="config_wifi_softap_ieee80211ac_supported" />
+  <java-symbol type="bool" name="config_wifi_wpa3_supported" /><java-symbol type="bool" name="config_enableMultiUserUI"/><java-symbol type="bool" name="config_enableNewAutoSelectNetworkUI"/><java-symbol type="bool" name="config_disableUsbPermissionDialogs"/>
diff --git a/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java b/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java
index 2e85014..2126719 100644
--- a/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java
+++ b/packages/SettingsLib/src/com/android/settingslib/wifi/AccessPoint.java
@@ -140,6 +140,7 @@ public class AccessPoint implements Comparable<AccessPoint> {*/private final Map<String, TimestampedScoredNetwork> mScoredNetworkCache = new HashMap<>();+    private boolean apSupportsSaeAndPsk;static final String KEY_NETWORKINFO = "key_networkinfo";static final String KEY_WIFIINFO = "key_wifiinfo";static final String KEY_SSID = "key_ssid";
@@ -313,6 +314,15 @@ public class AccessPoint implements Comparable<AccessPoint> {ssid = firstResult.SSID;bssid = firstResult.BSSID;security = getSecurity(firstResult);
+        apSupportsSaeAndPsk = checkForSaeAndPsk(firstResult);
+        if (apSupportsSaeAndPsk) {
+            boolean wpa3Support = mContext.getResources().getBoolean(
+                    com.android.internal.R.bool.config_wifi_wpa3_supported);
+            Log.e(TAG, "wpa3Support: " + wpa3Support);
+            if (!wpa3Support)
+                security = SECURITY_PSK;
+        }
+if (security == SECURITY_PSK) {pskType = getPskType(firstResult);}
@@ -624,7 +634,8 @@ public class AccessPoint implements Comparable<AccessPoint> {return ssid.equals(removeDoubleQuotes(config.SSID)) && config.FQDN.equals(mConfig.FQDN);} else {return ssid.equals(removeDoubleQuotes(config.SSID))
-                    && security == getSecurity(config)
+                && (security == getSecurity(config)
+                        || (apSupportsSaeAndPsk && (getSecurity(config) == SECURITY_PSK)))&& (mConfig == null || mConfig.shared == config.shared);}}
@@ -1387,6 +1398,15 @@ public class AccessPoint implements Comparable<AccessPoint> {return SECURITY_NONE;}+    private static boolean checkForSaeAndPsk(ScanResult result) {
+        if (result.capabilities.contains("SAE")
+                && result.capabilities.contains("PSK"))
+            return true;
+        else
+            return false;
+    }
+
+static int getSecurity(WifiConfiguration config) {if (config.allowedKeyManagement.get(KeyMgmt.WPA_PSK)) {return SECURITY_PSK;
diff --git a/packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java b/packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java
index 0270796..21d3e7c 100644
--- a/packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java
+++ b/packages/SettingsLib/src/com/android/settingslib/wifi/WifiTracker.java
@@ -150,7 +150,14 @@ public class WifiTracker implements LifecycleObserver, OnStart, OnStop, OnDestroprivate WifiNetworkScoreCache mScoreCache;private boolean mNetworkScoringUiEnabled;private long mMaxSpeedLabelScoreCacheAge;
+    private boolean mWpa3Support;+    private static final String WIFI_SECURITY_PSK = "PSK";
+    private static final String WIFI_SECURITY_EAP = "EAP";
+    private static final String WIFI_SECURITY_SAE = "SAE";
+    private static final String WIFI_SECURITY_OWE = "OWE";
+    private static final String WIFI_SECURITY_DPP = "DPP";
+    private static final String WIFI_SECURITY_SUITE_B_192 = "SUITE_B_192";@VisibleForTesting
@@ -217,6 +224,8 @@ public class WifiTracker implements LifecycleObserver, OnStart, OnStop, OnDestro.build();mNetworkScoreManager = networkScoreManager;
+        mWpa3Support = mContext.getResources().getBoolean(
+                com.android.internal.R.bool.config_wifi_wpa3_supported);// TODO(sghuman): Remove this and create less hacky solution for testingfinal HandlerThread workThread = new HandlerThread(TAG
@@ -500,17 +509,63 @@ public class WifiTracker implements LifecycleObserver, OnStart, OnStop, OnDestro}/**
+     * Filters unsupported networks from scan results. New WPA3 networks
+     * may not be compatible with the device HW/SW.
+     * @param scanResults List of scan results
+     * @return List of filtered scan results based on local device capabilities+     */
+    private List<ScanResult> filterScanResultsByCapabilities(List<ScanResult> scanResults) {
+        if (scanResults == null) {
+            return null;
+        }
+
+        List<ScanResult> filteredScanResultList = new ArrayList<>();
+
+        // Iterate through the list of scan results and filter out APs which are not
+        // compatible with our device.
+        for (ScanResult scanResult : scanResults) {
+            if (scanResult.capabilities.contains(WIFI_SECURITY_PSK)) {
+                // All devices (today) support RSN-PSK or WPA-PSK
+                // Add this here because some APs may support both PSK and SAE and the check
+                // below will filter it out.
+                filteredScanResultList.add(scanResult);
+                continue;
+            }
+
+            if (!mWpa3Support
+                    && (scanResult.capabilities.contains(WIFI_SECURITY_SUITE_B_192)
+                        || scanResult.capabilities.contains(WIFI_SECURITY_SAE)
+                        || scanResult.capabilities.contains(WIFI_SECURITY_OWE)
+                        || scanResult.capabilities.contains(WIFI_SECURITY_DPP))) {
+                if (isVerboseLoggingEnabled()) {
+                    Log.v(TAG, "filterScanResultsByCapabilities: Filtering SSID "
+                            + scanResult.SSID + " with capabilities: " + scanResult.capabilities);
+                }
+            } else {
+                // Safe to add
+                filteredScanResultList.add(scanResult);
+            }
+        }
+
+        return filteredScanResultList;
+    }
+
+    /*** Retrieves latest scan results and wifi configs, then calls* {@link #updateAccessPoints(List, List)}.*/private void fetchScansAndConfigsAndUpdateAccessPoints() {
-        final List<ScanResult> newScanResults = mWifiManager.getScanResults();
+        List<ScanResult> newScanResults = mWifiManager.getScanResults();
+
+        // Filter all unsupported networks from the scan result list
+        final List<ScanResult> filteredScanResults =
+            filterScanResultsByCapabilities(newScanResults);
+if (isVerboseLoggingEnabled()) {
-            Log.i(TAG, "Fetched scan results: " + newScanResults);
+            Log.i(TAG, "Fetched scan results: " + filteredScanResults);}List<WifiConfiguration> configs = mWifiManager.getConfiguredNetworks();
-        updateAccessPoints(newScanResults, configs);
+        updateAccessPoints(filteredScanResults, configs);}/** Update the internal list of access points. */
路径:frameworks/opt/net/wifi/diff --git a/service/java/com/android/server/wifi/WifiMetrics.java b/service/java/com/android/server/wifi/WifiMetrics.java
index a3bd169..a33e0eb 100644
--- a/service/java/com/android/server/wifi/WifiMetrics.java
+++ b/service/java/com/android/server/wifi/WifiMetrics.java
@@ -1616,7 +1616,16 @@ public class WifiMetrics {supporting80211mcAps++;}-                ScanResultMatchInfo matchInfo = ScanResultMatchInfo.fromScanResult(scanResult);
+                ScanResultMatchInfo matchInfo = null;
+                try{
+                    matchInfo = ScanResultMatchInfo.fromScanResult(scanResult);
+                } catch (IllegalArgumentException e) {
+                    Log.e(TAG,
+                            "Invalid BSSID provided in the scan result1111: " + scanResult.BSSID);
+                }
+                if(matchInfo == null){
+                    continue;
+                }Pair<PasspointProvider, PasspointMatch> providerMatch = null;PasspointProvider passpointProvider = null;if (networkDetail.isInterworking()) {
diff --git a/service/java/com/android/server/wifi/WifiNetworkSelector.java b/service/java/com/android/server/wifi/WifiNetworkSelector.java
index 883ba93..99830df 100644
--- a/service/java/com/android/server/wifi/WifiNetworkSelector.java
+++ b/service/java/com/android/server/wifi/WifiNetworkSelector.java
@@ -61,6 +61,7 @@ public class WifiNetworkSelector {private final int mStayOnNetworkMinimumTxRate;private final int mStayOnNetworkMinimumRxRate;private final boolean mEnableAutoJoinWhenAssociated;
+    private final boolean mWpa3Support;/*** WiFi Network Selector supports various types of networks. Each type can
@@ -350,6 +351,8 @@ public class WifiNetworkSelector {continue;}+            if (!mWpa3Support && ScanResultUtil.isScanResultForOweNetwork(scanResult))
+                continue;// Skip saved networksif (mWifiConfigManager.getConfiguredNetworkForScanDetailAndCache(scanDetail) != null) {continue;
@@ -612,5 +615,7 @@ public class WifiNetworkSelector {R.integer.config_wifi_framework_min_tx_rate_for_staying_on_network);mStayOnNetworkMinimumRxRate = context.getResources().getInteger(R.integer.config_wifi_framework_min_rx_rate_for_staying_on_network);
+        mWpa3Support = context.getResources().getBoolean(
+                R.bool.config_wifi_wpa3_supported);}}
diff --git a/service/java/com/android/server/wifi/util/ScanResultUtil.java b/service/java/com/android/server/wifi/util/ScanResultUtil.java
index 271b543..24d0e44 100644
--- a/service/java/com/android/server/wifi/util/ScanResultUtil.java
+++ b/service/java/com/android/server/wifi/util/ScanResultUtil.java
@@ -63,6 +63,14 @@ public class ScanResultUtil {}/**
+     * Helper method to check if the provided |scanResult| corresponds to a EAP network or not.
+     * This checks if the provided capabilities string contains EAP encryption type or not.
+     */
+    public static boolean isScanResultForEapSuiteBNetwork(ScanResult scanResult) {
+        return scanResult.capabilities.contains("SUITE_B_192");
+    }
+
+    /*** Helper method to check if the provided |scanResult| corresponds to a WEP network or not.* This checks if the provided capabilities string contains WEP encryption type or not.*/
@@ -118,7 +126,8 @@ public class ScanResultUtil {*/public static boolean isScanResultForOpenNetwork(ScanResult scanResult) {return !(isScanResultForWepNetwork(scanResult) || isScanResultForPskNetwork(scanResult)
-                || isScanResultForEapNetwork(scanResult));
+                || isScanResultForEapNetwork(scanResult) || isScanResultForSaeNetwork(scanResult)
+                || isScanResultForDppNetwork(scanResult) || isScanResultForEapSuiteBNetwork(scanResult));}/**
路径:packages/apps/Settings/diff --git a/res/layout/wifi_dialog.xml b/res/layout/wifi_dialog.xml
index 96d9b8b..1862cfe 100644
--- a/res/layout/wifi_dialog.xml
+++ b/res/layout/wifi_dialog.xml
@@ -83,10 +83,19 @@style="@style/wifi_item_label"android:text="@string/wifi_security" />+                <Spinner android:id="@+id/security_no_wpa3"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    style="@style/wifi_item_spinner"
+                    android:visibility="gone"
+                    android:prompt="@string/wifi_security"
+                    android:entries="@array/wifi_security_no_wpa3" />
+<Spinner android:id="@+id/security"android:layout_width="match_parent"android:layout_height="wrap_content"style="@style/wifi_item_spinner"
+                        android:visibility="gone"android:prompt="@string/wifi_security"android:entries="@array/wifi_security" /></LinearLayout>
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index b55de87..99e0bee 100755
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -230,6 +230,20 @@</string-array><!-- Match this with the constants in AccessPoint. --> <skip />
+    <!-- Wi-Fi security types for New User Dialog. WPA3 is not configurable. -->
+    <string-array name="wifi_security_no_wpa3">
+        <!-- The Wi-Fi network does not have any security. -->
+        <item>@string/wifi_security_none</item>
+        <!-- Do not translate. -->
+        <item>@string/wifi_security_wep</item>
+        <!-- Do not translate. -->
+        <item>@string/wifi_security_psk_generic</item>
+        <!-- Do not translate. -->
+        <item>@string/wifi_security_eap</item>
+    </string-array>
+
+
+    <!-- Match this with the constants in AccessPoint. --> <skip /><!-- Wi-Fi security types for New User Dialog. EAP is not configurable. --><string-array name="wifi_security_no_eap"><!-- The Wi-Fi network does not have any security. -->
diff --git a/src/com/android/settings/wifi/WifiConfigController.java b/src/com/android/settings/wifi/WifiConfigController.java
index 1c74ca9..5f25504 100644
--- a/src/com/android/settings/wifi/WifiConfigController.java
+++ b/src/com/android/settings/wifi/WifiConfigController.java
@@ -187,6 +187,7 @@ public class WifiConfigController implements TextWatcher,private TelephonyManager mTelephonyManager;private SubscriptionManager mSubscriptionManager = null;private int selectedSimCardNumber;
+    private boolean mWPA3Support;public WifiConfigController(WifiConfigUiBase parent, View view, AccessPoint accessPoint,int mode) {
@@ -245,13 +246,20 @@ public class WifiConfigController implements TextWatcher,: View.VISIBLE);mShareThisWifiCheckBox = (CheckBox) mView.findViewById(R.id.share_this_wifi);mWifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
+        mWPA3Support = mContext.getResources().getBoolean(com.android.internal.R.bool.config_wifi_wpa3_supported);if (mAccessPoint == null) { // new networkmConfigUi.setTitle(R.string.wifi_add_network);mSsidView = (TextView) mView.findViewById(R.id.ssid);mSsidView.addTextChangedListener(this);
-            mSecuritySpinner = ((Spinner) mView.findViewById(R.id.security));
+
+            if (mWPA3Support) {
+                mSecuritySpinner = ((Spinner) mView.findViewById(R.id.security));
+            } else {
+                mSecuritySpinner = ((Spinner) mView.findViewById(R.id.security_no_wpa3));
+            }
+            mSecuritySpinner.setVisibility(View.VISIBLE);mSecuritySpinner.setOnItemSelectedListener(this);mView.findViewById(R.id.type).setVisibility(View.VISIBLE);

http://www.ppmy.cn/news/662134.html

相关文章

【贪玩巴斯】无线传感器网络(三)「Mac协议讲解」——2021-10-08

Mac协议 Mac协议的研究热点竞争性Mac协议ALOHA协议CSMA协议CSMA/CA协议优点典型协议Smac协议-前提条件和基本思想TMac协议 PMAC协议 分配型MAC协议 Mac协议的研究热点 能量效率 空闲监听 冲突&#xff08;会导致重传&#xff09; 控制开销 可扩展型网络效率&#xff08;挺重…

科普 | 什么是5G消息平台功能完备性认证,怎么才能获得5G消息平台功能完备性证书

5G消息平台功能完备性测试是由中国信息通信研究院同中国通信企业协会在5G消息工作组共同发起&#xff0c;旨在提升CSP的5G消息平台质量&#xff0c;促进5G消息业务发展。 测试针对5G消息平台的Chatbot下行消息交互、Chatbot接收消息、消息平台业务配置管理、消息平台业务统计管…

windows系统耳机插入后无响应解决方案

之前win10时&#xff0c;插入耳机会自动弹出一个框来确定信息&#xff0c;但是后来更新了win11后框没有了&#xff0c;当然&#xff0c;插入时也没有反应。我曾经怀疑过是否是耳机的问题&#xff0c;但耳机插到手机上或者平板上是没有问题的。查了很多方法都没有效果&#xff0…

在Android Studio 中运行React Native 项目

项目根目录执行命令安装开发依赖 yarn检查项目SDK、NDK、JDK否配置正确 点击 Android Studio 里点击大象 全部下载完毕&#xff0c;点击运行按钮&#xff0c;编译项目 连接真机的两种方式 无线连接 adb devices adb tcpip 5555 #连接端口默认5555 adb connect 192.168.0…

mysql5.7 优化配置,服务器为16核32GB

mysql5.7 优化配置 mysql5.7 优化配置&#xff0c;服务器为16核32GB。 当前服务器为Windows系统&#xff0c;找到MySQL配置文件my.ini。 当前路径为C:\ProgramData\MySQL\MySQL Server 5.7 打开独立表空间 innodb_file_per_table 1 #back_log 是操作系统在监听队列中所能保持…

JMeter 后置处理器之JSON提取器

目录 前言&#xff1a; 测试环境 插件介绍 插件参数 插件使用示例 JSON-PATH表达式介绍 操作符 函数 过滤器操作符 JSON PATH示例 前言&#xff1a; JMeter是一个功能强大的性能测试工具&#xff0c;它提供了许多后置处理器来处理和提取测试结果。其中一个常用的后…

微信 认证

小程序创建后要认证&#xff0c;无年审认证。 公众号创建后要认证&#xff0c;要年审认证。 付费认证一个服务号后可以用服务号快速免费认证小程序。

微信for

<view wx:for"{{array}}" wx:for-index"idx" wx:for-item"itemName">{{idx}}: {{itemName.message}} </view>