Skip to content

Commit

Permalink
Merge branch 'main' into unified-install-step
Browse files Browse the repository at this point in the history
  • Loading branch information
tsterbak committed Feb 6, 2023
2 parents c56d42b + 1f73a79 commit 474d8bb
Show file tree
Hide file tree
Showing 17 changed files with 851 additions and 446 deletions.
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# These are supported funding model platforms

github: [openandroidinstaller-dev]
open_collective: openandroidinstaller
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</p>
</div>

> **Warning**: This application is currently in early alpha state, so use at your own risk! I take no responsibility for bricked devices or dead SD cards.
> **Warning**: This application is currently in alpha state, so use at your own risk! While many people tested the application so far and we heard of no bricked devices, thinks might still go wrong.
> **Note**: Unlocking the bootloader will erase all data on your device!
This also includes your DRM keys, which are stored in the Trim Area partition (also called TA).
Expand All @@ -36,7 +36,7 @@ If you wish to backup the TA partition first, you can find tutorials related to

## Usage

Linux is currently the best supported platform (tested with Ubuntu 20.04 LTS). Windows and MacOS are also supported but you might experience more issues. So far there is no support for ARM-based systems.
Linux is currently the best supported platform (tested with Ubuntu 20.04/22.04 LTS). Windows and MacOS are also supported but you might experience more issues. So far there is no support for ARM-based systems.

