blob: 1c6b09f15b346bdfcd86c64c778020b562d3a82c [file] [log] [blame]
bigbiffce8f83c2015-12-12 18:30:21 -05001/*
bigbiff bigbiff19fb79c2016-09-05 21:04:51 -04002 Copyright 2013 to 2017 TeamWin
bigbiffce8f83c2015-12-12 18:30:21 -05003 TWRP is free software: you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation, either version 3 of the License, or
6 (at your option) any later version.
7
8 TWRP is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with TWRP. If not, see <http://www.gnu.org/licenses/>.
15*/
16
bigbiff bigbiff19fb79c2016-09-05 21:04:51 -040017#ifndef _TWRPBACK_HPP
18#define _TWRPBACK_HPP
bigbiffce8f83c2015-12-12 18:30:21 -050019
bigbiff bigbiff19fb79c2016-09-05 21:04:51 -040020#include <fstream>
bigbiffce8f83c2015-12-12 18:30:21 -050021
22class twrpback {
23public:
24 int adbd_fd; // adbd data stream
bigbiffce8f83c2015-12-12 18:30:21 -050025 twrpback(void);
26 virtual ~twrpback(void);
27 int backup(std::string command); // adb backup stream
28 int restore(void); // adb restore stream
29 void adblogwrite(std::string writemsg); // adb debugging log function
bigbiff bigbiff19fb79c2016-09-05 21:04:51 -040030 void createFifos(void); // create fifos needed for adb backup
31 void closeFifos(void); // close created fifos
32 void streamFileForTWRP(void); // stream file to twrp via bu
33 void setStreamFileName(std::string fn); // tell adb backup what file to load on storage
34 void threadStream(void); // thread bu for streaming
bigbiffce8f83c2015-12-12 18:30:21 -050035
36private:
37 int read_fd; // ors input fd
38 int write_fd; // ors operation fd
39 int ors_fd; // ors output fd
40 int adb_control_twrp_fd; // fd for bu to twrp communication
41 int adb_control_bu_fd; // fd for twrp to bu communication
42 int adb_read_fd; // adb read data stream
43 int adb_write_fd; // adb write data stream
44 bool firstPart; // first partition in the stream
45 FILE *adbd_fp; // file pointer for adb stream
46 char cmd[512]; // store result of commands
47 char operation[512]; // operation to send to ors
48 std::ofstream adblogfile; // adb stream log file
bigbiff bigbiff19fb79c2016-09-05 21:04:51 -040049 std::string streamFn;
50 typedef void (twrpback::*ThreadPtr)(void);
51 typedef void* (*PThreadPtr)(void *);
bigbiffce8f83c2015-12-12 18:30:21 -050052 void adbloginit(void); // setup adb log stream file
bigbiff bigbiff19fb79c2016-09-05 21:04:51 -040053 void close_backup_fds(); // close backup resources
54 void close_restore_fds(); // close restore resources
bigbiffce8f83c2015-12-12 18:30:21 -050055};
bigbiff bigbiff19fb79c2016-09-05 21:04:51 -040056
57#endif // _TWRPBACK_HPP