MCPcopy
hub / github.com/budtmo/docker-android / __init__

Method __init__

cli/src/device/emulator.py:48–89  ·  view source on GitHub ↗
(self, name: str, device: str, android_version: str, data_partition: str,
                 additional_args: str, img_type: str, sys_img: str)

Source from the content-addressed store, hash-verified

46 POP_UP_WINDOW = "pop up window"
47
48 def __init__(self, name: str, device: str, android_version: str, data_partition: str,
49 additional_args: str, img_type: str, sys_img: str) -> None:
50 super().__init__()
51 self.logger = logging.getLogger(self.__class__.__name__)
52 self.adb_name = f"emulator-{Emulator.adb_name_id}"
53 self.device_type = DeviceType.EMULATOR.value
54 self.name = name
55 if device in self.DEVICE:
56 self.device = device
57 else:
58 raise RuntimeError(f"device '{device}' is not supported!")
59 if android_version in self.API_LEVEL.keys():
60 self.android_version = android_version
61 else:
62 raise RuntimeError(f"android version '{android_version}' is not supported!")
63 self.api_level = self.API_LEVEL[self.android_version]
64 self.data_partition = data_partition
65 self.additional_args = additional_args
66 self.img_type = img_type
67 self.sys_img = sys_img
68 workdir = get_env_value_or_raise(ENV.WORK_PATH)
69 self.path_device_profile_target = os.path.join(workdir, ".android", "devices.xml")
70 self.path_emulator = os.path.join(workdir, "emulator")
71 self.path_emulator_config = os.path.join(workdir, "emulator", "config.ini")
72 self.path_emulator_profiles = os.path.join(workdir, "docker-android", "mixins",
73 "configs", "devices", "profiles")
74 self.path_emulator_skins = os.path.join(workdir, "docker-android", "mixins",
75 "configs", "devices", "skins")
76 self.file_name = self.device.replace(" ", "_").lower()
77 self.no_skin = convert_str_to_bool(os.getenv(ENV.EMULATOR_NO_SKIN))
78 self.interval_after_booting = 15
79 Emulator.adb_name_id += 2
80 self.form_data.update({
81 self.form_field[Device.FORM_SCREEN_RESOLUTION]: f"{os.getenv(ENV.SCREEN_WIDTH)}x"
82 f"{os.getenv(ENV.SCREEN_HEIGHT)}x"
83 f"{os.getenv(ENV.SCREEN_DEPTH)}",
84 self.form_field[Device.FORM_EMU_DEVICE]: self.device,
85 self.form_field[Device.FORM_EMU_ANDROID_VERSION]: self.android_version,
86 self.form_field[Device.FORM_EMU_NO_SKIN]: self.no_skin,
87 self.form_field[Device.FORM_EMU_DATA_PARTITION]: self.data_partition,
88 self.form_field[Device.FORM_EMU_ADDITIONAL_ARGS]: self.additional_args
89 })
90
91 def is_initialized(self) -> bool:
92 import re

Callers

nothing calls this directly

Calls 2

get_env_value_or_raiseFunction · 0.90
convert_str_to_boolFunction · 0.90

Tested by

no test coverage detected