Snap for 9381392 from 9cc9ce67245a38bdacae78a0defe967ce4246495 to tm-qpr2-release

Change-Id: I58db6bf204981e82cb0e4599a25d20ff5aecc6cd
diff --git a/guest/commands/setup_wifi/main.cpp b/guest/commands/setup_wifi/main.cpp
index 4a91442..2727fb4 100644
--- a/guest/commands/setup_wifi/main.cpp
+++ b/guest/commands/setup_wifi/main.cpp
@@ -33,6 +33,7 @@
 #include "common/libs/net/network_interface_manager.h"
 
 DEFINE_string(mac_prefix, "", "mac prefix to use for wlan0");
+DEFINE_string(interface, "eth2", "interface to create wlan wrapper on");
 
 static std::array<unsigned char, 6> prefix_to_mac(
     const std::string& mac_prefix) {
@@ -138,9 +139,9 @@
 
   gflags::ParseCommandLineFlags(&argc, &argv, true);
 
-  int renamed_eth2 = RenameNetwork("eth2", "buried_eth2");
-  if (renamed_eth2 != 0) {
-    return renamed_eth2;
+  int renamed_if = RenameNetwork(FLAGS_interface, "buried_" + FLAGS_interface);
+  if (renamed_if != 0) {
+    return renamed_if;
   }
-  return CreateWifiWrapper("buried_eth2", "wlan0");
+  return CreateWifiWrapper("buried_" + FLAGS_interface, "wlan0");
 }
diff --git a/guest/commands/setup_wifi/setup_wifi.rc b/guest/commands/setup_wifi/setup_wifi.rc
index a2f1eb5..993e957 100644
--- a/guest/commands/setup_wifi/setup_wifi.rc
+++ b/guest/commands/setup_wifi/setup_wifi.rc
@@ -1,2 +1,2 @@
-service setup_wifi /vendor/bin/setup_wifi
+service setup_wifi /vendor/bin/setup_wifi --interface=${ro.vendor.virtwifi.port}
     oneshot
diff --git a/shared/config/init.vendor.rc b/shared/config/init.vendor.rc
index cb702a0..83a52c4 100644
--- a/shared/config/init.vendor.rc
+++ b/shared/config/init.vendor.rc
@@ -55,7 +55,7 @@
     # set RLIMIT_MEMLOCK to 64MB
     setrlimit 8 67108864 67108864
 
-on post-fs-data
+on post-fs-data && property:ro.vendor.disable_rename_eth0=
     # works around framework netiface enumeration issue
     # TODO(b/202731768): Add this `start rename_eth0` command to the init.rc for rename_netiface
     start rename_eth0
diff --git a/shared/device.mk b/shared/device.mk
index ebd5216..3213aeb 100644
--- a/shared/device.mk
+++ b/shared/device.mk
@@ -772,6 +772,12 @@
 PRODUCT_COPY_FILES += \
     device/google/cuttlefish/shared/config/wpa_supplicant.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/wpa_supplicant.rc
 
+# VirtWifi interface configuration
+ifeq ($(DEVICE_VIRTWIFI_PORT),)
+    DEVICE_VIRTWIFI_PORT := eth2
+endif
+PRODUCT_VENDOR_PROPERTIES += ro.vendor.virtwifi.port=${DEVICE_VIRTWIFI_PORT}
+
 # WLAN driver configuration files
 ifndef LOCAL_WPA_SUPPLICANT_OVERLAY
 LOCAL_WPA_SUPPLICANT_OVERLAY := $(LOCAL_PATH)/config/wpa_supplicant_overlay.conf