Reputation: 990
The Android Virtual Device is connected by defualt to a wifi network called "AndroidWifi". I am working with an app that expects to be connected to a wifi network with a particular name.
How can I change the name of the wifi network from "AndroidWifi"?
Upvotes: 3
Views: 3868
Reputation: 96
On any recent build of the Android emulator (which contains this commit from 2018), there is a feature flag which can be set to allow for custom SSIDs to be added via the telnet console. To enable it, open lib/advancedFeatures.ini
in the emulator directory (the default full path for this on Linux installations is ~/Android/Sdk/emulator/lib/advancedFeatures.ini
) and change:
WifiConfigurable = off
to
WifiConfigurable = on
Ensure that you have restarted the emulator after making this change.
You can then connect to the emulator via telnet (as described here) and after authenticating, the following wifi commands will be available:
wifi
allows you to manage wifi settings in the device
available sub-commands:
add add new WiFi SSID
block block network access on SSID
unblock unblock network access on SSID
Upvotes: 1
Reputation: 11
You can modify the hostapd.conf
file in your device (/data/vendor/wifi/hostapd/hostapd.conf
). It will allow you to set ssid (ssid=
) or even to set a password (wpa_passphrase
). You will need a root access to do that.
More details at https://wiki.gentoo.org/wiki/Hostapd#WiFi_Technology
Upvotes: 0
Reputation: 76569
Try something more pragmatic:
String getExpectedId() {
String ssid = this.getResources().getString(R.string.default_ssid);
if(Build.FINGERPRINT.contains("generic")) {ssid = "AndroidWifi";}
return ssid;
}
because you won't change the SSID (service set identifier) of the emulator's WiFi.
Despite there's adb
commands alike svc wifi enable
and svc wifi disable
, the password for the default network likely is unknown in /data/misc/wifi/wpa_supplicant.conf
; see Connecting to WiFi using adb shell. Since the emulator is rooted, one can generally configure any network alike that, while it is accessible (which the regular WiFi, which is exists in reality, obviously isn't). I think the first one approach is better, because editing emulator images isn't too portable.
Upvotes: 2
Reputation: 10235
AVD manager doesn't provide any ways to customize the simulated Wi-Fi access point AndroidWifi .
You may have to disable it and use another wifi simulator such as this one. It does need the Xposed framework in order to function. Here is how you can configure it.
Upvotes: 0