Skip to content

Commit 0462a30

Browse files
committed
Clean up and fixes
1 parent f2ae4a6 commit 0462a30

4 files changed

Lines changed: 8 additions & 20 deletions

File tree

openandroidinstaller/installer_config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ def __init__(
7979
self.metadata = metadata
8080
self.requirements = requirements
8181
self.device_code = metadata.get("devicecode")
82-
self.alternative_device_code = self.device_code_mapping.get(
82+
inverted_mapping = dict(map(reversed, self.device_code_mapping.items()))
83+
self.alternative_device_code = inverted_mapping.get(
8384
self.device_code, self.device_code
8485
)
8586

openandroidinstaller/tooling.py

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -303,20 +303,6 @@ def heimdall_flash_recovery(bin_path: Path, recovery: str) -> bool:
303303
def search_device(platform: str, bin_path: Path) -> Optional[str]:
304304
"""Search for a connected device."""
305305
logger.info(f"Search devices on {platform} with {bin_path}...")
306-
# map some detected device codes to their real code.
307-
device_code_mapping = {
308-
# Sony issues
309-
"C6603": "yuga",
310-
# OnePlus issues
311-
"OnePlus6": "enchilada",
312-
"OnePlus6T": "fajita",
313-
"OnePlus7": "guacamoleb",
314-
"OnePlus7Pro": "guacamole",
315-
"OnePlus7T": "hotdogb",
316-
"OnePlus7TPro": "hotdog",
317-
"Nord": "avicii",
318-
"NordN200": "dre",
319-
}
320306
try:
321307
# read device properties
322308
if platform in ("linux", "darwin"):
@@ -348,7 +334,7 @@ def search_device(platform: str, bin_path: Path) -> Optional[str]:
348334
raise Exception(f"Unknown platform {platform}.")
349335
device_code = output.split("[")[-1].strip()[:-1].strip()
350336
logger.info(device_code)
351-
return device_code_mapping.get(device_code, device_code)
337+
return device_code
352338
except CalledProcessError:
353339
logger.error("Failed to detect a device.")
354340
return None

openandroidinstaller/views/select_view.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def build(self):
148148
"Download TWRP recovery",
149149
icon=icons.DOWNLOAD_OUTLINED,
150150
on_click=lambda _: webbrowser.open(
151-
f"https://dl.twrp.me/{self.state.config.metadata.get('devicecode')}"
151+
f"https://dl.twrp.me/{self.state.config.device_code}"
152152
),
153153
expand=True,
154154
),
@@ -164,7 +164,7 @@ def build(self):
164164
Text("Select an OS image:", style="titleSmall"),
165165
Markdown(
166166
f"""
167-
The image file should look something like `lineage-19.1-20221101-nightly-{self.state.config.metadata.get('devicecode')}-signed.zip`."""
167+
The image file should look something like `lineage-19.1-20221101-nightly-{self.state.config.device_code}-signed.zip`."""
168168
),
169169
Row(
170170
[
@@ -185,7 +185,7 @@ def build(self):
185185
Text("Select a TWRP recovery image:", style="titleSmall"),
186186
Markdown(
187187
f"""
188-
The recovery image should look something like `twrp-3.6.2_9-0-{self.state.config.metadata.get('devicecode')}.img`.
188+
The recovery image should look something like `twrp-3.7.0_12-0-{self.state.config.device_code}.img`.
189189
190190
**Note:** This tool **only supports TWRP recoveries**.""",
191191
extension_set="gitHubFlavored",

openandroidinstaller/views/start_view.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
from app_state import AppState
3838
from widgets import get_title
3939
from tooling import search_device
40+
from installer_config import InstallerConfig
4041

4142

4243
class StartView(BaseView):
@@ -224,7 +225,7 @@ def search_devices(self, e):
224225
self.continue_button.disabled = False
225226
self.bootloader_switch.disabled = False
226227
# overwrite the text field with the real name from the config
227-
self.device_name.value = f"{device_name} (code: {device_code})"
228+
self.device_name.value = f"{device_name} (code: {InstallerConfig.device_code_mapping.get(device_code, device_code)})"
228229
self.device_name.color = colors.GREEN
229230
else:
230231
# failed to load config

0 commit comments

Comments
 (0)