@@ -3154,6 +3154,37 @@ bool TWPartitionManager::Repack_Images(const std::string& Target_Image, const st
31543154 }
31553155 DataManager::SetProgress (1 );
31563156 TWFunc::removeDir (REPACK_ORIG_DIR, false );
3157+ if (part->SlotSelect && Repack_Options.Type == REPLACE_RAMDISK) {
3158+ LOGINFO (" Switching slots to flash ramdisk to both partitions\n " );
3159+ string Current_Slot = Get_Active_Slot_Display ();
3160+ if (Current_Slot == " A" )
3161+ Set_Active_Slot (" B" );
3162+ else
3163+ Set_Active_Slot (" A" );
3164+ DataManager::SetProgress (.25 );
3165+ if (!PartitionManager.Prepare_Repack (part, REPACK_ORIG_DIR, Repack_Options.Backup_First , gui_lookup (" repack" , " Repack" )))
3166+ return false ;
3167+ if (TWFunc::copy_file (REPACK_NEW_DIR " ramdisk.cpio" , REPACK_ORIG_DIR " ramdisk.cpio" , 0644 )) {
3168+ LOGERR (" Failed to copy ramdisk\n " );
3169+ return false ;
3170+ }
3171+ path = REPACK_ORIG_DIR;
3172+ command = " cd " + path + " && /sbin/magiskboot --repack " + path + " boot.img" ;
3173+ if (TWFunc::Exec_Cmd (command) != 0 ) {
3174+ gui_msg (Msg (msg::kError , " repack_error=Error repacking image." ));
3175+ return false ;
3176+ }
3177+ DataManager::SetProgress (.75 );
3178+ std::string file = " new-boot.img" ;
3179+ DataManager::SetValue (" tw_flash_partition" , " /boot;" );
3180+ if (!PartitionManager.Flash_Image (path, file)) {
3181+ LOGINFO (" Error flashing new image\n " );
3182+ return false ;
3183+ }
3184+ DataManager::SetProgress (1 );
3185+ TWFunc::removeDir (REPACK_ORIG_DIR, false );
3186+ Set_Active_Slot (Current_Slot);
3187+ }
31573188 TWFunc::removeDir (REPACK_NEW_DIR, false );
31583189 return true ;
31593190}
0 commit comments