From 4f19caa016640892ae26b3b76a1b27df0b69eabc Mon Sep 17 00:00:00 2001 From: Captain Throwback Date: Thu, 18 Nov 2021 20:30:38 -0500 Subject: [PATCH 1/5] lptools: add to build Use TW_EXCLUDE_LPTOOLS to exclude from build Will only be included on devices with dynamic partitions Change-Id: I77092344a1e31e749161cb31e6e020f6e9fc3800 --- Android.mk | 3 +++ prebuilt/Android.bp | 5 +++++ prebuilt/Android.mk | 3 +++ 3 files changed, 11 insertions(+) create mode 100644 prebuilt/Android.bp diff --git a/Android.mk b/Android.mk index 302b143f..c5b1f2cd 100755 --- a/Android.mk +++ b/Android.mk @@ -161,6 +161,9 @@ ifeq ($(PRODUCT_USE_DYNAMIC_PARTITIONS),true) ifeq ($(TW_EXCLUDE_LPDUMP),) TWRP_REQUIRED_MODULES += lpdump lpdumpd.rc endif + ifeq ($(TW_EXCLUDE_LPTOOLS),) + TWRP_REQUIRED_MODULES += lptools + endif endif ifeq ($(TW_USES_VENDOR_LIBS),true) diff --git a/prebuilt/Android.bp b/prebuilt/Android.bp new file mode 100644 index 00000000..fdbb3d2e --- /dev/null +++ b/prebuilt/Android.bp @@ -0,0 +1,5 @@ +soong_namespace { + imports: [ + "external/lptools", + ], +} diff --git a/prebuilt/Android.mk b/prebuilt/Android.mk index effa2736..2413f1aa 100755 --- a/prebuilt/Android.mk +++ b/prebuilt/Android.mk @@ -245,6 +245,9 @@ ifeq ($(AB_OTA_UPDATER), true) RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/liblpdump_interface-V1-cpp.so RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libprotobuf-cpp-full.so endif + ifeq ($(TW_EXCLUDE_LPTOOLS),) + RECOVERY_BINARY_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/lptools + endif endif ifneq ($(wildcard system/core/libsparse/Android.*),) From a866b44f45ec37bfb2eb3a7b333f22a781831576 Mon Sep 17 00:00:00 2001 From: Captain Throwback Date: Fri, 19 Nov 2021 13:13:30 -0500 Subject: [PATCH 2/5] lpdump: only build for dynamic partition devices Change-Id: Ia4a90681a6342cb5e4269ca3475376507b5d5260 --- prebuilt/Android.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/prebuilt/Android.mk b/prebuilt/Android.mk index 2413f1aa..d409be03 100755 --- a/prebuilt/Android.mk +++ b/prebuilt/Android.mk @@ -237,6 +237,8 @@ ifeq ($(AB_OTA_UPDATER), true) RECOVERY_BINARY_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/system/bin/update_engine_sideload RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/android.hardware.boot@1.0.so RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/android.hardware.boot@1.1.so +endif +ifeq ($(PRODUCT_USE_DYNAMIC_PARTITIONS),true) ifeq ($(TW_EXCLUDE_LPDUMP),) RECOVERY_BINARY_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/bootctl RECOVERY_BINARY_SOURCE_FILES += $(TARGET_OUT_EXECUTABLES)/lpdump From ac43dd1179cbd8bb0cf5feeddcbcfdac449e1576 Mon Sep 17 00:00:00 2001 From: bigbiff Date: Sat, 20 Nov 2021 20:37:56 -0500 Subject: [PATCH 3/5] unmapping super devices: do not remove ramdisk mountpoints Change-Id: Iabd543e914887af78813805141604ae0ca1c812d --- partitionmanager.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/partitionmanager.cpp b/partitionmanager.cpp index a4d84ecb..9f67730d 100755 --- a/partitionmanager.cpp +++ b/partitionmanager.cpp @@ -3578,7 +3578,6 @@ bool TWPartitionManager::Unmap_Super_Devices() { LOGINFO("removing cow partition: %s\n", cow_partition.c_str()); destroyed = DestroyLogicalPartition(cow_partition); } - rmdir((*iter)->Mount_Point.c_str()); iter = Partitions.erase(iter); delete part; if (!destroyed) { From 0fc1ee2c1ab1775ac5f5115842b4aaea15ec9ad6 Mon Sep 17 00:00:00 2001 From: nebrassy Date: Sun, 21 Nov 2021 03:32:47 +0100 Subject: [PATCH 4/5] twrpRepacker: override slot back after flashing and move updating partition details to the function Change-Id: I6f27ab1191246b6a23e625b0e3459db9024691c7 --- partitionmanager.cpp | 1 + twrpRepacker.cpp | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/partitionmanager.cpp b/partitionmanager.cpp index 9f67730d..e0bd0054 100755 --- a/partitionmanager.cpp +++ b/partitionmanager.cpp @@ -3115,6 +3115,7 @@ void TWPartitionManager::Override_Active_Slot(const string& Slot) { LOGINFO("Overriding slot to '%s'\n", Slot.c_str()); Active_Slot_Display = Slot; DataManager::SetValue("tw_active_slot", Slot); + PartitionManager.Update_System_Details(); } void TWPartitionManager::Set_Active_Slot(const string& Slot) { diff --git a/twrpRepacker.cpp b/twrpRepacker.cpp index 8ca1409a..5a59fc6b 100755 --- a/twrpRepacker.cpp +++ b/twrpRepacker.cpp @@ -216,7 +216,6 @@ bool twrpRepacker::Repack_Image_And_Flash(const std::string& Target_Image, const else PartitionManager.Override_Active_Slot("A"); DataManager::SetProgress(.25); - PartitionManager.Update_System_Details(); if (!Backup_Image_For_Repack(part, REPACK_ORIG_DIR, Repack_Options.Backup_First, gui_lookup("repack", "Repack"))) return false; if (TWFunc::copy_file(REPACK_NEW_DIR "ramdisk.cpio", REPACK_ORIG_DIR "ramdisk.cpio", 0644)) { @@ -261,6 +260,11 @@ bool twrpRepacker::Repack_Image_And_Flash(const std::string& Target_Image, const }} TWFunc::removeDir(REPACK_NEW_DIR, false); gui_msg(Msg(msg::kWarning, "repack_overwrite_warning=If device was previously rooted, then root has been overwritten and will need to be reinstalled.")); + string Current_Slot = PartitionManager.Get_Active_Slot_Display(); + if (Current_Slot == "A") + PartitionManager.Override_Active_Slot("B"); + else + PartitionManager.Override_Active_Slot("A"); return true; } From d0b854b31daeda7f0bdce24a4171821a4fa82707 Mon Sep 17 00:00:00 2001 From: GarfieldHan <2652609017@qq.com> Date: Sun, 21 Nov 2021 23:46:20 +0800 Subject: [PATCH 5/5] Add EROFS to file system check list This commit will add EROFS Filesystem mount support Since Huawei announced the new file system EROFS and successfully merged into mainline. More and more OEMs switch the ext4 filesystem to EROFS filesystem for system/vendor/odm/product partitions like Oplus (OPPO / Realme / OnePlus). Test: Import the latest fstab from system, build and boot. EROFS-based partions like system and vendor partitions were sucessfully mounted. Notes: Although I tried to change 'ext4' to 'erofs' for correct partition in twrp.flags, but it was still recognized as 'ext4'. So you can just copy the line related erofs partitions from recovery.fstab and TWRP will failed to recognize the line in twrp.flags, and then skip this line, so the issue was solved. Signed-off-by: GarfieldHan <2652609017@qq.com> Change-Id: I49a04e4465f1d92eb589ad6d86b6db9b58d720eb --- partition.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/partition.cpp b/partition.cpp index ecd5be59..cc8fb07d 100755 --- a/partition.cpp +++ b/partition.cpp @@ -1112,6 +1112,7 @@ bool TWPartition::Is_File_System(string File_System) { File_System == "yaffs2" || File_System == "exfat" || File_System == "f2fs" || + File_System == "erofs" || File_System == "squashfs" || File_System == "auto") return true;