Skip to content

Commit 75d50a1

Browse files
committed
Prefer enforce_mac80211_hwsim configuration from android-info.txt
This allows build targets to express a preference for using the wmediumd mac80211 himplementation in their android-info.txt files. The existing mechanism of defining a preprocessor variable blocks being able to use the same compiled `assemble_cvd` executable for different build targets. Bug: b/421246590
1 parent 9c733e4 commit 75d50a1

3 files changed

Lines changed: 28 additions & 2 deletions

File tree

base/cvd/cuttlefish/host/commands/assemble_cvd/bootconfig_args.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,12 @@ Result<std::unordered_map<std::string, std::string>> BootconfigArgsFromConfig(
223223
fmt::format("192.168.98.{}", instance_id + 2);
224224
}
225225

226+
if (config.virtio_mac80211_hwsim()) {
227+
bootconfig_args["androidboot.wifi_impl"] = "mac80211_hwsim_virtio";
228+
} else {
229+
bootconfig_args["androidboot.wifi_impl"] = "virt_wifi";
230+
}
231+
226232
if (!instance.vcpu_config_path().empty()) {
227233
auto vcpu_config_json =
228234
CF_EXPECT(LoadFromFile(instance.vcpu_config_path()));

base/cvd/cuttlefish/host/commands/assemble_cvd/flags.cc

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,16 @@ Result<std::vector<GuestConfig>> ReadGuestConfig() {
784784
<< "\" for output audio stream count");
785785
}
786786

787+
Result<std::string> enforce_mac80211_hwsim = GetAndroidInfoConfig(
788+
instance_android_info_txt, "enforce_mac80211_hwsim");
789+
if (enforce_mac80211_hwsim.ok()) {
790+
if (*enforce_mac80211_hwsim == "true") {
791+
guest_config.enforce_mac80211_hwsim = true;
792+
} else if (*enforce_mac80211_hwsim == "false") {
793+
guest_config.enforce_mac80211_hwsim = false;
794+
}
795+
}
796+
787797
guest_configs.push_back(guest_config);
788798
}
789799
return guest_configs;
@@ -1179,8 +1189,17 @@ Result<CuttlefishConfig> InitializeCuttlefishConfiguration(
11791189
tmp_config_obj.set_enable_metrics(FLAGS_report_anonymous_usage_stats);
11801190
// TODO(moelsherif): Handle this flag (set_metrics_binary) in the future
11811191

1182-
// TODO: schuffelen - make this a device-specific android-info.txt setting
1183-
tmp_config_obj.set_virtio_mac80211_hwsim(true);
1192+
std::optional<bool> guest_config_mac80211_hwsim =
1193+
guest_configs[0].enforce_mac80211_hwsim;
1194+
if (guest_config_mac80211_hwsim.has_value()) {
1195+
tmp_config_obj.set_virtio_mac80211_hwsim(*guest_config_mac80211_hwsim);
1196+
} else {
1197+
#ifdef ENFORCE_MAC80211_HWSIM
1198+
tmp_config_obj.set_virtio_mac80211_hwsim(true);
1199+
#else
1200+
tmp_config_obj.set_virtio_mac80211_hwsim(false);
1201+
#endif
1202+
}
11841203

11851204
if ((FLAGS_ap_rootfs_image.empty()) != (FLAGS_ap_kernel_image.empty())) {
11861205
LOG(FATAL) << "Either both ap_rootfs_image and ap_kernel_image should be "

base/cvd/cuttlefish/host/commands/assemble_cvd/guest_config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ struct GuestConfig {
3939
std::optional<std::string> custom_keyboard_config;
4040
std::optional<std::string> domkey_mapping_config;
4141
int output_audio_streams_count = 1;
42+
std::optional<bool> enforce_mac80211_hwsim;
4243
};
4344

4445
}

0 commit comments

Comments
 (0)