bigbiff | ad58e1b | 2020-07-06 20:24:34 -0400 | [diff] [blame] | 1 | /*
|
| 2 | Copyright 2014 to 2020 TeamWin
|
| 3 | This file is part of TWRP/TeamWin Recovery Project.
|
| 4 |
|
| 5 | TWRP is free software: you can redistribute it and/or modify
|
| 6 | it under the terms of the GNU General Public License as published by
|
| 7 | the Free Software Foundation, either version 3 of the License, or
|
| 8 | (at your option) any later version.
|
| 9 |
|
| 10 | TWRP is distributed in the hope that it will be useful,
|
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 13 | GNU General Public License for more details.
|
| 14 |
|
| 15 | You should have received a copy of the GNU General Public License
|
| 16 | along with TWRP. If not, see <http://www.gnu.org/licenses/>.
|
| 17 | */
|
| 18 |
|
| 19 | #include <string>
|
| 20 | #include "partitions.hpp"
|
| 21 |
|
| 22 | #ifndef TWRP_REPACKER
|
| 23 | #define TWRP_REPACKER
|
| 24 |
|
| 25 | enum Repack_Type {
|
| 26 | REPLACE_NONE = 0,
|
| 27 | REPLACE_RAMDISK = 1,
|
| 28 | REPLACE_KERNEL = 2,
|
| 29 | };
|
| 30 |
|
| 31 | struct Repack_Options_struct {
|
| 32 | Repack_Type Type;
|
| 33 | bool Backup_First;
|
| 34 | bool Disable_Verity;
|
| 35 | bool Disable_Force_Encrypt;
|
| 36 | };
|
| 37 |
|
| 38 | class twrpRepacker {
|
| 39 | public:
|
| 40 | bool Backup_Image_For_Repack(TWPartition* Part, const std::string& Temp_Folder_Destination, const bool Create_Backup, const std::string& Backup_Name); // Prepares an image for repacking by unpacking it to the temp folder destination
|
| 41 | std::string Unpack_Image(const std::string& Source_Path, const std::string& Temp_Folder_Destination, const bool Copy_Source, const bool Create_Destination = true); // Prepares an image for repacking by unpacking it to the temp folder destination and return the ramdisk format
|
| 42 | bool Repack_Image_And_Flash(const std::string& Target_Image, const struct Repack_Options_struct& Repack_Options); // Repacks the boot image with a new kernel or a new ramdisk
|
| 43 | private:
|
| 44 | bool Prepare_Empty_Folder(const std::string& Folder); // Creates an empty folder at Folder. If the folder already exists, the folder is deleted, then created
|
| 45 | std::string original_ramdisk_format; // Ramdisk format of boot partition
|
| 46 | std::string image_ramdisk_format; // Ramdisk format of boot image to repack from
|
| 47 | };
|
| 48 | #endif // TWRP_REPACKER |