mirror of
https://github.com/budtmo/docker-android.git
synced 2026-07-31 04:07:25 +00:00
Compare commits
56
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
602dcf15a7 | ||
|
|
1dd79c6188 | ||
|
|
7abe6c19d8 | ||
|
|
eb91462bd4 | ||
|
|
ac251e7704 | ||
|
|
b997803064 | ||
|
|
88dbde577e | ||
|
|
a51e451a1f | ||
|
|
0f8d8eb98b | ||
|
|
97b3ca2c28 | ||
|
|
7b599fe7ea | ||
|
|
34846cd059 | ||
|
|
8df9081573 | ||
|
|
9f0c0dcfd2 | ||
|
|
e8186fb6bf | ||
|
|
f33fc1906c | ||
|
|
be3150f39f | ||
|
|
5688826f1a | ||
|
|
7064a9bc2c | ||
|
|
4e44e68946 | ||
|
|
2cb2bd6256 | ||
|
|
3af8eb3f48 | ||
|
|
55a628a673 | ||
|
|
667787bada | ||
|
|
cc5806bf71 | ||
|
|
db58150cf8 | ||
|
|
26206e43bd | ||
|
|
a0851223da | ||
|
|
1b05bfafdc | ||
|
|
e1ff20db98 | ||
|
|
df2dfbf6e1 | ||
|
|
03a6754869 | ||
|
|
99efbd21a5 | ||
|
|
05d3622c64 | ||
|
|
232ed8bbe6 | ||
|
|
20b1c6f71b | ||
|
|
4417553044 | ||
|
|
050144f8da | ||
|
|
5b25d2fb79 | ||
|
|
b5aa9c1290 | ||
|
|
7e8a082936 | ||
|
|
0eb43bee45 | ||
|
|
0702f34bd3 | ||
|
|
fbd31b9076 | ||
|
|
40864137ee | ||
|
|
c5cce78990 | ||
|
|
5002255cd8 | ||
|
|
f570984135 | ||
|
|
80e22c2b1c | ||
|
|
064e9c4f37 | ||
|
|
7db92991ab | ||
|
|
47eafe24e1 | ||
|
|
8875d83305 | ||
|
|
984f5ed69e | ||
|
|
a02375de57 | ||
|
|
363fc77b87 |
@@ -7,7 +7,7 @@ on:
|
||||
|
||||
jobs:
|
||||
run_test:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-24.04
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: ["3.8"]
|
||||
@@ -31,7 +31,7 @@ jobs:
|
||||
cd cli && nosetests -v
|
||||
|
||||
release_base:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-24.04
|
||||
needs: run_test
|
||||
steps:
|
||||
- name: Checkout the repo
|
||||
@@ -47,7 +47,7 @@ jobs:
|
||||
docker logout
|
||||
|
||||
release_emulator:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-24.04
|
||||
needs: release_base
|
||||
strategy:
|
||||
matrix:
|
||||
@@ -66,7 +66,7 @@ jobs:
|
||||
docker logout
|
||||
|
||||
release_genymotion:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-24.04
|
||||
needs: release_base
|
||||
steps:
|
||||
- name: Checkout the repo
|
||||
|
||||
@@ -10,7 +10,7 @@ on:
|
||||
|
||||
jobs:
|
||||
build_and_test:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout the repo
|
||||
uses: actions/checkout@v4
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
|
||||
Docker-Android is a docker image built to be used for everything related to Android. It can be used for Application development and testing (native, web and hybrid-app).
|
||||
|
||||
Advantages of using this projects
|
||||
---------------------------------
|
||||
Advantages of using this project
|
||||
--------------------------------
|
||||
1. Emulator with different device profile and skins, such as Samsung Galaxy S6, LG Nexus 4, HTC Nexus One and more.
|
||||
2. Support vnc to be able to see what happen inside docker container
|
||||
3. Support log sharing feature where all logs can be accessed from web-UI
|
||||
3. Support log sharing feature where all logs can be accessed from web-UI
|
||||
4. Ability to control emulator from outside container by using adb connect
|
||||
5. Integrated with other cloud solutions, e.g. [Genymotion Cloud](https://www.genymotion.com/cloud/)
|
||||
6. It can be used to build Android project
|
||||
@@ -45,6 +45,7 @@ Phone | Nexus 5
|
||||
Phone | Nexus One
|
||||
Phone | Nexus S
|
||||
Tablet | Nexus 7
|
||||
Tablet | Pixel C
|
||||
|
||||
Requirements
|
||||
------------
|
||||
@@ -74,6 +75,14 @@ Quick Start
|
||||
docker exec -it android-container cat device_status
|
||||
```
|
||||
|
||||
Persisting data
|
||||
-----------
|
||||
|
||||
The default behaviour is to destroy the emulated device on container restart. To persist data, you need to mount a volume at `/home/androidusr`:
|
||||
```
|
||||
docker run -v data:/home/androidusr budtmo/docker-android:emulator_11.0
|
||||
```
|
||||
|
||||
WSL2 Hardware acceleration (Windows 11 only)
|
||||
-----------
|
||||
|
||||
@@ -154,6 +163,7 @@ The differences between normal version and pro version are:
|
||||
|user-behavior-analytics|Yes|No|-|
|
||||
|proxy|No|Yes|Set up company proxy on Android emulator on fly|
|
||||
|language|No|Yes|Set up language on Android emulator on fly|
|
||||
|Newer Android version|No|Yes|Support other newer Android version e.g. Android 15, etc|
|
||||
|root-privileged|No|Yes|Able to run command with security privileged|
|
||||
|headless-mode|No|Yes|Save resources by using headless mode|
|
||||
|Selenium 4.x integration|No|Yes|Running Appium UI-Tests againt one (Selenium Hub) endpoint for Android- and iOS emulator(s) / device(s)|
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
autopep8==2.0.4
|
||||
click==8.1.7
|
||||
coverage==7.4.3
|
||||
mock==5.1.0
|
||||
autopep8==2.3.1
|
||||
click==8.1.8
|
||||
coverage==7.6.1
|
||||
mock==5.2.0
|
||||
nose==1.3.7
|
||||
requests==2.31.0
|
||||
requests==2.32.3
|
||||
|
||||
@@ -30,6 +30,7 @@ EMULATOR_IMG_TYPE = "EMULATOR_IMG_TYPE"
|
||||
EMULATOR_NAME = "EMULATOR_NAME"
|
||||
EMULATOR_NO_SKIN = "EMULATOR_NO_SKIN"
|
||||
EMULATOR_SYS_IMG = "EMULATOR_SYS_IMG"
|
||||
EMULATOR_CONFIG_PATH = "EMULATOR_CONFIG_PATH"
|
||||
|
||||
# Device (Genymotion - General)
|
||||
GENYMOTION_TEMPLATE_PATH = "GENYMOTION_TEMPLATE_PATH"
|
||||
|
||||
@@ -22,7 +22,8 @@ class Emulator(Device):
|
||||
"Samsung Galaxy S7 Edge",
|
||||
"Samsung Galaxy S8",
|
||||
"Samsung Galaxy S9",
|
||||
"Samsung Galaxy S10"
|
||||
"Samsung Galaxy S10",
|
||||
"Pixel C"
|
||||
)
|
||||
|
||||
API_LEVEL = {
|
||||
@@ -107,6 +108,30 @@ class Emulator(Device):
|
||||
symlink_force(path_device_profile_source, self.path_device_profile_target)
|
||||
self.logger.info("Samsung device profile is linked")
|
||||
|
||||
def _use_override_config(self) -> None:
|
||||
override_confg_path = os.getenv(ENV.EMULATOR_CONFIG_PATH)
|
||||
|
||||
if override_confg_path is None:
|
||||
self.logger.info(f"The environment variable 'EMULATOR_CONFIG_PATH' is not set")
|
||||
return
|
||||
|
||||
self.logger.info(f"Environment variable 'EMULATOR_CONFIG_PATH' found: {override_confg_path}")
|
||||
|
||||
if not os.path.isfile(override_confg_path):
|
||||
self.logger.warning(f"Source file '{override_confg_path}' does not exist.")
|
||||
return
|
||||
|
||||
if not os.access(override_confg_path, os.R_OK):
|
||||
self.logger.warning(f"Source file '{override_confg_path}' is not readable.")
|
||||
return
|
||||
|
||||
try:
|
||||
with open(override_confg_path, 'r') as src, open(self.path_emulator_config, 'a') as dst:
|
||||
dst.write(src.read())
|
||||
self.logger.info(f"Content from '{override_confg_path}' successfully appended to '{self.path_emulator_config}'.")
|
||||
except Exception as e:
|
||||
self.logger.error(f"An error occurred while copying file content: {e}")
|
||||
|
||||
def _add_skin(self) -> None:
|
||||
device_skin_path = os.path.join(
|
||||
self.path_emulator_skins, "{fn}".format(fn=self.file_name))
|
||||
@@ -131,6 +156,7 @@ class Emulator(Device):
|
||||
self.logger.info(f"Command to create emulator: '{creation_cmd}'")
|
||||
subprocess.check_call(creation_cmd, shell=True)
|
||||
self._add_skin()
|
||||
self._use_override_config()
|
||||
self.logger.info(f"{self.device_type} is created!")
|
||||
|
||||
def change_permission(self) -> None:
|
||||
|
||||
@@ -56,20 +56,23 @@ class TestEmulator(BaseDeviceTest):
|
||||
@mock.patch("src.device.emulator.Emulator._add_profile")
|
||||
@mock.patch("subprocess.check_call")
|
||||
@mock.patch("src.device.emulator.Emulator._add_skin")
|
||||
@mock.patch("src.device.emulator.Emulator._use_override_config")
|
||||
@mock.patch("src.device.emulator.Emulator.is_initialized", mock.MagicMock(return_value=False))
|
||||
def test_create_device_not_exist(self, mocked_status, mocked_profile, mocked_subprocess, mocked_skin):
|
||||
def test_create_device_not_exist(self, mocked_status, mocked_profile, mocked_subprocess, mocked_skin, mocked_override_config):
|
||||
self.emu.create()
|
||||
self.assertEqual(mocked_status.called, True)
|
||||
self.assertEqual(mocked_profile.called, True)
|
||||
self.assertEqual(mocked_subprocess.called, True)
|
||||
self.assertEqual(mocked_skin.called, True)
|
||||
self.assertEqual(mocked_override_config.called, True)
|
||||
|
||||
@mock.patch("src.device.Device.set_status")
|
||||
@mock.patch("src.device.emulator.Emulator._add_profile")
|
||||
@mock.patch("subprocess.check_call")
|
||||
@mock.patch("src.device.emulator.Emulator._add_skin")
|
||||
@mock.patch("src.device.emulator.Emulator._use_override_config")
|
||||
@mock.patch("src.device.emulator.Emulator.is_initialized", mock.MagicMock(return_value=True))
|
||||
def test_create_device_exists(self, mocked_status, mocked_profile, mocked_subprocess, mocked_skin):
|
||||
def test_create_device_exists(self, mocked_status, mocked_profile, mocked_subprocess, mocked_skin, mocked_override_config):
|
||||
self.emu.create()
|
||||
self.assertEqual(mocked_status.called, False)
|
||||
self.assertEqual(mocked_profile.called, False)
|
||||
@@ -85,3 +88,25 @@ class TestEmulator(BaseDeviceTest):
|
||||
with self.assertRaises(RuntimeError):
|
||||
self.emu.check_adb_command(
|
||||
self.emu.ReadinessCheck.BOOTED, "mocked_command", "1", 3, 0)
|
||||
|
||||
def test_use_override_config_no_env(self):
|
||||
with mock.patch("os.getenv", return_value=None):
|
||||
self.emu._use_override_config()
|
||||
|
||||
def test_use_override_config_file_not_exist(self):
|
||||
with mock.patch("os.getenv", return_value="mock/path/to/config"):
|
||||
with mock.patch("os.path.isfile", return_value=False):
|
||||
self.emu._use_override_config()
|
||||
|
||||
def test_use_override_config_file_not_readable(self):
|
||||
with mock.patch("os.getenv", return_value="mock/path/to/config"):
|
||||
with mock.patch("os.path.isfile", return_value=True):
|
||||
with mock.patch("os.access", return_value=False):
|
||||
self.emu._use_override_config()
|
||||
|
||||
def test_use_override_config_malformed_content(self):
|
||||
with mock.patch("os.getenv", return_value="mock/path/to/config"):
|
||||
with mock.patch("os.path.isfile", return_value=True):
|
||||
with mock.patch("os.access", return_value=True):
|
||||
with mock.patch("builtins.open", mock.mock_open(read_data="malformed data")):
|
||||
self.emu._use_override_config()
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
FROM appium/appium:v2.5.1-p0
|
||||
FROM appium/appium:v2.18.0-p0
|
||||
|
||||
LABEL maintainer "Budi Utomo <budtmo.os@gmail.com>"
|
||||
|
||||
|
||||
@@ -99,6 +99,8 @@ ENV LOG_PATH=${WORK_PATH}/logs \
|
||||
WEB_LOG_PORT=9000
|
||||
EXPOSE 9000
|
||||
RUN mkdir -p ${LOG_PATH}
|
||||
RUN mkdir -p "${WORK_PATH}/.config/Android Open Source Project" \
|
||||
&& echo "[General]\nshowNestedWarning=false\n" > "${WORK_PATH}/.config/Android Open Source Project/Emulator.conf"
|
||||
|
||||
#=========
|
||||
# Run App
|
||||
|
||||
@@ -57,5 +57,18 @@ Possible environment variable to configure the Emulator:
|
||||
|
||||
The user can also pass needed arguments to android emulator through environment variable ***EMULATOR_ADDITIONAL_ARGS***. Please check [this page](https://developer.android.com/studio/run/emulator-commandline) for possible arguments that can be passed.
|
||||
|
||||
EMULATOR - OVERRIDE CONFIG FILE
|
||||
-------------------------------
|
||||
|
||||
To utilize this feature, ensure the following setup:
|
||||
|
||||
- Set the config file path into environment variable EMULATOR_CONFIG_PATH, eg. `/tmp/emulator-override-config.ini` (the file name doesn't matter)
|
||||
- Mount the file as Docker volume (parameter `-v` for Docker run command) to the path as you set into ENV
|
||||
|
||||
Example:
|
||||
|
||||
```shell
|
||||
docker run -d -p 6080:6080 -e /tmp/emulator-override-config.ini -v /path/on/your/machine/emulator-override-config.ini:/tmp/emulator-override-config.ini -e EMULATOR_DEVICE="Samsung Galaxy S10" -e WEB_VNC=true --device /dev/kvm --name android-container budtmo/docker-android:emulator_14.0
|
||||
```
|
||||
|
||||
[<- BACK TO README](../README.md)
|
||||
|
||||
@@ -28,12 +28,14 @@ List of Docker-Images
|
||||
|12.0|32|Normal|budtmo2/docker-android-pro:emulator_12.0|budtmo2/docker-android-pro:emulator_12.0_<release_version>|
|
||||
|13.0|33|Normal|budtmo2/docker-android-pro:emulator_13.0|budtmo2/docker-android-pro:emulator_13.0_<release_version>|
|
||||
|14.0|34|Normal|budtmo2/docker-android-pro:emulator_14.0|budtmo2/docker-android-pro:emulator_14.0_<release_version>|
|
||||
|15.0|35|Normal|budtmo2/docker-android-pro:emulator_15.0|budtmo2/docker-android-pro:emulator_15.0_<release_version>|
|
||||
|9.0|28|Headless|budtmo2/docker-android-pro:emulator_headless_9.0|budtmo2/docker-android-pro:emulator_headless_9.0_<release_version>|
|
||||
|10.0|29|Headless|budtmo2/docker-android-pro:emulator_headless_10.0|budtmo2/docker-android-pro:emulator_headless_10.0_<release_version>|
|
||||
|11.0|30|Headless|budtmo2/docker-android-pro:emulator_headless_11.0|budtmo2/docker-android-pro:emulator_headless_11.0_<release_version>|
|
||||
|12.0|32|Headless|budtmo2/docker-android-pro:emulator_headless_12.0|budtmo2/docker-android-pro:emulator_headless_12.0_<release_version>|
|
||||
|13.0|33|Headless|budtmo2/docker-android-pro:emulator_headless_13.0|budtmo2/docker-android-pro:emulator_headless_13.0_<release_version>|
|
||||
|14.0|34|Headless|budtmo2/docker-android-pro:emulator_headless_14.0|budtmo2/docker-android-pro:emulator_headless_14.0_<release_version>|
|
||||
|15.0|35|Headless|budtmo2/docker-android-pro:emulator_headless_15.0|budtmo2/docker-android-pro:emulator_headless_15.0_<release_version>|
|
||||
|-|-|Selenium|budtmo2/docker-android-pro:selenium|budtmo2/docker-android-pro:selenium_<release_version>|
|
||||
|
||||
***Note: Headless mode does not have any Web-UI***
|
||||
@@ -57,6 +59,7 @@ Phone | Nexus 5
|
||||
Phone | Nexus One
|
||||
Phone | Nexus S
|
||||
Tablet | Nexus 7
|
||||
Tablet | Pixel C
|
||||
|
||||
|
||||
Proxy
|
||||
|
||||
Reference in New Issue
Block a user