Kể từ ngày 27 tháng 3 năm 2025, bạn nên sử dụng android-latest-release
thay vì aosp-main
để xây dựng và đóng góp cho AOSP. Để biết thêm thông tin, hãy xem phần Thay đổi đối với AOSP.
Quét để truyền dữ liệu về mạng ưu tiên Wi-Fi
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Quét mạng ưu tiên Wi-Fi (PNO) là các lần quét Wi-Fi tiêu thụ ít năng lượng diễn ra theo chu kỳ đều đặn khi thiết bị bị ngắt kết nối với Wi-Fi và màn hình tắt. Các lần quét PNO được dùng để tìm và kết nối với các mạng đã lưu. Các lượt quét này được lên lịch bởi khung bằng lệnh NL80211_CMD_START_SCHED_SCAN
. Để biết thêm thông tin, hãy xem nl80211.h.
Trên các thiết bị chạy Android 9 trở xuống, khi thiết bị bị ngắt kết nối Wi-Fi và màn hình tắt, các lần quét PNO sẽ diễn ra theo khoảng thời gian 20 giây cho 3 lần quét đầu tiên, sau đó giảm tốc độ xuống một lần quét mỗi 60 giây cho tất cả các lần quét tiếp theo. Quá trình quét PNO sẽ dừng khi tìm thấy một mạng đã lưu hoặc khi màn hình bật.
Android 10 giới thiệu một phương thức API không bắt buộc có tên là setDeviceMobilityState()
trong WifiManager
. Phương thức này tăng khoảng thời gian giữa các lần quét PNO dựa trên trạng thái di động của thiết bị để giảm mức tiêu thụ điện năng.
Có thể có các trạng thái di chuyển sau:
DEVICE_MOBILITY_STATE_UNKNOWN
:
Khả năng di chuyển không xác định
DEVICE_MOBILITY_STATE_HIGH_MVMT
: Đi xe đạp hoặc ngồi trong xe cơ giới
DEVICE_MOBILITY_STATE_LOW_MVMT
: Đi bộ hoặc chạy
DEVICE_MOBILITY_STATE_STATIONARY
: Không di chuyển
Nếu thiết bị đứng yên, khung Android sẽ tăng khoảng thời gian giữa các lần quét PNO từ 60 giây lên 180 giây để giảm mức tiêu thụ điện năng. Việc tối ưu hoá này được thực hiện dựa trên giả định rằng thiết bị khó có thể tìm thấy bất kỳ mạng mới nào trong quá trình quét PNO khi thiết bị không di chuyển.
Nếu thiết bị ở trạng thái di động khác hoặc nếu phương thức này không được gọi, thì thiết bị sẽ sử dụng hành vi quét PNO mặc định.
Triển khai
Để triển khai tính năng tối ưu hoá nguồn điện này trên một thiết bị chạy Android 10 trở lên, hãy lấy thông tin về khả năng di chuyển của thiết bị và gọi phương thức setDeviceMobilityState()
từ một ứng dụng hệ thống tuỳ chỉnh.
Nội dung và mã mẫu trên trang này phải tuân thủ các giấy phép như mô tả trong phần Giấy phép nội dung. Java và OpenJDK là nhãn hiệu hoặc nhãn hiệu đã đăng ký của Oracle và/hoặc đơn vị liên kết của Oracle.
Cập nhật lần gần đây nhất: 2025-07-27 UTC.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-07-27 UTC."],[],[],null,["# Wi-Fi preferred network offload scanning\n\nWi-Fi preferred network offload (PNO) scans are low-powered Wi-Fi scans that\noccur at regular intervals when a device is disconnected from Wi-Fi and the\nscreen is off. PNO scans are used to find and\nconnect to saved networks. These scans are scheduled by the framework using the\n`NL80211_CMD_START_SCHED_SCAN` command. For more information, see\n[nl80211.h](https://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless.git/tree/include/uapi/linux/nl80211.h).\n\nOptimize power usage with device mobility information\n-----------------------------------------------------\n\nOn devices running Android 9 or lower, when the device\nis disconnected from Wi-Fi and the screen is off, PNO scans occur at 20 second\nintervals for the first three scans, then slow down to one scan every 60 seconds\nfor all subsequent scans. PNO scanning stops when a saved network is found or\nthe screen is turned on.\n\nAndroid 10 introduces an optional API method named\n[`setDeviceMobilityState()`](https://cs.android.com/android/platform/superproject/+/android-latest-release:packages/modules/Wifi/framework/java/android/net/wifi/WifiManager.java?q=func:setDeviceMobilityState)\nin `WifiManager` that increases the interval between\nPNO scans based on the device's mobility state to reduce power consumption.\n\nThe possible mobility states are:\n\n- `DEVICE_MOBILITY_STATE_UNKNOWN`: Unknown mobility\n- `DEVICE_MOBILITY_STATE_HIGH_MVMT`: On a bike or in a motor vehicle\n- `DEVICE_MOBILITY_STATE_LOW_MVMT`: Walking or running\n- `DEVICE_MOBILITY_STATE_STATIONARY`: Not moving\n\nIf the device is stationary, the Android framework increases the\ninterval between PNO scans from 60 seconds to 180 seconds to reduce power\nconsumption. This optimization is made on the assumption that the device is\nunlikely to find any new networks in PNO scans when the device is not moving.\n\nIf the device is in any other mobility state or if the method isn't called, the\ndevice uses the default PNO scan behavior.\n\n### Implementation\n\nTo implement this power-optimizing feature on a device running Android\n10 or higher, derive the device mobility information\nand call the `setDeviceMobilityState()` method from a custom system app."]]