Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 24 additions & 14 deletions start-emulator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,31 @@ if [ -f /data/android.avd/ramdisk.img ]; then
RAMDISK="-ramdisk /data/android.avd/ramdisk.img"
fi

# Configure optional screen resolution and density
if [ -n "$SCREEN_RESOLUTION" ]; then
SCREEN_RESOLUTION_FLAG="-skin $SCREEN_RESOLUTION"
fi
if [ -n "$SCREEN_DENSITY" ]; then
SCREEN_DENSITY_FLAG="-dpi-device $SCREEN_DENSITY"
fi
# Path to the AVD config
CONFIG_FILE="/data/android.avd/config.ini"

# Configure optional screen resolution and density
if [ -n "$SCREEN_RESOLUTION" ]; then
SCREEN_RESOLUTION_FLAG="-skin $SCREEN_RESOLUTION"
fi
if [ -n "$SCREEN_DENSITY" ]; then
SCREEN_DENSITY_FLAG="-dpi-device $SCREEN_DENSITY"
update_config() {
local key="$1"
local value="$2"
if grep -q "^$key=" "$CONFIG_FILE"; then
sed -i "s/^$key=.*/$key=$value/" "$CONFIG_FILE"
else
echo "$key=$value" >> "$CONFIG_FILE"
fi
}

# Configure optional screen resolution and density directly via config.ini
if [ -f "$CONFIG_FILE" ]; then
if [ -n "$SCREEN_RESOLUTION" ]; then
WIDTH=${SCREEN_RESOLUTION%x*}
HEIGHT=${SCREEN_RESOLUTION#*x}
update_config "hw.lcd.width" "$WIDTH"
update_config "hw.lcd.height" "$HEIGHT"
fi
if [ -n "$SCREEN_DENSITY" ]; then
update_config "hw.lcd.density" "$SCREEN_DENSITY"
fi
fi

# Start the emulator with the appropriate ramdisk.img
/opt/android-sdk/emulator/emulator -avd android -nojni -netfast -writable-system -no-window -no-audio -no-boot-anim -skip-adb-auth -gpu swiftshader_indirect -no-snapshot -no-metrics $SCREEN_RESOLUTION_FLAG $SCREEN_DENSITY_FLAG $RAMDISK -qemu -m ${RAM_SIZE:-4096}
/opt/android-sdk/emulator/emulator -avd android -nojni -netfast -writable-system -no-window -no-audio -no-boot-anim -skip-adb-auth -gpu swiftshader_indirect -no-snapshot -no-metrics $RAMDISK -qemu -m ${RAM_SIZE:-4096}