Merge AOSP android-9.0.0_r3

Fix conflicts and make it build in 5.1, 6.0, 7.1, 8.1, and 9.0

Change-Id: Ida0a64c29ff27d339b7f42a18d820930964ac6e4
diff --git a/adbbu/twrpback.cpp b/adbbu/twrpback.cpp
index 56bc13d..b3de76d 100644
--- a/adbbu/twrpback.cpp
+++ b/adbbu/twrpback.cpp
@@ -144,7 +144,7 @@
 	uint64_t md5fnsize = 0;
 	struct AdbBackupControlType endadb;
 
-	ADBSTRUCT_STATIC_ASSERT(sizeof(endadb) == MAX_ADB_READ);
+	//ADBSTRUCT_STATIC_ASSERT(sizeof(endadb) == MAX_ADB_READ);
 
 	bool writedata = true;
 	bool compressed = false;
@@ -177,7 +177,7 @@
 	}
 
 	memset(operation, 0, sizeof(operation));
-	if (snprintf(operation, sizeof(operation), "adbbackup %s", command.c_str()) >= sizeof(operation)) {
+	if (snprintf(operation, sizeof(operation), "adbbackup %s", command.c_str()) >= (int)sizeof(operation)) {
 		adblogwrite("Operation too big to write to ORS_INPUT_FILE\n");
 		close_backup_fds();
 		return false;
@@ -278,7 +278,7 @@
 				adblogwrite("writing TWFN\n");
 				digest.init();
 
-				ADBSTRUCT_STATIC_ASSERT(sizeof(twfilehdr) == MAX_ADB_READ);
+				//ADBSTRUCT_STATIC_ASSERT(sizeof(twfilehdr) == MAX_ADB_READ);
 
 				memset(&twfilehdr, 0, sizeof(twfilehdr));
 				memcpy(&twfilehdr, cmd, sizeof(cmd));
@@ -420,7 +420,7 @@
 				fileBytes += bytes;
 				dataChunkBytes += bytes;
 
-				if (fwrite(writeAdbReadStream, 1, bytes, adbd_fp) != bytes) {
+				if (fwrite(writeAdbReadStream, 1, bytes, adbd_fp) != (unsigned long long)bytes) {
 					adblogwrite("Error writing backup data to adbd\n");
 					close_backup_fds();
 					return false;
@@ -508,8 +508,8 @@
 	int errctr = 0;
 	uint64_t totalbytes = 0, dataChunkBytes = 0;
 	uint64_t md5fnsize = 0, fileBytes = 0;
-	bool writedata, read_from_adb;
-	bool eofsent, md5trsent, md5sumdata;
+	bool read_from_adb;
+	bool md5sumdata;
 	bool compressed, tweofrcvd, extraData;
 
 	read_from_adb = true;
@@ -649,7 +649,7 @@
 					struct AdbBackupStreamHeader cnthdr;
 					uint32_t crc, cnthdrcrc;
 
-					ADBSTRUCT_STATIC_ASSERT(sizeof(cnthdr) == MAX_ADB_READ);
+					//ADBSTRUCT_STATIC_ASSERT(sizeof(cnthdr) == MAX_ADB_READ);
 
 					md5sumdata = false;
 					memset(&cnthdr, 0, sizeof(cnthdr));
@@ -884,7 +884,7 @@
 	struct AdbBackupFileTrailer md5tr;
 	uint32_t crc, md5trcrc, md5ident, md5identmatch;
 
-	ADBSTRUCT_STATIC_ASSERT(sizeof(md5tr) == MAX_ADB_READ);
+	//ADBSTRUCT_STATIC_ASSERT(sizeof(md5tr) == MAX_ADB_READ);
 	memcpy(&md5tr, readAdbStream, MAX_ADB_READ);
 	md5ident = md5tr.ident;