Skip to content

Commit f77f065

Browse files
authored
Add a requirements view to inform and check requirements (#39)
This PR adds: - another step for checking requirements and get them from config - restructure the welcome page
2 parents 674278b + 58b093b commit f77f065

11 files changed

Lines changed: 284 additions & 68 deletions

File tree

openandroidinstaller/app_state.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,6 @@ def load_config(self, device_code: str):
6666
def increment_progressbar(self):
6767
"""Increment the progressbar and step counter."""
6868
self.progressbar.value = (self.num_steps - 1) / (
69-
self.num_total_steps + 2
69+
self.num_total_steps + 3
7070
) # don't show on the first step
7171
self.num_steps += 1 # increase the step counter

openandroidinstaller/assets/configs/sargo.yaml

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,16 @@ metadata:
22
maintainer: Tobias Sterbak (tsterbak)
33
devicename: Pixel 3a
44
devicecode: sargo
5+
requirements:
6+
android: 12.1.0
57
steps:
68
unlock_bootloader:
7-
- type: confirm_button
9+
- type: call_button
810
content: >
911
As a first step, you need to unlock the bootloader. A bootloader is the piece of software, that tells your phone
1012
how to start and run an operating system (like Android). Your device should be turned on.
11-
- type: call_button
12-
content: Press 'Confirm and run' to reboot into the bootloader.
13+
Press 'Confirm and run' to reboot into the bootloader.
1314
command: adb_reboot_bootloader
14-
- type: confirm_button
15-
content: >
16-
Select 'Restart bootloader' on your smartphone screen by pressing the volume button and the confirm by pushing the power button.
17-
Then press 'Confirm and continue' here.
1815
- type: call_button
1916
content: In this step you actually unlock the bootloader. Just press 'Confirm and run' here. Once it's done, press continue here.
2017
command: fastboot_unlock
@@ -26,17 +23,14 @@ steps:
2623
content: To finish the unlocking, the phone needs to reboot. Just press 'Confirm and run' here to reboot. Then continue.
2724
command: fastboot_reboot
2825
- type: confirm_button
29-
content: The bootloader is now unlocked. Since the device resets completely, you will need to re-enable USB debugging to continue.
26+
content: The bootloader is now unlocked. Since the device resets completely, you will need to re-enable Developer Options and USB debugging to continue.
3027
flash_recovery:
31-
- type: confirm_button
28+
- type: call_button
3229
content: >
3330
Now you need to flash a custom recovery system on the phone. A recovery is a small subsystem on your phone, that manages updating,
3431
adapting and repairing of the operating system.
35-
- type: call_button
36-
content: Once the device is fully booted, you need to reboot into the bootloader again by pressing 'Confirm and run' here. Then continue.
32+
Make sure your device is turned on. You need to reboot into the bootloader again by pressing 'Confirm and run' here. Then continue.
3733
command: adb_reboot_bootloader
38-
- type: confirm_button
39-
content: Select 'Restart bootloader' on your smartphone screen. Then confirm to continue.
4034
- type: call_button
4135
content: Flash a custom recovery (temporarily) by pressing 'Confirm and run'. Once it's done continue.
4236
command: fastboot_flash_recovery

openandroidinstaller/assets/configs/starlte.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ metadata:
22
maintainer: Tobias Sterbak (tsterbak)
33
devicename: Samsung Galaxy S9
44
devicecode: starlte
5+
requirements:
6+
android: 10
57
steps:
68
unlock_bootloader:
79
flash_recovery:

openandroidinstaller/assets/configs/z3.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ metadata:
22
maintainer: Tobias Sterbak (tsterbak)
33
devicename: Sony Xperia Z3
44
devicecode: z3
5+
requirements:
6+
firmware: 23.5.A.1.291
57
steps:
68
unlock_bootloader:
79
- type: confirm_button
8.79 KB
Loading
8.13 KB
Loading

openandroidinstaller/installer_config.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,27 @@
2323

2424

2525
class Step:
26+
"""Class representing on step in the installer."""
27+
28+
default_images = {
29+
"Unlock the bootloader": "unlock-bootloader-default.png",
30+
}
31+
2632
def __init__(
2733
self,
2834
title: str,
2935
type: str,
3036
content: str,
3137
command: str = None,
32-
img: str = "placeholder.png",
38+
img: str = None,
3339
allow_skip: bool = False,
3440
link: str = None,
3541
):
3642
self.title = title
3743
self.type = type
3844
self.content = content
3945
self.command = command
40-
self.img = img
46+
self.img = img if img else self.default_images.get(title, "placeholder.png")
4147
self.allow_skip = allow_skip
4248
self.link = link
4349

@@ -49,11 +55,13 @@ def __init__(
4955
flash_recovery: List[Step],
5056
install_os: List[Step],
5157
metadata: dict,
58+
requirements: dict,
5259
):
5360
self.unlock_bootloader = unlock_bootloader
5461
self.flash_recovery = flash_recovery
5562
self.install_os = install_os
5663
self.metadata = metadata
64+
self.requirements = requirements
5765

5866
@classmethod
5967
def from_file(cls, path):
@@ -64,6 +72,7 @@ def from_file(cls, path):
6472
config = dict(raw_config)
6573
raw_steps = config["steps"]
6674
metadata = config["metadata"]
75+
requirements = config.get("requirements", None)
6776
else:
6877
logger.info("Validation of config failed.")
6978
return None
@@ -86,7 +95,9 @@ def from_file(cls, path):
8695
Step(**raw_step, title="Install OS")
8796
for raw_step in raw_steps.get("install_os", [])
8897
]
89-
return cls(unlock_bootloader, flash_recovery, install_os, metadata)
98+
return cls(
99+
unlock_bootloader, flash_recovery, install_os, metadata, requirements
100+
)
90101

