Toggle Android emulator network traffic from emulator invocation

Posted by highphi on Stack Overflow See other posts from Stack Overflow or by highphi
Published on 2012-11-05T01:27:49Z Indexed on 2012/11/05 17:00 UTC
Read the original article Hit count: 466

Filed under:
|

I'm working on scripts to manage large amounts of Android emulators and I need to disable all network traffic on some of them. Because I'm doing all of this on a headless server, I cannot use the F8 hotkey described on the emulater documentation.

I'm currently routing the TCP traffic through a null proxy with by using emulator-arm ... -http-proxy 0.0.0.0:0 and this blocks the traffic that I want it to.

I thought this was working well until I noticed some strange error messages while running my scripts. The console started outputting accept too many open files and checking the open files with lsof reveals numerous messages stating "can't identify protocol"

...
emulator- 19463 username   19u     sock                0,6       0t0 1976595845 can't identify protocol
emulator- 19463 username   20u     sock                0,6       0t0 1976595847 can't identify protocol
...

The only "solution" I found to this is to kill all of the emulators and then wait until this limit is reached again, which is hardly a solution at all.

Is there another way to do this while invoking the emulator? Am I incorrectly using the -htt-proxy switch to block the traffic?

Other people found solutions to block traffic by manually doing this by using airplane mode, but this isn't feasible for me as I'm controlling emulators via scripts. I could send keyevents to the emulator with my script and turn the phone on in airplane mode, but I would prefer something more reliable than this.

© Stack Overflow or respective owner

Related posts about android

Related posts about android-emulator