diff --git a/README.md b/README.md index 5b14bfca..6d41c33d 100644 --- a/README.md +++ b/README.md @@ -210,6 +210,7 @@ Other phone vendors stops allowing to unlock the bootloader all together. There - [Heimdall](https://gitlab.com/BenjaminDobell/Heimdall/) is an [MIT](https://gitlab.com/BenjaminDobell/Heimdall/-/blob/master/LICENSE)-licensed replacement for the leaked ODIN tool to flash Samsung devices. - [libusb-1.0](https://github.com/libusb/libusb) is a [LGPL-2.1](https://github.com/libusb/libusb/blob/master/COPYING)-licensed library for USB device access from Linux, macOS, Windows and others. - [copy-partitions-20220613-signed.zip](https://mirrorbits.lineageos.org/tools/copy-partitions-20220613-signed.zip) The copy-partitions script was created by LineageOS developer erfanoabdi and filipepferraz and released under LGPL. It is used when the partitions need to be copied before flashing. +- [universal_repartition_script7870](https://github.com/Astrako/universal_repartition_script7870) The universal repartition script for phones with the Samsung Exynos 7870 by [Astrako](https://github.com/Astrako) under Apache License, Version 2.0. ## Acknowledgements diff --git a/openandroidinstaller/assets/configs/a3y17lte.yaml b/openandroidinstaller/assets/configs/a3y17lte.yaml index d21410b1..c9f62023 100644 --- a/openandroidinstaller/assets/configs/a3y17lte.yaml +++ b/openandroidinstaller/assets/configs/a3y17lte.yaml @@ -22,6 +22,11 @@ steps: 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*. Confirm when the recovery screen appears. + - type: call_button + command: adb_twrp_resize_7870_partitions + content: > + With more recent Android ROMs based on Version 10 or higher, the system memory is too small. So the partitions of this device need to be resized. + Confirm to run the repartition process. Once it is finished you can continue. install_os: - type: call_button content: > diff --git a/openandroidinstaller/assets/universal_repartition_script7870.zip b/openandroidinstaller/assets/universal_repartition_script7870.zip new file mode 100644 index 00000000..76576dfd Binary files /dev/null and b/openandroidinstaller/assets/universal_repartition_script7870.zip differ diff --git a/openandroidinstaller/installer_config.py b/openandroidinstaller/installer_config.py index 2eae535d..59933075 100644 --- a/openandroidinstaller/installer_config.py +++ b/openandroidinstaller/installer_config.py @@ -160,7 +160,7 @@ def validate_config(config: str) -> bool: ), "content": str, schema.Optional("command"): Regex( - r"adb_reboot|adb_reboot_bootloader|adb_reboot_download|adb_sideload|adb_twrp_wipe_and_install|adb_twrp_copy_partitions|fastboot_flash_recovery|fastboot_unlock_with_code|fastboot_get_unlock_data|fastboot_unlock|fastboot_oem_unlock|fastboot_reboot|heimdall_flash_recovery" + r"adb_reboot|adb_reboot_bootloader|adb_reboot_download|adb_sideload|adb_twrp_wipe_and_install|adb_twrp_copy_partitions|adb_twrp_resize_7870_partitions|fastboot_flash_recovery|fastboot_unlock_with_code|fastboot_get_unlock_data|fastboot_unlock|fastboot_oem_unlock|fastboot_reboot|heimdall_flash_recovery" ), schema.Optional("allow_skip"): bool, schema.Optional("img"): str, diff --git a/openandroidinstaller/tooling.py b/openandroidinstaller/tooling.py index 3ecdc936..2fd108a6 100644 --- a/openandroidinstaller/tooling.py +++ b/openandroidinstaller/tooling.py @@ -154,6 +154,36 @@ def adb_twrp_copy_partitions(bin_path: Path, config_path: Path): return True +def adb_twrp_resize_7870_partitions(bin_path: Path, config_path: Path): + """Resize partitions on Samsung Exynos 7870 devices to make Android 10+ ROMs work.""" + logger.info("Sideload the resize partition script with adb.") + # activate sideload + for line in run_command("adb", ["shell", "twrp", "sideload"], bin_path): + yield line + if (type(line) == bool) and not line: + logger.error("Activating sideload failed.") + yield False + return + # now sideload the script + sleep(5) + for line in run_command( + "adb", + [ + "sideload", + f"{config_path.parent.joinpath(Path('universal_repartition_script7870.zip'))}", + ], + bin_path, + ): + if line: + yield line + if (type(line) == bool) and not line: + logger.error("Sideloading universal_repartition_script7870.zip failed.") + yield True + sleep(7) + # Resizing partitions end # + yield True + + def adb_twrp_wipe_and_install(bin_path: Path, target: str, config_path: Path) -> bool: """Wipe and format data with twrp, then flash os image with adb. diff --git a/openandroidinstaller/views/step_view.py b/openandroidinstaller/views/step_view.py index 7e80476e..1b9e7fea 100644 --- a/openandroidinstaller/views/step_view.py +++ b/openandroidinstaller/views/step_view.py @@ -45,6 +45,7 @@ adb_sideload, adb_twrp_wipe_and_install, adb_twrp_copy_partitions, + adb_twrp_resize_7870_partitions, fastboot_flash_recovery, fastboot_oem_unlock, fastboot_reboot, @@ -220,6 +221,9 @@ def call_to_phone(self, e, command: str): "adb_twrp_copy_partitions": partial( adb_twrp_copy_partitions, config_path=self.state.config_path ), + "adb_twrp_resize_7870_partitions": partial( + adb_twrp_resize_7870_partitions, config_path=self.state.config_path + ), "fastboot_unlock": fastboot_unlock, "fastboot_unlock_with_code": partial( fastboot_unlock_with_code, unlock_code=self.inputtext.value