Skip to content

Commit

Permalink
Release v0.2.1-alpha (#30)
Browse files Browse the repository at this point in the history
This PR for Release v.0.2.1-alpha adds:
- Simplify config files
- Popup enabled again
- Make enabeling developer options clearer, better design hierarchy
- Use twrp scripting
- Use specific functions to run commands with tools
- Write logs to file
- Only support twrp recoveries in tool now
- major refactoring and decoupling of frontend and logic
- Enable terminal output in tool
- Improve logging
- Adapt config for TWRP recovery for FairPhones
- Support new devices:
  - [x] samsung galaxy s9
  - [x] samsung galaxy s10
  - [x] Samsung Galaxy A7 (2016)
  - [x] Samsung Galaxy A72
  - [x] Samsung Galaxy J7 (2015)
  - [x] pixel 4
  - [x] pixel 4a
  - [x] pixel 5
  - [x] pixel 5a
  - [x] Sony Xperia Z3
  • Loading branch information
tsterbak authored Nov 15, 2022
2 parents 68cf85e + 6ec588d commit 1202bb1
Show file tree
Hide file tree
Showing 29 changed files with 1,539 additions and 993 deletions.
29 changes: 18 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
[![Release](https://img.shields.io/github/v/release/openandroidinstaller-dev/openandroidinstaller?include_prereleases&style=flat-square)](https://github.com/openandroidinstaller-dev/openandroidinstaller/releases)
[![Downloads](https://img.shields.io/github/downloads/openandroidinstaller-dev/openandroidinstaller/total?style=flat-square)](https://github.com/openandroidinstaller-dev/openandroidinstaller/releases)
[![Twitter](https://img.shields.io/twitter/follow/oainstaller?style=social)](https://twitter.com/OAInstaller)
[![Mastodon](https://img.shields.io/mastodon/follow/109341220262803943?domain=https%3A%2F%2Ffosstodon.org&style=social)](https://fosstodon.org/@openandroidinstaller)
<p>Makes installing alternative Android distributions nice and easy.</p>
<a href="https://github.com/openandroidinstaller-dev/openandroidinstaller">
<img src="openandroidinstaller/assets/logo-192x192.png" alt="OpenAndroidInstaller" height="80">
Expand Down Expand Up @@ -35,19 +36,29 @@ If you wish to backup the TA partition first, you can find tutorials related to
## Officially supported devices
Vendor | Device Name | CodeName | Models | Status
---|---|---|---|---
Samsung | Galaxy J7 2015 | j7elte | | tested
Samsung | Galaxy A3 2017 | a3y17lte | SM-A320FL | tested
Samsung | Galaxy A5 2016 | a5xelte | SM-A510F | tested
Samsung | Galaxy A7 2016 | a7xelte | | tested
Samsung | Galaxy S7 | herolte | SM-G930F | tested
Samsung | Galaxy S9 | starlte | | under development
Samsung | Galaxy S9 | starlte | | tested
Samsung | Galaxy S10 | beyond1lte | | tested
Google | Pixel 3a | sargo | sargo | tested
Google | Pixel 4a | sunfish | sunfish | planned
Google | Pixel 4 | flame | flame | tested
Google | Pixel 4a | sunfish | sunfish | tested
Google | Pixel 5 | redfin | redfin | tested
Google | Pixel 5a | barbet | barbet | tested
Sony | Xperia Z | yuga | C6603 | tested
Sony | Xperia Z3 | z3 | | under development
Sony | Xperia Z3 | z3 | | tested
Sony | Xperia ZX | kagura | | planned
Fairphone | Fairphone 2 | FP2 | | under development
Fairphone | Fairphone 3 | FP3 | | under development
Motorola | Moto G5 | cedric | | planned
Fairphone | Fairphone 2 | FP2 | | tested
Fairphone | Fairphone 3 | FP3 | | tested
Motorola | moto G5 | cedric | | planned
Motorola | moto g7 power | ocean | | under development
OnePlus | 6 | enchilada | | under development
OnePlus | 6T | fajita | | under development
OnePlus | 7T | hotdogb | | under development
OnePlus | 9 | lemonade | | under development


## Usage
Expand Down Expand Up @@ -87,18 +98,14 @@ If you want to use the tool for a non-supported smartphone, the fastest way is t
#### Content of a config file

Every step in the config file corresponds to one view in the application. These steps should contain the following fields:
- `title`: str; Describing the overall goal of the step. Will be displayed in the header of the view.
- `type`: str; Corresponds to the type of view to generate. There are the following options:
- `text`: Just display the text given in content.
- `confirm_button`: Display the content, as well as a button to allow the user to go to the next step.
- `call_button`: Display the content text and a button that runs a given command. After the command is run, a confirm button is displayed to allow the user to move to the next step.
- `call_button_with_input`: Display the content text, an input field and a button that runs a given command. The inputtext, can be used in the command by using the `<inputtext>` placeholder in the command field. After the command is run, a confirm button is displayed to allow the user to move to the next step.
- `link_button_with_confirm`: Display a button that opens a browser with a given link, confirm afterwards. Link is given in `link`.
- `content`: str; The content text displayed alongside the action of the step. Used to inform the user about whats going on.
- `command`: [ONLY for call_button* steps] str; This is a terminal command run in a shell. (For example fastboot or adb). There are three types of placeholders supported, that will be filled by the tool as soon as information is given.
- `<image>`: The path of the ROM image file.
- `<recovery>`: The path of the recovery file.
- `<inputtext>`: Text from the user input from `call_button_with_input` views.
- `command`: [ONLY for call_button* steps] str; The command to run. One of `adb_reboot`, `adb_reboot_bootloader`, `adb_reboot_download`, `adb_sideload`, `adb_twrp_wipe_and_install`, `fastboot_flash_recovery`, `fastboot_unlock_with_code`, `fastboot_unlock`, `fastboot_oem_unlock`, `fastboot_reboot`, `heimdall_flash_recovery`.
- `img`: [OPTIONAL] Display an image on the left pane of the step view. Images are loaded from `openandroidinstaller/assets/imgs/`.
- `allow_skip`: [OPTIONAL] boolean; If a skip button should be displayed to allow skipping this step. Can be useful when the bootloader is already unlocked.
- `link`: [OPTIONAL] Link to use for the link button if type is `link_button_with_confirm`.
Expand Down
72 changes: 72 additions & 0 deletions openandroidinstaller/app_state.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
"""This file contains a class and function to manage the app state over various steps."""

# This file is part of OpenAndroidInstaller.
# OpenAndroidInstaller is free software: you can redistribute it and/or modify it under the terms of
# the GNU General Public License as published by the Free Software Foundation,
# either version 3 of the License, or (at your option) any later version.

# OpenAndroidInstaller is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

# You should have received a copy of the GNU General Public License along with OpenAndroidInstaller.
# If not, see <https://www.gnu.org/licenses/>."""
# Author: Tobias Sterbak

from pathlib import Path

from flet import ProgressBar
from installer_config import _load_config
from loguru import logger


class AppState:
"""Container class to store the state of the application."""

def __init__(
self,
platform: str,
config_path: Path,
bin_path: Path,
progressbar: ProgressBar,
num_steps: int,
test: bool = False,
test_config: str = None,
):
self.platform = platform
self.config_path = config_path
self.bin_path = bin_path
self.progressbar = progressbar
self.num_steps = num_steps # keep track of the steps already taken
self.test = test
self.test_config = test_config

# initialize the progress bar at 0
self.progressbar.value = 0

# placeholders
self.advanced = False
self.config = None
self.image_path = None
self.recovery_path = None

# is this still needed?
self.steps = None

def load_config(self, device_code: str):
"""Load the config from file to state by device code."""
self.config = _load_config(device_code, self.config_path)
if self.config:
self.steps = (
self.config.unlock_bootloader
+ self.config.flash_recovery
+ self.config.install_os
)
self.num_total_steps = len(self.steps)

def increment_progressbar(self):
"""Increment the progressbar and step counter."""
self.progressbar.value = (self.num_steps - 1) / (
self.num_total_steps + 2
) # don't show on the first step
self.num_steps += 1 # increase the step counter
41 changes: 12 additions & 29 deletions openandroidinstaller/assets/configs/FP2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,25 @@ metadata:
steps:
unlock_bootloader:
flash_recovery:
- title: "Flash a custom recovery"
type: confirm_button
- type: confirm_button
content: >
Now you need to flash a custom recovery system on the phone. A recovery is a small subsystem on your phone, that manages updating,
adapting and repairing of the operating system.
- title: "Flash a custom recovery"
type: call_button
- type: call_button
content: Once the device is fully booted, you need to reboot into the bootloader again by pressing 'Confirm and run' here. Then continue.
command: "adb reboot bootloader"
- title: "Flash a custom recovery"
type: call_button
command: adb_reboot_bootloader
- type: call_button
content: Flash a custom recovery (temporarily) by pressing 'Confirm and run'. Once it's done continue.
command: "fastboot flash recovery <recovery>"
- title: "Flash temporary recovery"
type: confirm_button
command: fastboot_flash_recovery
- type: confirm_button
content: >
Now reboot into recovery to verify the installation. Do not reboot into the existing OS, since it will overwrite the recovery you just installed!
With the device powered off, hold 'Volume Up + Power'. Release when boot logo appears.
install_os:
- title: "Flash LineageOS"
type: confirm_button
- type: call_button
content: >
Now tap Factory Reset, then Format data / Factory reset on your phone screen and continue with the formatting process.
This will remove encryption and delete all files stored in the internal storage, as well as format your cache partition (if you have one).
- title: "Flash LineageOS"
type: confirm_button
content: Return to the main menu on the phone.
- title: "Flash LineageOS"
type: confirm_button
content: On the device, select “Apply Update”, then “Apply from ADB” to begin sideload. Then confirm here.
- title: "Flash LineageOS"
type: call_button
content: >
Now it's time to flash the LineageOS image. Don't remove the USB-Cable and press 'Confirm and run' to start!
This might take a while. Confirm after it's done.
command: "adb sideload <image>"
- title: "Flash LineageOS"
type: confirm_button
content: Flashing finished. Now press 'back' (arrow) and then 'Reboot system now' on the phone screen to finish the installation.
In the next steps, you finally flash the selected OS image.
Wait until the TWRP screen appears. Then run the command.
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. This might take a while. At the end your phone will boot into the new OS.
command: adb_twrp_wipe_and_install
66 changes: 34 additions & 32 deletions openandroidinstaller/assets/configs/FP3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,51 @@ metadata:
devicecode: FP3
steps:
unlock_bootloader:
- title: "Unlock the bootloader"
type: link_button_with_confirm
- type: link_button_with_confirm
content: >
As a first step, you need to unlock the bootloader. A bootloader is the piece of software, that tells your phone
how to start and run an operating system (like Android). Your device should be turned on.
Click on the button to open the instructions on the Fairphone Support official unlocking website to generate an unlock code for your device.
Once you done that, continue.
Once you've done that, continue.
link: https://www.fairphone.com/en/bootloader-unlocking-code-for-fairphone-3/
- type: call_button
content: Press 'Confirm and run' to reboot into the bootloader.
command: adb_reboot_bootloader
- type: confirm_button
content: >
Select 'Restart bootloader' on your smartphone screen by pressing the volume button and the confirm by pushing the power button.
Then press 'Confirm and continue' here.
- type: call_button
content: In this step you actually unlock the bootloader. Just press 'Confirm and run' here. Once it's done, press continue here.
command: fastboot_oem_unlock
- type: confirm_button
content: >
Follow the instructions on the Fairphone screen. This command will wipe all the personal data on your phone.
- type: call_button
content: To finish the unlocking, the phone needs to reboot. Just press 'Confirm and run' here to reboot. Then continue.
command: fastboot_reboot
- type: confirm_button
content: The bootloader is now unlocked. Since the device resets completely, you will need to re-enable USB debugging to continue.
flash_recovery:
- title: "Flash a custom recovery"
type: confirm_button
- type: confirm_button
content: >
Now you need to flash a custom recovery system on the phone. A recovery is a small subsystem on your phone, that manages updating,
adapting and repairing of the operating system.
- title: "Flash a custom recovery"
type: call_button
- type: call_button
content: Turn on your device. Once the device is fully booted, you need to reboot into the bootloader again by pressing 'Confirm and run' here. Then continue.
command: "adb reboot bootloader"
- title: "Flash a custom recovery"
type: call_button
command: adb_reboot_bootloader
- type: call_button
content: Once the device is in fastboot mode, flash the custom recovery (temporarily) by pressing 'Confirm and run'. Once it's done continue.
command: "fastboot flash boot <recovery>"
- title: "Flash temporary recovery"
type: confirm_button
command: fastboot_flash_recovery
- type: confirm_button
content: >
Now reboot into recovery to verify the installation. Do not reboot into the existing OS, since it will overwrite the recovery you just installed!
With the device powered off, hold 'Volume Up + Power'. Release when boot logo appears.
install_os:
- title: "Flash LineageOS"
type: confirm_button
content: >
Now tap 'Factory Reset', then 'Format data / Factory reset' on your phone screen and continue with the formatting process.
This will remove encryption and delete all files stored in the internal storage, as well as format your cache partition (if you have one).
- title: "Flash LineageOS"
type: confirm_button
content: Return to the main menu on the phone.
- title: "Flash LineageOS"
type: confirm_button
content: On the device, select “Apply Update”, then “Apply from ADB” to begin sideload. Then confirm here.
- title: "Flash LineageOS"
type: call_button
- type: call_button
content: >
Now it's time to flash the LineageOS image. Don't remove the USB-Cable and press 'Confirm and run' to start!
This might take a while. Confirm after it's done.
command: "adb sideload <image>"
- title: "Flash LineageOS"
type: confirm_button
content: Flashing finished. Now press 'back' (arrow) and then 'Reboot system now' on the phone screen to finish the installation. Then confirm here.
In the next steps, you finally flash the selected OS image.
Wait until the TWRP screen appears. Then run the command.
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. This might take a while. At the end your phone will boot into the new OS.
command: adb_twrp_wipe_and_install
47 changes: 12 additions & 35 deletions openandroidinstaller/assets/configs/a3y17lte.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,51 +5,28 @@ metadata:
steps:
unlock_bootloader:
flash_recovery:
- title: "Boot into bootloader"
type: call_button
- 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"
- title: "Flash custom recovery"
type: call_button
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 --no-reboot --RECOVERY <recovery>"
- title: "Boot into recovery"
type: confirm_button
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*.
hold *Volume Up* + *Home* + *Power*. Confirm when the recovery screen appears.
install_os:
- title: "Flash LineageOS"
type: confirm_button
- type: call_button
content: >
Now swipe right to allow modifications then tap 'Wipe' on your phone. Next tap 'Format Data' and follow
the instructions on your phone to continue with the formatting process. This will remove encryption and delete all files stored
in the internal storage. Confirm to continue once you are done.
- title: "Flash LineageOS"
type: confirm_button
content: >
Return to the previous menu on your phone by going back two times.
Them tap 'Advanced Wipe', and select the 'Cache' and 'System' partitions and then 'Swipe to Wipe'.
Confirm to continue once you are done.
- title: "Flash LineageOS"
type: confirm_button
content: >
Now connect the phone to the computer again with the USB-cable. On the device, go back three times and select “Advanced”,
then “ADB Sideload”. Select 'Wipe cache' and 'Wipe dalvik cache', then swipe to begin sideload. Then confirm here.
- title: "Flash LineageOS"
type: call_button
content: >
Now it's time to flash the LineageOS image. Don't remove the USB-Cable and press 'Confirm and run' to start!
This might take a while. Confirm after it's done.
command: "adb sideload <image>"
- title: "Reboot into LineageOS"
type: call_button
content: As a final step, reboot into LineageOS to finish the installation by pressing the button.
command: "adb reboot"
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
Loading

0 comments on commit 1202bb1

Please sign in to comment.