From 6be44c92d383d23e9edbdaf33f6b3b4ccf30e2fa Mon Sep 17 00:00:00 2001 From: Lerry Date: Thu, 5 May 2022 01:11:03 -0400 Subject: [PATCH 1/3] 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/3] 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 fcb6a21d00d2d05458a666cc230540287e85f577 Mon Sep 17 00:00:00 2001 From: Lerry Date: Fri, 23 Dec 2022 17:16:33 -0800 Subject: [PATCH 3/3] 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 ;;