Refactoring the GPU acceleration implementation

This commit is contained in:
Halim Qarroum
2023-03-13 15:32:56 +00:00
parent c74049d77c
commit 7250977729
2 changed files with 15 additions and 8 deletions
+2 -1
View File
@@ -38,6 +38,7 @@ ARG IMG_TYPE=google_apis
ARG ARCHITECTURE=x86_64
ARG CMD_LINE_VERSION=9477386_latest
ARG DEVICE_ID=pixel
ARG GPU_ACCELERATED=false
# Environment variables.
ENV ANDROID_SDK_ROOT=/opt/android \
@@ -47,8 +48,8 @@ ENV ANDROID_SDK_ROOT=/opt/android \
DEVICE_ID=$DEVICE_ID \
ARCHITECTURE=$ARCHITECTURE \
ABI=${IMG_TYPE}/${ARCHITECTURE} \
GPU_ACCELERATED=$GPU_ACCELERATED \
QTWEBENGINE_DISABLE_SANDBOX=1 \
DISPLAY=:99 \
ANDROID_EMULATOR_WAIT_TIME_BEFORE_KILL=10
# Exporting environment variables for keeping in the path
+13 -7
View File
@@ -23,13 +23,21 @@ export USER=root
# Creating the Android Virtual Emulator.
echo "Creating the Android Virtual Emulator ..."
echo "Using package '$PACKAGE_PATH', ABI '$ABI' and device '$DEVICE_ID' for creating the emulator"
echo no | avdmanager create avd -n android --abi "$ABI" -k "$PACKAGE_PATH" --device "$DEVICE_ID"
echo no | avdmanager create avd -f -n android --abi "$ABI" -k "$PACKAGE_PATH" --device "$DEVICE_ID"
Xvfb "$DISPLAY" -screen 0 1920x1080x16 -nolisten tcp &
# If GPU acceleration is enabled, we create a virtual framebuffer
# to be used by the emulator when running with GPU acceleration.
if [ "$GPU_ACCELERATED" == "true" ]; then
echo "Running with GPU acceleration enabled"
export DISPLAY=":0.0"
export GPU_MODE="host"
Xvfb "$DISPLAY" -screen 0 1920x1080x16 -nolisten tcp &;
else
export GPU_MODE="auto"
fi
# Asynchronously write updates on the standard output
# about the state of the boot sequence.
#cat ~/.android/avd/android.avd/config.ini
wait_for_boot &
# Start the emulator with no audio, no GUI, and no snapshots.
@@ -37,9 +45,7 @@ echo "Starting the emulator ..."
emulator \
-verbose \
-avd android \
-gpu host \
-gpu "$GPU_MODE" \
-no-boot-anim \
-no-window \
-no-snapshot-save \
-qemu \
-enable-kvm || update_state "ANDROID_STOPPED"
-no-snapshot-save || update_state "ANDROID_STOPPED"