[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],null,["# Wi-Fi low-latency mode\n\nAndroid 10 extends the Wi-Fi lock API to allow\nlatency-sensitive apps to configure Wi-Fi to a\n[low-latency\nmode](https://developer.android.com/reference/android/net/wifi/WifiManager#WIFI_MODE_FULL_LOW_LATENCY).\nThe low-latency mode starts when all of the following conditions are met:\n\n- Wi-Fi is enabled and the device has internet access.\n- The app has created and acquired a Wi-Fi lock, and is running in the foreground.\n- The screen is on.\n\nTo support low-latency mode on devices, device manufacturers must update the\nWLAN driver and vendor HAL. In low-latency mode, power save (also known as\ndoze state in the IEEE 802.11 standard) is explicitly disabled by the framework.\nThe scanning and roaming parameters in the driver and firmware layers can be\noptimized to further reduce Wi-Fi latency. The exact optimizations are\nimplementation specific.\n\nAndroid has a\n[high-performance Wi-Fi lock mode](https://developer.android.com/reference/android/net/wifi/WifiManager#WIFI_MODE_FULL_HIGH_PERF)\n(introduced in API level 12) that is separate from the low-latency mode.\n\nImplementation\n--------------\n\nTo support the Wi-Fi low-latency mode feature, provide implementations for\nthe following `IWifiChip` functions.\n\nIn the AIDL HAL:\n\n- `int getFeatureSet()`\n- `void setLatencyMode(in LatencyMode mode)`\n\nIn the HIDL HAL (1.3 or newer):\n\n- `getCapabilities_1_3() generates (WifiStatus status,\n bitfield\u003cChipCapabilityMask\u003e capabilities)`\n- `setLatencyMode(LatencyMode mode) generates (WifiStatus status)`\n\nA reference implementation can be found in\n[`wifi_legacy_hal.cpp`](https://android.googlesource.com/platform/hardware/interfaces/+/refs/heads/android16-release/wifi/aidl/default/wifi_legacy_hal.cpp)\nwith the following functions:\n\n- `wifi_error wifi_get_supported_feature_set(wifi_interface_handle\n iface, feature_set *set)`\n- `wifi_error wifi_set_latency_mode(wifi_interface_handle handle,\n wifi_latency_mode mode)`\n\nIn low-latency mode, power save is explicitly disabled by\n[`WifiLockManager`](https://cs.android.com/android/platform/superproject/+/android-latest-release:packages/modules/Wifi/service/java/com/android/server/wifi/WifiLockManager.java)\nin the Android framework.\nTo support this, the WLAN driver must support the NL80211 command,\n`NL80211_CMD_SET_POWER_SAVE`, to enable and disable power save. When Wi-Fi power\nsave is disabled, the Wi-Fi system must stay in the awake state and be ready to\nsend or receive packets with minimum delay.\n| **Note:** Low-latency mode is fully supported on devices that support the AIDL HAL, or the HIDL HAL (1.3 or newer). For devices running Android 10 that don't support `android.hardware.wifi@1.3`, `WifiLockManager` only disables power save when the low-latency mode Wi-Fi lock is acquired by the app and is active.\n\nDisable the feature\n-------------------\n\nTo turn off the low-latency mode feature, update the underlying code of\n`getFeatureSet()` for the AIDL HAL or\n`getCapabilities_1_3()` for the HIDL HAL,\nsuch that `capabilities & SET_LATENCY_MODE = 0`, where\n`SET_LATENCY_MODE` is defined in the `IWifiChip` AIDL or HIDL definition.\nWhen this feature is disabled,\nthe framework disables power save only when the low-latency mode is active.\n\nValidation\n----------\n\nTo test that low-latency mode works when enabled, run the following automated\ntests and manual ping latency tests.\n\n### Automated testing\n\nRun the following VTS and CTS tests:\n\n- VTS (AIDL): [`hardware/interfaces/wifi/aidl/vts/functional/wifi_chip_aidl_test.cpp`](https://android.googlesource.com/platform/hardware/interfaces/+/refs/heads/android16-release/wifi/aidl/vts/functional/wifi_chip_aidl_test.cpp)\n- VTS (HIDL): [`hardware/interfaces/wifi/1.3/vts/functional/wifi_chip_hidl_test.cpp`](https://android.googlesource.com/platform/hardware/interfaces/+/refs/heads/android16-release/wifi/1.3/vts/functional/wifi_chip_hidl_test.cpp)\n- CTS: [`cts/tests/tests/net/src/android/net/wifi/cts/WifiLockTest.java`](https://cs.android.com/android/platform/superproject/+/android-latest-release:cts/tests/tests/wifi/src/android/net/wifi/cts/WifiLockTest.java)\n\n### Manual testing\n\n#### Required test equipment and environment\n\nFor manual testing, the following setup is required:\n\n- Wi-Fi access point (AP)\n- Device-under-test (DUT) phone and test computer\n\n - The DUT must be connected to the access point over Wi-Fi.\n - The test computer must be connected to the access point over Wi-Fi or Ethernet.\n - The test computer must be connected to the DUT over USB.\n\n#### Uplink ping test\n\n1. Enable low latency mode.\n\n adb root\n adb shell cmd wifi force-low-latency-mode enabled\n\n2. Make sure your computer is connected with the phone through ADB. From\n the ADB shell, ping the gateway continuously for 3 hours at 1 second\n intervals.\n\n3. Save the test output in a text file and use a spreadsheet or a Python\n script to generate a histogram of the ping latency test results.\n\n4. Repeat steps 1 through 3 with latency mode disabled.\n\n adb root\n adb shell cmd wifi force-low-latency-mode disabled\n\n5. Compare the test results to ensure that the average ping latency value is\n reduced when the low-latency mode is enabled.\n\n| **Note:** Optionally, to determine whether end-to-end latency has improved overall, repeat the test using a well-known host address such as google.com.\n\n#### Downlink ping test\n\n1. Enable low-latency mode.\n\n adb root\n adb shell cmd wifi force-low-latency-mode enabled\n\n2. From the command line of the test computer, ping the phone's IP\n address continuously for 3 hours at 1 second intervals.\n\n3. Save the test output in a text file and use a spreadsheet or a Python\n script to generate a histogram of the ping latency test results.\n\n4. Repeat steps 1 through 3 with latency mode disabled.\n\n adb root\n adb shell cmd wifi force-low-latency-mode disabled\n\n5. Compare the test results to ensure that the average ping latency value is\n reduced when the low-latency mode is enabled.\n\n| **Note:** Optionally, to determine whether end-to-end latency is improved, repeat the ping test with a well-known host address such as google.com.\n\n#### Other tests\n\nRepeat the above tests in different environments. For example, at\nhome or in the office."]]