Android 9 以前を搭載しているデバイスは、Wi-Fi MAC アドレスのランダム化をサポートしていない可能性があります。こうしたデバイスを Android 10 にアップグレードする場合、Wi-Fi ベンダー HAL の make ファイルで WIFI_HIDL_FEATURE_DISABLE_AP_MAC_RANDOMIZATION フラグを true に設定すると、Wi-Fi MAC アドレスのランダム化機能を無効にできます。
検証
機能が意図したとおりに動作することを確認するには、手動テストを実行します。
MAC アドレスのランダム化がデバイスで有効になっていることを確認します(デバイス オーバーレイで config_wifi_connected_mac_randomization_supported が true に設定されていることを確認します)。
Wi-Fi ネットワークに接続します。
ネットワークをタップして、[ネットワークの詳細] ページに移動します。MAC アドレスのランダム化がオンになっていることを確認します。表示された MAC アドレスが、ローカルで生成されたビットが 1 に、マルチキャスト ビットが 0 に設定されたランダムな MAC アドレスであることを確認します。
MAC アドレスのランダム化をオフにします。同じネットワークに接続し、出荷時 MAC アドレスが使用されていることを確認します。
[[["わかりやすい","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-03-26 UTC。"],[],[],null,["# Implement MAC randomization\n\nStarting in Android 8.0, Android devices use randomized MAC addresses when\nprobing for new networks while not associated with a network. In\nAndroid 9, you can enable a developer option (it's\n**disabled** by default) to cause the device to use a randomized MAC address\nwhen connecting to a Wi-Fi network.\n\nIn Android 10, MAC randomization is enabled by default\nfor client mode, SoftAp, and Wi-Fi Direct.\n\nMAC randomization prevents listeners from using MAC addresses to build a history\nof device activity, thus increasing user privacy.\n\nAdditionally, MAC addresses are randomized as part of\n[Wi-Fi Aware](/docs/core/connect/wifi-aware) and\n[Wi-Fi RTT](/docs/core/connect/wifi-rtt) operations.\n\nFor more information, see\n[MAC Randomization Behavior](/docs/core/connect/wifi-mac-randomization-behavior).\n\nImplementation\n--------------\n\nTo implement MAC randomization on your device:\n\n1. Work with a Wi-Fi chip vendor to implement the following HAL methods:\n\n - `IWifiStaIface#setMacAddress`: Configures the MAC address of the interface. The default implementation brings the interface down, changes the MAC address, and brings the interface back up.\n - `IWifiStaIface#getFactoryMacAddress`: Gets the factory MAC of `wlan0` using an `ioctl` call.\n - `ISupplicantP2pIface#setMacRandomization`: Sets P2P MAC randomization on/off in the supplicant.\n2. Set\n [`config_wifi_connected_mac_randomization_supported`](https://android.googlesource.com/platform/frameworks/base/+/refs/heads/android16-release/core/res/res/values/config.xml)\n to `true` in the Settings `config.xml` (this can be done in a device\n custom overlay).\n\n - This flag is used to control whether client-mode MAC randomization is enabled.\n3. Set\n [`config_wifi_p2p_mac_randomization_supported`](https://android.googlesource.com/platform/frameworks/base/+/refs/heads/android16-release/core/res/res/values/config.xml)\n to `true` in the Settings `config.xml` (this can be done in a device\n custom overlay).\n\n - This flag is used to control whether Wi-Fi direct MAC randomization is enabled.\n4. Test your implementation using the methods described in\n [Validation](#validation).\n\nThe System UI must:\n\n- Have an option to enable or disable randomization for each SSID.\n- Have MAC randomization enabled by default for all newly added networks.\n\nUse the\n[reference implementation](https://cs.android.com/android/platform/superproject/+/android-latest-release:packages/apps/Settings/src/com/android/settings/wifi/details2/WifiPrivacyPreferenceController2.java)\nof Settings UI to implement new prompts.\n\nDevices running Android 9 or lower might not have\nsupport for Wi-Fi MAC randomization. When upgrading such devices to Android\n10, the Wi-Fi MAC randomization feature can be disabled\nby setting the `WIFI_HIDL_FEATURE_DISABLE_AP_MAC_RANDOMIZATION` flag to true in\nthe Wi-Fi vendor HAL make file.\n\nValidation\n----------\n\nTo validate that the feature is working as intended, run a manual test:\n\n1. Verify that MAC randomization is enabled on the device by checking that `config_wifi_connected_mac_randomization_supported` is set to `true` in the device overlay.\n2. Connect to a Wi-Fi network.\n3. Tap the network to go to the Network details page. Verify that MAC randomization is turned on. Verify that the MAC address displayed is a randomized MAC, which has the locally generated bit set to 1 and the multicast bit set to 0.\n4. Turn MAC randomization off. Connect to the same network and verify that the factory MAC is being used.\n5. Delete the network by tapping **Forget** on the Network details page.\n6. Connect to the same network and verify that the **same** randomized MAC\n address is being used.\n\n | **Note:** Randomized MAC addresses are generated per SSID and are persistent.\n\nTo test MAC randomization on a pre-Android 10 device\n(capable of supporting MAC randomization) upgrading to Android\n10 or higher:\n\n1. Have at least one saved network on a device running Android 9 or lower.\n2. Flash the Android 10 system image.\n3. In the Wi-Fi picker, verify that MAC randomization is turned off for all saved networks.\n4. Turn MAC randomization on. Connect to the same network and verify that the randomized MAC is being used.\n\n| **Note:** You may experience up to a three-second delay when connecting to a network due to the driver flushing saved scan results when the interface goes down. If this is the case, check with your silicon partners to resolve the issue."]]