Deprecate PRODUCT_STATIC_BOOT_CONTROL_HAL.

In favor of using boot control HAL under recovery.

Bug: 34254109
Test: TreeHugger
Test: Sideloading a package on bonito.
Change-Id: Ie9b11d41675be6b3aa13a51925b6b124b05fa44f
diff --git a/Android.bp b/Android.bp
index e69df8d..913278a 100644
--- a/Android.bp
+++ b/Android.bp
@@ -2,5 +2,6 @@
     imports: [
         "hardware/google/interfaces",
         "hardware/google/pixel",
+        "hardware/qcom/bootctrl",
     ],
 }
diff --git a/CleanSpec.mk b/CleanSpec.mk
index e8d17b1..6d71bc6 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -174,3 +174,6 @@
 # Remove generic atrace HAL
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/etc/init/android.hardware.atrace@1.0-service.rc)
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/etc/vintf/manifest/android.hardware.atrace@1.0-service.xml)
+
+# Remove obsolete android.hardware.boot@1.0-impl-wrapper.recovery.so
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/system/lib64/hw/android.hardware.boot@1.0-impl-wrapper.recovery.so)
diff --git a/bootctrl/Android.bp b/bootctrl/Android.bp
new file mode 100644
index 0000000..9dcf767
--- /dev/null
+++ b/bootctrl/Android.bp
@@ -0,0 +1,21 @@
+//
+// Copyright (C) 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+cc_library {
+    name: "bootctrl.sdm710",
+    defaults: ["bootctrl_hal_defaults"],
+    static_libs: ["libgptutils.bonito"],
+}
diff --git a/device.mk b/device.mk
index 11b9a13..b049879 100644
--- a/device.mk
+++ b/device.mk
@@ -138,7 +138,8 @@
     ro.sys.sdcardfs=1
 
 PRODUCT_PACKAGES += \
-    bootctrl.sdm710
+    bootctrl.sdm710 \
+    bootctrl.sdm710.recovery
 
 PRODUCT_PROPERTY_OVERRIDES += \
     ro.cp_system_other_odex=1
@@ -159,14 +160,6 @@
     FILESYSTEM_TYPE_vendor=ext4 \
     POSTINSTALL_OPTIONAL_vendor=true
 
-# Enable update engine sideloading by including the static version of the
-# boot_control HAL and its dependencies.
-PRODUCT_STATIC_BOOT_CONTROL_HAL := \
-    bootctrl.sdm710 \
-    libgptutils \
-    libz \
-    libcutils
-
 PRODUCT_PACKAGES += \
     update_engine_sideload \
     sg_write_buffer \
@@ -475,6 +468,7 @@
 # Boot control HAL
 PRODUCT_PACKAGES += \
     android.hardware.boot@1.0-impl \
+    android.hardware.boot@1.0-impl.recovery \
     android.hardware.boot@1.0-service \
 
 # Vibrator HAL
diff --git a/gpt-utils/Android.bp b/gpt-utils/Android.bp
new file mode 100644
index 0000000..271e945
--- /dev/null
+++ b/gpt-utils/Android.bp
@@ -0,0 +1,38 @@
+//
+// Copyright (C) 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+cc_library {
+    name: "libgptutils.bonito",
+    vendor: true,
+    recovery_available: true,
+    shared_libs: [
+        "libcutils",
+        "liblog",
+        "libz",
+    ],
+    cflags: [
+        "-Wall",
+        "-Werror",
+    ],
+    srcs: [
+        "gpt-utils.cpp",
+    ],
+    owner: "qti",
+    header_libs: [
+        "device_kernel_headers",
+    ],
+    export_include_dirs: ["."],
+}
diff --git a/gpt-utils/Android.mk b/gpt-utils/Android.mk
deleted file mode 100644
index 6dd1a44..0000000
--- a/gpt-utils/Android.mk
+++ /dev/null
@@ -1,46 +0,0 @@
-#
-# Copyright 2016 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := gpt-utils.cpp
-ifeq ($(TARGET_COMPILE_WITH_MSM_KERNEL),true)
-LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
-LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
-endif
-LOCAL_SHARED_LIBRARIES := liblog libz
-LOCAL_MODULE := libgptutils
-LOCAL_MODULE_OWNER := qti
-include $(BUILD_STATIC_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := gpt-utils.cpp
-ifeq ($(TARGET_COMPILE_WITH_MSM_KERNEL),true)
-LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
-LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
-endif
-LOCAL_SHARED_LIBRARIES += liblog libcutils libz
-LOCAL_EXPORT_HEADER_LIBRARY_HEADERS := libgptutils_headers
-LOCAL_MODULE := libgptutils
-LOCAL_MODULE_OWNER := qti
-LOCAL_PROPRIETARY_MODULE := true
-include $(BUILD_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := libgptutils_headers
-LOCAL_EXPORT_C_INCLUDE_DIRS:=$(LOCAL_PATH)
-include $(BUILD_HEADER_LIBRARY)
diff --git a/gpt-utils/gpt-utils.cpp b/gpt-utils/gpt-utils.cpp
index ff6e535..2a97f1b 100644
--- a/gpt-utils/gpt-utils.cpp
+++ b/gpt-utils/gpt-utils.cpp
@@ -747,7 +747,6 @@
     enum gpt_state gpt_prim, gpt_second;
     enum boot_update_stage internal_stage;
     struct stat xbl_partition_stat;
-    struct stat ufs_dir_stat;
 
     if (!dev_path) {
         fprintf(stderr, "%s: Invalid dev_path\n",
@@ -970,7 +969,6 @@
 
 int prepare_boot_update(enum boot_update_stage stage)
 {
-        int r, fd;
         int is_ufs = gpt_utils_is_ufs_device();
         struct stat ufs_dir_stat;
         struct update_data data;