Skip to content

Commit 0d3b1ec

Browse files
committedDec 3, 2024·
Fix x86_64 Android AVD in Windows (#2471)
1 parent b75d209 commit 0d3b1ec

File tree

2 files changed

+38
-4
lines changed

2 files changed

+38
-4
lines changed
 

‎scripts/start_avd.ps1

+34-2
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,37 @@ if (-not $AVD_FOUND) {
5151
}
5252

5353
# Start the emulator with user-defined AVD and port
54-
Start-Process -FilePath $EMULATOR_PATH -ArgumentList "-avd $AVD_NAME -writable-system -no-snapshot -wipe-data -port $START_PORT"
55-
Write-Output "Emulator started with AVD $AVD_NAME on port $START_PORT."
54+
Start-Process -NoNewWindow -FilePath $EMULATOR_PATH -ArgumentList "-avd $AVD_NAME -writable-system -no-snapshot -wipe-data -port $START_PORT"
55+
Write-Output "Starting AVD $AVD_NAME on port $START_PORT."
56+
57+
# Wait for the emulator to boot completely
58+
Write-Output "Waiting for emulator to boot..."
59+
& $ADB_PATH wait-for-device
60+
Start-Sleep -Seconds 5
61+
Write-Output "Emulator booted successfully."
62+
63+
# Allow /system remount
64+
Write-Output "Restarting adb as root..."
65+
Start-Process -NoNewWindow -Wait -FilePath $ADB_PATH -ArgumentList "root"
66+
67+
Write-Output "Disabling AVB verification..."
68+
Start-Process -NoNewWindow -Wait -FilePath $ADB_PATH -ArgumentList "shell avbctl disable-verification"
69+
70+
Write-Output "Disabling verity..."
71+
Start-Process -NoNewWindow -Wait -FilePath $ADB_PATH -ArgumentList "disable-verity"
72+
73+
Write-Output "Restarting emulator..."
74+
Start-Process -NoNewWindow -Wait -FilePath $ADB_PATH -ArgumentList "reboot"
75+
76+
Write-Output "Waiting for emulator to reboot..."
77+
& $ADB_PATH wait-for-device
78+
Start-Sleep -Seconds 5
79+
Write-Output "Emulator rebooted successfully."
80+
81+
Write-Output "Restarting adb as root..."
82+
Start-Process -NoNewWindow -Wait -FilePath $ADB_PATH -ArgumentList "root"
83+
84+
Write-Output "Remounting the filesystem..."
85+
Start-Process -NoNewWindow -Wait -FilePath $ADB_PATH -ArgumentList "remount"
86+
87+
Write-Output "Emulator ready for Dynamic Analysis with MobSF."

‎scripts/start_avd.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ done
6666

6767
# Start the emulator with user-defined AVD and port
6868
"$EMULATOR_PATH" -avd "$AVD_NAME" -writable-system -no-snapshot -wipe-data -port "$START_PORT" >/dev/null 2>&1 &
69-
echo "$(tput setaf 2)Emulator AVD $AVD_NAME started on port $START_PORT$(tput sgr0)"
69+
echo "$(tput setaf 2)Starting AVD $AVD_NAME on port $START_PORT$(tput sgr0)"
70+
echo "Waiting for emulator to boot..."
71+
"$ADB_PATH" wait-for-device
7072

7173
# Check if socat is available only on Linux
7274
if [ "$(uname)" = "Linux" ]; then
@@ -124,7 +126,7 @@ if [ -n "$GAPPS_ZIP" ]; then
124126
tar -x --strip-components 2 -f $f -C $PLAY_EXTRACT_DIR || { echo "$(tput setaf 1)Error: Extraction failed$(tput sgr0)"; exit 1; }
125127
done
126128

127-
echo "Waiting for emulator to complete booting..."
129+
echo "Waiting for the emulator to be ready..."
128130
sleep 25
129131
echo "Installing PlayStore components"
130132
"$ADB_PATH" root

0 commit comments

Comments
 (0)
Please sign in to comment.