Merge "Add EV parameters to VHAL"
diff --git a/CleanSpec.mk b/CleanSpec.mk
index e82fefa..075aa2d 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -52,7 +52,7 @@
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib/hw/android.hardware.bluetooth*)
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib64/hw/android.hardware.bluetooth*)
 $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/init/android.hardware.bluetooth*)
-$(call add-clean-step, rm -rf $(OUT)/soong/.intermediates/)
+$(call add-clean-step, rm -rf $(OUT_DIR)/soong/.intermediates/)
 $(call add-clean-step, rm -rf $(OUT_DIR)/soong/.intermediates/hardware/interfaces/)
 $(call add-clean-step, rm -rf $(OUT_DIR)/soong/.intermediates/hardware/interfaces/)
 $(call add-clean-step, find $(PRODUCT_OUT)/system $(PRODUCT_OUT)/vendor -type f -name "android\.hardware\.configstore*" -print0 | xargs -0 rm -f)
diff --git a/audio/Android.bp b/audio/Android.bp
index 8046672..f4a5846 100644
--- a/audio/Android.bp
+++ b/audio/Android.bp
@@ -6,5 +6,6 @@
     "common/2.0/default",
     "common/test/utility",
     "effect/2.0",
+    "effect/2.0/default",
     "effect/2.0/vts/functional",
 ]
diff --git a/audio/effect/2.0/default/Android.bp b/audio/effect/2.0/default/Android.bp
new file mode 100644
index 0000000..79bb8b0
--- /dev/null
+++ b/audio/effect/2.0/default/Android.bp
@@ -0,0 +1,46 @@
+cc_library_shared {
+    name: "android.hardware.audio.effect@2.0-impl",
+    vendor: true,
+    relative_install_path: "hw",
+    srcs: [
+        "AcousticEchoCancelerEffect.cpp",
+        "AudioBufferManager.cpp",
+        "AutomaticGainControlEffect.cpp",
+        "BassBoostEffect.cpp",
+        "Conversions.cpp",
+        "DownmixEffect.cpp",
+        "Effect.cpp",
+        "EffectsFactory.cpp",
+        "EnvironmentalReverbEffect.cpp",
+        "EqualizerEffect.cpp",
+        "LoudnessEnhancerEffect.cpp",
+        "NoiseSuppressionEffect.cpp",
+        "PresetReverbEffect.cpp",
+        "VirtualizerEffect.cpp",
+        "VisualizerEffect.cpp",
+    ],
+
+    shared_libs: [
+        "libbase",
+        "libcutils",
+        "libeffects",
+        "libfmq",
+        "libhidlbase",
+        "libhidlmemory",
+        "libhidltransport",
+        "liblog",
+        "libutils",
+        "android.hardware.audio.common@2.0",
+        "android.hardware.audio.common@2.0-util",
+        "android.hardware.audio.effect@2.0",
+        "android.hidl.memory@1.0",
+    ],
+
+    header_libs: [
+        "libaudio_system_headers",
+        "libaudioclient_headers",
+        "libeffects_headers",
+        "libhardware_headers",
+        "libmedia_headers",
+    ],
+}
diff --git a/audio/effect/2.0/default/Android.mk b/audio/effect/2.0/default/Android.mk
deleted file mode 100644
index f89d4f7..0000000
--- a/audio/effect/2.0/default/Android.mk
+++ /dev/null
@@ -1,46 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.audio.effect@2.0-impl
-LOCAL_PROPRIETARY_MODULE := true
-LOCAL_MODULE_RELATIVE_PATH := hw
-LOCAL_SRC_FILES := \
-    AcousticEchoCancelerEffect.cpp \
-    AudioBufferManager.cpp \
-    AutomaticGainControlEffect.cpp \
-    BassBoostEffect.cpp \
-    Conversions.cpp \
-    DownmixEffect.cpp \
-    Effect.cpp \
-    EffectsFactory.cpp \
-    EnvironmentalReverbEffect.cpp \
-    EqualizerEffect.cpp \
-    LoudnessEnhancerEffect.cpp \
-    NoiseSuppressionEffect.cpp \
-    PresetReverbEffect.cpp \
-    VirtualizerEffect.cpp \
-    VisualizerEffect.cpp \
-
-LOCAL_SHARED_LIBRARIES := \
-    libbase \
-    libcutils \
-    libeffects \
-    libfmq \
-    libhidlbase \
-    libhidlmemory \
-    libhidltransport \
-    liblog \
-    libutils \
-    android.hardware.audio.common@2.0 \
-    android.hardware.audio.common@2.0-util \
-    android.hardware.audio.effect@2.0 \
-    android.hidl.memory@1.0 \
-
-LOCAL_HEADER_LIBRARIES := \
-    libaudio_system_headers \
-    libaudioclient_headers \
-    libeffects_headers \
-    libhardware_headers \
-    libmedia_headers \
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/biometrics/Android.bp b/biometrics/Android.bp
index c87e3af..19a1062 100644
--- a/biometrics/Android.bp
+++ b/biometrics/Android.bp
@@ -1,5 +1,6 @@
 // This is an autogenerated file, do not edit.
 subdirs = [
     "fingerprint/2.1",
+    "fingerprint/2.1/default",
     "fingerprint/2.1/vts/functional",
 ]
