Merge pull request #260 from yintro4ha/master

Able to add proxy user and password on Android emulator
This commit is contained in:
Budi Utomo 2020-08-27 12:56:15 +02:00 committed by GitHub
commit 2e5237ec80
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View file

@ -13,6 +13,15 @@ You can enable proxy inside container and Android emulator by passing following
- NO_PROXY="localhost"
- ENABLE_PROXY_ON_EMULATOR=true
Proxy with authentication
----
You can set proxy with authentication by passing following environment variable:
- HTTP_PROXY_USER="\<username>"
- HTTPS_PROXY_PASSWORD="\<password>"
Language
--------

View file

@ -53,6 +53,15 @@ function enable_proxy_if_needed () {
sleep 5
adb shell "content update --uri content://telephony/carriers --bind proxy:s:"${p[0]}" --bind port:s:"${p[1]}" --where "mcc=310" --where "mnc=260""
if [ ! -z "${HTTP_PROXY_USER}" ]; then
sleep 2
adb shell "content update --uri content://telephony/carriers --bind user:s:"${HTTP_PROXY_USER}" --where "mcc=310" --where "mnc=260""
fi
if [ ! -z "${HTTP_PROXY_PASSWORD}" ]; then
sleep 2
adb shell "content update --uri content://telephony/carriers --bind password:s:"${HTTP_PROXY_PASSWORD}" --where "mcc=310" --where "mnc=260""
fi
adb unroot
# Mobile data need to be restarted for Android 10 or higher