Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit adcb4d8c authored by bigbiff bigbiff's avatar bigbiff bigbiff Committed by Dees Troy
Browse files

ADB Backup: Fix gzip backup and restore

Change-Id: I92821c7053089d130a5ab73fa36aec486da77bf1
parent 19fb79c7
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -31,7 +31,8 @@

int main(int argc, char **argv) {
	int index;
	int ret = 0, pos = 0;
	int pos = 0;
	bool ret = false;
	int maxpos = sizeof(TWRPARG + 2);
	std::string command;
	twrpback tw;
@@ -73,8 +74,9 @@ int main(int argc, char **argv) {
	else if (command.substr(0, sizeof(TWRP_STREAM_ARG) - 1) == TWRP_STREAM_ARG) {
		tw.setStreamFileName(argv[3]);
		tw.threadStream();
		ret = true;
	}
	if (ret == 0)
	if (ret)
		tw.adblogwrite("Adb backup/restore completed\n");
	else
		tw.adblogwrite("Adb backup/restore failed\n");
@@ -85,5 +87,8 @@ int main(int argc, char **argv) {
		tw.adblogwrite("Unable to remove TW_ADB_BU_CONTROL: " + str.str());
	}
	unlink(TW_ADB_TWRP_CONTROL);
	return ret;
	if (ret)
		return 0;
	else
		return -1;
}
+14 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@

#include "twadbstream.h"
#include "libtwadbbu.hpp"
#include "twrpback.hpp"

bool twadbbu::Check_ADB_Backup_File(std::string fname) {
	struct AdbBackupStreamHeader adbbuhdr;
@@ -290,3 +291,16 @@ bool twadbbu::Write_TWENDADB() {
	close(adb_control_bu_fd);
	return true;
}

bool twadbbu::Write_TWDATA(FILE* adbd_fp) {
	struct AdbBackupControlType data_block;
	memset(&data_block, 0, sizeof(data_block));
	strncpy(data_block.start_of_header, TWRP, sizeof(data_block.start_of_header));
	strncpy(data_block.type, TWDATA, sizeof(data_block.type));
	data_block.crc = crc32(0L, Z_NULL, 0);
	data_block.crc = crc32(data_block.crc, (const unsigned char*) &data_block, sizeof(data_block));
	if (fwrite(&data_block, 1, sizeof(data_block), adbd_fp) != sizeof(data_block))  {
		return false;
	}
	return true;
}
+1 −1
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@
#include <sstream>

#include "twadbstream.h"
#include "twrpback.hpp"

class twadbbu {
public:
@@ -46,6 +45,7 @@ public:
	static bool Write_TWEOF();                                                                     //Write ADB End-Of-File marker to stream
	static bool Write_TWERROR();                                                                   //Write error message occurred to stream
	static bool Write_TWENDADB();                                                                  //Write ADB End-Of-Stream command to stream
	static bool Write_TWDATA(FILE* adbd_fp);                                                       //Write TWDATA separator
};

#endif //__LIBTWADBBU_HPP
+1 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@
#define TWMD5 "twverifymd5"				//This command is compared to the md5trailer by ORS to verify transfer
#define TWENDADB "twendadb"				//End Protocol
#define TWERROR "twerror"				//Send error
#define ADB_BACKUP_VERSION 1				//Backup Version
#define ADB_BACKUP_VERSION 2				//Backup Version
#define DATA_MAX_CHUNK_SIZE 1048576			//Maximum size between each data header
#define MAX_ADB_READ 512				//align with default tar size for amount to read fom adb stream

+239 −185

File changed.

Preview size limit exceeded, changes collapsed.

Loading