diff --git a/biometrics/fingerprint/2.1/default/Android.bp b/biometrics/fingerprint/2.1/default/Android.bp
new file mode 100644
index 0000000..e1d2cf7
--- /dev/null
+++ b/biometrics/fingerprint/2.1/default/Android.bp
@@ -0,0 +1,21 @@
+cc_binary {
+    name: "android.hardware.biometrics.fingerprint@2.1-service",
+    init_rc: ["android.hardware.biometrics.fingerprint@2.1-service.rc"],
+    vendor: true,
+    relative_install_path: "hw",
+    srcs: [
+        "BiometricsFingerprint.cpp",
+        "service.cpp",
+    ],
+
+    shared_libs: [
+        "libcutils",
+        "liblog",
+        "libhidlbase",
+        "libhidltransport",
+        "libhardware",
+        "libutils",
+        "android.hardware.biometrics.fingerprint@2.1",
+    ],
+
+}
diff --git a/biometrics/fingerprint/2.1/default/Android.mk b/biometrics/fingerprint/2.1/default/Android.mk
deleted file mode 100644
index f02db94..0000000
--- a/biometrics/fingerprint/2.1/default/Android.mk
+++ /dev/null
@@ -1,21 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.biometrics.fingerprint@2.1-service
-LOCAL_INIT_RC := android.hardware.biometrics.fingerprint@2.1-service.rc
-LOCAL_PROPRIETARY_MODULE := true
-LOCAL_MODULE_RELATIVE_PATH := hw
-LOCAL_SRC_FILES := \
-    BiometricsFingerprint.cpp \
-    service.cpp \
-
-LOCAL_SHARED_LIBRARIES := \
-    libcutils \
-    liblog \
-    libhidlbase \
-    libhidltransport \
-    libhardware \
-    libutils \
-    android.hardware.biometrics.fingerprint@2.1 \
-
-include $(BUILD_EXECUTABLE)
diff --git a/bluetooth/1.0/default/Android.bp b/bluetooth/1.0/default/Android.bp
index 31a2641..63e7562 100644
--- a/bluetooth/1.0/default/Android.bp
+++ b/bluetooth/1.0/default/Android.bp
@@ -112,3 +112,23 @@
         "liblog",
     ],
 }
+
+cc_binary {
+    name: "android.hardware.bluetooth@1.0-service",
+    relative_install_path: "hw",
+    vendor: true,
+    init_rc: ["android.hardware.bluetooth@1.0-service.rc"],
+    srcs: ["service.cpp"],
+
+    shared_libs: [
+        "liblog",
+        "libcutils",
+        "libdl",
+        "libbase",
+        "libutils",
+        "libhardware",
+        "libhidlbase",
+        "libhidltransport",
+        "android.hardware.bluetooth@1.0",
+    ],
+}
diff --git a/bluetooth/1.0/default/Android.mk b/bluetooth/1.0/default/Android.mk
deleted file mode 100644
index 38294c7..0000000
--- a/bluetooth/1.0/default/Android.mk
+++ /dev/null
@@ -1,39 +0,0 @@
-#
-# Copyright (C) 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_MODULE_RELATIVE_PATH := hw
-LOCAL_PROPRIETARY_MODULE := true
-LOCAL_MODULE := android.hardware.bluetooth@1.0-service
-LOCAL_INIT_RC := android.hardware.bluetooth@1.0-service.rc
-LOCAL_SRC_FILES := \
-  service.cpp
-
-LOCAL_SHARED_LIBRARIES := \
-  liblog \
-  libcutils \
-  libdl \
-  libbase \
-  libutils \
-  libhardware \
-
-LOCAL_SHARED_LIBRARIES += \
-  libhidlbase \
-  libhidltransport \
-  android.hardware.bluetooth@1.0 \
-
-include $(BUILD_EXECUTABLE)
diff --git a/boot/1.0/default/Android.bp b/boot/1.0/default/Android.bp
new file mode 100644
index 0000000..c9b7492
--- /dev/null
+++ b/boot/1.0/default/Android.bp
@@ -0,0 +1,34 @@
+cc_library_shared {
+    name: "android.hardware.boot@1.0-impl",
+    relative_install_path: "hw",
+    vendor: true,
+    srcs: ["BootControl.cpp"],
+
+    shared_libs: [
+        "liblog",
+        "libhidlbase",
+        "libhidltransport",
+        "libhardware",
+        "libutils",
+        "android.hardware.boot@1.0",
+    ],
+
+}
+
+cc_binary {
+    name: "android.hardware.boot@1.0-service",
+    relative_install_path: "hw",
+    vendor: true,
+    init_rc: ["android.hardware.boot@1.0-service.rc"],
+    srcs: ["service.cpp"],
+
+    shared_libs: [
+        "liblog",
+        "libhardware",
+        "libhidlbase",
+        "libhidltransport",
+        "libutils",
+        "android.hardware.boot@1.0",
+    ],
+
+}
diff --git a/boot/1.0/default/Android.mk b/boot/1.0/default/Android.mk
deleted file mode 100644
index 5e7ecb4..0000000
--- a/boot/1.0/default/Android.mk
+++ /dev/null
@@ -1,36 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.boot@1.0-impl
-LOCAL_MODULE_RELATIVE_PATH := hw
-LOCAL_PROPRIETARY_MODULE := true
-LOCAL_SRC_FILES := \
-    BootControl.cpp \
-
-LOCAL_SHARED_LIBRARIES := \
-    liblog \
-    libhidlbase \
-    libhidltransport \
-    libhardware \
-    libutils \
-    android.hardware.boot@1.0 \
-
-include $(BUILD_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE_RELATIVE_PATH := hw
-LOCAL_PROPRIETARY_MODULE := true
-LOCAL_MODULE := android.hardware.boot@1.0-service
-LOCAL_INIT_RC := android.hardware.boot@1.0-service.rc
-LOCAL_SRC_FILES := \
-    service.cpp
-
-LOCAL_SHARED_LIBRARIES := \
-    liblog \
-    libhardware \
-    libhidlbase \
-    libhidltransport \
-    libutils \
-    android.hardware.boot@1.0 \
-
-include $(BUILD_EXECUTABLE)
diff --git a/boot/Android.bp b/boot/Android.bp
index 33f70eb..ed19a37 100644
--- a/boot/Android.bp
+++ b/boot/Android.bp
@@ -1,5 +1,6 @@
 // This is an autogenerated file, do not edit.
 subdirs = [
     "1.0",
+    "1.0/default",
     "1.0/vts/functional",
 ]
diff --git a/compatibility_matrix.26.xml b/compatibility_matrix.26.xml
index 6692de0..940588f 100644
--- a/compatibility_matrix.26.xml
+++ b/compatibility_matrix.26.xml
@@ -164,6 +164,14 @@
         </interface>
     </hal>
     <hal format="hidl" optional="true">
+        <name>android.hardware.health</name>
+        <version>2.0</version>
+        <interface>
+            <name>IHealth</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+    <hal format="hidl" optional="true">
         <name>android.hardware.ir</name>
         <version>1.0</version>
     </hal>
diff --git a/compatibility_matrix.27.xml b/compatibility_matrix.27.xml
index 5c81f26..80001f7 100644
--- a/compatibility_matrix.27.xml
+++ b/compatibility_matrix.27.xml
@@ -164,6 +164,14 @@
         </interface>
     </hal>
     <hal format="hidl" optional="true">
+        <name>android.hardware.health</name>
+        <version>2.0</version>
+        <interface>
+            <name>IHealth</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+    <hal format="hidl" optional="true">
         <name>android.hardware.ir</name>
         <version>1.0</version>
     </hal>
diff --git a/compatibility_matrix.current.xml b/compatibility_matrix.current.xml
index 6692de0..4b09c3b 100644
--- a/compatibility_matrix.current.xml
+++ b/compatibility_matrix.current.xml
@@ -163,6 +163,14 @@
             <instance>default</instance>
         </interface>
     </hal>
+    <hal format="hidl" optional="false">
+        <name>android.hardware.health</name>
+        <version>2.0</version>
+        <interface>
+            <name>IHealth</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
     <hal format="hidl" optional="true">
         <name>android.hardware.ir</name>
         <version>1.0</version>
diff --git a/compatibility_matrix.legacy.xml b/compatibility_matrix.legacy.xml
index 5f06a8e..d562fd0 100644
--- a/compatibility_matrix.legacy.xml
+++ b/compatibility_matrix.legacy.xml
@@ -164,6 +164,14 @@
         </interface>
     </hal>
     <hal format="hidl" optional="true">
+        <name>android.hardware.health</name>
+        <version>2.0</version>
+        <interface>
+            <name>IHealth</name>
+            <instance>default</instance>
+        </interface>
+    </hal>
+    <hal format="hidl" optional="true">
         <name>android.hardware.ir</name>
         <version>1.0</version>
     </hal>
diff --git a/contexthub/1.0/default/Contexthub.cpp b/contexthub/1.0/default/Contexthub.cpp
index 3626a09..8d10c75 100644
--- a/contexthub/1.0/default/Contexthub.cpp
+++ b/contexthub/1.0/default/Contexthub.cpp
@@ -155,6 +155,12 @@
         .message = static_cast<const uint8_t *>(msg.msg.data()),
     };
 
