Skip to content

Commit 3e24422

Browse files
committed
Add a request device button if no config for the device code is found; improve logging in this case
1 parent 1ac4e7a commit 3e24422

File tree

3 files changed

+30
-14
lines changed

3 files changed

+30
-14
lines changed

openandroidinstaller/installer_config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ def from_file(cls, path):
7676
metadata = config["metadata"]
7777
requirements = config.get("requirements", None)
7878
else:
79-
logger.info("Validation of config failed.")
79+
logger.error(f"Validation of config at {path} failed.")
8080
return None
8181
except yaml.YAMLError as exc:
82-
logger.info(exc)
82+
logger.error(f"Loading the config from {path} failed with {exc}")
8383
return None
8484

8585
if raw_steps.get("unlock_bootloader") is not None:
@@ -137,7 +137,7 @@ def _load_config(device_code: str, config_path: Path) -> Optional[InstallerConfi
137137
logger.info(f"Config metadata: {config.metadata}.")
138138
return config
139139
else:
140-
logger.info(f"No device config found for {path}.")
140+
logger.info(f"No device config found for device code '{device_code}'.")
141141
return None
142142

143143

openandroidinstaller/tooling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ def search_device(platform: str, bin_path: Path) -> Optional[str]:
485485
else:
486486
raise Exception(f"Unknown platform {platform}.")
487487
device_code = output.split("[")[-1].strip()[:-1].strip()
488-
logger.info(device_code)
488+
logger.info(f"Found device code '{device_code}'")
489489
return device_code
490490
except CalledProcessError:
491491
logger.error("Failed to detect a device.")

openandroidinstaller/views/start_view.py

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# Author: Tobias Sterbak
1515

1616
import copy
17+
import webbrowser
1718
from loguru import logger
1819
from typing import Callable
1920

@@ -122,6 +123,13 @@ def check_bootloader_unlocked(e):
122123
self.device_detection_infobox = Row(
123124
[Text("Detected device:"), self.device_name]
124125
)
126+
self.device_request_row = Row([], alignment="center")
127+
self.device_infobox = Column(
128+
[
129+
self.device_detection_infobox,
130+
self.device_request_row,
131+
]
132+
)
125133

126134
def build(self):
127135
self.clear()
@@ -176,17 +184,13 @@ def build(self):
176184
),
177185
Row([self.bootloader_switch]),
178186
Divider(),
179-
Column(
180-
[
181-
self.device_detection_infobox,
182-
]
183-
),
187+
self.device_infobox,
184188
Row(
185189
[
186190
self.back_button,
187191
FilledButton(
188192
"Search for device",
189-
on_click=self.search_devices,
193+
on_click=self.search_devices_clicked,
190194
icon=icons.DEVICES_OTHER_OUTLINED,
191195
expand=True,
192196
tooltip="Search for a connected device.",
@@ -210,8 +214,9 @@ def close_developer_options_dlg(self, e):
210214
self.dlg_help_developer_options.open = False
211215
self.page.update()
212216

213-
def search_devices(self, e):
217+
def search_devices_clicked(self, e):
214218
"""Search the device when the button is clicked."""
219+
self.device_request_row.controls.clear()
215220
# search the device
216221
if self.state.test:
217222
# this only happens for testing
@@ -258,10 +263,21 @@ def search_devices(self, e):
258263
if len(self.state.config.unlock_bootloader) == 0:
259264
self.bootloader_switch.value = True
260265
else:
261-
# failed to load config
262-
logger.error(f"Failed to load config for {device_code}.")
266+
# failed to load config or device is not supported
267+
logger.error(
268+
f"Device with code '{device_code}' is not supported or the config is corrupted. Please check the logs for more information."
269+
)
263270
self.device_name.value = (
264-
f"Failed to load config for device with code {device_code}."
271+
f"Device with code '{device_code}' is not supported yet."
272+
)
273+
# add request support for device button
274+
request_url = f"https://github.com/openandroidinstaller-dev/openandroidinstaller/issues/new?assignees=&labels=device&projects=&template=device-support-request.md&title=Add support for {device_code}"
275+
self.device_request_row.controls.append(
276+
ElevatedButton(
277+
"Request support for this device",
278+
icon=icons.PHONELINK_SETUP_OUTLINED,
279+
on_click=lambda _: webbrowser.open(request_url),
280+
)
265281
)
266282
self.device_name.color = colors.RED
267283
self.view.update()

0 commit comments

Comments
 (0)