Skip to content

Commit 02dec80

Browse files
committed
read config for samsung galaxy a3 2017 and flash successfully
1 parent 51eef01 commit 02dec80

File tree

2 files changed

+33
-16
lines changed

2 files changed

+33
-16
lines changed

openandroidinstaller/installer_config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ def from_file(cls, path):
2727
print(exc)
2828

2929
steps = [Step(**raw_step) for raw_step in raw_steps]
30-
return cls(raw_steps)
30+
return cls(steps)

openandroidinstaller/openandroidinstaller.py

+32-15
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
import flet
44
from flet import (AppBar, ElevatedButton, Page, Text, View, Row, ProgressRing, Column, FilePicker, FilePickerResultEvent, icons)
55
from typing import List
6-
from subprocess import check_output, STDOUT, call
6+
from subprocess import check_output, STDOUT, call, CalledProcessError
77
from functools import partial
88

9+
from installer_config import InstallerConfig
10+
911

1012
recovery_path = None
1113
image_path = None
@@ -32,28 +34,43 @@ def go_back(e):
3234
page.update()
3335

3436
def search_devices(e):
37+
config_path = "openandroidinstaller/assets/configs/"
3538
try:
39+
# read device properties
3640
output = check_output(["adb", "shell", "dumpsys", "bluetooth_manager", "|", "grep", "\'name:\'", "|", "cut", "-c9-"], stderr=STDOUT).decode()
3741
page.views[-1].controls.append(Text(f"Detected: {output}"))
42+
# load config from file
43+
config = InstallerConfig.from_file(config_path + output.strip() + ".yaml")
44+
page.views[-1].controls.append(Text(f"Installer configuration found."))
3845
page.views[-1].controls.append(ElevatedButton("Confirm and continue", on_click=confirm))
39-
views.extend([
40-
get_new_view(title="Unlock the bootloader", content=[confirm_button("Turn on developer options and OEM Unlock on your phone.")], index=2),
41-
get_new_view(title="Boot into recovery", content=[confirm_button("Turn on your device and wait until its fully booted.")], index=3),
42-
get_new_view(title="Boot into recovery", content=[call_button("Reboot into bootloader", command="adb reboot download")], index=4),
43-
get_new_view(title="Boot into recovery", content=[call_button("Flash custom recovery", command="heimdall flash --no-reboot --RECOVERY recovery")], index=5),
44-
get_new_view(title="Boot into recovery", content=[confirm_button("Unplug the USB cable from your device. Manually reboot into recovery. Press the Volume Down + Power buttons for 8~10 seconds until the screen turns black & release the buttons immediately when it does, then boot to recovery with the device powered off, hold Volume Up + Home + Power.")], index=6),
45-
get_new_view(title="Flash LineageOS", content=[confirm_button("Now tap 'Wipe'. Then tap 'Format Data' and continue with the formatting process. This will remove encryption and delete all files stored in the internal storage.")], index=7),
46-
get_new_view(title="Flash LineageOS", content=[confirm_button("Return to the previous menu and tap 'Advanced Wipe', then select the 'Cache' and 'System' partitions and then 'Swipe to Wipe'.")], index=8),
47-
get_new_view(title="Flash LineageOS", content=[confirm_button("On the device, go back and select “Advanced”, “ADB Sideload”, then swipe to begin sideload. Then confirm here")], index=9),
48-
get_new_view(title="Flash LineageOS", content=[call_button("Flash lineageOS image. Don't remove the USB-Cable!", command="adb sideload image")], index=10),
49-
get_new_view(title="Boot into recovery", content=[call_button("Reboot into OS", command="adb reboot")], index=11),
50-
get_new_view(title="Successfully finished flashing", content=[Text("Have fun with LineageOS!")], index=12),
51-
])
52-
except:
46+
new_views = views_from_config(config)
47+
views.extend(new_views)
48+
except CalledProcessError:
5349
output = "No device detected!"
5450
page.views[-1].controls.append(Text(f"{output}"))
5551
page.update()
5652

53+
54+
def views_from_config(config: InstallerConfig) -> List[View]:
55+
new_views = []
56+
for num_step, step in enumerate(config.steps):
57+
if step.type == "confirm_button":
58+
new_views.append(
59+
get_new_view(title=step.title, content=[confirm_button(step.content)], index=2+num_step)
60+
)
61+
elif step.type == "call_button":
62+
new_views.append(
63+
get_new_view(title=step.title, content=[call_button(step.content, command=step.command)], index=2+num_step)
64+
)
65+
elif step.type == "text":
66+
new_views.append(
67+
get_new_view(title=step.title, content=[Text(step.content)], index=2+num_step)
68+
)
69+
else:
70+
raise Exception(f"Unknown step type: {step.type}")
71+
return new_views
72+
73+
5774
def call_to_phone(e, command: str):
5875
command = command.replace("recovery", recovery_path)
5976
command = command.replace("image", image_path)

0 commit comments

Comments
 (0)