0

I launch an emulator via command line emulator -avd MyEmulator -http-proxy http://username:password@IP:Port. Where are stored proxy settings? And how can I check it ?

Lrrr
  • 4,755
  • 5
  • 41
  • 63
  • I am able to connect to Internet via browser or other apps without any problem and use the proxy, I can check that via whatismyip.com or wireshark. But I can't see where those proxy settings are stored on the emulator. I try adb shell getprop and it returns nothing configured for proxy, I check sqlite3 system.db and nothing configured for proxy, I check the menu "Access Point Name" and none proxy is configured too. – tuan dat nguyen Mar 29 '15 at 07:20

1 Answers1

1

You could debug your emulator HTTP/S traffic using Charles .. check this for more info

using system's settings database:

$ adb shell 
$ sqlite3 /data/data/com.google.android.providers.settings/databases/settings.db 
  sqlite> INSERT INTO system VALUES(99,'http_proxy', 'proxy:port'); 
  sqlite> exit

using Android Emulator itself:

It is much better to manage it inside the running emulator itself .. apply the following if it is not working with you:

  • Got to Settings | Wireless & Networks | Mobile Networks | Access Point Names
  • Here you will find Telkila Internet, click on it.
  • In the "Edit access point" section, input the "proxy" and "port" Also provide the user/pass .. leave rest of the fields blank

if you're running emulator from eclipse:

from Window | Preferences | Android | Launch | Default Emulator Options then set there the following:

-http-proxy="http://user:pass@ip:port"

or open your project's run configuration (click on "Run as" | "Run Configuration") and edit its configuration in the "target" tab .. add the proxy in the field "Additional Emulator command line options"

using environment variables:

you could even set environment variable "http_proxy" if it is not working using param -http-param .. the emulator looks up the http_proxy environment variable and automatically uses

for more info, check the following

Community
  • 1
  • 1
Muhammad Soliman
  • 21,644
  • 6
  • 109
  • 75
  • The problem is that my conditions are, the emulator is already opened, change the proxy from time to time on the fly. Yes, the good solution would be to change proxy via menu "Edit access point" and it works well but it works only for browser and not for the other apps which ignore those proxy settings. The only way I can make all the apps on the emulator using the proxy is to launch the emulator via command line and with option -http-proxy, but my issue is where I can find those proxy settings and switch proxy on the fly on the same emulator – tuan dat nguyen Mar 29 '15 at 07:43
  • I can try to set the proxy via environment variable, and switch it on the fly to check if can still work with the new proxy. – tuan dat nguyen Mar 29 '15 at 07:48
  • Okay I got you now .. proxy settings are stored in settings database. you could try the following and update me if it's helpful for you $ adb shell $ sqlite3 /data/data/com.google.android.providers.settings/databases/settings.db sqlite> INSERT INTO system VALUES(99,’http_proxy', 'proxy:port'); sqlite>exit .. I will update the answer for better format – Muhammad Soliman Mar 29 '15 at 07:56
  • check section "using system's settings database" .. give it a try and update if is was helpful – Muhammad Soliman Mar 29 '15 at 08:04
  • yes, I try that, the proxy entry is added into the system database but browser and other apps seem to ignore those proxy settings. I will do further tests to confirm that. – tuan dat nguyen Mar 29 '15 at 08:23
  • I try all those solutions, none of them are working properly, the only way is to use option -http-proxy, either via command line or eclipse does not matter, as specified in the doc, all tcp connections use the proxy with this option. If you try to launch the emulator via command line the proxy settings are not stored in the system database of the emulator, I try to find it on the emulator but without success. I have the impression that is stored on my machine, I search on the folder of the avd, no success too, no idea where it can be stored :) – tuan dat nguyen Mar 29 '15 at 10:27
  • I was searching on the wrong direction with the option -http-option, sometimes I forget that android is also a linux box, thanks for your help. – tuan dat nguyen Mar 31 '15 at 04:03