Here is the solution I came up with to simulate the overall loss of network connectivity on an emulator:
Write the following script and name it "nonetwork.sh"
netcfg eth0 down sleep 10 netcfg eth0 up netcfg eth0 dhcp
Download the following emulation script with this command:
adb push nonetwork.sh /data/local/nonetwork.sh
Change permissions
adb shell chmod 700 /data/local/nonetwork.sh
Run it
adb shell /data/local/nonetwork.sh
While the network is not working on the device, you will also lose access to adb, but as soon as the connection is restored, it will work again. Hope this helps.
source share