+    // Use a dummy to prevent send_message with empty message from failing prematurely
+    static uint8_t dummy;
+    if (txMsg.message_len == 0 && txMsg.message == nullptr) {
+        txMsg.message = &dummy;
+    }
+
     ALOGI("Sending msg of type %" PRIu32 ", size %" PRIu32 " to app 0x%" PRIx64,
           txMsg.message_type,
           txMsg.message_len,
diff --git a/dumpstate/1.0/default/Android.bp b/dumpstate/1.0/default/Android.bp
new file mode 100644
index 0000000..41ccd59
--- /dev/null
+++ b/dumpstate/1.0/default/Android.bp
@@ -0,0 +1,22 @@
+cc_binary {
+    name: "android.hardware.dumpstate@1.0-service",
+    init_rc: ["android.hardware.dumpstate@1.0-service.rc"],
+    relative_install_path: "hw",
+    vendor: true,
+    srcs: [
+        "DumpstateDevice.cpp",
+        "service.cpp",
+    ],
+
+    shared_libs: [
+        "android.hardware.dumpstate@1.0",
+        "libbase",
+        "libcutils",
+        "libdumpstateutil",
+        "libhidlbase",
+        "libhidltransport",
+        "liblog",
+        "libutils",
+    ],
+
+}
diff --git a/dumpstate/1.0/default/Android.mk b/dumpstate/1.0/default/Android.mk
deleted file mode 100644
index 0b07f49..0000000
--- a/dumpstate/1.0/default/Android.mk
+++ /dev/null
@@ -1,22 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.dumpstate@1.0-service
-LOCAL_INIT_RC := android.hardware.dumpstate@1.0-service.rc
-LOCAL_MODULE_RELATIVE_PATH := hw
-LOCAL_PROPRIETARY_MODULE := true
-LOCAL_SRC_FILES := \
-    DumpstateDevice.cpp \
-    service.cpp
-
-LOCAL_SHARED_LIBRARIES := \
-    android.hardware.dumpstate@1.0 \
-    libbase \
-    libcutils \
-    libdumpstateutil \
-    libhidlbase \
-    libhidltransport \
-    liblog \
-    libutils
-
-include $(BUILD_EXECUTABLE)
diff --git a/dumpstate/Android.bp b/dumpstate/Android.bp
index 33f70eb..ed19a37 100644
--- a/dumpstate/Android.bp
+++ b/dumpstate/Android.bp
@@ -1,5 +1,6 @@
 // This is an autogenerated file, do not edit.
 subdirs = [
     "1.0",
+    "1.0/default",
     "1.0/vts/functional",
 ]
diff --git a/gatekeeper/1.0/default/Android.bp b/gatekeeper/1.0/default/Android.bp
new file mode 100644
index 0000000..4e6c9f0
--- /dev/null
+++ b/gatekeeper/1.0/default/Android.bp
@@ -0,0 +1,36 @@
+cc_library_shared {
+    name: "android.hardware.gatekeeper@1.0-impl",
+    relative_install_path: "hw",
+    vendor: true,
+
+    srcs: ["Gatekeeper.cpp"],
+
+    shared_libs: [
+        "android.hardware.gatekeeper@1.0",
+        "libhardware",
+        "libhidlbase",
+        "libhidltransport",
+        "libutils",
+        "liblog",
+    ],
+
+}
+
+cc_binary {
+    name: "android.hardware.gatekeeper@1.0-service",
+    relative_install_path: "hw",
+    vendor: true,
+    init_rc: ["android.hardware.gatekeeper@1.0-service.rc"],
+
+    srcs: ["service.cpp"],
+
+    shared_libs: [
+        "android.hardware.gatekeeper@1.0",
+        "libhardware",
+        "libhidlbase",
+        "libhidltransport",
+        "libutils",
+        "liblog",
+    ],
+
+}
diff --git a/gatekeeper/1.0/default/Android.mk b/gatekeeper/1.0/default/Android.mk
deleted file mode 100644
index d084535..0000000
--- a/gatekeeper/1.0/default/Android.mk
+++ /dev/null
@@ -1,40 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_RELATIVE_PATH := hw
-LOCAL_PROPRIETARY_MODULE := true
-LOCAL_MODULE := android.hardware.gatekeeper@1.0-impl
-
-LOCAL_SRC_FILES := \
-    Gatekeeper.cpp \
-
-LOCAL_SHARED_LIBRARIES := \
-    android.hardware.gatekeeper@1.0 \
-    libhardware \
-    libhidlbase \
-    libhidltransport \
-    libutils \
-    liblog \
-
-include $(BUILD_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_RELATIVE_PATH := hw
-LOCAL_PROPRIETARY_MODULE := true
-LOCAL_MODULE := android.hardware.gatekeeper@1.0-service
-LOCAL_INIT_RC := android.hardware.gatekeeper@1.0-service.rc
-
-LOCAL_SRC_FILES := \
-    service.cpp    \
-
-LOCAL_SHARED_LIBRARIES := \
-    android.hardware.gatekeeper@1.0 \
-    libhardware \
-    libhidlbase \
-    libhidltransport \
-    libutils \
-    liblog \
-
-include $(BUILD_EXECUTABLE)
diff --git a/gatekeeper/Android.bp b/gatekeeper/Android.bp
index 33f70eb..ed19a37 100644
--- a/gatekeeper/Android.bp
+++ b/gatekeeper/Android.bp
@@ -1,5 +1,6 @@
 // This is an autogenerated file, do not edit.
 subdirs = [
     "1.0",
+    "1.0/default",
     "1.0/vts/functional",
 ]
diff --git a/gnss/1.0/default/Android.bp b/gnss/1.0/default/Android.bp
new file mode 100644
index 0000000..007ed97
--- /dev/null
+++ b/gnss/1.0/default/Android.bp
@@ -0,0 +1,54 @@
+cc_library_shared {
+    name: "android.hardware.gnss@1.0-impl",
+    vendor: true,
+    relative_install_path: "hw",
+    srcs: [
+        "ThreadCreationWrapper.cpp",
+        "AGnss.cpp",
+        "AGnssRil.cpp",
+        "Gnss.cpp",
+        "GnssBatching.cpp",
+        "GnssDebug.cpp",
+        "GnssGeofencing.cpp",
+        "GnssMeasurement.cpp",
+        "GnssNavigationMessage.cpp",
+        "GnssNi.cpp",
+        "GnssXtra.cpp",
+        "GnssConfiguration.cpp",
+        "GnssUtils.cpp",
+    ],
+
+    shared_libs: [
+        "liblog",
+        "libhidlbase",
+        "libhidltransport",
+        "libutils",
+        "android.hardware.gnss@1.0",
+        "libhardware",
+    ],
+
+    cflags: ["-Werror"],
+
+}
+
+cc_binary {
+    relative_install_path: "hw",
+    vendor: true,
+    name: "android.hardware.gnss@1.0-service",
+    init_rc: ["android.hardware.gnss@1.0-service.rc"],
+    srcs: ["service.cpp"],
+
+    shared_libs: [
+        "liblog",
+        "libcutils",
+        "libdl",
+        "libbase",
+        "libutils",
+        "libhardware",
+        "libbinder",
+        "libhidlbase",
+        "libhidltransport",
+        "android.hardware.gnss@1.0",
+    ],
+
+}
diff --git a/gnss/1.0/default/Android.mk b/gnss/1.0/default/Android.mk
deleted file mode 100644
index 34da64e..0000000
--- a/gnss/1.0/default/Android.mk
+++ /dev/null
@@ -1,56 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.gnss@1.0-impl
-LOCAL_PROPRIETARY_MODULE := true
-LOCAL_MODULE_RELATIVE_PATH := hw
-LOCAL_SRC_FILES := \
-    ThreadCreationWrapper.cpp \
-    AGnss.cpp \
-    AGnssRil.cpp \
-    Gnss.cpp \
-    GnssBatching.cpp \
-    GnssDebug.cpp \
-    GnssGeofencing.cpp \
-    GnssMeasurement.cpp \
-    GnssNavigationMessage.cpp \
-    GnssNi.cpp \
-    GnssXtra.cpp \
-    GnssConfiguration.cpp \
-    GnssUtils.cpp
-
-LOCAL_SHARED_LIBRARIES := \
-    liblog \
-    libhidlbase \
-    libhidltransport \
-    libutils \
-    android.hardware.gnss@1.0 \
-    libhardware
-
-LOCAL_CFLAGS += -Werror
-
-include $(BUILD_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE_RELATIVE_PATH := hw
-LOCAL_PROPRIETARY_MODULE := true
-LOCAL_MODULE := android.hardware.gnss@1.0-service
-LOCAL_INIT_RC := android.hardware.gnss@1.0-service.rc
-LOCAL_SRC_FILES := \
-    service.cpp \
-
-LOCAL_SHARED_LIBRARIES := \
-    liblog \
-    libcutils \
-    libdl \
-    libbase \
-    libutils \
-    libhardware \
-    libbinder \
-
-LOCAL_SHARED_LIBRARIES += \
-    libhidlbase \
-    libhidltransport \
-    android.hardware.gnss@1.0 \
-
-include $(BUILD_EXECUTABLE)
diff --git a/gnss/Android.bp b/gnss/Android.bp
index 33f70eb..ed19a37 100644
--- a/gnss/Android.bp
+++ b/gnss/Android.bp
@@ -1,5 +1,6 @@
 // This is an autogenerated file, do not edit.
 subdirs = [
     "1.0",
+    "1.0/default",
     "1.0/vts/functional",
 ]
diff --git a/graphics/allocator/2.0/default/OWNERS b/graphics/allocator/2.0/default/OWNERS
new file mode 100644
index 0000000..3aa5fa1
--- /dev/null
+++ b/graphics/allocator/2.0/default/OWNERS
@@ -0,0 +1,4 @@
+# Graphics team
+jessehall@google.com
+olv@google.com
+stoza@google.com
diff --git a/graphics/composer/2.1/default/Android.bp b/graphics/composer/2.1/default/Android.bp
index 037f810..140e50e 100644
--- a/graphics/composer/2.1/default/Android.bp
+++ b/graphics/composer/2.1/default/Android.bp
@@ -38,7 +38,8 @@
         "liblog",
         "libsync",
         "libutils",
-        "libhwc2on1adapter"
+        "libhwc2on1adapter",
+        "libhwc2onfbadapter",
     ],
 }
 
diff --git a/graphics/composer/2.1/default/Hwc.cpp b/graphics/composer/2.1/default/Hwc.cpp
index 1618dcc..fdb4af8 100644
--- a/graphics/composer/2.1/default/Hwc.cpp
+++ b/graphics/composer/2.1/default/Hwc.cpp
@@ -23,8 +23,10 @@
 #include <log/log.h>
 
 #include "ComposerClient.h"
+#include "hardware/fb.h"
 #include "hardware/hwcomposer.h"
 #include "hwc2on1adapter/HWC2On1Adapter.h"
+#include "hwc2onfbadapter/HWC2OnFbAdapter.h"
 
 using namespace std::chrono_literals;
 
@@ -37,6 +39,30 @@
 
 HwcHal::HwcHal(const hw_module_t* module)
     : mDevice(nullptr), mDispatch(), mMustValidateDisplay(true), mAdapter() {
+    uint32_t majorVersion;
+    if (module->id && strcmp(module->id, GRALLOC_HARDWARE_MODULE_ID) == 0) {
+        majorVersion = initWithFb(module);
+    } else {
+        majorVersion = initWithHwc(module);
+    }
+
+    initCapabilities();
+    if (majorVersion >= 2 &&
+        hasCapability(Capability::PRESENT_FENCE_IS_NOT_RELIABLE)) {
+        ALOGE("Present fence must be reliable from HWC2 on.");
+        abort();
+    }
+
+    initDispatch();
+}
+
+HwcHal::~HwcHal()
+{
+    hwc2_close(mDevice);
+}
+
+uint32_t HwcHal::initWithHwc(const hw_module_t* module)
+{
     // Determine what kind of module is available (HWC2 vs HWC1.X).
     hw_device_t* device = nullptr;
     int error = module->methods->open(module, HWC_HARDWARE_COMPOSER, &device);
@@ -65,19 +91,22 @@
         mDevice = reinterpret_cast<hwc2_device_t*>(device);
     }
 
-    initCapabilities();
-    if (majorVersion >= 2 &&
-        hasCapability(Capability::PRESENT_FENCE_IS_NOT_RELIABLE)) {
-        ALOGE("Present fence must be reliable from HWC2 on.");
+    return majorVersion;
+}
+
+uint32_t HwcHal::initWithFb(const hw_module_t* module)
+{
+    framebuffer_device_t* fb_device;
+    int error = framebuffer_open(module, &fb_device);
+    if (error != 0) {
+        ALOGE("Failed to open FB device (%s), aborting", strerror(-error));
         abort();
     }
 
-    initDispatch();
-}
+    mFbAdapter = std::make_unique<HWC2OnFbAdapter>(fb_device);
+    mDevice = mFbAdapter.get();
 
-HwcHal::~HwcHal()
-{
-    hwc2_close(mDevice);
+    return 0;
 }
 
 void HwcHal::initCapabilities()
@@ -757,7 +786,11 @@
     const hw_module_t* module = nullptr;
     int err = hw_get_module(HWC_HARDWARE_MODULE_ID, &module);
     if (err) {
-        ALOGE("failed to get hwcomposer module");
+        ALOGI("falling back to FB HAL");
+        err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module);
+    }
+    if (err) {
+        ALOGE("failed to get hwcomposer or fb module");
         return nullptr;
     }
 
