@@ -8,21 +8,31 @@ if [ -f /data/android.avd/ramdisk.img ]; then
88 RAMDISK=" -ramdisk /data/android.avd/ramdisk.img"
99fi
1010
11- # Configure optional screen resolution and density
12- if [ -n " $SCREEN_RESOLUTION " ]; then
13- SCREEN_RESOLUTION_FLAG=" -skin $SCREEN_RESOLUTION "
14- fi
15- if [ -n " $SCREEN_DENSITY " ]; then
16- SCREEN_DENSITY_FLAG=" -dpi-device $SCREEN_DENSITY "
17- fi
11+ # Path to the AVD config
12+ CONFIG_FILE=" /data/android.avd/config.ini"
1813
19- # Configure optional screen resolution and density
20- if [ -n " $SCREEN_RESOLUTION " ]; then
21- SCREEN_RESOLUTION_FLAG=" -skin $SCREEN_RESOLUTION "
22- fi
23- if [ -n " $SCREEN_DENSITY " ]; then
24- SCREEN_DENSITY_FLAG=" -dpi-device $SCREEN_DENSITY "
14+ update_config () {
15+ local key=" $1 "
16+ local value=" $2 "
17+ if grep -q " ^$key =" " $CONFIG_FILE " ; then
18+ sed -i " s/^$key =.*/$key =$value /" " $CONFIG_FILE "
19+ else
20+ echo " $key =$value " >> " $CONFIG_FILE "
21+ fi
22+ }
23+
24+ # Configure optional screen resolution and density directly via config.ini
25+ if [ -f " $CONFIG_FILE " ]; then
26+ if [ -n " $SCREEN_RESOLUTION " ]; then
27+ WIDTH=${SCREEN_RESOLUTION% x* }
28+ HEIGHT=${SCREEN_RESOLUTION#* x}
29+ update_config " hw.lcd.width" " $WIDTH "
30+ update_config " hw.lcd.height" " $HEIGHT "
31+ fi
32+ if [ -n " $SCREEN_DENSITY " ]; then
33+ update_config " hw.lcd.density" " $SCREEN_DENSITY "
34+ fi
2535fi
2636
2737# Start the emulator with the appropriate ramdisk.img
28- /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}
38+ /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}
0 commit comments