Enabled proxy on Android emulator
This commit is contained in:
parent
de073327af
commit
19e26a086b
|
@ -1,11 +1,12 @@
|
||||||
Proxy
|
Proxy
|
||||||
-----
|
-----
|
||||||
|
|
||||||
You can enable proxy inside container by passing following environment variables:
|
You can enable proxy inside container and Android emulator by passing following environment variables:
|
||||||
|
|
||||||
- HTTP_PROXY="\<docker\_bridge\_ip\_address>"
|
- HTTP_PROXY="http://\<docker\_bridge\_ip>:<port>"
|
||||||
- HTTPS_PROXY="\<docker\_bridge\_ip\_address>"
|
- HTTPS_PROXY=""http://\<docker\_bridge\_ip>:<port>"
|
||||||
- NO_PROXY="localhost"
|
- NO_PROXY="localhost"
|
||||||
|
- ENABLE_PROXY_ON_EMULATOR=true
|
||||||
|
|
||||||
Language
|
Language
|
||||||
--------
|
--------
|
||||||
|
|
|
@ -204,9 +204,9 @@ def run():
|
||||||
cfg.write('\ndisk.dataPartition.size={dp}'.format(dp=dp_size))
|
cfg.write('\ndisk.dataPartition.size={dp}'.format(dp=dp_size))
|
||||||
|
|
||||||
if is_first_run:
|
if is_first_run:
|
||||||
cmd = 'emulator/emulator @{name} -gpu swiftshader_indirect -accel on -wipe-data -verbose {custom_args}'.format(name=avd_name, custom_args=custom_args)
|
cmd = 'emulator/emulator @{name} -gpu swiftshader_indirect -accel on -wipe-data -writable-system -verbose {custom_args}'.format(name=avd_name, custom_args=custom_args)
|
||||||
else:
|
else:
|
||||||
cmd = 'emulator/emulator @{name} -gpu swiftshader_indirect -accel on -verbose {custom_args}'.format(name=avd_name, custom_args=custom_args)
|
cmd = 'emulator/emulator @{name} -gpu swiftshader_indirect -accel on -verbose -writable-system {custom_args}'.format(name=avd_name, custom_args=custom_args)
|
||||||
appium = convert_str_to_bool(str(os.getenv('APPIUM', False)))
|
appium = convert_str_to_bool(str(os.getenv('APPIUM', False)))
|
||||||
if appium:
|
if appium:
|
||||||
subprocess.Popen(cmd.split())
|
subprocess.Popen(cmd.split())
|
||||||
|
|
39
src/utils.sh
39
src/utils.sh
|
@ -38,6 +38,45 @@ function disable_animation () {
|
||||||
adb shell "settings put global animator_duration_scale 0.0"
|
adb shell "settings put global animator_duration_scale 0.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function enable_proxy_if_needed () {
|
||||||
|
if [ "$ENABLE_PROXY_ON_EMULATOR" = true ]; then
|
||||||
|
if [ ! -z "${HTTP_PROXY// }" ]; then
|
||||||
|
if [[ $HTTP_PROXY == *"http"* ]]; then
|
||||||
|
protocol="$(echo $HTTP_PROXY | grep :// | sed -e's,^\(.*://\).*,\1,g')"
|
||||||
|
proxy="$(echo ${HTTP_PROXY/$protocol/})"
|
||||||
|
echo "[EMULATOR] - Proxy: $proxy"
|
||||||
|
|
||||||
|
IFS=':' read -r -a p <<< "$proxy"
|
||||||
|
|
||||||
|
echo "[EMULATOR] - Proxy-IP: ${p[0]}"
|
||||||
|
echo "[EMULATOR] - Proxy-Port: ${p[1]}"
|
||||||
|
|
||||||
|
wait_emulator_to_be_ready
|
||||||
|
echo "Enable proxy on Android emulator. Please make sure that docker-container has internet access!"
|
||||||
|
adb root
|
||||||
|
|
||||||
|
echo "Mount system to read write access"
|
||||||
|
adb shell "mount -o rw,remount /system"
|
||||||
|
|
||||||
|
echo "Updateing Proxy"
|
||||||
|
|
||||||
|
adb shell "content update --uri content://telephony/carriers --bind proxy:s:"${p[0]}" --bind port:s:"${p[1]}" --where "mcc=310" --where "mnc=260""
|
||||||
|
|
||||||
|
echo "remount system back to read only"
|
||||||
|
adb shell "mount -o ro,remount /system"
|
||||||
|
adb unroot
|
||||||
|
else
|
||||||
|
echo "Please use http:// in the beginning!"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "$HTTP_PROXY is not given! Please pass it through environment variable!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
enable_proxy_if_needed
|
||||||
|
sleep 1
|
||||||
change_language_if_needed
|
change_language_if_needed
|
||||||
sleep 1
|
sleep 1
|
||||||
install_google_play
|
install_google_play
|
||||||
|
|
Loading…
Reference in a new issue