diff --git a/graphics/composer/2.1/default/Hwc.h b/graphics/composer/2.1/default/Hwc.h
index cf6a72a..32c6b0b 100644
--- a/graphics/composer/2.1/default/Hwc.h
+++ b/graphics/composer/2.1/default/Hwc.h
@@ -34,6 +34,7 @@
 
 namespace android {
     class HWC2On1Adapter;
+    class HWC2OnFbAdapter;
 }
 
 namespace android {
@@ -147,6 +148,9 @@
     Error setLayerZOrder(Display display, Layer layer, uint32_t z) override;
 
 private:
+    uint32_t initWithHwc(const hw_module_t* module);
+    uint32_t initWithFb(const hw_module_t* module);
+
     void initCapabilities();
 
     template<typename T>
@@ -221,6 +225,10 @@
     // If the HWC implementation version is < 2.0, use an adapter to interface
     // between HWC 2.0 <-> HWC 1.X.
     std::unique_ptr<HWC2On1Adapter> mAdapter;
+
+    // If there is no HWC implementation, use an adapter to interface between
+    // HWC 2.0 <-> FB HAL.
+    std::unique_ptr<HWC2OnFbAdapter> mFbAdapter;
 };
 
 extern "C" IComposer* HIDL_FETCH_IComposer(const char* name);
diff --git a/graphics/composer/2.1/default/OWNERS b/graphics/composer/2.1/default/OWNERS
new file mode 100644
index 0000000..3aa5fa1
--- /dev/null
+++ b/graphics/composer/2.1/default/OWNERS
@@ -0,0 +1,4 @@
+# Graphics team
+jessehall@google.com
+olv@google.com
+stoza@google.com
diff --git a/graphics/mapper/2.0/default/OWNERS b/graphics/mapper/2.0/default/OWNERS
new file mode 100644
index 0000000..3aa5fa1
--- /dev/null
+++ b/graphics/mapper/2.0/default/OWNERS
@@ -0,0 +1,4 @@
+# Graphics team
+jessehall@google.com
+olv@google.com
+stoza@google.com
diff --git a/health/2.0/Android.bp b/health/2.0/Android.bp
index 8281a84..97265ec 100644
--- a/health/2.0/Android.bp
+++ b/health/2.0/Android.bp
@@ -82,7 +82,6 @@
         ":android.hardware.health@2.0_hal",
     ],
     out: [
-        "android/hardware/health/V2_0/HealthInfo.java",
         "android/hardware/health/V2_0/Result.java",
         "android/hardware/health/V2_0/IHealth.java",
         "android/hardware/health/V2_0/IHealthInfoCallback.java",
diff --git a/health/2.0/IHealthInfoCallback.hal b/health/2.0/IHealthInfoCallback.hal
index 15352ee..8e17bb9 100644
--- a/health/2.0/IHealthInfoCallback.hal
+++ b/health/2.0/IHealthInfoCallback.hal
@@ -16,6 +16,8 @@
 
 package android.hardware.health@2.0;
 
+import @1.0::HealthInfo;
+
 /**
  * IHealthInfoCallback is the callback interface to
  * {@link IHealthInfoBus.registerCallback}.
diff --git a/health/2.0/types.hal b/health/2.0/types.hal
index 0d17f9f..8c6d88f 100644
--- a/health/2.0/types.hal
+++ b/health/2.0/types.hal
@@ -26,40 +26,3 @@
     NOT_FOUND,
     CALLBACK_DIED,
 };
-
-struct HealthInfo {
-    /**
-     * Legacy information from 1.0 HAL.
-     *
-     * If a value is not available, it must be set to 0, UNKNOWN, or empty
-     * string.
-     */
-    @1.0::HealthInfo legacy;
-
-    /**
-     * Average battery current in microamperes. Positive
-     * values indicate net current entering the battery from a charge source,
-     * negative values indicate net current discharging from the battery.
-     * The time period over which the average is computed may depend on the
-     * fuel gauge hardware and its configuration.
-     *
-     * If this value is not available, it must be set to 0.
-     */
-    int32_t batteryCurrentAverage;
-
-    /**
-     * Remaining battery capacity percentage of total capacity
-     * (with no fractional part). This value must be in the range 0-100
-     * (inclusive).
-     *
-     * If this value is not available, it must be set to 0.
-     */
-    int32_t batteryCapacity;
-
-    /**
-     * Battery remaining energy in nanowatt-hours.
-     *
-     * If this value is not available, it must be set to 0.
-     */
-    int64_t energyCounter;
-};
\ No newline at end of file
diff --git a/health/2.0/vts/functional/VtsHalHealthV2_0TargetTest.cpp b/health/2.0/vts/functional/VtsHalHealthV2_0TargetTest.cpp
index a19a4a4..9b86873 100644
--- a/health/2.0/vts/functional/VtsHalHealthV2_0TargetTest.cpp
+++ b/health/2.0/vts/functional/VtsHalHealthV2_0TargetTest.cpp
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#define LOG_TAG "mHealthhidl_hal_test"
+#define LOG_TAG "health_hidl_hal_test"
 
 #include <mutex>
 
@@ -35,6 +35,7 @@
 namespace V2_0 {
 
 using V1_0::BatteryStatus;
+using V1_0::HealthInfo;
 
 // Test environment for graphics.composer
 class HealthHidlEnvironment : public VtsHalHidlTargetTestEnvBase {
diff --git a/sensors/1.0/default/Android.bp b/sensors/1.0/default/Android.bp
index 4bbafa6..2485b05 100644
--- a/sensors/1.0/default/Android.bp
+++ b/sensors/1.0/default/Android.bp
@@ -43,4 +43,21 @@
     ],
 }
 
+cc_binary {
+    name: "android.hardware.sensors@1.0-service",
+    relative_install_path: "hw",
+    vendor: true,
+    init_rc: ["android.hardware.sensors@1.0-service.rc"],
+    srcs: ["service.cpp"],
 
+    shared_libs: [
+        "liblog",
+        "libcutils",
+        "libdl",
+        "libbase",
+        "libutils",
+        "libhidlbase",
+        "libhidltransport",
+        "android.hardware.sensors@1.0",
+    ],
+}
diff --git a/sensors/1.0/default/Android.mk b/sensors/1.0/default/Android.mk
deleted file mode 100644
index d114542..0000000
--- a/sensors/1.0/default/Android.mk
+++ /dev/null
@@ -1,23 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE_RELATIVE_PATH := hw
-LOCAL_PROPRIETARY_MODULE := true
-LOCAL_MODULE := android.hardware.sensors@1.0-service
-LOCAL_INIT_RC := android.hardware.sensors@1.0-service.rc
-LOCAL_SRC_FILES := \
-        service.cpp \
-
-LOCAL_SHARED_LIBRARIES := \
-        liblog \
-        libcutils \
-        libdl \
-        libbase \
-        libutils \
-
-LOCAL_SHARED_LIBRARIES += \
-        libhidlbase \
-        libhidltransport \
-        android.hardware.sensors@1.0 \
-
-include $(BUILD_EXECUTABLE)
diff --git a/thermal/1.0/default/Android.bp b/thermal/1.0/default/Android.bp
index 1510509..2054b88 100644
--- a/thermal/1.0/default/Android.bp
+++ b/thermal/1.0/default/Android.bp
@@ -1,7 +1,22 @@
+//
+// Copyright (C) 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.
+
 cc_library_shared {
     name: "android.hardware.thermal@1.0-impl",
     defaults: ["hidl_defaults"],
-    proprietary: true,
+    vendor: true,
     relative_install_path: "hw",
     srcs: ["Thermal.cpp"],
     shared_libs: [
@@ -16,3 +31,23 @@
         "android.hardware.thermal@1.0",
     ],
 }
