Skip to content

twrpinstall: prepare dynamic partitions before flashing - #23

Open
sorrow404Null wants to merge 1 commit into
TWRP-Test:twrp-16.0from
sorrow404Null:fix-dynamic-partition-install
Open

twrpinstall: prepare dynamic partitions before flashing#23
sorrow404Null wants to merge 1 commit into
TWRP-Test:twrp-16.0from
sorrow404Null:fix-dynamic-partition-install

Conversation

@sorrow404Null

@sorrow404Null sorrow404Null commented Aug 31, 2026

Copy link
Copy Markdown

Summary

  • recognize both unsuffixed and slot-suffixed dynamic partition operation lists
  • discover logical-partition holders from TWRP's registered super devices and each running init service's process mappings and file descriptors
  • stop only services that actually reference a logical partition, unmap through TWPartitionManager, then restore their previous running state
  • avoid device-specific service names, mount points, partition names, and boot properties

Testing

  • source setup-env.sh && export TARGET_HW_DISK_ENCRYPTION=false TARGET_HW_DISK_ENCRYPTION_PERF=false && m SOONG_CONFIG_TYPE_twrpGlobalVars_supports_hw_fde=bool SOONG_CONFIG_TYPE_twrpGlobalVars_supports_hw_fde_perf=bool -j12 libtwrpinstall
  • Xiaomi 15 (dada): the original failure reproduced as DM_DEV_REMOVE/EBUSY; dynamic-partition teardown allowed the full-device package to complete with updater RC=0 while affected recovery services were restored after unmapping

Stop recovery services that keep logical vendor and odm partitions open before removing their dm mappings, then restore services that were running before teardown. Recognize slot-suffixed dynamic partition operation lists used by full-device packages.

Test: source setup-env.sh && export TARGET_HW_DISK_ENCRYPTION=false TARGET_HW_DISK_ENCRYPTION_PERF=false && m SOONG_CONFIG_TYPE_twrpGlobalVars_supports_hw_fde=bool SOONG_CONFIG_TYPE_twrpGlobalVars_supports_hw_fde_perf=bool -j12 libtwrpinstall

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates twrpinstall to better support flashing update packages on devices using dynamic partitions by detecting more OTA package layouts and preparing dynamic partition mappings/services before invoking the updater binary.

Changes:

  • Extend update-package detection to recognize slot-suffixed dynamic_partitions_op_list_{a,b} entries.
  • Add logic to discover running init services whose processes reference logical (dynamic) partitions via /proc inspection.
  • Stop affected services and unmap dynamic partitions prior to flashing.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread twrpinstall/twinstall.cpp
Comment on lines +456 to +469
if (ret_val == INSTALL_SUCCESS && _isUpdatePkg && PartitionManager.Get_Super_Status()) {
const std::vector<std::string> services_to_restart = Get_Super_Device_Services();
Set_Init_Service_State(services_to_restart, "stop", "stopped", std::chrono::seconds(2));

gui_msg("unmount_dynamic_partitions=Unmounting dynamic partitions...");
if (!PartitionManager.Unmap_Super_Devices()) {
gui_err("unmount_dynamic_partitions_err=Failed unmapping dynamic partitions");
ret_val = INSTALL_ERROR;
}

Set_Init_Service_State(services_to_restart, "start", "running", std::chrono::seconds(5));
}
if (ret_val == INSTALL_SUCCESS)
ret_val = Run_Update_Binary(path, wipe_cache, UPDATE_BINARY_ZIP_TYPE);
Comment thread twrpinstall/twinstall.cpp
Comment on lines +247 to +251
for (const char* suffix : { "_a", "_b" }) {
std::string op_list = UPDATE_DYNAMIC_PART_OP_LIST_NAME;
op_list += suffix;
if (FindEntry(Zip, op_list, &find_entry) == 0) return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants