Add AIDL library to update_engine

Also move IApexService.h header to apex_handler_android.h, so that
consumer of ApexHandlerInterface do not need to see IApexService.h.

IApexService.h includes some binder_ndk headers, which includes
syslog.h, which defines LOG_INFO/LOG_WARNING. libchrome also defines
these macros, so including both libchrome and AIDL headers will cause
macro conflict.

Test: th
Bug: 227536004
Change-Id: Ia17d91cc878d106e9b2adeddafe35a71105e1663
diff --git a/aosp/apex_handler_android.cc b/aosp/apex_handler_android.cc
index 8beef96..f47889b 100644
--- a/aosp/apex_handler_android.cc
+++ b/aosp/apex_handler_android.cc
@@ -47,7 +47,8 @@
 
 }  // namespace
 
-std::unique_ptr<ApexHandlerInterface> CreateApexHandler() {
+std::unique_ptr<ApexHandlerInterface>
+ApexHandlerInterface::CreateApexHandler() {
   if (android::sysprop::ApexProperties::updatable().value_or(false)) {
     return std::make_unique<ApexHandlerAndroid>();
   } else {
@@ -65,7 +66,7 @@
   }
 
   auto compressed_apex_info_list = CreateCompressedApexInfoList(apex_infos);
-  int64_t size_from_apexd;
+  int64_t size_from_apexd = 0;
   auto result = apex_service->calculateSizeForCompressedApex(
       compressed_apex_info_list, &size_from_apexd);
   if (!result.isOk()) {
diff --git a/aosp/apex_handler_android.h b/aosp/apex_handler_android.h
index 767f561..5aaf49b 100644
--- a/aosp/apex_handler_android.h
+++ b/aosp/apex_handler_android.h
@@ -29,7 +29,6 @@
 
 namespace chromeos_update_engine {
 
-std::unique_ptr<ApexHandlerInterface> CreateApexHandler();
 
 class ApexHandlerAndroid : virtual public ApexHandlerInterface {
  public:
diff --git a/aosp/apex_handler_android_unittest.cc b/aosp/apex_handler_android_unittest.cc
index 8c58e47..dd96256 100644
--- a/aosp/apex_handler_android_unittest.cc
+++ b/aosp/apex_handler_android_unittest.cc
@@ -38,7 +38,7 @@
   result.set_version(version);
   result.set_is_compressed(is_compressed);
   result.set_decompressed_size(decompressed_size);
-  return std::move(result);
+  return result;
 }
 
 TEST(ApexHandlerAndroidTest, CalculateSizeUpdatableApex) {
diff --git a/aosp/apex_handler_interface.h b/aosp/apex_handler_interface.h
index b9b6c96..a0c1e9f 100644
--- a/aosp/apex_handler_interface.h
+++ b/aosp/apex_handler_interface.h
@@ -31,6 +31,7 @@
   virtual android::base::Result<uint64_t> CalculateSize(
       const std::vector<ApexInfo>& apex_infos) const = 0;
   virtual bool AllocateSpace(const std::vector<ApexInfo>& apex_infos) const = 0;
+  static std::unique_ptr<ApexHandlerInterface> CreateApexHandler();
 };
 
 }  // namespace chromeos_update_engine
diff --git a/aosp/daemon_state_android.cc b/aosp/daemon_state_android.cc
index da49080..dd659ad 100644
--- a/aosp/daemon_state_android.cc
+++ b/aosp/daemon_state_android.cc
@@ -18,7 +18,7 @@
 
 #include <base/logging.h>
 
-#include "update_engine/aosp/apex_handler_android.h"
+#include "update_engine/aosp/apex_handler_interface.h"
 #include "update_engine/aosp/update_attempter_android.h"
 #include "update_engine/common/boot_control.h"
 #include "update_engine/common/boot_control_stub.h"
@@ -65,11 +65,12 @@
   certificate_checker_->Init();
 
   // Initialize the UpdateAttempter before the UpdateManager.
-  update_attempter_.reset(new UpdateAttempterAndroid(this,
-                                                     prefs_.get(),
-                                                     boot_control_.get(),
-                                                     hardware_.get(),
-                                                     CreateApexHandler()));
+  update_attempter_.reset(
+      new UpdateAttempterAndroid(this,
+                                 prefs_.get(),
+                                 boot_control_.get(),
+                                 hardware_.get(),
+                                 ApexHandlerInterface::CreateApexHandler()));
 
   return true;
 }