+
+cc_binary {
+    name: "android.hardware.thermal@1.0-service",
+    relative_install_path: "hw",
+    vendor: true,
+    init_rc: ["android.hardware.thermal@1.0-service.rc"],
+    srcs: ["service.cpp"],
+
+    shared_libs: [
+        "liblog",
+        "libcutils",
+        "libdl",
+        "libbase",
+        "libutils",
+        "libhardware",
+        "libhidlbase",
+        "libhidltransport",
+        "android.hardware.thermal@1.0",
+    ],
+}
diff --git a/thermal/1.0/default/Android.mk b/thermal/1.0/default/Android.mk
deleted file mode 100644
index 113020a..0000000
--- a/thermal/1.0/default/Android.mk
+++ /dev/null
@@ -1,39 +0,0 @@
-#
-# Copyright (C) 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_MODULE_RELATIVE_PATH := hw
-LOCAL_PROPRIETARY_MODULE := true
-LOCAL_MODULE := android.hardware.thermal@1.0-service
-LOCAL_INIT_RC := android.hardware.thermal@1.0-service.rc
-LOCAL_SRC_FILES := \
-        service.cpp \
-
-LOCAL_SHARED_LIBRARIES := \
-        liblog \
-        libcutils \
-        libdl \
-        libbase \
-        libutils \
-        libhardware \
-
-LOCAL_SHARED_LIBRARIES += \
-        libhidlbase \
-        libhidltransport \
-        android.hardware.thermal@1.0 \
-
-include $(BUILD_EXECUTABLE)
diff --git a/tv/Android.bp b/tv/Android.bp
index ac54910..58d840e 100644
--- a/tv/Android.bp
+++ b/tv/Android.bp
@@ -1,6 +1,8 @@
 // This is an autogenerated file, do not edit.
 subdirs = [
     "cec/1.0",
+    "cec/1.0/default",
     "input/1.0",
+    "input/1.0/default",
     "input/1.0/vts/functional",
 ]
diff --git a/tv/cec/1.0/default/Android.bp b/tv/cec/1.0/default/Android.bp
new file mode 100644
index 0000000..efb88ec
--- /dev/null
+++ b/tv/cec/1.0/default/Android.bp
@@ -0,0 +1,39 @@
+cc_library_shared {
+    name: "android.hardware.tv.cec@1.0-impl",
+    vendor: true,
+    relative_install_path: "hw",
+    srcs: ["HdmiCec.cpp"],
+
+    shared_libs: [
+        "libhidlbase",
+        "libhidltransport",
+        "liblog",
+        "libbase",
+        "libutils",
+        "libhardware",
+        "android.hardware.tv.cec@1.0",
+    ],
+
+}
+
+cc_binary {
+    name: "android.hardware.tv.cec@1.0-service",
+    relative_install_path: "hw",
+    vendor: true,
+    init_rc: ["android.hardware.tv.cec@1.0-service.rc"],
+    srcs: ["service.cpp"],
+
+    shared_libs: [
+        "liblog",
+        "libcutils",
+        "libdl",
+        "libbase",
+        "libutils",
+        "libhardware_legacy",
+        "libhardware",
+        "libhidlbase",
+        "libhidltransport",
+        "android.hardware.tv.cec@1.0",
+    ],
+
+}
diff --git a/tv/cec/1.0/default/Android.mk b/tv/cec/1.0/default/Android.mk
deleted file mode 100644
index 9d37344..0000000
--- a/tv/cec/1.0/default/Android.mk
+++ /dev/null
@@ -1,44 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.tv.cec@1.0-impl
-LOCAL_PROPRIETARY_MODULE := true
-LOCAL_MODULE_RELATIVE_PATH := hw
-LOCAL_SRC_FILES := \
-    HdmiCec.cpp
-
-LOCAL_SHARED_LIBRARIES := \
-    libhidlbase \
-    libhidltransport \
-    liblog \
-    libbase \
-    libutils \
-    libhardware \
-    android.hardware.tv.cec@1.0 \
-
-include $(BUILD_SHARED_LIBRARY)
-
-
-include $(CLEAR_VARS)
-LOCAL_MODULE_RELATIVE_PATH := hw
-LOCAL_PROPRIETARY_MODULE := true
-LOCAL_MODULE := android.hardware.tv.cec@1.0-service
-LOCAL_INIT_RC := android.hardware.tv.cec@1.0-service.rc
-LOCAL_SRC_FILES := \
-    service.cpp \
-
-LOCAL_SHARED_LIBRARIES := \
-    liblog \
-    libcutils \
-    libdl \
-    libbase \
-    libutils \
-    libhardware_legacy \
-    libhardware \
-
-LOCAL_SHARED_LIBRARIES += \
-    libhidlbase \
-    libhidltransport \
-    android.hardware.tv.cec@1.0 \
-
-include $(BUILD_EXECUTABLE)
diff --git a/tv/cec/1.0/default/HdmiCec.cpp b/tv/cec/1.0/default/HdmiCec.cpp
index ebe2681..171bdfe 100644
--- a/tv/cec/1.0/default/HdmiCec.cpp
+++ b/tv/cec/1.0/default/HdmiCec.cpp
@@ -264,8 +264,7 @@
 
 sp<IHdmiCecCallback> HdmiCec::mCallback = nullptr;
 
