Snap for 11216811 from 1a2734574332d691a8d16ec6e7c423cc3941af7b to 24Q1-release

Change-Id: I0f5a8ec808acc86ef481500acbfdc1b44ccffddd
diff --git a/aosp/update_attempter_android.cc b/aosp/update_attempter_android.cc
index 0f4b2e4..1adaabc 100644
--- a/aosp/update_attempter_android.cc
+++ b/aosp/update_attempter_android.cc
@@ -23,6 +23,7 @@
 #include <utility>
 #include <vector>
 
+#include <android-base/parsebool.h>
 #include <android-base/properties.h>
 #include <android-base/unique_fd.h>
 #include <base/bind.h>
@@ -391,7 +392,11 @@
     install_plan_.vabc_none = true;
   }
   if (!headers[kPayloadEnableThreading].empty()) {
-    install_plan_.enable_threading = true;
+    const auto res = android::base::ParseBool(headers[kPayloadEnableThreading]);
+    if (res != android::base::ParseBoolResult::kError) {
+      install_plan_.enable_threading =
+          res == android::base::ParseBoolResult::kTrue;
+    }
   }
   if (!headers[kPayloadBatchedWrites].empty()) {
     install_plan_.batched_writes = true;
diff --git a/payload_consumer/delta_performer.cc b/payload_consumer/delta_performer.cc
index 8350825..8a820f9 100644
--- a/payload_consumer/delta_performer.cc
+++ b/payload_consumer/delta_performer.cc
@@ -530,7 +530,7 @@
     if (install_plan_->enable_threading) {
       manifest_.mutable_dynamic_partition_metadata()
           ->mutable_vabc_feature_set()
-          ->set_threaded(true);
+          ->set_threaded(install_plan_->enable_threading.value());
       LOG(INFO) << "Attempting to enable multi-threaded compression for VABC";
     }
     if (install_plan_->batched_writes) {
diff --git a/payload_consumer/delta_performer_unittest.cc b/payload_consumer/delta_performer_unittest.cc
index 0f48da1..e90bb7c 100644
--- a/payload_consumer/delta_performer_unittest.cc
+++ b/payload_consumer/delta_performer_unittest.cc
@@ -17,7 +17,6 @@
 #include "update_engine/payload_consumer/delta_performer.h"
 
 #include <endian.h>
-#include <inttypes.h>
 #include <time.h>
 
 #include <algorithm>
@@ -43,7 +42,6 @@
 #include "update_engine/common/fake_boot_control.h"
 #include "update_engine/common/fake_hardware.h"
 #include "update_engine/common/fake_prefs.h"
-#include "update_engine/common/hardware_interface.h"
 #include "update_engine/common/hash_calculator.h"
 #include "update_engine/common/mock_download_action.h"
 #include "update_engine/common/test_utils.h"
diff --git a/payload_consumer/install_plan.h b/payload_consumer/install_plan.h
index bad34a0..dbbe4b2 100644
--- a/payload_consumer/install_plan.h
+++ b/payload_consumer/install_plan.h
@@ -204,7 +204,7 @@
   bool batched_writes = false;
 
   // Whether to enable multi-threaded compression on COW writes
-  bool enable_threading = false;
+  std::optional<bool> enable_threading;
 };
 
 class InstallPlanAction;
diff --git a/scripts/update_device.py b/scripts/update_device.py
index f515140..26e6e1c 100755
--- a/scripts/update_device.py
+++ b/scripts/update_device.py
@@ -22,7 +22,6 @@
 
 import argparse
 import binascii
-import hashlib
 import logging
 import os
 import re
@@ -33,7 +32,6 @@
 import tempfile
 import time
 import threading
-import xml.etree.ElementTree
 import zipfile
 import shutil
 
@@ -338,9 +336,7 @@
         assert magic == b"CrAU", "Invalid magic {}, expected CrAU".format(magic)
         assert major_version == 2, "Invalid major version {}, only version 2 is supported".format(major_version)
         output_fp.write(header)
-
-        shutil.copyfileobj(payload_fp, output_fp, manifest_size + metadata_signature_size)
-
+        output_fp.write(payload_fp.read(manifest_size + metadata_signature_size))
 
       return dut.adb([
           "push",
@@ -412,6 +408,8 @@
                       help='Option to enable or disable vabc. If set to false, will fall back on A/B')
   parser.add_argument('--enable-threading', action='store_true',
                       help='Enable multi-threaded compression for VABC')
+  parser.add_argument('--disable-threading', action='store_true',
+                      help='Enable multi-threaded compression for VABC')
   parser.add_argument('--batched-writes', action='store_true',
                       help='Enable batched writes for VABC')
   parser.add_argument('--speed-limit', type=str,
@@ -481,6 +479,8 @@
     args.extra_headers += "\nDISABLE_VABC=1"
   if args.enable_threading:
     args.extra_headers += "\nENABLE_THREADING=1"
+  elif args.disable_threading:
+    args.extra_headers += "\nENABLE_THREADING=0"
   if args.batched_writes:
     args.extra_headers += "\nBATCHED_WRITES=1"