blob: f3a493a72d1057f0aa10ffbc58d6092f7209454a [file] [log] [blame]
<html devsite><head>
<meta name="book_path" value="/_book.yaml"/>
<meta name="project_path" value="/_project.yaml"/>
</head>
<body>
<!--
Copyright 2018 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<h1 id="testing_debugging_and_tuning_wi-fi" class="page-title">测试、调试和调整 WLAN</h1>
<p>本文将介绍如何使用 ASOP 中提供的工具测试、调试和调整 WLAN 实现。</p>
<h2 id="testing">测试</h2>
<p>为了测试 WLAN 框架,AOSP 提供了一系列单元测试、集成测试 (ACTS) 和 CTS 测试。</p>
<h3 id="unit_tests">单元测试</h3>
<p>AOSP 包括针对默认 WLAN 框架的功能测试和单元测试:这两项测试均适用于 WLAN Manager(应用端代码)和 WLAN 服务。</p>
<p>WLAN Manager 测试:</p>
<ul>
<li>位于 <code>frameworks/base/wifi/tests</code></li>
<li><p>使用以下 shell 可执行文件运行(有关更多执行选项,请参阅文件):</p>
<pre class="prettyprint"><code>% ./frameworks/base/wifi/tests/runtest.sh
</code></pre></li>
</ul>
<p>WLAN 服务测试:</p>
<ul>
<li>位于 <code>frameworks/opt/net/wifi/tests/wifitest</code></li>
<li><p>使用以下 shell 可执行文件运行(有关更多执行选项,请参阅文件):</p>
<pre class="prettyprint"><code>% ./frameworks/opt/net/wifi/tests/wifitests/runtest.sh
</code></pre></li>
</ul>
<h3 id="android_comms_test_suite">Android 通讯测试套件</h3>
<p>Android 通讯测试套件 (ACTS) 用于执行对连接堆栈(例如 WLAN、蓝牙和移动网络服务)的自动测试。该测试工具需要 adb 和 Python,您可以在以下位置找到它:<code>tools/test/connectivity/acts</code></p>
<p>您可以在以下位置找到针对 WLAN 的 ACTS 测试:<code>tools/test/connectivity/acts/tests/google/wifi</code>,而且同一目录下还包含以下示例测试配置:<code>example_config.json</code></p>
<h3 id="cts_tests">CTS 测试</h3>
<p><a href="/compatibility/cts/">兼容性测试套件</a> (CTS) 包括针对 WLAN 框架的测试。这些测试位于以下位置:<code>cts/tests/tests/net/src/android/net/wifi</code>。WLAN CTS 测试要求在测试开始运行时将受测设备与接入点相关联。</p>
<h2 id="enhanced_logging_options_for_debugging">针对调试的增强型日志记录选项</h2>
<p>Android 9 改进了 WLAN 日志记录功能,以便更轻松地调试 WLAN 问题。在 Android 9 中,驱动程序/固件环形缓冲区可以始终处于开启状态。在检测到错误状态时,可能会自动触发错误报告(仅限 userdebug 和 eng 版本)。如果您使用的是最新 WLAN HAL(1.2 版),则固件调试缓冲区存储在 HAL 中而不是框架内,以节省 IPC 费用。</p>
<h3 id="implementation">实现</h3>
<p>有关参考实现,请参阅供应商 HAL 中的<a href="https://android.googlesource.com/platform/hardware/interfaces/+/master/wifi/1.2/default/wifi_chip.cpp#1388" class="external">默认实现</a></p>
<p>您可以通过将资源 <code>config_wifi_enable_wifi_firmware_debugging</code> 设置为 false 来停用固件日志记录。</p>
<h3 id="integration_test_acts">集成测试 (ACTS)</h3>
<p>您可以在以下位置找到集成测试:<code>/tools/test/connectivity/acts/tests/google/wifi/WifiDiagnosticsTest.py</code></p>
<p>对于 userdebug 版本,已验证的固件转储会保留在闪存中相应的 tombstone 目录下。在创建错误报告时,Dumpstate 就是从此目录中收集的。</p>
<h3 id="manual_test">手动测试</h3>
<p>运行以下手动测试,以验证 <a href="/devices/tech/debug/#debuggerd">tombstone 目录</a>中的旧文件是否已被删除。</p>
<ol>
<li>开启 WLAN。</li>
<li>连接到网络。</li>
<li>生成<a href="/setup/contribute/read-bug-reports">错误报告</a></li>
<li>检查 bugreport zip 文件并验证 <code>/lshal-debug/android.hardware.wifi@1.2__IWifi_default.txt</code> 中是否包含已归档的固件日志。</li>
</ol>
<h2 id="configuration_tuning">配置调整</h2>
<p>为了控制设备在与网络建立关联和取消关联时采用的信号强度,WLAN 框架使用了“entry”和“exit”RSSI 阈值。<em></em><em></em></p>
<p>系统会将“entry”和“exit”阈值存储为可过载的配置参数,并使用以下名称(其中 <code>bad</code> 参数是指“exit”RSSI 阈值):<em></em><em></em><em></em></p>
<ul>
<li><code>config_wifi_framework_wifi_score_bad_rssi_threshold_5GHz</code></li>
<li><code>config_wifi_framework_wifi_score_entry_rssi_threshold_5GHz</code></li>
<li><code>config_wifi_framework_wifi_score_bad_rssi_threshold_24GHz</code></li>
<li><code>config_wifi_framework_wifi_score_entry_rssi_threshold_24GHz</code></li>
</ul>
<p>系统会将这些参数存储在 <code>&lt;root&gt;/frameworks/base/core/res/res/values/config.xml</code> 中,并可能会使用叠加层文件 <code>&lt;root&gt;/device/&lt;dev_dir&gt;/overlay/frameworks/base/core/res/res/values/config.xml</code> 对其进行过载。</p>
<aside class="note"><strong>注意</strong><span><code>bad</code> 配置参数(适用于 2.4GHz 和 5GHz 的频段)已在 Android 8.1 之前的版本中引入。<code>entry</code> 配置参数已在 Android 8.1 中引入,其默认值等于对应的 bad 参数。这些默认值会导致出现 Android 8.1 之前的版本中的行为,即系统在选择网络时不使用迟滞功能。要充分利用 Android 8.1 中引入的迟滞功能,请使用上文中指定的叠加层文件将 <code>entry</code> 参数设为 3dB 或比 <code>bad</code> 参数更高的值。</span></aside>
<p>您可以使用 adb 命令来配置设备,从而测试新的阈值(或者,您也可以使用新的叠加层来创建编译,但使用 adb 命令可以加快测试周期)。</p>
<pre class="prettyprint"><code>% adb shell settings put global wifi_score_params \
[rssi2|rssi5]=&lt;bad&gt;:&lt;entry&gt;:&lt;low&gt;:&lt;good&gt;
</code></pre>
<p>例如,以下命令可以配置新的阈值参数(此示例命令中使用的值是 AOSP 代码库中配置的默认值):</p>
<pre class="prettyprint"><code>% adb shell settings put global wifi_score_params \
rssi2=-85:-85:-73:-60,rssi5=-82:-82:-70:-57
</code></pre>
<p>要恢复内置的参数值(即移除替换),请使用以下 abd 命令:</p>
<pre class="prettyprint"><code>% adb shell settings delete global wifi_score_params
</code></pre>
</body></html>