-HdmiCec::HdmiCec(hdmi_cec_device_t* device) : mDevice(device) {
-}
+HdmiCec::HdmiCec(hdmi_cec_device_t* device) : mDevice(device) {}
 
 // Methods from ::android::hardware::tv::cec::V1_0::IHdmiCec follow.
 Return<Result> HdmiCec::addLogicalAddress(CecLogicalAddress addr) {
@@ -319,8 +318,16 @@
 }
 
 Return<void> HdmiCec::setCallback(const sp<IHdmiCecCallback>& callback) {
-    mCallback = callback;
-    mDevice->register_event_callback(mDevice, eventCallback, nullptr);
+    if (mCallback != nullptr) {
+        mCallback->unlinkToDeath(this);
+        mCallback = nullptr;
+    }
+
+    if (callback != nullptr) {
+        mCallback = callback;
+        mCallback->linkToDeath(this, 0 /*cookie*/);
+        mDevice->register_event_callback(mDevice, eventCallback, nullptr);
+    }
     return Void();
 }
 
diff --git a/tv/cec/1.0/default/HdmiCec.h b/tv/cec/1.0/default/HdmiCec.h
index 34a3bb0..0133abc 100644
--- a/tv/cec/1.0/default/HdmiCec.h
+++ b/tv/cec/1.0/default/HdmiCec.h
@@ -47,7 +47,7 @@
 using ::android::hardware::hidl_string;
 using ::android::sp;
 
-struct HdmiCec : public IHdmiCec {
+struct HdmiCec : public IHdmiCec, public hidl_death_recipient {
     HdmiCec(hdmi_cec_device_t* device);
     // Methods from ::android::hardware::tv::cec::V1_0::IHdmiCec follow.
     Return<Result> addLogicalAddress(CecLogicalAddress addr)  override;
@@ -87,7 +87,12 @@
         }
     }
 
-private:
+    virtual void serviceDied(uint64_t /*cookie*/,
+                             const wp<::android::hidl::base::V1_0::IBase>& /*who*/) {
+        setCallback(nullptr);
+    }
+
+   private:
     static sp<IHdmiCecCallback> mCallback;
     const hdmi_cec_device_t* mDevice;
 };
diff --git a/tv/input/1.0/default/Android.bp b/tv/input/1.0/default/Android.bp
new file mode 100644
index 0000000..f8956f1
--- /dev/null
+++ b/tv/input/1.0/default/Android.bp
@@ -0,0 +1,41 @@
+cc_library_shared {
+    name: "android.hardware.tv.input@1.0-impl",
+    vendor: true,
+    relative_install_path: "hw",
+    srcs: ["TvInput.cpp"],
+
+    shared_libs: [
+        "libbase",
+        "liblog",
+        "libhardware",
+        "libhidlbase",
+        "libhidltransport",
+        "libutils",
+        "android.hardware.audio.common@2.0",
+        "android.hardware.tv.input@1.0",
+    ],
+
+}
+
+cc_binary {
+    name: "android.hardware.tv.input@1.0-service",
+    relative_install_path: "hw",
+    vendor: true,
+    init_rc: ["android.hardware.tv.input@1.0-service.rc"],
+    srcs: ["service.cpp"],
+
+    shared_libs: [
+        "liblog",
+        "libcutils",
+        "libdl",
+        "libbase",
+        "libutils",
+        "libhardware_legacy",
+        "libhardware",
+        "libhidlbase",
+        "libhidltransport",
+        "android.hardware.audio.common@2.0",
+        "android.hardware.tv.input@1.0",
+    ],
+
+}
diff --git a/tv/input/1.0/default/Android.mk b/tv/input/1.0/default/Android.mk
deleted file mode 100644
index 210da86..0000000
--- a/tv/input/1.0/default/Android.mk
+++ /dev/null
@@ -1,46 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.tv.input@1.0-impl
-LOCAL_PROPRIETARY_MODULE := true
-LOCAL_MODULE_RELATIVE_PATH := hw
-LOCAL_SRC_FILES := \
-    TvInput.cpp \
-
-LOCAL_SHARED_LIBRARIES := \
-    libbase \
-    liblog \
-    libhardware \
-    libhidlbase \
-    libhidltransport \
-    libutils \
-    android.hardware.audio.common@2.0 \
-    android.hardware.tv.input@1.0 \
-
-include $(BUILD_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE_RELATIVE_PATH := hw
-LOCAL_PROPRIETARY_MODULE := true
-LOCAL_MODULE := android.hardware.tv.input@1.0-service
-LOCAL_INIT_RC := android.hardware.tv.input@1.0-service.rc
-LOCAL_SRC_FILES := \
-    service.cpp \
-
-LOCAL_SHARED_LIBRARIES := \
-    liblog \
-    libcutils \
-    libdl \
-    libbase \
-    libutils \
-    libhardware_legacy \
-    libhardware \
-
-LOCAL_SHARED_LIBRARIES += \
-    libhidlbase \
-    libhidltransport \
-    android.hardware.audio.common@2.0 \
-    android.hardware.tv.input@1.0 \
-
-include $(BUILD_EXECUTABLE)
-