1. Download the AppImage, .exe or appropriate executable file for your OS. You might need to change permissions to run the executable.
- On Windows also [install the Universal USB Drivers](https://adb.clockworkmod.com/) and other potentially drivers needed for your device.
Expand All @@ -55,7 +55,7 @@ Linux is currently the best supported platform (tested with Ubuntu 20.04 LTS). W

## Officially supported devices

Currently, the **we support 45 devices** by various vendors and working on adding more soon!
Currently, the **we support 48 devices** by various vendors and working on adding more soon!


Support for these devices is provided as best effort, but things might still go wrong.
Expand All @@ -69,7 +69,10 @@ Samsung | Galaxy J7 2015 | j7elte | | tested
Samsung | Galaxy A3 2017 | a3y17lte | SM-A320FL | tested
Samsung | Galaxy A5 2016 | [a5xelte](https://wiki.lineageos.org/devices/a5xelte/) | SM-A510F | tested
Samsung | Galaxy A7 2016 | a7xelte | | tested
Samsung | Galaxy S6 | [zerofltexx](https://wiki.lineageos.org/devices/zerofltexx/) | | tested
Samsung | Galaxy S6 Edge | [zeroltexx](https://wiki.lineageos.org/devices/zeroltexx/) | | tested
Samsung | Galaxy S7 | [herolte](https://wiki.lineageos.org/devices/herolte/) | SM-G930F | tested
Samsung | Galaxy S7 Edge | [hero2lte](https://wiki.lineageos.org/devices/hero2lte/) | | tested
Samsung | Galaxy S9 | [starlte](https://wiki.lineageos.org/devices/starlte/) | | tested
Samsung | Galaxy Note 9 | [crownlte](https://wiki.lineageos.org/devices/crownlte/) | | tested
Samsung | Galaxy S10 | [beyond1lte](https://wiki.lineageos.org/devices/beyond1lte/) | | tested
Expand Down
30 changes: 30 additions & 0 deletions openandroidinstaller/assets/configs/hero2lte.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
metadata:
maintainer: Tobias Sterbak (tsterbak)
devicename: Samsung Galaxy S7 Edge
devicecode: hero2lte
steps:
unlock_bootloader:
flash_recovery:
- type: call_button
content: >
As a first step, you need to boot into the bootloader. A bootloader is the piece of software,
that tells your phone who to start and run an operating system (like Android). Your device should be turned on.
Then press 'Confirm and run' to reboot into the bootloader. Continue once it's done.
command: adb_reboot_download
- type: call_button
content: In this step, you need to flash a custom recovery on your device. Press 'Confirm and run' to start the process. Confirm afterwards to continue.
command: heimdall_flash_recovery
- type: confirm_button
img: samsung-buttons.png
content: >
Unplug the USB cable from your device. Then manually reboot into recovery by pressing 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 button*.
install_os:
- type: call_button
content: >
In the next steps, you finally flash the selected OS image.
Connect your device with your computer with the USB-Cable.
This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored
in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS.
command: adb_twrp_wipe_and_install
30 changes: 30 additions & 0 deletions openandroidinstaller/assets/configs/zerofltexx.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
metadata:
maintainer: Tobias Sterbak (tsterbak)
devicename: Samsung Galaxy S6
devicecode: zerofltexx
steps:
unlock_bootloader:
flash_recovery:
- type: call_button
content: >
As a first step, you need to boot into the bootloader. A bootloader is the piece of software,
that tells your phone who to start and run an operating system (like Android). Your device should be turned on.
Then press 'Confirm and run' to reboot into the bootloader. Continue once it's done.
command: adb_reboot_download
- type: call_button
content: In this step, you need to flash a custom recovery on your device. Press 'Confirm and run' to start the process. Confirm afterwards to continue.
command: heimdall_flash_recovery
- type: confirm_button
img: samsung-buttons.png
content: >
Unplug the USB cable from your device. Then manually reboot into recovery by pressing 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 button*.
install_os:
- type: call_button
content: >
In the next steps, you finally flash the selected OS image.
Connect your device with your computer with the USB-Cable.
This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored
in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS.
command: adb_twrp_wipe_and_install
30 changes: 30 additions & 0 deletions openandroidinstaller/assets/configs/zeroltexx.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
metadata:
maintainer: Tobias Sterbak (tsterbak)
devicename: Samsung Galaxy S6 Edge
devicecode: zeroltexx
steps:
unlock_bootloader:
flash_recovery:
- type: call_button
content: >
As a first step, you need to boot into the bootloader. A bootloader is the piece of software,
that tells your phone who to start and run an operating system (like Android). Your device should be turned on.
Then press 'Confirm and run' to reboot into the bootloader. Continue once it's done.
command: adb_reboot_download
- type: call_button
content: In this step, you need to flash a custom recovery on your device. Press 'Confirm and run' to start the process. Confirm afterwards to continue.
command: heimdall_flash_recovery
- type: confirm_button
img: samsung-buttons.png
content: >
Unplug the USB cable from your device. Then manually reboot into recovery by pressing 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 button*.
install_os:
- type: call_button
content: >
In the next steps, you finally flash the selected OS image.
Connect your device with your computer with the USB-Cable.
This step will format your phone and wipe all the data. It will also remove encryption and delete all files stored
in the internal storage. Then the OS image will be installed. Confirm to run. This might take a while. At the end your phone will boot into the new OS.
command: adb_twrp_wipe_and_install
70 changes: 50 additions & 20 deletions openandroidinstaller/openandroidinstaller.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
# where to write the logs
logger.add("openandroidinstaller.log")

# VERSION number
VERSION = "0.3.4-alpha"

# detect platform
PLATFORM = sys.platform
Expand All @@ -75,19 +77,22 @@ def __init__(self, state: AppState):

# create default starter views
welcome_view = WelcomeView(
on_confirm=self.confirm,
on_confirm=self.to_next_view,
state=self.state,
)
start_view = StartView(
on_confirm=self.confirm,
on_confirm=self.to_next_view,
on_back=self.to_previous_view,
state=self.state,
)
requirements_view = RequirementsView(
on_confirm=self.confirm,
on_confirm=self.to_next_view,
on_back=self.to_previous_view,
state=self.state,
)
select_files_view = SelectFilesView(
on_confirm=self.confirm,
on_confirm=self.to_next_view,
on_back=self.to_previous_view,
state=self.state,
)
# ordered to allow for pop
Expand All @@ -99,7 +104,7 @@ def __init__(self, state: AppState):
]

# create the install view
self.install_view = InstallView(on_confirm=self.confirm, state=self.state)
self.install_view = InstallView(on_confirm=self.to_next_view, state=self.state)

# create the final success view
self.final_view = SuccessView(state=self.state)
Expand All @@ -114,8 +119,11 @@ def __init__(self, state: AppState):
self.state.final_default_views = self.final_default_views
self.state.final_view = self.final_view

# stack of previous default views for the back-button
self.previous_views = []

# initialize the addon view
self.select_addon_view = AddonsView(on_confirm=self.confirm, state=self.state)
self.select_addon_view = AddonsView(on_confirm=self.to_next_view, state=self.state)
self.flash_recovery_view = StepView(
step=Step(
title="Flash custom recovery",
Expand All @@ -125,10 +133,10 @@ def __init__(self, state: AppState):
img="twrp-start.jpeg",
),
state=self.state,
on_confirm=self.confirm,
on_confirm=self.to_next_view,
)
self.install_addons_view = InstallAddonsView(
on_confirm=self.confirm, state=self.state
on_confirm=self.to_next_view, state=self.state
)
self.state.addon_views = [
self.install_addons_view,
Expand All @@ -140,8 +148,21 @@ def build(self):
self.view.controls.append(self.default_views.pop())
return self.view

def confirm(self, e):
def to_previous_view(self, e):
"""Method to display the previous view."""
# store the current view
self.default_views.append(self.view.controls[-1])
# clear the current view
self.view.controls = []
# retrieve the new view and update
self.view.controls.append(self.previous_views.pop())
logger.info("One step back.")
self.view.update()

def to_next_view(self, e):
"""Confirmation event handler to use in views."""
# store the current view
self.previous_views.append(self.view.controls[-1])
# remove all elements from column view
self.view.controls = []
# if there are default views left, display them first
Expand All @@ -152,7 +173,7 @@ def confirm(self, e):
StepView(
step=self.state.steps.pop(0),
state=self.state,
on_confirm=self.confirm,
on_confirm=self.to_next_view,
)
)
elif self.final_default_views:
Expand All @@ -162,7 +183,7 @@ def confirm(self, e):
# else:
# # display the final view
# self.view.controls.append(self.final_view)
logger.info("Confirmed.")
logger.info("Confirmed and moved to next step.")
self.view.update()


Expand All @@ -182,19 +203,28 @@ def configure(page: Page):
def log_version_infos(bin_path):
"""Log the version infos of adb, fastboot and heimdall."""
# adb
adbversion = [line for line in run_command("adb", ["version"], bin_path)]
adbversion = "\n".join(adbversion[:1])
logger.info(f"{adbversion}")
adbversion = [
line for line in run_command("adb", ["version"], bin_path, enable_logging=False)
]
logger.info(f"{adbversion[1].strip()}")
# fastboot
fbversion = [line for line in run_command("fastboot", ["--version"], bin_path)]
logger.info(f"{fbversion[0]}")
fbversion = [
line
for line in run_command(
"fastboot", ["--version"], bin_path, enable_logging=False
)
]
logger.info(f"{fbversion[1].strip()}")
# heimdall
hdversion = [line for line in run_command("heimdall", ["info"], bin_path)]
logger.info(f"Heimdall version: {hdversion[0]}")
hdversion = [
line
for line in run_command("heimdall", ["info"], bin_path, enable_logging=False)
]
logger.info(f"Heimdall version: {hdversion[1].strip()}")


def main(page: Page, test: bool = False, test_config: str = "sargo"):
logger.info(f"Running OpenAndroidInstaller on {PLATFORM}")
logger.info(f"Running OpenAndroidInstaller version '{VERSION}' on '{PLATFORM}'.")
log_version_infos(bin_path=BIN_PATH)
logger.info(100 * "-")

Expand All @@ -209,7 +239,7 @@ def main(page: Page, test: bool = False, test_config: str = "sargo"):
leading_width=56,
toolbar_height=72,
elevation=0,
title=Text("OpenAndroidInstaller alpha version", style="displaySmall"),
title=Text(f"OpenAndroidInstaller version {VERSION}", style="displaySmall"),
center_title=False,
bgcolor="#00d886",
actions=[
Expand Down
10 changes: 7 additions & 3 deletions openandroidinstaller/tooling.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
PLATFORM = sys.platform


def run_command(tool: str, command: List[str], bin_path: Path) -> CompletedProcess:
def run_command(
tool: str, command: List[str], bin_path: Path, enable_logging: bool = True
) -> CompletedProcess:
"""Run a command with a tool (adb, fastboot, heimdall)."""
yield f"${' '.join([tool] + command )}"
if tool not in ["adb", "fastboot", "heimdall"]:
Expand All @@ -45,7 +47,8 @@ def run_command(tool: str, command: List[str], bin_path: Path) -> CompletedProce
else:
full_command = [str(bin_path.joinpath(Path(f"{tool}")))] + command
si = None
logger.info(f"Run command: {full_command}")
if enable_logging:
logger.info(f"Run command: {full_command}")
# run the command
with Popen(
full_command,
Expand All @@ -56,7 +59,8 @@ def run_command(tool: str, command: List[str], bin_path: Path) -> CompletedProce
startupinfo=si,
) as p:
for line in p.stdout:
logger.info(line.strip())
if enable_logging:
logger.info(line.strip())
yield line

yield p.returncode == 0
Expand Down
7 changes: 7 additions & 0 deletions openandroidinstaller/views/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,10 @@ def __init__(self, state: AppState, image: str = "placeholder.png"):
],
alignment="spaceEvenly",
)

def clear(
self,
):
"""Clear the right view."""
self.right_view.controls = []
self.right_view_header.controls = []
Loading

0 comments on commit 474d8bb

Please sign in to comment.