Skip to content

Commit

Permalink
feat(android-emulator): inject ANDROID_EMULATOR_CAMERA_IMAGE into bac…
Browse files Browse the repository at this point in the history
…k-camera scene

useful for QR code scanning

- add sane default android emulator user config
  • Loading branch information
legobeat committed Oct 11, 2024
1 parent 364b47c commit e9c727a
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 2 deletions.
1 change: 1 addition & 0 deletions compose/android.compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ services:
volumes:
- '${L7_XAUTHORITY_VOLUME:-desktop_x11_xauthority}:/etc/x11/xauthority'
- '${L7_X11_SOCKET_VOLUME:-desktop_x11_unix}:/tmp/.X11-unix'
- '${ANDROID_EMULATOR_CAMERA_IMAGE:-${PWD}/skel/.zsh/pure/screenshot.png}:/android-camera-image:ro'



11 changes: 11 additions & 0 deletions imags/android-emulator/AVD.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[perAvd]
battery\charge_level=100
loc\altitude=5
loc\heading=0
loc\latitude=37.422
loc\longitude=-122.084
loc\velocity=0
mic\available=false
set\enforceKeycodeForwarding=false
set\pauseAvdWhenMinimized=false
virtualscene\tv_animation=false
10 changes: 8 additions & 2 deletions imags/android-emulator/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,20 @@ ENV ANDROID_SDK_ROOT=/home/user/Android/Sdk


COPY docker-entrypoint.sh /usr/bin/docker-entrypoint.sh
COPY cameraimage.poster /tmp/cameraimage.poster
WORKDIR /home/user

ARG AVD_DEVICE_MODEL=pixel_5
RUN avdmanager create avd -n default -d "${AVD_DEVICE_MODEL}" -k "${ANDROID_IMAGE}"
ENV ANDROID_HOME=/home/user/Android/Sdk
ARG AVD_DEVICE_MODEL=pixel_5

RUN avdmanager create avd -n default -d "${AVD_DEVICE_MODEL}" -k "${ANDROID_IMAGE}" \
&& cat /tmp/cameraimage.poster >> ${ANDROID_HOME}/emulator/resources/Toren1BD.posters

ARG TARGETARCH="amd64"
ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-${TARGETARCH}
ENV PATH="/home/user/Android/Sdk/emulator:$PATH"
COPY AVD.conf /home/user/.android/avd/default.avd/AVD.conf
COPY ["Emulator.conf", "/home/user/.config/Android Open Source Project/Emulator.conf"]

WORKDIR /home/user
ENTRYPOINT ["/usr/bin/docker-entrypoint.sh"]
11 changes: 11 additions & 0 deletions imags/android-emulator/Emulator.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[General]
showVirtualSceneInfo=false

[set]
autoFindAdb=true
clipboardSharing=true
crashReportPreference=0
disableMouseWheel=false
disablePinchToZoom=false
savePath=/home/user/Desktop
theme=1
7 changes: 7 additions & 0 deletions imags/android-emulator/cameraimage.poster
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

poster custom
size 1 1
position 0.1 -0.1 -1.2
rotation 0 0 0
default /android-camera-image

22 changes: 22 additions & 0 deletions imags/android-emulator/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,33 @@ sh -c 'sleep 1; while true; do socat -s -d -lf /var/log/socat-5555.log TCP4-LIST

sh -c "sleep 1; adb connect ${ANDROID_EMULATOR_ADDRESS}:5557" &

#echo "
#poster custom
#size 1 1
#position 0.1 -0.1 -1.9
#rotation 0 0 0
#default /android-camera-image" >> /home/user/Android/Sdk/emulator/resources/Toren1BD.posters
#echo "
#poster custom
#size 2 2
#position 0 0 -1.8
#rotation 0 0 0
#default /android-camera-image" >> /home/user/Android/Sdk/emulator/resources/Toren1BD.posters

# echo "
#poster custom
#size 2 2
#position 0 0 -1.8
#rotation 0 0 0
#default ${ANDROID_EMULATOR_CAMERA_IMAGE}" >> /home/user/Android/Sdk/emulator/resources/Toren1BD.posters

#-no-window \
/home/user/Android/Sdk/emulator/emulator \
-avd default \
-no-boot-anim \
-camera-back virtualscene \
-gpu off \
-no-metrics \
-skip-adb-auth \
-delay-adb \
-no-audio \
Expand Down

0 comments on commit e9c727a

Please sign in to comment.