From 6be44c92d383d23e9edbdaf33f6b3b4ccf30e2fa Mon Sep 17 00:00:00 2001 From: Lerry Date: Thu, 5 May 2022 01:11:03 -0400 Subject: [PATCH 1/5] Fixing 'System UI not responding' popup message appearing on newest android versions --- src/utils.sh | 78 ++++++++++++++++++++++++++++++++++++++++++++++-- supervisord.conf | 2 +- 2 files changed, 76 insertions(+), 4 deletions(-) diff --git a/src/utils.sh b/src/utils.sh index eed4b56..ab1fc62 100755 --- a/src/utils.sh +++ b/src/utils.sh @@ -10,7 +10,7 @@ function wait_emulator_to_be_ready () { boot_completed=true else sleep 1 - fi + fi done } @@ -52,7 +52,7 @@ function enable_proxy_if_needed () { adb shell "content update --uri content://telephony/carriers --bind proxy:s:"0.0.0.0" --bind port:s:"0000" --where "mcc=310" --where "mnc=260"" 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"" @@ -61,7 +61,7 @@ function enable_proxy_if_needed () { 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 @@ -77,8 +77,80 @@ function enable_proxy_if_needed () { fi } +function change_emulator_ram_size() { + echo '-------------------------------------------------' + echo 'Changing emulator ram size for better performance' + echo '-------------------------------------------------' + sed '/^hw.ramSize /s/=.*$/= 4096/' /root/android_emulator/hardware-qemu.ini + echo '-------------------------------------------------' + echo 'Emulator ram size changed to 4096' + echo '-------------------------------------------------' +} + +function check_emulator_popups() { + echo "Waiting for device..." + wait_emulator_to_be_ready + $ANDROID_HOME/platform-tools/adb wait-for-device shell true + + EMU_BOOTED=0 + n=0 + first_launcher=1 + echo 1 > /tmp/failed + while [[ $EMU_BOOTED = 0 ]];do + echo "Test for current focus" + CURRENT_FOCUS=`$ANDROID_HOME/platform-tools/adb shell dumpsys window 2>/dev/null | grep -i mCurrentFocus` + echo "Current focus: ${CURRENT_FOCUS}" + case $CURRENT_FOCUS in + *"Launcher"*) + if [[ $first_launcher == 1 ]]; then + echo "Launcher seems to be ready, wait 10 sec for another popup..." + sleep 10 + first_launcher=0 + else + echo "Launcher is ready, Android boot completed" + EMU_BOOTED=1 + rm /tmp/failed + fi + ;; + *"Not Responding: com.android.systemui"*) + echo "Dismiss System UI isn't responding alert" + change_emulator_ram_size + adb shell su root 'kill $(pidof com.android.systemui)' + first_launcher=1 + ;; + *"Not Responding: com.google.android.gms"*) + echo "Dismiss GMS isn't responding alert" + adb shell input keyevent KEYCODE_ENTER + first_launcher=1 + ;; + *"Not Responding: system"*) + echo "Dismiss Process system isn't responding alert" + adb shell input keyevent KEYCODE_ENTER + first_launcher=1 + ;; + *"ConversationListActivity"*) + echo "Close Messaging app" + adb shell input keyevent KEYCODE_ENTER + first_launcher=1 + ;; + *) + n=$((n + 1)) + echo "Waiting Android to boot 10 sec ($n)..." + sleep 10 + if [ $n -gt 60 ]; then + echo "Android Emulator does not start in 10 minutes" + exit 2 + fi + ;; + esac + done + echo "Android Emulator started." +} + change_language_if_needed sleep 1 enable_proxy_if_needed sleep 1 install_google_play +sleep 1 +check_emulator_popups diff --git a/supervisord.conf b/supervisord.conf index 63a6b10..d1bd32b 100644 --- a/supervisord.conf +++ b/supervisord.conf @@ -64,7 +64,7 @@ stderr_logfile=%(ENV_LOG_PATH)s/video-recording.stderr.log priority=4 [program:adb-utils] -command=./src/utils.sh +command=bash ./src/utils.sh autorestart=false stdout_logfile=%(ENV_LOG_PATH)s/adb-utils.stdout.log stderr_logfile=%(ENV_LOG_PATH)s/adb-utils.stderr.log From 607f9de6b46001dede858c9eccddd479f7170c14 Mon Sep 17 00:00:00 2001 From: Lerry Date: Fri, 6 May 2022 00:45:47 -0400 Subject: [PATCH 2/5] Fixing 'System UI not responding' popup message appearing on newest android versions (indenting code) --- src/utils.sh | 124 +++++++++++++++++++++++++-------------------------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/src/utils.sh b/src/utils.sh index ab1fc62..c712900 100755 --- a/src/utils.sh +++ b/src/utils.sh @@ -78,73 +78,73 @@ function enable_proxy_if_needed () { } function change_emulator_ram_size() { - echo '-------------------------------------------------' - echo 'Changing emulator ram size for better performance' - echo '-------------------------------------------------' - sed '/^hw.ramSize /s/=.*$/= 4096/' /root/android_emulator/hardware-qemu.ini - echo '-------------------------------------------------' - echo 'Emulator ram size changed to 4096' - echo '-------------------------------------------------' + echo '-------------------------------------------------' + echo 'Changing emulator ram size for better performance' + echo '-------------------------------------------------' + sed '/^hw.ramSize /s/=.*$/= 4096/' /root/android_emulator/hardware-qemu.ini + echo '-------------------------------------------------' + echo 'Emulator ram size changed to 4096' + echo '-------------------------------------------------' } function check_emulator_popups() { - echo "Waiting for device..." - wait_emulator_to_be_ready - $ANDROID_HOME/platform-tools/adb wait-for-device shell true + echo "Waiting for device..." + wait_emulator_to_be_ready + $ANDROID_HOME/platform-tools/adb wait-for-device shell true - EMU_BOOTED=0 - n=0 + EMU_BOOTED=0 + n=0 + first_launcher=1 + echo 1 > /tmp/failed + while [[ $EMU_BOOTED = 0 ]];do + echo "Test for current focus" + CURRENT_FOCUS=`$ANDROID_HOME/platform-tools/adb shell dumpsys window 2>/dev/null | grep -i mCurrentFocus` + echo "Current focus: ${CURRENT_FOCUS}" + case $CURRENT_FOCUS in + *"Launcher"*) + if [[ $first_launcher == 1 ]]; then + echo "Launcher seems to be ready, wait 10 sec for another popup..." + sleep 10 + first_launcher=0 + else + echo "Launcher is ready, Android boot completed" + EMU_BOOTED=1 + rm /tmp/failed + fi + ;; + *"Not Responding: com.android.systemui"*) + echo "Dismiss System UI isn't responding alert" + change_emulator_ram_size + adb shell su root 'kill $(pidof com.android.systemui)' first_launcher=1 - echo 1 > /tmp/failed - while [[ $EMU_BOOTED = 0 ]];do - echo "Test for current focus" - CURRENT_FOCUS=`$ANDROID_HOME/platform-tools/adb shell dumpsys window 2>/dev/null | grep -i mCurrentFocus` - echo "Current focus: ${CURRENT_FOCUS}" - case $CURRENT_FOCUS in - *"Launcher"*) - if [[ $first_launcher == 1 ]]; then - echo "Launcher seems to be ready, wait 10 sec for another popup..." - sleep 10 - first_launcher=0 - else - echo "Launcher is ready, Android boot completed" - EMU_BOOTED=1 - rm /tmp/failed - fi - ;; - *"Not Responding: com.android.systemui"*) - echo "Dismiss System UI isn't responding alert" - change_emulator_ram_size - adb shell su root 'kill $(pidof com.android.systemui)' - first_launcher=1 - ;; - *"Not Responding: com.google.android.gms"*) - echo "Dismiss GMS isn't responding alert" - adb shell input keyevent KEYCODE_ENTER - first_launcher=1 - ;; - *"Not Responding: system"*) - echo "Dismiss Process system isn't responding alert" - adb shell input keyevent KEYCODE_ENTER - first_launcher=1 - ;; - *"ConversationListActivity"*) - echo "Close Messaging app" - adb shell input keyevent KEYCODE_ENTER - first_launcher=1 - ;; - *) - n=$((n + 1)) - echo "Waiting Android to boot 10 sec ($n)..." - sleep 10 - if [ $n -gt 60 ]; then - echo "Android Emulator does not start in 10 minutes" - exit 2 - fi - ;; - esac - done - echo "Android Emulator started." + ;; + *"Not Responding: com.google.android.gms"*) + echo "Dismiss GMS isn't responding alert" + adb shell input keyevent KEYCODE_ENTER + first_launcher=1 + ;; + *"Not Responding: system"*) + echo "Dismiss Process system isn't responding alert" + adb shell input keyevent KEYCODE_ENTER + first_launcher=1 + ;; + *"ConversationListActivity"*) + echo "Close Messaging app" + adb shell input keyevent KEYCODE_ENTER + first_launcher=1 + ;; + *) + n=$((n + 1)) + echo "Waiting Android to boot 10 sec ($n)..." + sleep 10 + if [ $n -gt 60 ]; then + echo "Android Emulator does not start in 10 minutes" + exit 2 + fi + ;; + esac + done + echo "Android Emulator started." } change_language_if_needed From 3ea820cd9903a48d1164a67495780ca9dd748158 Mon Sep 17 00:00:00 2001 From: budtmo Date: Fri, 19 Aug 2022 16:31:05 +0200 Subject: [PATCH 3/5] Using newest base image 1.22.3-p1 --- docker/Emulator_x86 | 2 +- docker/Genymotion | 2 +- docker/Real_device | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docker/Emulator_x86 b/docker/Emulator_x86 index 67b3cc6..0e86ae3 100644 --- a/docker/Emulator_x86 +++ b/docker/Emulator_x86 @@ -1,4 +1,4 @@ -FROM appium/appium:v1.22.3-p0 +FROM appium/appium:v1.22.3-p1 LABEL maintainer "Budi Utomo " diff --git a/docker/Genymotion b/docker/Genymotion index 81ceb56..4d3ac6a 100644 --- a/docker/Genymotion +++ b/docker/Genymotion @@ -1,4 +1,4 @@ -FROM appium/appium:v1.22.3-p0 +FROM appium/appium:v1.22.3-p1 LABEL maintainer "Budi Utomo " diff --git a/docker/Real_device b/docker/Real_device index 60a46f8..55afbc2 100644 --- a/docker/Real_device +++ b/docker/Real_device @@ -1,4 +1,4 @@ -FROM appium/appium:v1.22.3-p0 +FROM appium/appium:v1.22.3-p1 LABEL maintainer "Budi Utomo " From d436eb36c130d0c4b347c07a492e680de052a914 Mon Sep 17 00:00:00 2001 From: budtmo Date: Fri, 19 Aug 2022 20:33:19 +0200 Subject: [PATCH 4/5] Removed ATD and cleaned up the code because of ANDROID_HOME --- README_CUSTOM_CONFIG.md | 5 ----- docker/Emulator_x86 | 4 ++-- docker/Genymotion | 2 +- src/app.py | 8 ++++---- src/atd.sh | 6 ------ supervisord.conf | 7 ------- 6 files changed, 7 insertions(+), 25 deletions(-) delete mode 100755 src/atd.sh diff --git a/README_CUSTOM_CONFIG.md b/README_CUSTOM_CONFIG.md index 4a721f2..07cb0b1 100644 --- a/README_CUSTOM_CONFIG.md +++ b/README_CUSTOM_CONFIG.md @@ -63,11 +63,6 @@ If you want to add more arguments for running emulator, you can ***pass an envir docker run --privileged -d -p 6080:6080 -p 4723:4723 -p 5554:5554 -p 5555:5555 -e DEVICE="Samsung Galaxy S6" -e EMULATOR_ARGS="-no-snapshot-load -partition-size 512" --name android-container budtmo/docker-android-x86-8.1 ``` -Appium Test Distribution (ATD) ------------------------------- - -You can enable [ATD](https://github.com/AppiumTestDistribution/AppiumTestDistribution) by passing environment variable ATD=true and bind the port to the host, e.g. -p 4567:4567 - SaltStack --------- diff --git a/docker/Emulator_x86 b/docker/Emulator_x86 index 0e86ae3..2ebfd1d 100644 --- a/docker/Emulator_x86 +++ b/docker/Emulator_x86 @@ -183,7 +183,7 @@ EXPOSE 4723 6080 5554 5555 #====================== # Add Emulator Devices #====================== -COPY devices /root/devices +COPY devices ${ANDROID_HOME}/devices #=================== # Run docker-appium @@ -195,6 +195,6 @@ RUN chmod -R +x /root/src && chmod +x /root/supervisord.conf HEALTHCHECK --interval=2s --timeout=40s --retries=1 \ CMD timeout 40 adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done' -RUN ln -s /root/emulator/emulator /usr/bin/ +RUN ln -s ${ANDROID_HOME}/emulator/emulator /usr/bin/ CMD /usr/bin/supervisord --configuration supervisord.conf diff --git a/docker/Genymotion b/docker/Genymotion index 4d3ac6a..f3c2591 100644 --- a/docker/Genymotion +++ b/docker/Genymotion @@ -168,5 +168,5 @@ EXPOSE 4723 6080 5555 COPY src /root/src COPY supervisord.conf /root/ RUN chmod -R +x /root/src && chmod +x /root/supervisord.conf /root/geny_start.sh -RUN gmsaas config set android-sdk-path /root +RUN gmsaas config set android-sdk-path ${ANDROID_HOME} CMD ["./geny_start.sh"] diff --git a/src/app.py b/src/app.py index b853e3f..2177882 100644 --- a/src/app.py +++ b/src/app.py @@ -98,12 +98,12 @@ def prepare_avd(device: str, avd_name: str, dp_size: str): profile_dst_path = os.path.join(ROOT, '.android', 'devices.xml') if 'samsung' in device.lower(): # profile file name = skin name - profile_src_path = os.path.join(ROOT, 'devices', 'profiles', '{profile}.xml'.format(profile=skin_name)) + profile_src_path = os.path.join(ANDROID_HOME, 'devices', 'profiles', '{profile}.xml'.format(profile=skin_name)) logger.info('Hardware profile resource path: {rsc}'.format(rsc=profile_src_path)) logger.info('Hardware profile destination path: {dst}'.format(dst=profile_dst_path)) symlink_force(profile_src_path, profile_dst_path) - avd_path = '/'.join([ANDROID_HOME, 'android_emulator']) + avd_path = '/'.join([ROOT, 'android_emulator']) creation_cmd = 'avdmanager create avd -f -n {name} -b {img_type}/{sys_img} -k "system-images;android-{api_lvl};' \ '{img_type};{sys_img}" -d {device} -p {path}'.format(name=avd_name, img_type=IMG_TYPE, sys_img=SYS_IMG, @@ -226,10 +226,10 @@ def run(): if is_first_run: logger.info('Emulator was not previously initialized. Preparing a new one...') - cmd = 'emulator/emulator @{name} -gpu swiftshader_indirect -accel on -wipe-data -writable-system -verbose {custom_args}'.format(name=avd_name, custom_args=custom_args) + cmd = 'emulator @{name} -gpu swiftshader_indirect -accel on -wipe-data -writable-system -verbose {custom_args}'.format(name=avd_name, custom_args=custom_args) else: logger.info('Using previously initialized AVD...') - cmd = 'emulator/emulator @{name} -gpu swiftshader_indirect -accel on -verbose -writable-system {custom_args}'.format(name=avd_name, custom_args=custom_args) + cmd = '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))) if appium: diff --git a/src/atd.sh b/src/atd.sh deleted file mode 100755 index 35111d7..0000000 --- a/src/atd.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -if [ "$ATD" = true ]; then - echo "Starting ATD..." - java -jar /root/RemoteAppiumManager.jar -DPort=4567 -fi diff --git a/supervisord.conf b/supervisord.conf index 63a6b10..e1a5c65 100644 --- a/supervisord.conf +++ b/supervisord.conf @@ -42,13 +42,6 @@ stdout_logfile=%(ENV_LOG_PATH)s/screen-copy.stdout.log stderr_logfile=%(ENV_LOG_PATH)s/screen-copy.stderr.log priority=3 -[program:atd] -command=./src/atd.sh -autorestart=false -stdout_logfile=%(ENV_LOG_PATH)s/atd.stdout.log -stderr_logfile=%(ENV_LOG_PATH)s/atd.stderr.log -priority=4 - [program:docker-appium] command=./src/appium.sh autorestart=false From fcb6a21d00d2d05458a666cc230540287e85f577 Mon Sep 17 00:00:00 2001 From: Lerry Date: Fri, 23 Dec 2022 17:16:33 -0800 Subject: [PATCH 5/5] removing function change_emulator_ram_size since it's not necessary anymore --- src/utils.sh | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/utils.sh b/src/utils.sh index c712900..e29b5b3 100755 --- a/src/utils.sh +++ b/src/utils.sh @@ -77,16 +77,6 @@ function enable_proxy_if_needed () { fi } -function change_emulator_ram_size() { - echo '-------------------------------------------------' - echo 'Changing emulator ram size for better performance' - echo '-------------------------------------------------' - sed '/^hw.ramSize /s/=.*$/= 4096/' /root/android_emulator/hardware-qemu.ini - echo '-------------------------------------------------' - echo 'Emulator ram size changed to 4096' - echo '-------------------------------------------------' -} - function check_emulator_popups() { echo "Waiting for device..." wait_emulator_to_be_ready @@ -114,7 +104,6 @@ function check_emulator_popups() { ;; *"Not Responding: com.android.systemui"*) echo "Dismiss System UI isn't responding alert" - change_emulator_ram_size adb shell su root 'kill $(pidof com.android.systemui)' first_launcher=1 ;;