91102

92103
def _load_config(device_code: str, config_path: Path) -> Optional[InstallerConfig]:
@@ -139,6 +150,10 @@ def validate_config(config: str) -> bool:
139150
"devicename": str,
140151
"devicecode": str,
141152
},
153+
schema.Optional("requirements"): {
154+
schema.Optional("android"): str,
155+
schema.Optional("firmware"): str,
156+
},
142157
"steps": {
143158
"unlock_bootloader": schema.Or(None, [step_schema]),
144159
"flash_recovery": [step_schema],

openandroidinstaller/openandroidinstaller.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@
1818
import webbrowser
1919
from pathlib import Path
2020

21-
import flet
21+
import flet as ft
2222
from app_state import AppState
2323
from flet import (
2424
AppBar,
2525
Banner,
2626
Column,
2727
Container,
2828
ElevatedButton,
29+
CircleAvatar,
2930
FloatingActionButton,
3031
Icon,
3132
Image,
@@ -38,15 +39,15 @@
3839
icons,
3940
)
4041
from loguru import logger
41-
from views import SelectFilesView, StepView, SuccessView, WelcomeView
42+
from views import SelectFilesView, StepView, SuccessView, WelcomeView, RequirementsView
4243
from tool_utils import run_command
4344

4445
# where to write the logs
4546
logger.add("openandroidinstaller.log")
4647

4748
# Toggle to True for development purposes
48-
DEVELOPMENT = False
49-
DEVELOPMENT_CONFIG = "yuga" # "a3y17lte" # "sargo"
49+
DEVELOPMENT = True
50+
DEVELOPMENT_CONFIG = "sargo" # "a3y17lte" # "sargo"
5051

5152

5253
PLATFORM = sys.platform
@@ -75,16 +76,20 @@ def __init__(self):
7576
self.view = Column(expand=True, width=1200)
7677

7778
# create default starter views
78-
welcome = WelcomeView(
79+
welcome_view = WelcomeView(
7980
on_confirm=self.confirm,
8081
state=self.state,
8182
)
82-
select_files = SelectFilesView(
83+
requirements_view = RequirementsView(
84+
on_confirm=self.confirm,
85+
state=self.state,
86+
)
87+
select_files_view = SelectFilesView(
8388
on_confirm=self.confirm,
8489
state=self.state,
8590
)
8691
# ordered to allow for pop
87-
self.default_views = [select_files, welcome]
92+
self.default_views = [select_files_view, requirements_view, welcome_view]
8893
# create the final success view
8994
self.final_view = SuccessView(state=self.state)
9095

@@ -124,7 +129,7 @@ def log_version_infos(bin_path):
124129
"""Log the version infos of adb, fastboot and heimdall."""
125130
# adb
126131
adbversion = [line for line in run_command("adb", ["version"], bin_path)]
127-
adbversion = '\n'.join(adbversion[:1])
132+
adbversion = "\n".join(adbversion[:1])
128133
logger.info(f"{adbversion}")
129134
# fastboot
130135
fbversion = [line for line in run_command("fastboot", ["--version"], bin_path)]
@@ -137,10 +142,10 @@ def log_version_infos(bin_path):
137142
def main(page: Page):
138143
logger.info(f"Running OpenAndroidInstaller on {PLATFORM}")
139144
log_version_infos(bin_path=BIN_PATH)
140-
logger.info(20*"-")
145+
logger.info(100 * "-")
141146
# Configure the application base page
142147
page.title = "OpenAndroidInstaller"
143-
page.window_height = 780
148+
page.window_height = 820
144149
page.window_width = int(1.77 * page.window_height)
145150
page.window_top = 100
146151
page.window_left = 120
@@ -213,4 +218,4 @@ def restart_process(e):
213218
page.add(app)
214219

215220

216-
flet.app(target=main, assets_dir="assets")
221+
ft.app(target=main, assets_dir="assets")

openandroidinstaller/tool_utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,11 @@ def adb_twrp_wipe_and_install(bin_path: Path, target: str, config_path: Path) ->
159159
if (type(line) == bool) and not line:
160160
logger.error(f"Wiping {partition} failed.")
161161
# TODO: if this fails, a fix can be to just sideload something and then adb reboot
162-
for line in run_command("adb", ["sideload", str(config_path.parent.parent) + "/helper.txt"], bin_path):
162+
for line in run_command(
163+
"adb",
164+
["sideload", str(config_path.parent.parent) + "/helper.txt"],
165+
bin_path,
166+
):
163167
yield line
164168
sleep(1)
165169
if (type(line) == bool) and not line:

openandroidinstaller/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121

2222

2323
def get_download_link(devicecode: str) -> Optional[str]:
24-
"""Check if a lineageOS version for this device exists on lineageosroms.com and return the respective download link."""
24+
"""Check if a lineageOS version for this device exists on download.lineageos.com and return the respective download link."""
2525
url = f"https://download.lineageos.org/{devicecode.lower()}"
2626
try:
2727
logger.info(f"Checking {url}")
2828
# Get Url
29-
res = requests.get(url)
29+
res = requests.get(url, timeout=5)
3030
# if the request succeeds
3131
if res.status_code == 200:
3232
logger.info(f"{url} exists.")

0 commit comments

Comments
 (0)