Convert build system to soong using Android.bp

* Convert top level Android.mk into build templates in build/Android.bp
  and build/fluoride.go
* Initial conversion is done by "androidmk Android.mk > Android.bp"
* Android.bp does not allow source inclusion from external directories
  and therefore they have to be made in to cc_library_static in their
  respective sub-directories and linked using whole_static_libs in the
  modules where they are used
* As Android.bp does not allow multiple modules of the same name,
  same-name mudules for different target are merged into one definition
  with target specific setup
* Generated proto header path has to be changed in osi/src/metrics.cc as
  Android.bp only generate header path relative to the Android.bp file
  instead of top-level directory such as system/bt
* Android.bp does not support resource copying yet and hence conf files
  are left un-touched.
* Android.bp does support conditional module declaration and therefore
  test-vendor libs are left untouched except for unit tests
* The goal of this CL is to direct (almost) translate Android.mk to
  Android.bp first with Android.bp specific optimizations coming later

Bug: 32958753
Test: Code compilation, manual testing by test team

Change-Id: I5249e1f2135c4121205619b1d735ce448feb7499
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..69ed54b
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,18 @@
+subdirs = [
+    "build",
+    "btif",
+    "btcore",
+    "audio_a2dp_hw",
+    "hci",
+    "utils",
+    "device",
+    "stack",
+    "osi",
+    "embdrv",
+    "service",
+    "main",
+    "bta",
+    "vendor_libs",
+    "test",
+    "udrv",
+]
diff --git a/Android.mk b/Android.mk
index dbbd32b..5053e7d 100644
--- a/Android.mk
+++ b/Android.mk
@@ -1,52 +1 @@
-LOCAL_PATH := $(call my-dir)
-
-# Setup Bluetooth local make variables for handling configuration
-ifneq ($(BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR),)
-  bluetooth_C_INCLUDES := $(BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR)
-  bluetooth_CFLAGS += -DHAS_BDROID_BUILDCFG
-else
-  bluetooth_C_INCLUDES :=
-  bluetooth_CFLAGS += -DHAS_NO_BDROID_BUILDCFG
-endif
-
-ifneq ($(BOARD_BLUETOOTH_BDROID_HCILP_INCLUDED),)
-  bluetooth_CFLAGS += -DHCILP_INCLUDED=$(BOARD_BLUETOOTH_BDROID_HCILP_INCLUDED)
-endif
-
-ifneq ($(TARGET_BUILD_VARIANT),user)
-bluetooth_CFLAGS += -DBLUEDROID_DEBUG
-endif
-
-bluetooth_CFLAGS += -DEXPORT_SYMBOL="__attribute__((visibility(\"default\")))"
-
-#
-# Common C/C++ compiler flags.
-#
-# -Wno-gnu-variable-sized-type-not-at-end is needed, because struct BT_HDR
-#  is defined as a variable-size header in a struct.
-# -Wno-typedef-redefinition is needed because of the way the struct typedef
-#  is done in osi/include header files. This issue can be obsoleted by
-#  switching to C11 or C++.
-# -Wno-unused-parameter is needed, because there are too many unused
-#  parameters in all the code.
-#
-bluetooth_CFLAGS += \
-  -fvisibility=hidden \
-  -Wall \
-  -Wextra \
-  -Werror \
-  -Wno-gnu-variable-sized-type-not-at-end \
-  -Wno-typedef-redefinition \
-  -Wno-unused-parameter \
-  -DLOG_NDEBUG=1
-
-bluetooth_CONLYFLAGS += -std=c99
-bluetooth_CPPFLAGS :=
-
 include $(call all-subdir-makefiles)
-
-# Cleanup our locals
-bluetooth_C_INCLUDES :=
-bluetooth_CFLAGS :=
-bluetooth_CONLYFLAGS :=
-bluetooth_CPPFLAGS :=
diff --git a/audio_a2dp_hw/Android.bp b/audio_a2dp_hw/Android.bp
new file mode 100644
index 0000000..df7e33f
--- /dev/null
+++ b/audio_a2dp_hw/Android.bp
@@ -0,0 +1,26 @@
+// Audio A2DP shared library for target
+// ========================================================
+cc_library_shared {
+    name: "audio.a2dp.default",
+    defaults: ["fluoride_defaults"],
+    relative_install_path: "hw",
+    srcs: [
+        "audio_a2dp_hw.cc",
+        "audio_a2dp_hw_utils.cc",
+    ],
+    include_dirs: [
+        "system/bt",
+    ],
+    shared_libs: [
+        "liblog",
+    ],
+    static_libs: ["libosi"],
+}
+
+cc_library_static {
+    name: "libaudio-a2dp-hw-utils",
+    defaults: ["fluoride_defaults"],
+    srcs: [
+        "audio_a2dp_hw_utils.cc",
+    ],
+}
diff --git a/audio_a2dp_hw/Android.mk b/audio_a2dp_hw/Android.mk
deleted file mode 100644
index 8b4273f..0000000
--- a/audio_a2dp_hw/Android.mk
+++ /dev/null
@@ -1,29 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-# Audio A2DP shared library for target
-# ========================================================
-include $(CLEAR_VARS)
-LOCAL_CPP_EXTENSION := .cc
-
-LOCAL_SRC_FILES := \
-	audio_a2dp_hw.cc \
-	audio_a2dp_hw_utils.cc
-
-LOCAL_C_INCLUDES := \
-	. \
-	$(LOCAL_PATH)/../ \
-	$(LOCAL_PATH)/../utils/include
-
-LOCAL_MODULE := audio.a2dp.default
-LOCAL_MODULE_RELATIVE_PATH := hw
-
-LOCAL_SHARED_LIBRARIES := liblog libchrome
-LOCAL_STATIC_LIBRARIES := libosi
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_CFLAGS += $(bluetooth_CFLAGS)
-LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
-LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/audio_a2dp_hw/audio_a2dp_hw.cc b/audio_a2dp_hw/audio_a2dp_hw.cc
index ecc27a6..24a5014 100644
--- a/audio_a2dp_hw/audio_a2dp_hw.cc
+++ b/audio_a2dp_hw/audio_a2dp_hw.cc
@@ -44,13 +44,13 @@
 #include <hardware/hardware.h>
 #include <system/audio.h>
 
-#include "audio_a2dp_hw.h"
-#include "bt_utils.h"
 #include "osi/include/hash_map_utils.h"
 #include "osi/include/log.h"
 #include "osi/include/osi.h"
 #include "osi/include/socket_utils/sockets.h"
 
+#include "audio_a2dp_hw.h"
+
 /*****************************************************************************
  *  Constants & Macros
  *****************************************************************************/
diff --git a/bta/Android.bp b/bta/Android.bp
new file mode 100644
index 0000000..08ce3b1
--- /dev/null
+++ b/bta/Android.bp
@@ -0,0 +1,135 @@
+cc_defaults {
+    name: "fluoride_bta_defaults",
+    defaults: ["fluoride_defaults"],
+    local_include_dirs: [
+        "include",
+        "sys",
+        "dm",
+        "hd",
+        "hh",
+        "closure",
+    ],
+    include_dirs: [
+        "system/bt",
+        "system/bt/bta/include",
+        "system/bt/btcore/include",
+        "system/bt/hci/include",
+        "system/bt/include",
+        "system/bt/stack/include",
+        "system/bt/stack/btm",
+        "system/bt/udrv/include",
+        "system/bt/vnd/include",
+        "system/bt/utils/include",
+    ],
+    shared_libs: [
+        "libcutils",
+    ],
+    cflags: ["-DBUILDCFG"],
+}
+
+// BTA static library for target
+// ========================================================
+cc_library_static {
+    name: "libbt-bta",
+    defaults: ["fluoride_bta_defaults"],
+    srcs: [
+        "ag/bta_ag_act.cc",
+        "ag/bta_ag_api.cc",
+        "ag/bta_ag_at.cc",
+        "ag/bta_ag_cfg.cc",
+        "ag/bta_ag_ci.cc",
+        "ag/bta_ag_cmd.cc",
+        "ag/bta_ag_main.cc",
+        "ag/bta_ag_rfc.cc",
+        "ag/bta_ag_sco.cc",
+        "ag/bta_ag_sdp.cc",
+        "ar/bta_ar.cc",
+        "av/bta_av_aact.cc",
+        "av/bta_av_act.cc",
+        "av/bta_av_api.cc",
+        "av/bta_av_cfg.cc",
+        "av/bta_av_ci.cc",
+        "av/bta_av_main.cc",
+        "av/bta_av_ssm.cc",
+        "closure/bta_closure.cc",
+        "dm/bta_dm_act.cc",
+        "dm/bta_dm_api.cc",
+        "dm/bta_dm_cfg.cc",
+        "dm/bta_dm_ci.cc",
+        "dm/bta_dm_main.cc",
+        "dm/bta_dm_pm.cc",
+        "dm/bta_dm_sco.cc",
+        "gatt/bta_gattc_act.cc",
+        "gatt/bta_gattc_api.cc",
+        "gatt/bta_gattc_cache.cc",
+        "gatt/bta_gattc_main.cc",
+        "gatt/bta_gattc_utils.cc",
+        "gatt/bta_gatts_act.cc",
+        "gatt/bta_gatts_api.cc",
+        "gatt/bta_gatts_main.cc",
+        "gatt/bta_gatts_utils.cc",
+        "hf_client/bta_hf_client_act.cc",
+        "hf_client/bta_hf_client_api.cc",
+        "hf_client/bta_hf_client_at.cc",
+        "hf_client/bta_hf_client_main.cc",
+        "hf_client/bta_hf_client_rfc.cc",
+        "hf_client/bta_hf_client_sco.cc",
+        "hf_client/bta_hf_client_sdp.cc",
+        "hh/bta_hh_act.cc",
+        "hh/bta_hh_api.cc",
+        "hh/bta_hh_cfg.cc",
+        "hh/bta_hh_le.cc",
+        "hh/bta_hh_main.cc",
+        "hh/bta_hh_utils.cc",
+        "hl/bta_hl_act.cc",
+        "hl/bta_hl_api.cc",
+        "hl/bta_hl_ci.cc",
+        "hl/bta_hl_main.cc",
+        "hl/bta_hl_sdp.cc",
+        "hl/bta_hl_utils.cc",
+        "hd/bta_hd_act.cc",
+        "hd/bta_hd_api.cc",
+        "hd/bta_hd_main.cc",
+        "jv/bta_jv_act.cc",
+        "jv/bta_jv_api.cc",
+        "jv/bta_jv_cfg.cc",
+        "jv/bta_jv_main.cc",
+        "mce/bta_mce_act.cc",
+        "mce/bta_mce_api.cc",
+        "mce/bta_mce_cfg.cc",
+        "mce/bta_mce_main.cc",
+        "pan/bta_pan_act.cc",
+        "pan/bta_pan_api.cc",
+        "pan/bta_pan_ci.cc",
+        "pan/bta_pan_main.cc",
+        "sdp/bta_sdp.cc",
+        "sdp/bta_sdp_act.cc",
+        "sdp/bta_sdp_api.cc",
+        "sdp/bta_sdp_cfg.cc",
+        "sys/bta_sys_conn.cc",
+        "sys/bta_sys_main.cc",
+        "sys/utl.cc",
+    ],
+}
+
+// bta unit tests for target
+// ========================================================
+cc_test {
+    name: "net_test_bta",
+    defaults: ["fluoride_bta_defaults"],
+    srcs: [
+        "test/bta_closure_test.cc",
+        "test/bta_hf_client_test.cc",
+    ],
+    shared_libs: [
+        "libhardware",
+        "liblog",
+        "libprotobuf-cpp-lite",
+    ],
+    static_libs: [
+        "libbtcore",
+        "libbt-bta",
+        "libosi",
+        "libbt-protos",
+    ],
+}
diff --git a/bta/Android.mk b/bta/Android.mk
deleted file mode 100644
index 429e319..0000000
--- a/bta/Android.mk
+++ /dev/null
@@ -1,139 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-# Tests
-btaTestSrc := \
-  test/bta_closure_test.cc \
-  test/bta_hf_client_test.cc
-
-btaCommonIncludes := \
-                   $(LOCAL_PATH)/../ \
-                   $(LOCAL_PATH)/include \
-                   $(LOCAL_PATH)/sys \
-                   $(LOCAL_PATH)/dm \
-                   $(LOCAL_PATH)/hh \
-                   $(LOCAL_PATH)/hd \
-                   $(LOCAL_PATH)/closure \
-                   $(LOCAL_PATH)/../btcore/include \
-                   $(LOCAL_PATH)/../hci/include \
-                   $(LOCAL_PATH)/../include \
-                   $(LOCAL_PATH)/../stack/include \
-                   $(LOCAL_PATH)/../stack/btm \
-                   $(LOCAL_PATH)/../udrv/include \
-                   $(LOCAL_PATH)/../vnd/include \
-                   $(LOCAL_PATH)/../utils/include \
-                   $(bluetooth_C_INCLUDES)
-
-# BTA static library for target
-# ========================================================
-include $(CLEAR_VARS)
-LOCAL_CPP_EXTENSION := .cc
-
-LOCAL_SRC_FILES:= \
-    ./ag/bta_ag_act.cc \
-    ./ag/bta_ag_api.cc \
-    ./ag/bta_ag_at.cc \
-    ./ag/bta_ag_cfg.cc \
-    ./ag/bta_ag_ci.cc \
-    ./ag/bta_ag_cmd.cc \
-    ./ag/bta_ag_main.cc \
-    ./ag/bta_ag_rfc.cc \
-    ./ag/bta_ag_sco.cc \
-    ./ag/bta_ag_sdp.cc \
-    ./ar/bta_ar.cc \
-    ./av/bta_av_aact.cc \
-    ./av/bta_av_act.cc \
-    ./av/bta_av_api.cc \
-    ./av/bta_av_cfg.cc \
-    ./av/bta_av_ci.cc \
-    ./av/bta_av_main.cc \
-    ./av/bta_av_ssm.cc \
-    ./closure/bta_closure.cc \
-    ./dm/bta_dm_act.cc \
-    ./dm/bta_dm_api.cc \
-    ./dm/bta_dm_cfg.cc \
-    ./dm/bta_dm_ci.cc \
-    ./dm/bta_dm_main.cc \
-    ./dm/bta_dm_pm.cc \
-    ./dm/bta_dm_sco.cc \
-    ./gatt/bta_gattc_act.cc \
-    ./gatt/bta_gattc_api.cc \
-    ./gatt/bta_gattc_cache.cc \
-    ./gatt/bta_gattc_main.cc \
-    ./gatt/bta_gattc_utils.cc \
-    ./gatt/bta_gatts_act.cc \
-    ./gatt/bta_gatts_api.cc \
-    ./gatt/bta_gatts_main.cc \
-    ./gatt/bta_gatts_utils.cc \
-    ./hf_client/bta_hf_client_act.cc \
-    ./hf_client/bta_hf_client_api.cc \
-    ./hf_client/bta_hf_client_at.cc \
-    ./hf_client/bta_hf_client_main.cc \
-    ./hf_client/bta_hf_client_rfc.cc \
-    ./hf_client/bta_hf_client_sco.cc \
-    ./hf_client/bta_hf_client_sdp.cc \
-    ./hh/bta_hh_act.cc \
-    ./hh/bta_hh_api.cc \
-    ./hh/bta_hh_cfg.cc \
-    ./hh/bta_hh_le.cc \
-    ./hh/bta_hh_main.cc \
-    ./hh/bta_hh_utils.cc \
-    ./hd/bta_hd_act.cc \
-    ./hd/bta_hd_api.cc \
-    ./hd/bta_hd_main.cc \
-    ./hl/bta_hl_act.cc \
-    ./hl/bta_hl_api.cc \
-    ./hl/bta_hl_ci.cc \
-    ./hl/bta_hl_main.cc \
-    ./hl/bta_hl_sdp.cc \
-    ./hl/bta_hl_utils.cc \
-    ./jv/bta_jv_act.cc \
-    ./jv/bta_jv_api.cc \
-    ./jv/bta_jv_cfg.cc \
-    ./jv/bta_jv_main.cc \
-    ./mce/bta_mce_act.cc \
-    ./mce/bta_mce_api.cc \
-    ./mce/bta_mce_cfg.cc \
-    ./mce/bta_mce_main.cc \
-    ./pan/bta_pan_act.cc \
-    ./pan/bta_pan_api.cc \
-    ./pan/bta_pan_ci.cc \
-    ./pan/bta_pan_main.cc \
-    ./sdp/bta_sdp.cc \
-    ./sdp/bta_sdp_act.cc \
-    ./sdp/bta_sdp_api.cc \
-    ./sdp/bta_sdp_cfg.cc \
-    ./sys/bta_sys_conn.cc \
-    ./sys/bta_sys_main.cc \
-    ./sys/utl.cc
-
-LOCAL_MODULE := libbt-bta
-LOCAL_MODULE_CLASS := STATIC_LIBRARIES
-LOCAL_MODULE_TAGS := optional
-LOCAL_SHARED_LIBRARIES := libcutils libc libchrome
-
-LOCAL_C_INCLUDES := $(btaCommonIncludes)
-
-LOCAL_CFLAGS += $(bluetooth_CFLAGS) -DBUILDCFG
-LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
-LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
-
-include $(BUILD_STATIC_LIBRARY)
-
-# bta unit tests for target
-# ========================================================
-include $(CLEAR_VARS)
-
-LOCAL_CPP_EXTENSION := .cc
-
-LOCAL_C_INCLUDES := $(btaCommonIncludes)
-LOCAL_SRC_FILES := $(btaTestSrc)
-LOCAL_SHARED_LIBRARIES := libcutils libc libchrome libhardware liblog libprotobuf-cpp-lite
-LOCAL_STATIC_LIBRARIES := libbtcore libbt-bta libosi libbt-protos
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE := net_test_bta
-
-LOCAL_CFLAGS += $(bluetooth_CFLAGS) -DBUILDCFG
-LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
-LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
-
-include $(BUILD_NATIVE_TEST)
diff --git a/btcore/Android.bp b/btcore/Android.bp
new file mode 100644
index 0000000..6e058d2
--- /dev/null
+++ b/btcore/Android.bp
@@ -0,0 +1,60 @@
+// libbtcore static library for target and host
+// ========================================================
+cc_library_static {
+    name: "libbtcore",
+    defaults: ["fluoride_defaults"],
+    local_include_dirs: ["include"],
+    include_dirs: ["system/bt"],
+    srcs: [
+        "src/bdaddr.cc",
+        "src/device_class.cc",
+        "src/hal_util.cc",
+        "src/module.cc",
+        "src/osi_module.cc",
+        "src/property.cc",
+        "src/uuid.cc",
+    ],
+    shared_libs: [
+        "liblog",
+    ],
+    host_supported: true,
+    target: {
+        darwin: {
+            enabled: false,
+        },
+        linux: {
+            cflags: ["-D_GNU_SOURCE"],
+        },
+    },
+}
+
+// Note: It's good to get the tests compiled both for the host and the target so
+// we get to test with both Bionic libc and glibc
+// libbtcore unit tests for target and host
+// ========================================================
+cc_test {
+    name: "net_test_btcore",
+    defaults: ["fluoride_defaults"],
+    local_include_dirs: ["include"],
+    include_dirs: ["system/bt"],
+    srcs: [
+        "test/bdaddr_test.cc",
+        "test/device_class_test.cc",
+        "test/property_test.cc",
+        "test/uuid_test.cc",
+    ],
+    shared_libs: [
+        "liblog",
+    ],
+    static_libs: [
+        "libbtcore",
+        "libosi-AllocationTestHarness",
+        "libosi",
+    ],
+    host_supported: true,
+    target: {
+        darwin: {
+            enabled: false,
+        }
+    }
+}
diff --git a/btcore/Android.mk b/btcore/Android.mk
deleted file mode 100644
index a18f04a..0000000
--- a/btcore/Android.mk
+++ /dev/null
@@ -1,119 +0,0 @@
- ##############################################################################
- #
- #  Copyright (C) 2014 Google, Inc.
- #
- #  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)
-
-# Common variables
-# ========================================================
-btcoreCommonSrc := \
-    src/bdaddr.cc \
-    src/device_class.cc \
-    src/hal_util.cc \
-    src/module.cc \
-    src/osi_module.cc \
-    src/property.cc \
-    src/uuid.cc
-
-btcoreCommonTestSrc := \
-	./test/bdaddr_test.cc \
-    ./test/device_class_test.cc \
-    ./test/property_test.cc \
-    ./test/uuid_test.cc \
-    ../osi/test/AllocationTestHarness.cc
-
-btcoreCommonIncludes := \
-    $(LOCAL_PATH)/include \
-    $(LOCAL_PATH)/..
-
-# libbtcore static library for target
-# ========================================================
-include $(CLEAR_VARS)
-LOCAL_CPP_EXTENSION := .cc
-LOCAL_C_INCLUDES := $(btcoreCommonIncludes)
-LOCAL_SRC_FILES := $(btcoreCommonSrc)
-LOCAL_MODULE := libbtcore
-LOCAL_MODULE_TAGS := optional
-LOCAL_SHARED_LIBRARIES := libc liblog libchrome
-LOCAL_MODULE_CLASS := STATIC_LIBRARIES
-
-LOCAL_CFLAGS += $(bluetooth_CFLAGS)
-LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
-LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
-
-include $(BUILD_STATIC_LIBRARY)
-
-# libbtcore static library for host
-# ========================================================
-ifeq ($(HOST_OS),linux)
-include $(CLEAR_VARS)
-LOCAL_CPP_EXTENSION := .cc
-LOCAL_C_INCLUDES := $(btcoreCommonIncludes)
-LOCAL_SRC_FILES := $(btcoreCommonSrc)
-LOCAL_MODULE := libbtcore-host
-LOCAL_MODULE_TAGS := optional
-LOCAL_SHARED_LIBRARIES := liblog libchrome
-LOCAL_MODULE_CLASS := STATIC_LIBRARIES
-
-# TODO(armansito): Setting _GNU_SOURCE isn't very platform-independent but
-# should be compatible for a Linux host OS. We should figure out what to do for
-# a non-Linux host OS.
-LOCAL_CFLAGS += $(bluetooth_CFLAGS) -D_GNU_SOURCE
-LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
-LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
-
-include $(BUILD_HOST_STATIC_LIBRARY)
-endif
-
-# Note: It's good to get the tests compiled both for the host and the target so
-# we get to test with both Bionic libc and glibc
-
-# libbtcore unit tests for target
-# ========================================================
-include $(CLEAR_VARS)
-LOCAL_CPP_EXTENSION := .cc
-LOCAL_C_INCLUDES := $(btcoreCommonIncludes)
-LOCAL_SRC_FILES := $(btcoreCommonTestSrc)
-LOCAL_MODULE := net_test_btcore
-LOCAL_MODULE_TAGS := tests
-LOCAL_SHARED_LIBRARIES := liblog libchrome
-LOCAL_STATIC_LIBRARIES := libbtcore libosi
-
-LOCAL_CFLAGS += $(bluetooth_CFLAGS)
-LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
-LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
-
-include $(BUILD_NATIVE_TEST)
-
-# libbtcore unit tests for host
-# ========================================================
-ifeq ($(HOST_OS),linux)
-include $(CLEAR_VARS)
-LOCAL_CPP_EXTENSION := .cc
-LOCAL_C_INCLUDES := $(btcoreCommonIncludes)
-LOCAL_SRC_FILES := $(btcoreCommonTestSrc)
-LOCAL_MODULE := net_test_btcore
-LOCAL_MODULE_TAGS := tests
-LOCAL_SHARED_LIBRARIES := liblog libchrome
-LOCAL_STATIC_LIBRARIES := libbtcore-host libosi-host
-
-LOCAL_CFLAGS += $(bluetooth_CFLAGS)
-LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
-LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
-
-include $(BUILD_HOST_NATIVE_TEST)
-endif
diff --git a/btif/Android.bp b/btif/Android.bp
new file mode 100644
index 0000000..b3d7dab
--- /dev/null
+++ b/btif/Android.bp
@@ -0,0 +1,121 @@
+// Common variables
+// ========================================================
+btifCommonIncludes = [
+    "system/bt",
+    "system/bt/bta/include",
+    "system/bt/bta/sys",
+    "system/bt/bta/dm",
+    "system/bt/btcore/include",
+    "system/bt/include",
+    "system/bt/stack/include",
+    "system/bt/stack/l2cap",
+    "system/bt/stack/a2dp",
+    "system/bt/stack/btm",
+    "system/bt/stack/avdt",
+    "system/bt/udrv/include",
+    "system/bt/btif/include",
+    "system/bt/btif/co",
+    "system/bt/hci/include",
+    "system/bt/vnd/include",
+    "system/bt/embdrv/sbc/encoder/include",
+    "system/bt/embdrv/sbc/decoder/include",
+    "system/bt/audio_a2dp_hw",
+    "system/bt/utils/include",
+]
+
+// libbtif static library for target
+// ========================================================
+cc_library_static {
+    name: "libbtif",
+    defaults: ["fluoride_defaults"],
+    include_dirs: btifCommonIncludes,
+    srcs: [
+        // HAL layer
+        "src/bluetooth.cc",
+        // BTIF implementation
+        "src/btif_a2dp.cc",
+        "src/btif_a2dp_control.cc",
+        "src/btif_a2dp_sink.cc",
+        "src/btif_a2dp_source.cc",
+        "src/btif_av.cc",
+        "src/btif_avrcp_audio_track.cc",
+        "src/btif_ble_advertiser.cc",
+        "src/btif_ble_scanner.cc",
+        "src/btif_config.cc",
+        "src/btif_config_transcode.cc",
+        "src/btif_core.cc",
+        "src/btif_debug.cc",
+        "src/btif_debug_btsnoop.cc",
+        "src/btif_debug_conn.cc",
+        "src/btif_dm.cc",
+        "src/btif_gatt.cc",
+        "src/btif_gatt_client.cc",
+        "src/btif_gatt_server.cc",
+        "src/btif_gatt_test.cc",
+        "src/btif_gatt_util.cc",
+        "src/btif_hf.cc",
+        "src/btif_hf_client.cc",
+        "src/btif_hh.cc",
+        "src/btif_hd.cc",
+        "src/btif_hl.cc",
+        "src/btif_mce.cc",
+        "src/btif_pan.cc",
+        "src/btif_profile_queue.cc",
+        "src/btif_rc.cc",
+        "src/btif_sdp.cc",
+        "src/btif_sdp_server.cc",
+        "src/btif_sm.cc",
+        "src/btif_sock.cc",
+        "src/btif_sock_rfc.cc",
+        "src/btif_sock_l2cap.cc",
+        "src/btif_sock_sco.cc",
+        "src/btif_sock_sdp.cc",
+        "src/btif_sock_thread.cc",
+        "src/btif_sock_util.cc",
+        "src/btif_storage.cc",
+        "src/btif_uid.cc",
+        "src/btif_util.cc",
+        "src/stack_manager.cc",
+        // Callouts
+        "co/bta_ag_co.cc",
+        "co/bta_dm_co.cc",
+        "co/bta_av_co.cc",
+        "co/bta_hh_co.cc",
+        "co/bta_hl_co.cc",
+        "co/bta_pan_co.cc",
+        "co/bta_gatts_co.cc",
+    ],
+    shared_libs: [
+        "libaudioclient",
+        "libcutils",
+        "liblog",
+        "libz",
+        "libtinyxml2",
+    ],
+    whole_static_libs: [
+        "libaudio-a2dp-hw-utils",
+    ],
+    cflags: ["-DBUILDCFG"],
+
+}
+
+// btif unit tests for target
+// ========================================================
+cc_test {
+    name: "net_test_btif",
+    defaults: ["fluoride_defaults"],
+    include_dirs: btifCommonIncludes,
+    srcs: ["test/btif_storage_test.cc"],
+    shared_libs: [
+        "liblog",
+        "libhardware",
+        "libcutils",
+    ],
+    static_libs: [
+        "libbtcore",
+        "libbtif",
+        "libbt-stack",
+        "libosi",
+    ],
+    cflags: ["-DBUILDCFG"],
+}
diff --git a/btif/Android.mk b/btif/Android.mk
deleted file mode 100644
index 843934a..0000000
--- a/btif/Android.mk
+++ /dev/null
@@ -1,154 +0,0 @@
- ##############################################################################
- #
- #  Copyright (C) 2014 Google, Inc.
- #
- #  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)
-
-# Common variables
-# ========================================================
-
-# HAL layer
-btifCommonSrc += \
-  src/bluetooth.cc \
-  ../EventLogTags.logtags
-
-# BTIF implementation
-btifCommonSrc += \
-  ../audio_a2dp_hw/audio_a2dp_hw_utils.cc \
-  src/btif_a2dp.cc \
-  src/btif_a2dp_control.cc \
-  src/btif_a2dp_sink.cc \
-  src/btif_a2dp_source.cc \
-  src/btif_av.cc \
-  src/btif_avrcp_audio_track.cc \
-  src/btif_ble_advertiser.cc \
-  src/btif_ble_scanner.cc \
-  src/btif_config.cc \
-  src/btif_config_transcode.cc \
-  src/btif_core.cc \
-  src/btif_debug.cc \
-  src/btif_debug_btsnoop.cc \
-  src/btif_debug_conn.cc \
-  src/btif_dm.cc \
-  src/btif_gatt.cc \
-  src/btif_gatt_client.cc \
-  src/btif_gatt_server.cc \
-  src/btif_gatt_test.cc \
-  src/btif_gatt_util.cc \
-  src/btif_hf.cc \
-  src/btif_hf_client.cc \
-  src/btif_hh.cc \
-  src/btif_hd.cc \
-  src/btif_hl.cc \
-  src/btif_mce.cc \
-  src/btif_pan.cc \
-  src/btif_profile_queue.cc \
-  src/btif_rc.cc \
-  src/btif_sdp.cc \
-  src/btif_sdp_server.cc \
-  src/btif_sm.cc \
-  src/btif_sock.cc \
-  src/btif_sock_rfc.cc \
-  src/btif_sock_l2cap.cc \
-  src/btif_sock_sco.cc \
-  src/btif_sock_sdp.cc \
-  src/btif_sock_thread.cc \
-  src/btif_sock_util.cc \
-  src/btif_storage.cc \
-  src/btif_uid.cc \
-  src/btif_util.cc \
-  src/stack_manager.cc
-
-# Callouts
-btifCommonSrc += \
-  co/bta_ag_co.cc \
-  co/bta_dm_co.cc \
-  co/bta_av_co.cc \
-  co/bta_hh_co.cc \
-  co/bta_hl_co.cc \
-  co/bta_pan_co.cc \
-  co/bta_gatts_co.cc
-
-# Tests
-btifTestSrc := \
-  test/btif_storage_test.cc
-
-# Includes
-btifCommonIncludes := \
-  $(LOCAL_PATH)/../ \
-  $(LOCAL_PATH)/../bta/include \
-  $(LOCAL_PATH)/../bta/sys \
-  $(LOCAL_PATH)/../bta/dm \
-  $(LOCAL_PATH)/../btcore/include \
-  $(LOCAL_PATH)/../include \
-  $(LOCAL_PATH)/../stack/include \
-  $(LOCAL_PATH)/../stack/l2cap \
-  $(LOCAL_PATH)/../stack/a2dp \
-  $(LOCAL_PATH)/../stack/btm \
-  $(LOCAL_PATH)/../stack/avdt \
-  $(LOCAL_PATH)/../udrv/include \
-  $(LOCAL_PATH)/../btif/include \
-  $(LOCAL_PATH)/../btif/co \
-  $(LOCAL_PATH)/../hci/include\
-  $(LOCAL_PATH)/../vnd/include \
-  $(LOCAL_PATH)/../embdrv/sbc/encoder/include \
-  $(LOCAL_PATH)/../embdrv/sbc/decoder/include \
-  $(LOCAL_PATH)/../audio_a2dp_hw \
-  $(LOCAL_PATH)/../utils/include \
-  $(bluetooth_C_INCLUDES) \
-  external/tinyxml2 \
-  external/zlib
-
-# libbtif static library for target
-# ========================================================
-include $(CLEAR_VARS)
-
-LOCAL_CPP_EXTENSION := .cc
-
-LOCAL_C_INCLUDES := $(btifCommonIncludes)
-LOCAL_SRC_FILES := $(btifCommonSrc)
-# Many .h files have redefined typedefs
-LOCAL_SHARED_LIBRARIES := libaudioclient libcutils liblog libchrome
-LOCAL_MODULE_CLASS := STATIC_LIBRARIES
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE := libbtif
-
-LOCAL_CFLAGS += $(bluetooth_CFLAGS) -DBUILDCFG
-LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
-LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
-
-include $(BUILD_STATIC_LIBRARY)
-
-# btif unit tests for target
-# ========================================================
-include $(CLEAR_VARS)
-
-LOCAL_CPP_EXTENSION := .cc
-
-LOCAL_C_INCLUDES := $(btifCommonIncludes)
-LOCAL_SRC_FILES := $(btifTestSrc)
-LOCAL_SHARED_LIBRARIES := liblog libhardware libhardware_legacy libcutils \
-	libchrome
-LOCAL_STATIC_LIBRARIES := libbtcore libbtif libbt-stack libosi
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE := net_test_btif
-
-LOCAL_CFLAGS += $(bluetooth_CFLAGS) -DBUILDCFG
-LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
-LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
-
-include $(BUILD_NATIVE_TEST)
diff --git a/build/Android.bp b/build/Android.bp
new file mode 100644
index 0000000..2c47df7
--- /dev/null
+++ b/build/Android.bp
@@ -0,0 +1,44 @@
+bootstrap_go_package {
+    name: "soong-fluoride",
+    pkgPath: "android/soong/fluoride",
+    deps: [
+        "blueprint",
+        "blueprint-pathtools",
+        "soong",
+        "soong-android",
+        "soong-cc",
+    ],
+    srcs: [
+        "fluoride.go",
+    ],
+    pluginFor: ["soong_build"],
+}
+
+fluoride_defaults {
+    name: "fluoride_defaults",
+    cflags: [
+        "-DEXPORT_SYMBOL=__attribute__((visibility(\"default\")))",
+        "-fvisibility=hidden",
+        "-Wall",
+        "-Wextra",
+        "-Werror",
+        // struct BT_HDR is defined as a variable-size header in a struct.
+        "-Wno-gnu-variable-sized-type-not-at-end",
+        // needed because of the way the struct typedef is done in osi/include
+        // header files. This issue can be obsoleted by switching to C11 or C++.
+        "-Wno-typedef-redefinition",
+        // there are too many unused parameters in all the code.
+        "-Wno-unused-parameter",
+        "-DLOG_NDEBUG=1",
+    ],
+    conlyflags: [
+        "-std=c99",
+    ],
+    product_variables: {
+        debuggable: {
+            cflags: ["-DBLUEDROID_DEBUG"],
+        },
+    },
+    shared_libs: [ "libchrome" ]
+    // Setup Bluetooth local make variables for handling configuration
+}
diff --git a/build/fluoride.go b/build/fluoride.go
new file mode 100644
index 0000000..b269170
--- /dev/null
+++ b/build/fluoride.go
@@ -0,0 +1,69 @@
+// 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.
+package fluoride
+
+import (
+  "android/soong/android"
+  "android/soong/cc"
+
+  "github.com/google/blueprint"
+)
+
+func init() {
+  android.RegisterModuleType("fluoride_defaults", fluorideDefaultsFactory)
+}
+
+func fluorideDefaultsFactory() (blueprint.Module, []interface{}) {
+  module, props := cc.DefaultsFactory()
+  android.AddLoadHook(module, fluorideDefaults)
+
+  return module, props
+}
+
+func fluorideDefaults(ctx android.LoadHookContext) {
+  type props struct {
+    Include_dirs []string
+    Cflags []string
+  }
+
+  p := &props{}
+  p.Cflags, p.Include_dirs = globalDefaults(ctx)
+
+  ctx.AppendProperties(p)
+}
+
+func globalDefaults(ctx android.BaseContext) ([]string, []string) {
+  var cflags []string
+  var includeDirs []string
+
+  board_bt_buildcfg_include_dir := ctx.DeviceConfig().BtConfigIncludeDir()
+  if (len(board_bt_buildcfg_include_dir) > 0) {
+    cflags = append(cflags, "-DHAS_BDROID_BUILDCFG")
+    includeDirs = append(includeDirs, board_bt_buildcfg_include_dir)
+  } else {
+    cflags = append(cflags, "-DHAS_NO_BDROID_BUILDCFG")
+  }
+
+  board_bt_hcilp_included := ctx.DeviceConfig().BtHcilpIncluded()
+  if (len(board_bt_hcilp_included) > 0) {
+      cflags = append(cflags, "-DHCILP_INCLUDED=" + board_bt_hcilp_included)
+  }
+
+  board_bt_hci_use_mct := ctx.DeviceConfig().BtHciUseMct()
+  if (board_bt_hci_use_mct) {
+      cflags = append(cflags, "-DHCI_USE_MCT")
+  }
+
+  return cflags, includeDirs
+}
diff --git a/conf/Android.mk b/conf/Android.mk
index 5bc5a63..6f5037c 100644
--- a/conf/Android.mk
+++ b/conf/Android.mk
@@ -1,3 +1,5 @@
+# Cannot convert to Android.bp as resource copying has not
+# yet implemented for soong as of 12/16/2016
 LOCAL_PATH := $(call my-dir)
 
 # Bluetooth bt_stack.conf config file
diff --git a/device/Android.bp b/device/Android.bp
new file mode 100644
index 0000000..314dd50
--- /dev/null
+++ b/device/Android.bp
@@ -0,0 +1,45 @@
+// Bluetooth device static library for target
+// ========================================================
+cc_library_static {
+    name: "libbtdevice",
+    defaults: ["fluoride_defaults"],
+    local_include_dirs: [
+        "include",
+    ],
+    include_dirs: [
+        "system/bt",
+        "system/bt/btcore/include",
+        "system/bt/hci/include",
+        "system/bt/include",
+        "system/bt/stack/include",
+    ],
+    srcs: [
+        "src/controller.cc",
+        "src/interop.cc",
+    ],
+    shared_libs: [
+        "liblog",
+    ],
+}
+
+// Bluetooth device unit tests for target
+// ========================================================
+cc_test {
+    name: "net_test_device",
+    defaults: ["fluoride_defaults"],
+    include_dirs: ["system/bt"],
+    srcs: [
+        "test/interop_test.cc",
+    ],
+    shared_libs: [
+        "liblog",
+        "libdl",
+    ],
+    static_libs: [
+        "libbtdevice",
+        "libbtcore",
+        "libosi",
+        "libosi-AllocationTestHarness",
+        "libcutils",
+    ],
+}
diff --git a/device/Android.mk b/device/Android.mk
deleted file mode 100644
index f191aa1..0000000
--- a/device/Android.mk
+++ /dev/null
@@ -1,71 +0,0 @@
- ##############################################################################
- #
- #  Copyright (C) 2014 Google, Inc.
- #
- #  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)
-
-# Bluetooth device static library for target
-# ========================================================
-include $(CLEAR_VARS)
-LOCAL_CPP_EXTENSION := .cc
-
-LOCAL_C_INCLUDES := \
-    $(LOCAL_PATH)/.. \
-    $(LOCAL_PATH)/include \
-    $(LOCAL_PATH)/../btcore/include \
-    $(LOCAL_PATH)/../hci/include \
-    $(LOCAL_PATH)/../include \
-    $(LOCAL_PATH)/../stack/include \
-    $(bluetooth_C_INCLUDES)
-
-LOCAL_SRC_FILES := \
-    src/controller.cc \
-    src/interop.cc
-
-LOCAL_MODULE := libbtdevice
-LOCAL_MODULE_TAGS := optional
-LOCAL_SHARED_LIBRARIES := libc liblog libchrome
-LOCAL_MODULE_CLASS := STATIC_LIBRARIES
-
-LOCAL_CFLAGS += $(bluetooth_CFLAGS)
-LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
-LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
-
-include $(BUILD_STATIC_LIBRARY)
-
-# Bluetooth device unit tests for target
-# ========================================================
-include $(CLEAR_VARS)
-LOCAL_CPP_EXTENSION := .cc
-LOCAL_C_INCLUDES := \
-    $(LOCAL_PATH)/.. \
-    $(bluetooth_C_INCLUDES)
-
-LOCAL_SRC_FILES := \
-    ../osi/test/AllocationTestHarness.cc \
-    ./test/interop_test.cc
-
-LOCAL_MODULE := net_test_device
-LOCAL_MODULE_TAGS := tests
-LOCAL_SHARED_LIBRARIES := liblog libdl libchrome
-LOCAL_STATIC_LIBRARIES := libbtdevice libbtcore libosi libcutils
-
-LOCAL_CFLAGS += $(bluetooth_CFLAGS)
-LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
-LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
-
-include $(BUILD_NATIVE_TEST)
diff --git a/embdrv/Android.bp b/embdrv/Android.bp
new file mode 100644
index 0000000..7c6328e
--- /dev/null
+++ b/embdrv/Android.bp
@@ -0,0 +1,3 @@
+subdirs = [
+    "sbc",
+]
diff --git a/embdrv/Android.mk b/embdrv/Android.mk
deleted file mode 100644
index c455f97..0000000
--- a/embdrv/Android.mk
+++ /dev/null
@@ -1,3 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-include $(call all-subdir-makefiles)
diff --git a/embdrv/sbc/Android.bp b/embdrv/sbc/Android.bp
new file mode 100644
index 0000000..5696377
--- /dev/null
+++ b/embdrv/sbc/Android.bp
@@ -0,0 +1,4 @@
+subdirs = [
+    "decoder",
+    "encoder",
+]
diff --git a/embdrv/sbc/Android.mk b/embdrv/sbc/Android.mk
deleted file mode 100644
index c455f97..0000000
--- a/embdrv/sbc/Android.mk
+++ /dev/null
@@ -1,3 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-include $(call all-subdir-makefiles)
diff --git a/embdrv/sbc/decoder/Android.bp b/embdrv/sbc/decoder/Android.bp
new file mode 100644
index 0000000..274f2bf
--- /dev/null
+++ b/embdrv/sbc/decoder/Android.bp
@@ -0,0 +1,26 @@
+// Bluetooth SBC decoder static library for target
+// ========================================================
+cc_library_static {
+    name: "libbt-sbc-decoder",
+    defaults: ["fluoride_defaults"],
+    srcs: [
+        "srce/alloc.c",
+        "srce/bitalloc.c",
+        "srce/bitalloc-sbc.c",
+        "srce/bitstream-decode.c",
+        "srce/decoder-oina.c",
+        "srce/decoder-private.c",
+        "srce/decoder-sbc.c",
+        "srce/dequant.c",
+        "srce/framing.c",
+        "srce/framing-sbc.c",
+        "srce/oi_codec_version.c",
+        "srce/synthesis-sbc.c",
+        "srce/synthesis-dct8.c",
+        "srce/synthesis-8-generated.c",
+    ],
+    local_include_dirs: [
+        "include",
+        "srce",
+    ],
+}
diff --git a/embdrv/sbc/decoder/Android.mk b/embdrv/sbc/decoder/Android.mk
deleted file mode 100644
index 267de82..0000000
--- a/embdrv/sbc/decoder/Android.mk
+++ /dev/null
@@ -1,37 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-# Bluetooth SBC decoder static library for target
-# ========================================================
-include $(CLEAR_VARS)
-
-LOCAL_CPP_EXTENSION := .cc
-
-# SBC decoder
-LOCAL_SRC_FILES := \
-        ./srce/alloc.c \
-        ./srce/bitalloc.c \
-        ./srce/bitalloc-sbc.c \
-        ./srce/bitstream-decode.c \
-        ./srce/decoder-oina.c \
-        ./srce/decoder-private.c \
-        ./srce/decoder-sbc.c \
-        ./srce/dequant.c \
-        ./srce/framing.c \
-        ./srce/framing-sbc.c \
-        ./srce/oi_codec_version.c \
-        ./srce/synthesis-sbc.c \
-        ./srce/synthesis-dct8.c \
-        ./srce/synthesis-8-generated.c
-
-LOCAL_C_INCLUDES := $(LOCAL_PATH)/include \
-	$(LOCAL_PATH)/srce
-
-LOCAL_MODULE := libbt-sbc-decoder
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE_CLASS := STATIC_LIBRARIES
-
-LOCAL_CFLAGS += $(bluetooth_CFLAGS)
-LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
-LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
-
-include $(BUILD_STATIC_LIBRARY)
diff --git a/embdrv/sbc/encoder/Android.bp b/embdrv/sbc/encoder/Android.bp
new file mode 100644
index 0000000..6e22f89
--- /dev/null
+++ b/embdrv/sbc/encoder/Android.bp
@@ -0,0 +1,23 @@
+cc_library_static {
+    name: "libbt-sbc-encoder",
+    defaults: ["fluoride_defaults"],
+    srcs: [
+        "srce/sbc_analysis.c",
+        "srce/sbc_dct.c",
+        "srce/sbc_dct_coeffs.c",
+        "srce/sbc_enc_bit_alloc_mono.c",
+        "srce/sbc_enc_bit_alloc_ste.c",
+        "srce/sbc_enc_coeffs.c",
+        "srce/sbc_encoder.c",
+        "srce/sbc_packing.c",
+    ],
+    local_include_dirs: [
+        "include",
+        "srce",
+    ],
+    include_dirs: [
+        "system/bt",
+        "system/bt/include",
+        "system/bt/stack/include",
+    ],
+}
diff --git a/embdrv/sbc/encoder/Android.mk b/embdrv/sbc/encoder/Android.mk
deleted file mode 100644
index e5eb406..0000000
--- a/embdrv/sbc/encoder/Android.mk
+++ /dev/null
@@ -1,34 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-# Bluetooth SBC encoder static library for target
-# ========================================================
-include $(CLEAR_VARS)
-
-LOCAL_CPP_EXTENSION := .cc
-
-# SBC encoder
-LOCAL_SRC_FILES := \
-        ./srce/sbc_analysis.c \
-        ./srce/sbc_dct.c \
-        ./srce/sbc_dct_coeffs.c \
-        ./srce/sbc_enc_bit_alloc_mono.c \
-        ./srce/sbc_enc_bit_alloc_ste.c \
-        ./srce/sbc_enc_coeffs.c \
-        ./srce/sbc_encoder.c \
-        ./srce/sbc_packing.c
-
-LOCAL_C_INCLUDES := $(LOCAL_PATH)/include \
-        $(LOCAL_PATH)/../../../include \
-        $(LOCAL_PATH)/../../../stack/include \
-        $(LOCAL_PATH)/srce \
-        $(bluetooth_C_INCLUDES)
-
-LOCAL_MODULE := libbt-sbc-encoder
-# LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE_CLASS := STATIC_LIBRARIES
-
-LOCAL_CFLAGS += $(bluetooth_CFLAGS)
-LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
-LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
-
-include $(BUILD_STATIC_LIBRARY)
diff --git a/hci/Android.bp b/hci/Android.bp
new file mode 100644
index 0000000..40d0d3e
--- /dev/null
+++ b/hci/Android.bp
@@ -0,0 +1,73 @@
+// HCI static library for target
+// ========================================================
+cc_library_static {
+    name: "libbt-hci",
+    defaults: ["fluoride_defaults"],
+    srcs: [
+        "src/btsnoop.cc",
+        "src/btsnoop_mem.cc",
+        "src/btsnoop_net.cc",
+        "src/buffer_allocator.cc",
+        "src/hci_audio.cc",
+        "src/hci_hal.cc",
+        "src/hci_hal_h4.cc",
+        "src/hci_hal_mct.cc",
+        "src/hci_inject.cc",
+        "src/hci_layer.cc",
+        "src/hci_packet_factory.cc",
+        "src/hci_packet_parser.cc",
+        "src/low_power_manager.cc",
+        "src/packet_fragmenter.cc",
+        "src/vendor.cc",
+    ],
+    local_include_dirs: [
+        "include",
+    ],
+    include_dirs: [
+        "system/bt",
+        "system/bt/include",
+        "system/bt/btcore/include",
+        "system/bt/stack/include",
+        "system/bt/utils/include",
+        "system/bt/bta/include",
+    ],
+}
+
+// HCI unit tests for target
+// ========================================================
+cc_test {
+    name: "net_test_hci",
+    defaults: ["fluoride_defaults"],
+    local_include_dirs: [
+        "include",
+    ],
+    include_dirs: [
+        "system/bt",
+        "system/bt/include",
+        "system/bt/btcore/include",
+        "system/bt/osi/test",
+        "system/bt/stack/include",
+        "system/bt/utils/include",
+    ],
+    srcs: [
+        "test/hci_hal_h4_test.cc",
+        "test/hci_hal_mct_test.cc",
+        "test/hci_layer_test.cc",
+        "test/low_power_manager_test.cc",
+        "test/packet_fragmenter_test.cc",
+    ],
+    shared_libs: [
+        "liblog",
+        "libdl",
+        "libprotobuf-cpp-lite",
+    ],
+    static_libs: [
+        "libbt-hci",
+        "libosi",
+        "libosi-AlarmTestHarness",
+        "libosi-AllocationTestHarness",
+        "libcutils",
+        "libbtcore",
+        "libbt-protos",
+    ],
+}
diff --git a/hci/Android.mk b/hci/Android.mk
deleted file mode 100644
index cf2c94f..0000000
--- a/hci/Android.mk
+++ /dev/null
@@ -1,83 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-# HCI static library for target
-# ========================================================
-include $(CLEAR_VARS)
-LOCAL_CPP_EXTENSION := .cc
-
-LOCAL_SRC_FILES := \
-    src/btsnoop.cc \
-    src/btsnoop_mem.cc \
-    src/btsnoop_net.cc \
-    src/buffer_allocator.cc \
-    src/hci_audio.cc \
-    src/hci_hal.cc \
-    src/hci_hal_h4.cc \
-    src/hci_hal_mct.cc \
-    src/hci_inject.cc \
-    src/hci_layer.cc \
-    src/hci_packet_factory.cc \
-    src/hci_packet_parser.cc \
-    src/low_power_manager.cc \
-    src/packet_fragmenter.cc \
-    src/vendor.cc \
-    ../EventLogTags.logtags
-
-LOCAL_C_INCLUDES := \
-    $(LOCAL_PATH)/include \
-    $(LOCAL_PATH)/.. \
-    $(LOCAL_PATH)/../include \
-    $(LOCAL_PATH)/../btcore/include \
-    $(LOCAL_PATH)/../stack/include \
-    $(LOCAL_PATH)/../utils/include \
-    $(LOCAL_PATH)/../bta/include \
-    $(bluetooth_C_INCLUDES)
-
-LOCAL_MODULE := libbt-hci
-LOCAL_SHARED_LIBRARIES := libchrome
-
-ifeq ($(BLUETOOTH_HCI_USE_MCT),true)
-    LOCAL_CFLAGS += -DHCI_USE_MCT
-endif
-LOCAL_CFLAGS += $(bluetooth_CFLAGS)
-LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
-LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
-
-include $(BUILD_STATIC_LIBRARY)
-
-# HCI unit tests for target
-# ========================================================
-ifeq (,$(strip $(SANITIZE_TARGET)))
-include $(CLEAR_VARS)
-LOCAL_CPP_EXTENSION := .cc
-
-LOCAL_C_INCLUDES := \
-    $(LOCAL_PATH)/include \
-    $(LOCAL_PATH)/.. \
-    $(LOCAL_PATH)/../include \
-    $(LOCAL_PATH)/../btcore/include \
-    $(LOCAL_PATH)/../osi/test \
-    $(LOCAL_PATH)/../stack/include \
-    $(LOCAL_PATH)/../utils/include \
-    $(bluetooth_C_INCLUDES)
-
-LOCAL_SRC_FILES := \
-    ../osi/test/AllocationTestHarness.cc \
-    ../osi/test/AlarmTestHarness.cc \
-    ./test/hci_hal_h4_test.cc \
-    ./test/hci_hal_mct_test.cc \
-    ./test/hci_layer_test.cc \
-    ./test/low_power_manager_test.cc \
-    ./test/packet_fragmenter_test.cc
-
-LOCAL_MODULE := net_test_hci
-LOCAL_MODULE_TAGS := tests
-LOCAL_SHARED_LIBRARIES := liblog libdl libprotobuf-cpp-lite libchrome
-LOCAL_STATIC_LIBRARIES := libbt-hci libosi libcutils libbtcore libbt-protos
-
-LOCAL_CFLAGS += $(bluetooth_CFLAGS)
-LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
-LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
-
-include $(BUILD_NATIVE_TEST)
-endif # SANITIZE_TARGET
diff --git a/main/Android.bp b/main/Android.bp
new file mode 100644
index 0000000..a6d20d9
--- /dev/null
+++ b/main/Android.bp
@@ -0,0 +1,81 @@
+// Bluetooth main HW module / shared library for target
+// ========================================================
+cc_library_shared {
+    name: "bluetooth.default",
+    defaults: ["fluoride_defaults"],
+    relative_install_path: "hw",
+    srcs: [
+        // platform specific
+        "bte_conf.cc",
+        "bte_init.cc",
+        "bte_init_cpp_logging.cc",
+        "bte_logmsg.cc",
+        "bte_main.cc",
+        "stack_config.cc",
+    ],
+    include_dirs: [
+        "system/bt",
+        "system/bt/bta/include",
+        "system/bt/bta/sys",
+        "system/bt/bta/dm",
+        "system/bt/btcore/include",
+        "system/bt/include",
+        "system/bt/stack/include",
+        "system/bt/stack/l2cap",
+        "system/bt/stack/a2dp",
+        "system/bt/stack/btm",
+        "system/bt/stack/avdt",
+        "system/bt/udrv/include",
+        "system/bt/btif/include",
+        "system/bt/btif/co",
+        "system/bt/hci/include",
+        "system/bt/vnd/include",
+        "system/bt/embdrv/sbc/encoder/include",
+        "system/bt/embdrv/sbc/decoder/include",
+        "system/bt/audio_a2dp_hw",
+        "system/bt/utils/include",
+    ],
+    logtags: ["../EventLogTags.logtags"],
+    shared_libs: [
+        "libcutils",
+        "libdl",
+        "liblog",
+        "libz",
+        "libprotobuf-cpp-lite",
+        "libaudioclient",
+        "libutils",
+        "libtinyxml2",
+    ],
+    static_libs: [
+        "libbt-sbc-decoder",
+        "libbt-sbc-encoder",
+        "libudrv-uipc",
+    ],
+    whole_static_libs: [
+        "libbt-bta",
+        "libbtdevice",
+        "libbtif",
+        "libbt-hci",
+        "libbt-protos",
+        "libbt-stack",
+        "libbt-utils",
+        "libbtcore",
+        "libosi",
+    ],
+    // Shared library link options.
+    // References to global symbols and functions should bind to the library
+    // itself. This is to avoid issues with some of the unit/system tests
+    // that might link statically with some of the code in the library, and
+    // also dlopen(3) the shared library.
+    ldflags: ["-Wl,-Bsymbolic,-Bsymbolic-functions"],
+    required: [
+        "bt_did.conf",
+        "bt_stack.conf",
+        "libbt-hci",
+        "libbt-vendor",
+        "libldacBT_enc",
+    ],
+    cflags: [
+        "-DBUILDCFG",
+    ],
+}
diff --git a/main/Android.mk b/main/Android.mk
deleted file mode 100644
index 10bf746..0000000
--- a/main/Android.mk
+++ /dev/null
@@ -1,97 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-# Bluetooth main HW module / shared library for target
-# ========================================================
-include $(CLEAR_VARS)
-
-LOCAL_CPP_EXTENSION := .cc
-
-# platform specific
-LOCAL_SRC_FILES := \
-    bte_conf.cc \
-    bte_init.cc \
-    bte_init_cpp_logging.cc \
-    bte_logmsg.cc \
-    bte_main.cc \
-    stack_config.cc
-
-LOCAL_SRC_FILES += \
-    ../udrv/ulinux/uipc.cc
-
-LOCAL_C_INCLUDES := . \
-    $(LOCAL_PATH)/../ \
-    $(LOCAL_PATH)/../bta/include \
-    $(LOCAL_PATH)/../bta/sys \
-    $(LOCAL_PATH)/../bta/dm \
-    $(LOCAL_PATH)/../btcore/include \
-    $(LOCAL_PATH)/../include \
-    $(LOCAL_PATH)/../stack/include \
-    $(LOCAL_PATH)/../stack/l2cap \
-    $(LOCAL_PATH)/../stack/a2dp \
-    $(LOCAL_PATH)/../stack/btm \
-    $(LOCAL_PATH)/../stack/avdt \
-    $(LOCAL_PATH)/../udrv/include \
-    $(LOCAL_PATH)/../btif/include \
-    $(LOCAL_PATH)/../btif/co \
-    $(LOCAL_PATH)/../hci/include\
-    $(LOCAL_PATH)/../vnd/include \
-    $(LOCAL_PATH)/../embdrv/sbc/encoder/include \
-    $(LOCAL_PATH)/../embdrv/sbc/decoder/include \
-    $(LOCAL_PATH)/../audio_a2dp_hw \
-    $(LOCAL_PATH)/../utils/include \
-    $(bluetooth_C_INCLUDES) \
-    external/tinyxml2 \
-    external/zlib
-
-LOCAL_SHARED_LIBRARIES := \
-    libcutils \
-    libdl \
-    liblog \
-    libz \
-    libprotobuf-cpp-lite \
-    libaudioclient \
-    libutils \
-    libchrome \
-    libtinyxml2
-
-LOCAL_STATIC_LIBRARIES := \
-    libbt-sbc-decoder \
-    libbt-sbc-encoder
-
-LOCAL_WHOLE_STATIC_LIBRARIES := \
-    libbt-bta \
-    libbtdevice \
-    libbtif \
-    libbt-hci \
-    libbt-protos \
-    libbt-stack \
-    libbt-utils \
-    libbtcore \
-    libosi
-
-LOCAL_MODULE := bluetooth.default
-LOCAL_MODULE_RELATIVE_PATH := hw
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE_CLASS := SHARED_LIBRARIES
-
-#
-# Shared library link options.
-# References to global symbols and functions should bind to the library
-# itself. This is to avoid issues with some of the unit/system tests
-# that might link statically with some of the code in the library, and
-# also dlopen(3) the shared library.
-#
-LOCAL_LDLIBS := -Wl,-Bsymbolic,-Bsymbolic-functions
-
-LOCAL_REQUIRED_MODULES := \
-    bt_did.conf \
-    bt_stack.conf \
-    libbt-hci \
-    libbt-vendor \
-    libldacBT_enc
-
-LOCAL_CFLAGS += $(bluetooth_CFLAGS) -DBUILDCFG
-LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
-LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/osi/Android.bp b/osi/Android.bp
new file mode 100644
index 0000000..a114ce8
--- /dev/null
+++ b/osi/Android.bp
@@ -0,0 +1,161 @@
+cc_defaults {
+    name: "fluoride_osi_defaults",
+    defaults: ["fluoride_defaults"],
+    include_dirs: [
+        "system/bt",
+        "system/bt/include",
+        "system/bt/osi/src/protos",
+        "system/bt/utils/include",
+        "system/bt/stack/include",
+    ]
+}
+
+// Static libraries required by other modules
+// ========================================================
+cc_test_library {
+    name: "libosi-AllocationTestHarness",
+    defaults: ["fluoride_osi_defaults"],
+    srcs: [
+        "test/AllocationTestHarness.cc",
+    ],
+    host_supported: true,
+    shared: {
+        enabled: false
+    }
+}
+
+cc_test_library {
+    name: "libosi-AlarmTestHarness",
+    defaults: ["fluoride_osi_defaults"],
+    srcs: [
+        "test/AlarmTestHarness.cc",
+    ],
+    host_supported: true,
+    shared: {
+        enabled: false
+    }
+}
+
+// Bluetooth Protobuf static library for target and host
+// ========================================================
+cc_library_static {
+    name: "libbt-protos",
+    defaults: ["fluoride_defaults"],
+    srcs: ["src/protos/bluetooth.proto"],
+    proto: {
+        export_proto_headers: true,
+    },
+    host_supported: true
+}
+
+
+// libosi static library for target
+// ========================================================
+cc_library_static {
+    name: "libosi",
+    defaults: ["fluoride_osi_defaults"],
+    // TODO(mcchou): Remove socket_utils sources after platform specific
+    // dependencies are abstracted.
+    srcs: [
+        "src/alarm.cc",
+        "src/allocation_tracker.cc",
+        "src/allocator.cc",
+        "src/array.cc",
+        "src/buffer.cc",
+        "src/compat.cc",
+        "src/config.cc",
+        "src/data_dispatcher.cc",
+        "src/eager_reader.cc",
+        "src/fixed_queue.cc",
+        "src/future.cc",
+        "src/hash_map_utils.cc",
+        "src/list.cc",
+        "src/metrics.cc",
+        "src/mutex.cc",
+        "src/osi.cc",
+        "src/properties.cc",
+        "src/reactor.cc",
+        "src/ringbuffer.cc",
+        "src/semaphore.cc",
+        "src/socket.cc",
+        "src/socket_utils/socket_local_client.cc",
+        "src/socket_utils/socket_local_server.cc",
+        "src/thread.cc",
+        "src/time.cc",
+        "src/wakelock.cc",
+    ],
+    shared_libs: [
+        "liblog",
+    ],
+    static_libs: ["libbt-protos"],
+    host_supported: true,
+    // TODO(armansito): Setting _GNU_SOURCE isn't very platform-independent but
+    // should be compatible for a Linux host OS. We should figure out what to do for
+    // a non-Linux host OS.
+    target: {
+        darwin: {
+            enabled: false,
+        },
+        linux: {
+            cflags: [
+                "-D_GNU_SOURCE",
+                "-DOS_GENERIC",
+            ],
+        },
+    },
+}
+
+// libosi unit tests for target and host
+// ========================================================
+cc_test {
+    name: "net_test_osi",
+    defaults: ["fluoride_osi_defaults"],
+    host_supported: true,
+    srcs: [
+        "test/AlarmTestHarness.cc",
+        "test/AllocationTestHarness.cc",
+        "test/alarm_test.cc",
+        "test/allocation_tracker_test.cc",
+        "test/allocator_test.cc",
+        "test/array_test.cc",
+        "test/config_test.cc",
+        "test/data_dispatcher_test.cc",
+        "test/eager_reader_test.cc",
+        "test/fixed_queue_test.cc",
+        "test/future_test.cc",
+        "test/hash_map_utils_test.cc",
+        "test/leaky_bonded_queue_test.cc",
+        "test/list_test.cc",
+        "test/metrics_test.cc",
+        "test/properties_test.cc",
+        "test/rand_test.cc",
+        "test/reactor_test.cc",
+        "test/ringbuffer_test.cc",
+        "test/semaphore_test.cc",
+        "test/thread_test.cc",
+        "test/time_test.cc",
+        "test/wakelock_test.cc",
+    ],
+    shared_libs: [
+        "liblog",
+        "libprotobuf-cpp-lite",
+        "libcutils",
+    ],
+    static_libs: [
+        "libbt-protos",
+        "libgmock",
+        "libosi",
+    ],
+    target: {
+        linux: {
+            cflags: ["-DOS_GENERIC"],
+            host_ldlibs: [
+                "-lrt",
+                "-lpthread",
+            ],
+        },
+        darwin: {
+            enabled: false,
+        }
+    },
+}
diff --git a/osi/Android.mk b/osi/Android.mk
deleted file mode 100644
index db2820a..0000000
--- a/osi/Android.mk
+++ /dev/null
@@ -1,201 +0,0 @@
- ##############################################################################
- #
- #  Copyright (C) 2014 Google, Inc.
- #
- #  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)
-
-# Common variables
-# ========================================================
-
-# TODO(mcchou): Remove socket_utils sources after platform specific
-# dependencies are abstracted.
-btosiCommonSrc := \
-    ./src/alarm.cc \
-    ./src/allocation_tracker.cc \
-    ./src/allocator.cc \
-    ./src/array.cc \
-    ./src/buffer.cc \
-    ./src/compat.cc \
-    ./src/config.cc \
-    ./src/data_dispatcher.cc \
-    ./src/eager_reader.cc \
-    ./src/fixed_queue.cc \
-    ./src/future.cc \
-    ./src/hash_map_utils.cc \
-    ./src/list.cc \
-    ./src/metrics.cc \
-    ./src/mutex.cc \
-    ./src/osi.cc \
-    ./src/properties.cc \
-    ./src/reactor.cc \
-    ./src/ringbuffer.cc \
-    ./src/semaphore.cc \
-    ./src/socket.cc \
-    ./src/socket_utils/socket_local_client.cc \
-    ./src/socket_utils/socket_local_server.cc \
-    ./src/thread.cc \
-    ./src/time.cc \
-    ./src/wakelock.cc
-
-btosiCommonTestSrc := \
-    ./test/AlarmTestHarness.cc \
-    ./test/AllocationTestHarness.cc \
-    ./test/alarm_test.cc \
-    ./test/allocation_tracker_test.cc \
-    ./test/allocator_test.cc \
-    ./test/array_test.cc \
-    ./test/config_test.cc \
-    ./test/data_dispatcher_test.cc \
-    ./test/eager_reader_test.cc \
-    ./test/fixed_queue_test.cc \
-    ./test/future_test.cc \
-    ./test/hash_map_utils_test.cc \
-    ./test/leaky_bonded_queue_test.cc \
-    ./test/list_test.cc \
-    ./test/metrics_test.cc \
-    ./test/properties_test.cc \
-    ./test/rand_test.cc \
-    ./test/reactor_test.cc \
-    ./test/ringbuffer_test.cc \
-    ./test/semaphore_test.cc \
-    ./test/thread_test.cc \
-    ./test/time_test.cc \
-    ./test/wakelock_test.cc
-
-btosiCommonIncludes := \
-    $(LOCAL_PATH)/.. \
-    $(LOCAL_PATH)/../include \
-    $(LOCAL_PATH)/../utils/include \
-    $(LOCAL_PATH)/../stack/include \
-    $(bluetooth_C_INCLUDES)
-
-# Bluetooth Protobuf static library for target
-# ========================================================
-include $(CLEAR_VARS)
-LOCAL_CPP_EXTENSION := .cc
-LOCAL_MODULE := libbt-protos
-LOCAL_MODULE_CLASS := STATIC_LIBRARIES
-generated_sources_dir := $(call local-generated-sources-dir)
-LOCAL_EXPORT_C_INCLUDE_DIRS := \
-    $(generated_sources_dir)/proto/system/bt
-LOCAL_SRC_FILES := $(call all-proto-files-under,src/protos/)
-
-LOCAL_CFLAGS += $(bluetooth_CFLAGS)
-LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
-LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
-
-include $(BUILD_STATIC_LIBRARY)
-
-# Bluetooth Protobuf static library for host
-# ========================================================
-include $(CLEAR_VARS)
-LOCAL_CPP_EXTENSION := .cc
-LOCAL_MODULE := libbt-protos
-LOCAL_MODULE_CLASS := STATIC_LIBRARIES
-LOCAL_IS_HOST_MODULE := true
-generated_sources_dir := $(call local-generated-sources-dir)
-LOCAL_EXPORT_C_INCLUDE_DIRS := \
-    $(generated_sources_dir)/proto/system/bt
-LOCAL_SRC_FILES := $(call all-proto-files-under,src/protos/)
-
-LOCAL_CFLAGS += $(bluetooth_CFLAGS)
-LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
-LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
-
-include $(BUILD_HOST_STATIC_LIBRARY)
-
-# libosi static library for target
-# ========================================================
-include $(CLEAR_VARS)
-LOCAL_CPP_EXTENSION := .cc
-LOCAL_C_INCLUDES := $(btosiCommonIncludes)
-LOCAL_SRC_FILES := $(btosiCommonSrc)
-LOCAL_MODULE := libosi
-LOCAL_MODULE_TAGS := optional
-LOCAL_SHARED_LIBRARIES := libc liblog libchrome
-LOCAL_STATIC_LIBRARIES := libbt-protos
-LOCAL_MODULE_CLASS := STATIC_LIBRARIES
-
-LOCAL_CFLAGS += $(bluetooth_CFLAGS)
-LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
-LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
-
-include $(BUILD_STATIC_LIBRARY)
-
-# libosi static library for host
-# ========================================================
-ifeq ($(HOST_OS),linux)
-include $(CLEAR_VARS)
-LOCAL_CPP_EXTENSION := .cc
-LOCAL_C_INCLUDES := $(btosiCommonIncludes)
-LOCAL_SRC_FILES := $(btosiCommonSrc)
-LOCAL_MODULE := libosi-host
-LOCAL_MODULE_TAGS := optional
-LOCAL_SHARED_LIBRARIES := liblog libchrome
-LOCAL_STATIC_LIBRARIES := libbt-protos
-LOCAL_MODULE_CLASS := STATIC_LIBRARIES
-
-# TODO(armansito): Setting _GNU_SOURCE isn't very platform-independent but
-# should be compatible for a Linux host OS. We should figure out what to do for
-# a non-Linux host OS.
-LOCAL_CFLAGS += $(bluetooth_CFLAGS) -D_GNU_SOURCE -DOS_GENERIC
-LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
-LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
-
-include $(BUILD_HOST_STATIC_LIBRARY)
-endif
-
-#
-# Note: It's good to get the tests compiled both for the host and the target so
-# we get to test with both Bionic libc and glibc
-#
-# libosi unit tests for target
-# ========================================================
-include $(CLEAR_VARS)
-LOCAL_CPP_EXTENSION := .cc
-LOCAL_C_INCLUDES := $(btosiCommonIncludes)
-LOCAL_SRC_FILES := $(btosiCommonTestSrc)
-LOCAL_MODULE := net_test_osi
-LOCAL_MODULE_TAGS := tests
-LOCAL_SHARED_LIBRARIES := libc liblog libprotobuf-cpp-lite libchrome libcutils
-LOCAL_STATIC_LIBRARIES := libosi libbt-protos libgmock
-
-LOCAL_CFLAGS += $(bluetooth_CFLAGS)
-LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
-LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
-
-include $(BUILD_NATIVE_TEST)
-
-# libosi unit tests for host
-# ========================================================
-ifeq ($(HOST_OS),linux)
-include $(CLEAR_VARS)
-LOCAL_CPP_EXTENSION := .cc
-LOCAL_C_INCLUDES := $(btosiCommonIncludes)
-LOCAL_SRC_FILES := $(btosiCommonTestSrc)
-LOCAL_LDLIBS := -lrt -lpthread
-LOCAL_MODULE := net_test_osi
-LOCAL_MODULE_TAGS := tests
-LOCAL_SHARED_LIBRARIES := liblog libprotobuf-cpp-lite libchrome
-LOCAL_STATIC_LIBRARIES := libosi-host libbt-protos libgmock
-
-LOCAL_CFLAGS += $(bluetooth_CFLAGS) -DOS_GENERIC
-LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
-LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
-
-include $(BUILD_HOST_NATIVE_TEST)
-endif
diff --git a/osi/src/metrics.cc b/osi/src/metrics.cc
index e5f9b55..2cce3d3 100644
--- a/osi/src/metrics.cc
+++ b/osi/src/metrics.cc
@@ -35,7 +35,7 @@
 #include "osi/include/time.h"
 #include "stack/include/btm_api_types.h"
 
-#include "osi/src/protos/bluetooth.pb.h"
+#include "src/protos/bluetooth.pb.h"
 
 #include "osi/include/metrics.h"
 
diff --git a/osi/test/metrics_test.cc b/osi/test/metrics_test.cc
index ce4057e..8bcf673 100644
--- a/osi/test/metrics_test.cc
+++ b/osi/test/metrics_test.cc
@@ -28,7 +28,7 @@
 
 #include "osi/include/metrics.h"
 #include "osi/include/time.h"
-#include "osi/src/protos/bluetooth.pb.h"
+#include "src/protos/bluetooth.pb.h"
 
 #define BTM_COD_MAJOR_AUDIO_TEST 0x04
 
diff --git a/service/Android.bp b/service/Android.bp
new file mode 100644
index 0000000..586b0a1
--- /dev/null
+++ b/service/Android.bp
@@ -0,0 +1,242 @@
+cc_defaults {
+    name: "fluoride_service_defaults",
+    defaults: ["fluoride_defaults"],
+    local_include_dirs: [
+        "common"
+    ],
+    include_dirs: [
+        "system/bt"
+    ],
+    srcs: [
+        "common/bluetooth/adapter_state.cc",
+        "common/bluetooth/advertise_data.cc",
+        "common/bluetooth/advertise_settings.cc",
+        "common/bluetooth/descriptor.cc",
+        "common/bluetooth/characteristic.cc",
+        "common/bluetooth/scan_filter.cc",
+        "common/bluetooth/scan_result.cc",
+        "common/bluetooth/scan_settings.cc",
+        "common/bluetooth/service.cc",
+        "common/bluetooth/util/address_helper.cc",
+        "common/bluetooth/util/atomic_string.cc",
+        "common/bluetooth/uuid.cc",
+    ]
+}
+
+// Source variables
+// ========================================================
+btserviceCommonBinderSrc = [
+    "common/android/bluetooth/IBluetooth.aidl",
+    "common/android/bluetooth/IBluetoothCallback.aidl",
+    "common/android/bluetooth/IBluetoothGattClient.aidl",
+    "common/android/bluetooth/IBluetoothGattClientCallback.aidl",
+    "common/android/bluetooth/IBluetoothGattServer.aidl",
+    "common/android/bluetooth/IBluetoothGattServerCallback.aidl",
+    "common/android/bluetooth/IBluetoothLeAdvertiser.aidl",
+    "common/android/bluetooth/IBluetoothLeAdvertiserCallback.aidl",
+    "common/android/bluetooth/IBluetoothLeScanner.aidl",
+    "common/android/bluetooth/IBluetoothLeScannerCallback.aidl",
+    "common/android/bluetooth/IBluetoothLowEnergy.aidl",
+    "common/android/bluetooth/IBluetoothLowEnergyCallback.aidl",
+    "common/android/bluetooth/advertise_data.cc",
+    "common/android/bluetooth/advertise_settings.cc",
+    "common/android/bluetooth/bluetooth_gatt_characteristic.cc",
+    "common/android/bluetooth/bluetooth_gatt_descriptor.cc",
+    "common/android/bluetooth/bluetooth_gatt_included_service.cc",
+    "common/android/bluetooth/bluetooth_gatt_service.cc",
+    "common/android/bluetooth/scan_filter.cc",
+    "common/android/bluetooth/scan_result.cc",
+    "common/android/bluetooth/scan_settings.cc",
+    "common/android/bluetooth/uuid.cc",
+]
+
+btserviceCommonAidlInclude = [
+    "system/bt/service/common",
+    "frameworks/native/aidl/binder",
+]
+
+btserviceDaemonSrc = [
+    "adapter.cc",
+    "daemon.cc",
+    "gatt_client.cc",
+    "gatt_server.cc",
+    "gatt_server_old.cc",
+    "hal/bluetooth_gatt_interface.cc",
+    "hal/bluetooth_interface.cc",
+    "ipc/ipc_handler.cc",
+    "ipc/ipc_manager.cc",
+    "logging_helpers.cc",
+    "low_energy_advertiser.cc",
+    "low_energy_scanner.cc",
+    "low_energy_client.cc",
+    "settings.cc",
+]
+
+btserviceLinuxSrc = [
+    "ipc/ipc_handler_linux.cc",
+    "ipc/linux_ipc_host.cc",
+]
+
+btserviceBinderDaemonImplSrc = [
+    "ipc/binder/bluetooth_binder_server.cc",
+    "ipc/binder/bluetooth_gatt_client_binder_server.cc",
+    "ipc/binder/bluetooth_gatt_server_binder_server.cc",
+    "ipc/binder/bluetooth_le_advertiser_binder_server.cc",
+    "ipc/binder/bluetooth_le_scanner_binder_server.cc",
+    "ipc/binder/bluetooth_low_energy_binder_server.cc",
+    "ipc/binder/interface_with_instances_base.cc",
+    "ipc/binder/ipc_handler_binder.cc",
+]
+
+btserviceBinderDaemonSrc = btserviceCommonBinderSrc + btserviceBinderDaemonImplSrc
+
+// Main unit test sources. These get built for host and target.
+// ========================================================
+btserviceBaseTestSrc = [
+    "hal/fake_bluetooth_gatt_interface.cc",
+    "hal/fake_bluetooth_interface.cc",
+    "test/adapter_unittest.cc",
+    "test/advertise_data_unittest.cc",
+    "test/fake_hal_util.cc",
+    "test/gatt_client_unittest.cc",
+    "test/gatt_server_unittest.cc",
+    "test/low_energy_advertiser_unittest.cc",
+    "test/low_energy_client_unittest.cc",
+    "test/low_energy_scanner_unittest.cc",
+    "test/settings_unittest.cc",
+    "test/util_unittest.cc",
+    "test/uuid_unittest.cc",
+]
+
+// Native system service for target
+// ========================================================
+cc_binary {
+    name: "bluetoothtbd",
+    defaults: ["fluoride_service_defaults"],
+    srcs: btserviceBinderDaemonSrc
+        + btserviceLinuxSrc
+        + btserviceDaemonSrc
+        + ["main.cc"],
+    aidl: {
+        include_dirs: btserviceCommonAidlInclude
+    },
+    required: ["bluetooth.default"],
+    static_libs: ["libbtcore"],
+    shared_libs: [
+        "libbinder",
+        "libcutils",
+        "libhardware",
+        "liblog",
+        "libutils",
+    ],
+    init_rc: ["bluetoothtbd.rc"],
+}
+
+// Native system service unit tests for target and host
+
+// ========================================================
+cc_test {
+    name: "bluetoothtbd_test",
+    defaults: ["fluoride_service_defaults"],
+    srcs: btserviceBaseTestSrc
+        + btserviceDaemonSrc + [
+        "test/main.cc"
+    ],
+    aidl: {
+        include_dirs: btserviceCommonAidlInclude,
+    },
+    static_libs: [
+        "libgmock",
+        "liblog",
+    ],
+    host_supported: true,
+    target: {
+        // This includes Binder related tests that can only be run
+        // on target.
+        android: {
+            srcs: btserviceBinderDaemonSrc + [
+                "test/parcelable_unittest.cc",
+                "test/ParcelableTest.aidl",
+            ],
+            shared_libs: [
+                "libbinder",
+                "libutils",
+            ],
+        },
+        host: {
+            srcs: [
+                "test/stub_ipc_handler_binder.cc",
+            ],
+        },
+        darwin: {
+            srcs: [
+                "test/stub_ipc_handler_linux.cc",
+            ],
+        },
+        linux: {
+            srcs: btserviceLinuxSrc + [
+                "test/ipc_linux_unittest.cc",
+            ],
+            host_ldlibs: ["-lrt"],
+        },
+    },
+}
+
+// Client library for interacting with Bluetooth daemon
+// This is a static library for target.
+// ========================================================
+cc_library_static {
+    name: "libbluetooth-client",
+    defaults: ["fluoride_service_defaults"],
+    srcs: btserviceCommonBinderSrc,
+    aidl: {
+        export_aidl_headers: true,
+        include_dirs: btserviceCommonAidlInclude
+    },
+    export_include_dirs: ["common"],
+    shared_libs: [
+        "libbinder",
+        "libutils",
+    ],
+}
+
+// Native system service CLI for target
+// ========================================================
+cc_binary {
+    name: "bluetooth-cli",
+    defaults: ["fluoride_defaults"],
+    srcs: ["client/main.cc"],
+    static_libs: ["libbluetooth-client"],
+    shared_libs: [
+        "libbinder",
+        "libutils",
+    ],
+}
+
+// Heart Rate GATT service example for target
+// ========================================================
+cc_binary {
+    name: "bt-example-hr-server",
+    defaults: ["fluoride_defaults"],
+    local_include_dirs: ["example/heart_rate"],
+    srcs: [
+        "example/heart_rate/heart_rate_server.cc",
+        "example/heart_rate/server_main.cc",
+    ],
+    static_libs: ["libbluetooth-client"],
+    shared_libs: [
+        "libbinder",
+        "libutils",
+    ],
+}
+
+cc_library_static {
+    name: "libbluetoothtbd_hal",
+    defaults: ["fluoride_defaults"],
+    include_dirs: ["system/bt"],
+    srcs = [
+        "hal/bluetooth_gatt_interface.cc",
+        "hal/bluetooth_interface.cc",
+        "logging_helpers.cc",
+    ]
+}
diff --git a/service/Android.mk b/service/Android.mk
deleted file mode 100644
index 5074254..0000000
--- a/service/Android.mk
+++ /dev/null
@@ -1,272 +0,0 @@
-#
-#  Copyright (C) 2015 Google
-#
-#  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)
-
-# Source variables
-# ========================================================
-btserviceCommonSrc := \
-	common/bluetooth/adapter_state.cc \
-	common/bluetooth/advertise_data.cc \
-	common/bluetooth/advertise_settings.cc \
-	common/bluetooth/descriptor.cc \
-	common/bluetooth/characteristic.cc \
-	common/bluetooth/scan_filter.cc \
-	common/bluetooth/scan_result.cc \
-	common/bluetooth/scan_settings.cc \
-	common/bluetooth/service.cc \
-	common/bluetooth/util/address_helper.cc \
-	common/bluetooth/util/atomic_string.cc \
-	common/bluetooth/uuid.cc
-
-btserviceCommonBinderSrc := \
-	common/android/bluetooth/IBluetooth.aidl \
-	common/android/bluetooth/IBluetoothCallback.aidl \
-	common/android/bluetooth/IBluetoothGattClient.aidl \
-	common/android/bluetooth/IBluetoothGattClientCallback.aidl \
-	common/android/bluetooth/IBluetoothGattServer.aidl \
-	common/android/bluetooth/IBluetoothGattServerCallback.aidl \
-	common/android/bluetooth/IBluetoothLeAdvertiser.aidl \
-	common/android/bluetooth/IBluetoothLeAdvertiserCallback.aidl \
-	common/android/bluetooth/IBluetoothLeScanner.aidl \
-	common/android/bluetooth/IBluetoothLeScannerCallback.aidl \
-	common/android/bluetooth/IBluetoothLowEnergy.aidl \
-	common/android/bluetooth/IBluetoothLowEnergyCallback.aidl \
-	common/android/bluetooth/advertise_data.cc \
-	common/android/bluetooth/advertise_settings.cc \
-	common/android/bluetooth/bluetooth_gatt_characteristic.cc \
-	common/android/bluetooth/bluetooth_gatt_descriptor.cc \
-	common/android/bluetooth/bluetooth_gatt_included_service.cc \
-	common/android/bluetooth/bluetooth_gatt_service.cc \
-	common/android/bluetooth/scan_filter.cc \
-	common/android/bluetooth/scan_result.cc \
-	common/android/bluetooth/scan_settings.cc \
-	common/android/bluetooth/uuid.cc \
-
-btserviceCommonAidlInclude := \
-	system/bt/service/common \
-	frameworks/native/aidl/binder
-
-btserviceDaemonSrc := \
-	adapter.cc \
-	daemon.cc \
-	gatt_client.cc \
-	gatt_server.cc \
-	gatt_server_old.cc \
-	hal/bluetooth_gatt_interface.cc \
-	hal/bluetooth_interface.cc \
-	ipc/ipc_handler.cc \
-	ipc/ipc_manager.cc \
-	logging_helpers.cc \
-	low_energy_advertiser.cc \
-	low_energy_scanner.cc \
-	low_energy_client.cc \
-	settings.cc
-
-btserviceLinuxSrc := \
-	ipc/ipc_handler_linux.cc \
-	ipc/linux_ipc_host.cc
-
-btserviceBinderDaemonImplSrc := \
-	ipc/binder/bluetooth_binder_server.cc \
-	ipc/binder/bluetooth_gatt_client_binder_server.cc \
-	ipc/binder/bluetooth_gatt_server_binder_server.cc \
-	ipc/binder/bluetooth_le_advertiser_binder_server.cc \
-	ipc/binder/bluetooth_le_scanner_binder_server.cc \
-	ipc/binder/bluetooth_low_energy_binder_server.cc \
-	ipc/binder/interface_with_instances_base.cc \
-	ipc/binder/ipc_handler_binder.cc \
-
-btserviceBinderDaemonSrc := \
-	$(btserviceCommonBinderSrc) \
-	$(btserviceBinderDaemonImplSrc)
-
-btserviceCommonIncludes := \
-	$(LOCAL_PATH)/../ \
-	$(LOCAL_PATH)/common
-
-# Main unit test sources. These get built for host and target.
-# ========================================================
-btserviceBaseTestSrc := \
-	hal/fake_bluetooth_gatt_interface.cc \
-	hal/fake_bluetooth_interface.cc \
-	test/adapter_unittest.cc \
-	test/advertise_data_unittest.cc \
-	test/fake_hal_util.cc \
-	test/gatt_client_unittest.cc \
-	test/gatt_server_unittest.cc \
-	test/low_energy_advertiser_unittest.cc \
-	test/low_energy_client_unittest.cc \
-	test/low_energy_scanner_unittest.cc \
-	test/settings_unittest.cc \
-	test/util_unittest.cc \
-	test/uuid_unittest.cc
-
-# Native system service for target
-# ========================================================
-include $(CLEAR_VARS)
-LOCAL_CPP_EXTENSION := .cc
-LOCAL_SRC_FILES := \
-	$(btserviceCommonSrc) \
-	$(btserviceBinderDaemonSrc) \
-	$(btserviceLinuxSrc) \
-	$(btserviceDaemonSrc) \
-	main.cc
-LOCAL_AIDL_INCLUDES = $(btserviceCommonAidlInclude)
-LOCAL_C_INCLUDES := $(btserviceCommonIncludes)
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE := bluetoothtbd
-LOCAL_REQUIRED_MODULES := bluetooth.default
-LOCAL_STATIC_LIBRARIES := libbtcore
-LOCAL_SHARED_LIBRARIES := \
-	libbinder \
-	libchrome \
-	libcutils \
-	libhardware \
-	liblog \
-	libutils
-LOCAL_INIT_RC := bluetoothtbd.rc
-
-LOCAL_CFLAGS += $(bluetooth_CFLAGS)
-LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
-LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
-
-include $(BUILD_EXECUTABLE)
-
-# Native system service unit tests for host
-# ========================================================
-include $(CLEAR_VARS)
-LOCAL_CPP_EXTENSION := .cc
-LOCAL_SRC_FILES := \
-	$(btserviceBaseTestSrc) \
-	$(btserviceCommonSrc) \
-	$(btserviceDaemonSrc) \
-	test/main.cc \
-	test/stub_ipc_handler_binder.cc
-ifeq ($(HOST_OS),linux)
-LOCAL_SRC_FILES += \
-	$(btserviceLinuxSrc) \
-	test/ipc_linux_unittest.cc
-LOCAL_LDLIBS += -lrt
-else
-LOCAL_SRC_FILES += \
-	test/stub_ipc_handler_linux.cc
-endif
-LOCAL_C_INCLUDES := $(btserviceCommonIncludes)
-LOCAL_MODULE_TAGS := debug tests
-LOCAL_MODULE := bluetoothtbd-host_test
-LOCAL_SHARED_LIBRARIES := libchrome
-LOCAL_STATIC_LIBRARIES := libgmock_host libgtest_host liblog
-
-LOCAL_CFLAGS += $(bluetooth_CFLAGS)
-LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
-LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
-
-include $(BUILD_HOST_NATIVE_TEST)
-
-# Native system service unit tests for target.
-# This includes Binder related tests that can only be run
-# on target.
-# ========================================================
-include $(CLEAR_VARS)
-LOCAL_CPP_EXTENSION := .cc
-LOCAL_SRC_FILES := \
-	$(btserviceBaseTestSrc) \
-	$(btserviceCommonSrc) \
-	$(btserviceBinderDaemonSrc) \
-	$(btserviceDaemonSrc) \
-	test/main.cc \
-	test/parcelable_unittest.cc \
-	test/ParcelableTest.aidl
-LOCAL_AIDL_INCLUDES := $(btserviceCommonAidlInclude)
-LOCAL_AIDL_INCLUDES += ./
-LOCAL_C_INCLUDES := $(btserviceCommonIncludes)
-LOCAL_MODULE_TAGS := debug tests
-LOCAL_MODULE := bluetoothtbd_test
-LOCAL_SHARED_LIBRARIES := \
-	libbinder \
-	libchrome \
-	libutils
-LOCAL_STATIC_LIBRARIES := libgmock libgtest liblog
-
-LOCAL_CFLAGS += $(bluetooth_CFLAGS)
-LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
-LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
-
-include $(BUILD_NATIVE_TEST)
-
-# Client library for interacting with Bluetooth daemon
-# This is a static library for target.
-# ========================================================
-include $(CLEAR_VARS)
-LOCAL_CPP_EXTENSION := .cc
-LOCAL_SRC_FILES := \
-	$(btserviceCommonSrc) \
-	$(btserviceCommonBinderSrc)
-LOCAL_AIDL_INCLUDES := $(btserviceCommonAidlInclude)
-LOCAL_C_INCLUDES := $(btserviceCommonIncludes)
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/common
-LOCAL_MODULE := libbluetooth-client
-LOCAL_SHARED_LIBRARIES := libbinder libchrome libutils
-
-LOCAL_CFLAGS += $(bluetooth_CFLAGS)
-LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
-LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
-
-include $(BUILD_STATIC_LIBRARY)
-
-# Native system service CLI for target
-# ========================================================
-include $(CLEAR_VARS)
-LOCAL_CPP_EXTENSION := .cc
-LOCAL_SRC_FILES := client/main.cc
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE := bluetooth-cli
-LOCAL_STATIC_LIBRARIES := libbluetooth-client
-LOCAL_SHARED_LIBRARIES := \
-	libbinder \
-	libchrome \
-	libutils
-
-LOCAL_CFLAGS += $(bluetooth_CFLAGS)
-LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
-LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
-
-include $(BUILD_EXECUTABLE)
-
-# Heart Rate GATT service example for target
-# ========================================================
-# TODO(armansito): Move this into a new makefile under examples/ once we build
-# a client static library that the examples can depend on.
-include $(CLEAR_VARS)
-LOCAL_CPP_EXTENSION := .cc
-LOCAL_SRC_FILES := \
-	example/heart_rate/heart_rate_server.cc \
-	example/heart_rate/server_main.cc
-LOCAL_C_INCLUDES := $(LOCAL_PATH)/../
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE := bt-example-hr-server
-LOCAL_STATIC_LIBRARIES := libbluetooth-client
-LOCAL_SHARED_LIBRARIES := \
-	libbinder \
-	libchrome \
-	libutils
-
-LOCAL_CFLAGS += $(bluetooth_CFLAGS)
-LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
-LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
-
-include $(BUILD_EXECUTABLE)
diff --git a/service/example/heart_rate/heart_rate_server.cc b/service/example/heart_rate/heart_rate_server.cc
index 63b68be..a7bfe52 100644
--- a/service/example/heart_rate/heart_rate_server.cc
+++ b/service/example/heart_rate/heart_rate_server.cc
@@ -13,9 +13,6 @@
 //  See the License for the specific language governing permissions and
 //  limitations under the License.
 //
-
-#include "service/example/heart_rate/heart_rate_server.h"
-
 #include <base/bind.h>
 #include <base/location.h>
 #include <base/logging.h>
@@ -25,7 +22,8 @@
 #include <android/bluetooth/IBluetoothLeAdvertiser.h>
 #include <bluetooth/low_energy_constants.h>
 
-#include "service/example/heart_rate/constants.h"
+#include "constants.h"
+#include "heart_rate_server.h"
 
 using android::binder::Status;
 using android::String8;
diff --git a/service/example/heart_rate/server_main.cc b/service/example/heart_rate/server_main.cc
index 27fac53..76e7741 100644
--- a/service/example/heart_rate/server_main.cc
+++ b/service/example/heart_rate/server_main.cc
@@ -28,7 +28,7 @@
 
 #include <android/bluetooth/IBluetooth.h>
 
-#include "service/example/heart_rate/heart_rate_server.h"
+#include "heart_rate_server.h"
 
 using android::sp;
 using android::OK;
diff --git a/stack/Android.bp b/stack/Android.bp
new file mode 100644
index 0000000..899407b
--- /dev/null
+++ b/stack/Android.bp
@@ -0,0 +1,263 @@
+// Bluetooth stack static library for target
+// ========================================================
+cc_library_static {
+    name: "libbt-stack",
+    defaults: ["fluoride_defaults"],
+    local_include_dirs: [
+        "include",
+        "avct",
+        "btm",
+        "avrc",
+        "l2cap",
+        "avdt",
+        "gatt",
+        "gap",
+        "pan",
+        "bnep",
+        "hid",
+        "sdp",
+        "smp",
+        "srvc",
+    ],
+    include_dirs: [
+        "external/libldac/inc",
+        "system/bt",
+        "system/bt/btcore/include",
+        "system/bt/vnd/include",
+        "system/bt/vnd/ble",
+        "system/bt/btif/include",
+        "system/bt/hci/include",
+        "system/bt/include",
+        "system/bt/udrv/include",
+        "system/bt/bta/include",
+        "system/bt/bta/sys",
+        "system/bt/utils/include",
+    ],
+    srcs: [
+        "a2dp/a2dp_api.cc",
+        "a2dp/a2dp_codec_config.cc",
+        "a2dp/a2dp_sbc.cc",
+        "a2dp/a2dp_sbc_encoder.cc",
+        "a2dp/a2dp_sbc_up_sample.cc",
+        "a2dp/a2dp_vendor.cc",
+        "a2dp/a2dp_vendor_aptx.cc",
+        "a2dp/a2dp_vendor_aptx_hd.cc",
+        "a2dp/a2dp_vendor_aptx_encoder.cc",
+        "a2dp/a2dp_vendor_aptx_hd_encoder.cc",
+        "a2dp/a2dp_vendor_ldac.cc",
+        "a2dp/a2dp_vendor_ldac_encoder.cc",
+        "avct/avct_api.cc",
+        "avct/avct_bcb_act.cc",
+        "avct/avct_ccb.cc",
+        "avct/avct_l2c.cc",
+        "avct/avct_l2c_br.cc",
+        "avct/avct_lcb.cc",
+        "avct/avct_lcb_act.cc",
+        "avdt/avdt_ad.cc",
+        "avdt/avdt_api.cc",
+        "avdt/avdt_ccb.cc",
+        "avdt/avdt_ccb_act.cc",
+        "avdt/avdt_l2c.cc",
+        "avdt/avdt_msg.cc",
+        "avdt/avdt_scb.cc",
+        "avdt/avdt_scb_act.cc",
+        "avrc/avrc_api.cc",
+        "avrc/avrc_bld_ct.cc",
+        "avrc/avrc_bld_tg.cc",
+        "avrc/avrc_opt.cc",
+        "avrc/avrc_pars_ct.cc",
+        "avrc/avrc_pars_tg.cc",
+        "avrc/avrc_sdp.cc",
+        "avrc/avrc_utils.cc",
+        "bnep/bnep_api.cc",
+        "bnep/bnep_main.cc",
+        "bnep/bnep_utils.cc",
+        "btm/ble_advertiser_hci_interface.cc",
+        "btm/btm_acl.cc",
+        "btm/btm_ble.cc",
+        "btm/btm_ble_addr.cc",
+        "btm/btm_ble_adv_filter.cc",
+        "btm/btm_ble_batchscan.cc",
+        "btm/btm_ble_bgconn.cc",
+        "btm/btm_ble_cont_energy.cc",
+        "btm/btm_ble_gap.cc",
+        "btm/btm_ble_multi_adv.cc",
+        "btm/btm_ble_privacy.cc",
+        "btm/btm_dev.cc",
+        "btm/btm_devctl.cc",
+        "btm/btm_inq.cc",
+        "btm/btm_main.cc",
+        "btm/btm_pm.cc",
+        "btm/btm_sco.cc",
+        "btm/btm_sec.cc",
+        "btu/btu_hcif.cc",
+        "btu/btu_init.cc",
+        "btu/btu_task.cc",
+        "gap/gap_api.cc",
+        "gap/gap_ble.cc",
+        "gap/gap_conn.cc",
+        "gap/gap_utils.cc",
+        "gatt/att_protocol.cc",
+        "gatt/gatt_api.cc",
+        "gatt/gatt_attr.cc",
+        "gatt/gatt_auth.cc",
+        "gatt/gatt_cl.cc",
+        "gatt/gatt_db.cc",
+        "gatt/gatt_main.cc",
+        "gatt/gatt_sr.cc",
+        "gatt/gatt_utils.cc",
+        "hcic/hciblecmds.cc",
+        "hcic/hcicmds.cc",
+        "hid/hidh_api.cc",
+        "hid/hidh_conn.cc",
+        "hid/hidd_api.cc",
+        "hid/hidd_conn.cc",
+        "l2cap/l2c_api.cc",
+        "l2cap/l2c_ble.cc",
+        "l2cap/l2c_csm.cc",
+        "l2cap/l2c_fcr.cc",
+        "l2cap/l2c_link.cc",
+        "l2cap/l2c_main.cc",
+        "l2cap/l2c_ucd.cc",
+        "l2cap/l2c_utils.cc",
+        "l2cap/l2cap_client.cc",
+        "mcap/mca_api.cc",
+        "mcap/mca_cact.cc",
+        "mcap/mca_csm.cc",
+        "mcap/mca_dact.cc",
+        "mcap/mca_dsm.cc",
+        "mcap/mca_l2c.cc",
+        "mcap/mca_main.cc",
+        "pan/pan_api.cc",
+        "pan/pan_main.cc",
+        "pan/pan_utils.cc",
+        "rfcomm/port_api.cc",
+        "rfcomm/port_rfc.cc",
+        "rfcomm/port_utils.cc",
+        "rfcomm/rfc_l2cap_if.cc",
+        "rfcomm/rfc_mx_fsm.cc",
+        "rfcomm/rfc_port_fsm.cc",
+        "rfcomm/rfc_port_if.cc",
+        "rfcomm/rfc_ts_frames.cc",
+        "rfcomm/rfc_utils.cc",
+        "sdp/sdp_api.cc",
+        "sdp/sdp_db.cc",
+        "sdp/sdp_discovery.cc",
+        "sdp/sdp_main.cc",
+        "sdp/sdp_server.cc",
+        "sdp/sdp_utils.cc",
+        "smp/aes.cc",
+        "smp/p_256_curvepara.cc",
+        "smp/p_256_ecc_pp.cc",
+        "smp/p_256_multprecision.cc",
+        "smp/smp_act.cc",
+        "smp/smp_api.cc",
+        "smp/smp_br_main.cc",
+        "smp/smp_cmac.cc",
+        "smp/smp_keys.cc",
+        "smp/smp_l2c.cc",
+        "smp/smp_main.cc",
+        "smp/smp_utils.cc",
+        "srvc/srvc_battery.cc",
+        "srvc/srvc_dis.cc",
+        "srvc/srvc_eng.cc",
+    ],
+    static_libs: ["libbt-hci"],
+    shared_libs: [
+        "libcutils",
+        "liblog",
+    ],
+    required: [
+        "libldacBT_enc",
+    ]
+}
+
+// Bluetooth stack unit tests for target
+// ========================================================
+cc_test {
+    name: "net_test_stack",
+    defaults: ["fluoride_defaults"],
+    local_include_dirs: [
+        "include",
+    ],
+    include_dirs: [
+        "system/bt",
+        "system/bt/include",
+    ],
+    srcs: ["test/stack_a2dp_test.cc"],
+    shared_libs: [
+        "liblog",
+    ],
+    static_libs: [
+        "libbt-stack",
+        "libbt-sbc-encoder",
+        "libosi",
+    ],
+}
+
+// Bluetooth stack smp unit tests for target
+// ========================================================
+cc_test {
+    name: "net_test_stack_smp",
+    defaults: ["fluoride_defaults"],
+    local_include_dirs: [
+        "include",
+        "btm",
+        "l2cap",
+        "smp",
+    ],
+    include_dirs: [
+        "system/bt",
+        "system/bt/include",
+        "system/bt/btcore/include",
+        "system/bt/hci/include",
+        "system/bt/utils/include",
+    ],
+    srcs: [
+        "smp/smp_keys.cc",
+        "smp/aes.cc",
+        "smp/smp_api.cc",
+        "smp/smp_main.cc",
+        "smp/smp_utils.cc",
+        "test/stack_smp_test.cc",
+    ],
+    shared_libs: [
+        "libcutils",
+    ],
+    static_libs: [
+        "liblog",
+        "libgmock",
+        "libosi",
+    ],
+}
+
+
+// Bluetooth stack multi-advertising unit tests for target
+// ========================================================
+cc_test {
+    name: "net_test_stack_multi_adv",
+    defaults: ["fluoride_defaults"],
+    local_include_dirs: [
+        "include",
+        "btm",
+    ],
+    include_dirs: [
+        "system/bt",
+        "system/bt/include",
+        "system/bt/btcore/include",
+        "system/bt/hci/include",
+        "system/bt/include",
+        "system/bt/utils/include",
+    ],
+    srcs: [
+        "btm/btm_ble_multi_adv.cc",
+        "test/ble_advertiser_test.cc",
+    ],
+    shared_libs: [
+        "libcutils",
+    ],
+    static_libs: [
+        "liblog",
+        "libgmock",
+    ],
+}
diff --git a/stack/Android.mk b/stack/Android.mk
deleted file mode 100644
index 71bd5af..0000000
--- a/stack/Android.mk
+++ /dev/null
@@ -1,264 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-# Bluetooth stack static library for target
-# ========================================================
-include $(CLEAR_VARS)
-LOCAL_CPP_EXTENSION := .cc
-LOCAL_C_INCLUDES := \
-                   external/libldac/inc \
-                   $(LOCAL_PATH)/include \
-                   $(LOCAL_PATH)/avct \
-                   $(LOCAL_PATH)/btm \
-                   $(LOCAL_PATH)/avrc \
-                   $(LOCAL_PATH)/l2cap \
-                   $(LOCAL_PATH)/avdt \
-                   $(LOCAL_PATH)/gatt \
-                   $(LOCAL_PATH)/gap \
-                   $(LOCAL_PATH)/pan \
-                   $(LOCAL_PATH)/bnep \
-                   $(LOCAL_PATH)/hid \
-                   $(LOCAL_PATH)/sdp \
-                   $(LOCAL_PATH)/smp \
-                   $(LOCAL_PATH)/srvc \
-                   $(LOCAL_PATH)/../btcore/include \
-                   $(LOCAL_PATH)/../vnd/include \
-                   $(LOCAL_PATH)/../vnd/ble \
-                   $(LOCAL_PATH)/../btif/include \
-                   $(LOCAL_PATH)/../hci/include \
-                   $(LOCAL_PATH)/../include \
-                   $(LOCAL_PATH)/../udrv/include \
-                   $(LOCAL_PATH)/../bta/include \
-                   $(LOCAL_PATH)/../bta/sys \
-                   $(LOCAL_PATH)/../utils/include \
-                   $(LOCAL_PATH)/../ \
-                   $(bluetooth_C_INCLUDES)
-
-LOCAL_SRC_FILES := \
-    ./a2dp/a2dp_api.cc \
-    ./a2dp/a2dp_codec_config.cc \
-    ./a2dp/a2dp_sbc.cc \
-    ./a2dp/a2dp_sbc_encoder.cc \
-    ./a2dp/a2dp_sbc_up_sample.cc \
-    ./a2dp/a2dp_vendor.cc \
-    ./a2dp/a2dp_vendor_aptx.cc \
-    ./a2dp/a2dp_vendor_aptx_hd.cc \
-    ./a2dp/a2dp_vendor_aptx_encoder.cc \
-    ./a2dp/a2dp_vendor_aptx_hd_encoder.cc \
-    ./a2dp/a2dp_vendor_ldac.cc \
-    ./a2dp/a2dp_vendor_ldac_encoder.cc \
-    ./avct/avct_api.cc \
-    ./avct/avct_bcb_act.cc \
-    ./avct/avct_ccb.cc \
-    ./avct/avct_l2c.cc \
-    ./avct/avct_l2c_br.cc \
-    ./avct/avct_lcb.cc \
-    ./avct/avct_lcb_act.cc \
-    ./avdt/avdt_ad.cc \
-    ./avdt/avdt_api.cc \
-    ./avdt/avdt_ccb.cc \
-    ./avdt/avdt_ccb_act.cc \
-    ./avdt/avdt_l2c.cc \
-    ./avdt/avdt_msg.cc \
-    ./avdt/avdt_scb.cc \
-    ./avdt/avdt_scb_act.cc \
-    ./avrc/avrc_api.cc \
-    ./avrc/avrc_bld_ct.cc \
-    ./avrc/avrc_bld_tg.cc \
-    ./avrc/avrc_opt.cc \
-    ./avrc/avrc_pars_ct.cc \
-    ./avrc/avrc_pars_tg.cc \
-    ./avrc/avrc_sdp.cc \
-    ./avrc/avrc_utils.cc \
-    ./bnep/bnep_api.cc \
-    ./bnep/bnep_main.cc \
-    ./bnep/bnep_utils.cc \
-    ./btm/ble_advertiser_hci_interface.cc \
-    ./btm/btm_acl.cc \
-    ./btm/btm_ble.cc \
-    ./btm/btm_ble_addr.cc \
-    ./btm/btm_ble_adv_filter.cc \
-    ./btm/btm_ble_batchscan.cc \
-    ./btm/btm_ble_bgconn.cc \
-    ./btm/btm_ble_cont_energy.cc \
-    ./btm/btm_ble_gap.cc \
-    ./btm/btm_ble_multi_adv.cc \
-    ./btm/btm_ble_privacy.cc \
-    ./btm/btm_dev.cc \
-    ./btm/btm_devctl.cc \
-    ./btm/btm_inq.cc \
-    ./btm/btm_main.cc \
-    ./btm/btm_pm.cc \
-    ./btm/btm_sco.cc \
-    ./btm/btm_sec.cc \
-    ./btu/btu_hcif.cc \
-    ./btu/btu_init.cc \
-    ./btu/btu_task.cc \
-    ./gap/gap_api.cc \
-    ./gap/gap_ble.cc \
-    ./gap/gap_conn.cc \
-    ./gap/gap_utils.cc \
-    ./gatt/att_protocol.cc \
-    ./gatt/gatt_api.cc \
-    ./gatt/gatt_attr.cc \
-    ./gatt/gatt_auth.cc \
-    ./gatt/gatt_cl.cc \
-    ./gatt/gatt_db.cc \
-    ./gatt/gatt_main.cc \
-    ./gatt/gatt_sr.cc \
-    ./gatt/gatt_utils.cc \
-    ./hcic/hciblecmds.cc \
-    ./hcic/hcicmds.cc \
-    ./hid/hidh_api.cc \
-    ./hid/hidh_conn.cc \
-    ./hid/hidd_api.cc \
-    ./hid/hidd_conn.cc \
-    ./l2cap/l2c_api.cc \
-    ./l2cap/l2c_ble.cc \
-    ./l2cap/l2c_csm.cc \
-    ./l2cap/l2c_fcr.cc \
-    ./l2cap/l2c_link.cc \
-    ./l2cap/l2c_main.cc \
-    ./l2cap/l2c_ucd.cc \
-    ./l2cap/l2c_utils.cc \
-    ./l2cap/l2cap_client.cc \
-    ./mcap/mca_api.cc \
-    ./mcap/mca_cact.cc \
-    ./mcap/mca_csm.cc \
-    ./mcap/mca_dact.cc \
-    ./mcap/mca_dsm.cc \
-    ./mcap/mca_l2c.cc \
-    ./mcap/mca_main.cc \
-    ./pan/pan_api.cc \
-    ./pan/pan_main.cc \
-    ./pan/pan_utils.cc \
-    ./rfcomm/port_api.cc \
-    ./rfcomm/port_rfc.cc \
-    ./rfcomm/port_utils.cc \
-    ./rfcomm/rfc_l2cap_if.cc \
-    ./rfcomm/rfc_mx_fsm.cc \
-    ./rfcomm/rfc_port_fsm.cc \
-    ./rfcomm/rfc_port_if.cc \
-    ./rfcomm/rfc_ts_frames.cc \
-    ./rfcomm/rfc_utils.cc \
-    ./sdp/sdp_api.cc \
-    ./sdp/sdp_db.cc \
-    ./sdp/sdp_discovery.cc \
-    ./sdp/sdp_main.cc \
-    ./sdp/sdp_server.cc \
-    ./sdp/sdp_utils.cc \
-    ./smp/aes.cc \
-    ./smp/p_256_curvepara.cc \
-    ./smp/p_256_ecc_pp.cc \
-    ./smp/p_256_multprecision.cc \
-    ./smp/smp_act.cc \
-    ./smp/smp_api.cc \
-    ./smp/smp_br_main.cc \
-    ./smp/smp_cmac.cc \
-    ./smp/smp_keys.cc \
-    ./smp/smp_l2c.cc \
-    ./smp/smp_main.cc \
-    ./smp/smp_utils.cc \
-    ./srvc/srvc_battery.cc \
-    ./srvc/srvc_dis.cc \
-    ./srvc/srvc_eng.cc
-
-LOCAL_MODULE := libbt-stack
-LOCAL_STATIC_LIBRARIES := libbt-hci
-LOCAL_SHARED_LIBRARIES := libcutils liblog libchrome
-LOCAL_REQUIRED_MODULES := libldacBT_enc
-
-LOCAL_CFLAGS += $(bluetooth_CFLAGS)
-LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
-LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
-
-include $(BUILD_STATIC_LIBRARY)
-
-# Bluetooth stack unit tests for target
-# ========================================================
-include $(CLEAR_VARS)
-
-LOCAL_CPP_EXTENSION := .cc
-
-LOCAL_C_INCLUDES := \
-                   $(LOCAL_PATH)/include \
-                   $(LOCAL_PATH)/../include \
-                   $(LOCAL_PATH)/../ \
-                   $(bluetooth_C_INCLUDES)
-
-LOCAL_SRC_FILES := test/stack_a2dp_test.cc
-LOCAL_SHARED_LIBRARIES := libc liblog libchrome
-LOCAL_STATIC_LIBRARIES := libbt-stack libbt-sbc-encoder libosi
-LOCAL_MODULE_TAGS := tests
-LOCAL_MODULE := net_test_stack
-
-LOCAL_CFLAGS += $(bluetooth_CFLAGS)
-LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
-LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
-
-include $(BUILD_NATIVE_TEST)
-
-# Bluetooth smp unit tests for target
-# ========================================================
-include $(CLEAR_VARS)
-
-LOCAL_CPP_EXTENSION := .cc
-
-LOCAL_C_INCLUDES := \
-                   $(LOCAL_PATH)/include \
-                   $(LOCAL_PATH)/btm \
-                   $(LOCAL_PATH)/l2cap \
-                   $(LOCAL_PATH)/smp \
-                   $(LOCAL_PATH)/../btcore/include \
-                   $(LOCAL_PATH)/../hci/include \
-                   $(LOCAL_PATH)/../include \
-                   $(LOCAL_PATH)/../utils/include \
-                   $(LOCAL_PATH)/../ \
-                   $(bluetooth_C_INCLUDES)
-
-LOCAL_SRC_FILES := smp/smp_keys.cc \
-                    smp/aes.cc \
-                    smp/smp_api.cc \
-                    smp/smp_main.cc \
-                    smp/smp_utils.cc \
-                    test/stack_smp_test.cc
-LOCAL_SHARED_LIBRARIES := libcutils libchrome
-LOCAL_STATIC_LIBRARIES := liblog libgtest libgmock libosi
-LOCAL_MODULE_TAGS := tests
-LOCAL_MODULE := net_test_stack_smp
-
-LOCAL_CFLAGS += $(bluetooth_CFLAGS)
-LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
-LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
-
-include $(BUILD_NATIVE_TEST)
-
-# Bluetooth stack multi-advertising unit tests for target
-# ========================================================
-include $(CLEAR_VARS)
-
-LOCAL_CPP_EXTENSION := .cc
-
-LOCAL_C_INCLUDES := \
-                   $(LOCAL_PATH)/include \
-                   $(LOCAL_PATH)/../include \
-                   $(LOCAL_PATH)/../ \
-                   $(LOCAL_PATH)/btm \
-                   $(LOCAL_PATH)/../btcore/include \
-                   $(LOCAL_PATH)/../hci/include \
-                   $(LOCAL_PATH)/../include \
-                   $(LOCAL_PATH)/../utils/include \
-                   $(LOCAL_PATH)/../ \
-                   $(bluetooth_C_INCLUDES)
-
-LOCAL_SRC_FILES := btm/btm_ble_multi_adv.cc \
-                   test/ble_advertiser_test.cc
-LOCAL_SHARED_LIBRARIES := libcutils libchrome
-LOCAL_STATIC_LIBRARIES := liblog libgmock libgtest
-LOCAL_MODULE_TAGS := tests
-LOCAL_MODULE := net_test_stack_multi_adv
-
-LOCAL_CFLAGS += $(bluetooth_CFLAGS)
-LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
-LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
-
-include $(BUILD_NATIVE_TEST)
diff --git a/test/Android.bp b/test/Android.bp
new file mode 100644
index 0000000..c873d78
--- /dev/null
+++ b/test/Android.bp
@@ -0,0 +1,3 @@
+subdirs = [
+    "suite",
+]
diff --git a/test/Android.mk b/test/Android.mk
deleted file mode 100644
index 5053e7d..0000000
--- a/test/Android.mk
+++ /dev/null
@@ -1 +0,0 @@
-include $(call all-subdir-makefiles)
diff --git a/test/suite/Android.bp b/test/suite/Android.bp
new file mode 100644
index 0000000..a576901
--- /dev/null
+++ b/test/suite/Android.bp
@@ -0,0 +1,50 @@
+// Bluetooth test suite for target
+// ========================================================
+cc_test {
+    name: "net_test_bluetooth",
+    defaults: ["fluoride_defaults"],
+    include_dirs: ["system/bt"],
+    srcs: [
+        "adapter/adapter_unittest.cc",
+        "adapter/bluetooth_test.cc",
+        "gatt/gatt_test.cc",
+        "gatt/gatt_unittest.cc",
+    ],
+    shared_libs: [
+        "liblog",
+        "libhardware",
+        "libcutils",
+    ],
+    static_libs: [
+        "libbtcore",
+        "libosi",
+    ],
+    whole_static_libs: [
+        "libbluetoothtbd_hal",
+    ],
+}
+
+// Bluetooth test suite for target
+// ========================================================
+cc_test {
+    name: "net_test_rfcomm",
+    defaults: ["fluoride_defaults"],
+    include_dirs: ["system/bt"],
+    srcs: [
+        "adapter/bluetooth_test.cc",
+        "rfcomm/rfcomm_test.cc",
+        "rfcomm/rfcomm_unittest.cc",
+    ],
+    shared_libs: [
+        "liblog",
+        "libhardware",
+        "libcutils",
+    ],
+    static_libs: [
+        "libbtcore",
+        "libosi",
+    ],
+    whole_static_libs: [
+        "libbluetoothtbd_hal",
+    ],
+}
diff --git a/test/suite/Android.mk b/test/suite/Android.mk
deleted file mode 100644
index bfd30c6..0000000
--- a/test/suite/Android.mk
+++ /dev/null
@@ -1,93 +0,0 @@
-#
-#  Copyright (C) 2015 Google, Inc.
-#
-#  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)
-
-# These tests use the bluetoothtbd HAL wrappers in order to easily interact
-# with the interface using C++
-# TODO: Make the bluetoothtbd HAL a static library
-bluetoothHalSrc := \
-    ../../service/hal/bluetooth_gatt_interface.cc \
-    ../../service/hal/bluetooth_interface.cc \
-    ../../service/logging_helpers.cc
-
-# Bluetooth test suite for target
-# ========================================================
-include $(CLEAR_VARS)
-LOCAL_CPP_EXTENSION := .cc
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE := net_test_bluetooth
-
-LOCAL_C_INCLUDES := \
-    $(LOCAL_PATH)/../../
-
-LOCAL_SRC_FILES := \
-    adapter/adapter_unittest.cc \
-    adapter/bluetooth_test.cc \
-    gatt/gatt_test.cc \
-    gatt/gatt_unittest.cc \
-    $(bluetoothHalSrc)
-
-LOCAL_SHARED_LIBRARIES := \
-    liblog \
-    libhardware \
-    libhardware_legacy \
-    libcutils \
-    libchrome
-
-LOCAL_STATIC_LIBRARIES := \
-    libbtcore \
-    libosi
-
-LOCAL_CFLAGS += $(bluetooth_CFLAGS)
-LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
-LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
-
-include $(BUILD_NATIVE_TEST)
-
-# Bluetooth test suite for target
-# ========================================================
-include $(CLEAR_VARS)
-LOCAL_CPP_EXTENSION := .cc
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE := net_test_rfcomm
-
-LOCAL_C_INCLUDES := \
-    $(LOCAL_PATH)/../../ \
-    $(bluetooth_C_INCLUDES) \
-
-LOCAL_SRC_FILES := \
-    adapter/bluetooth_test.cc \
-    rfcomm/rfcomm_test.cc \
-    rfcomm/rfcomm_unittest.cc \
-    $(bluetoothHalSrc)
-
-LOCAL_SHARED_LIBRARIES := \
-    liblog \
-    libhardware \
-    libhardware_legacy \
-    libcutils \
-    libchrome \
-
-LOCAL_STATIC_LIBRARIES := \
-    libbtcore \
-    libosi \
-
-LOCAL_CFLAGS += $(bluetooth_CFLAGS)
-LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
-LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
-
-include $(BUILD_NATIVE_TEST)
diff --git a/udrv/Android.bp b/udrv/Android.bp
new file mode 100644
index 0000000..b1530f7
--- /dev/null
+++ b/udrv/Android.bp
@@ -0,0 +1,20 @@
+cc_library_static {
+    name: "libudrv-uipc",
+    defaults: ["fluoride_defaults"],
+    srcs: [
+        "ulinux/uipc.cc",
+    ],
+    include_dirs: [
+      "system/bt",
+      "system/bt/include",
+      "system/bt/audio_a2dp_hw",
+      "system/bt/utils/include",
+      "system/bt/stack/include",
+    ],
+    local_include_dirs: [
+      "include",
+    ],
+    shared_libs: [
+      "liblog",
+    ],
+}
diff --git a/utils/Android.bp b/utils/Android.bp
new file mode 100644
index 0000000..6a6c510
--- /dev/null
+++ b/utils/Android.bp
@@ -0,0 +1,15 @@
+// Utils static library for target
+// ========================================================
+cc_library_static {
+    name: "libbt-utils",
+    defaults: ["fluoride_defaults"],
+    local_include_dirs: [
+        "include",
+    ],
+    include_dirs: [
+        "system/bt",
+        "system/bt/btcore/include",
+        "system/bt/stack/include",
+    ],
+    srcs: ["src/bt_utils.cc"],
+}
diff --git a/utils/Android.mk b/utils/Android.mk
deleted file mode 100644
index 5ba3e88..0000000
--- a/utils/Android.mk
+++ /dev/null
@@ -1,27 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-# Utils static library for target
-# ========================================================
-include $(CLEAR_VARS)
-
-LOCAL_CPP_EXTENSION := .cc
-
-LOCAL_C_INCLUDES := \
-    $(LOCAL_PATH)/include \
-    $(LOCAL_PATH)/../btcore/include \
-    $(LOCAL_PATH)/../stack/include \
-    $(LOCAL_PATH)/../ \
-    $(bluetooth_C_INCLUDES)
-
-LOCAL_SRC_FILES := \
-    ./src/bt_utils.cc
-
-LOCAL_MODULE := libbt-utils
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE_CLASS := STATIC_LIBRARIES
-
-LOCAL_CFLAGS += $(bluetooth_CFLAGS)
-LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
-LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
-
-include $(BUILD_STATIC_LIBRARY)
diff --git a/vendor_libs/Android.bp b/vendor_libs/Android.bp
new file mode 100644
index 0000000..07dde0f
--- /dev/null
+++ b/vendor_libs/Android.bp
@@ -0,0 +1,3 @@
+subdirs = [
+    "test_vendor_lib",
+]
diff --git a/vendor_libs/Android.mk b/vendor_libs/Android.mk
index 5053e7d..31d6e6b 100644
--- a/vendor_libs/Android.mk
+++ b/vendor_libs/Android.mk
@@ -1 +1,28 @@
+# Common C/C++ compiler flags for test-vendor lib
+#
+# -Wno-gnu-variable-sized-type-not-at-end is needed, because struct BT_HDR
+#  is defined as a variable-size header in a struct.
+# -Wno-typedef-redefinition is needed because of the way the struct typedef
+#  is done in osi/include header files. This issue can be obsoleted by
+#  switching to C11 or C++.
+# -Wno-unused-parameter is needed, because there are too many unused
+#  parameters in all the code.
+#
+test-vendor_CFLAGS += \
+  -fvisibility=hidden \
+  -Wall \
+  -Wextra \
+  -Werror \
+  -Wno-gnu-variable-sized-type-not-at-end \
+  -Wno-typedef-redefinition \
+  -Wno-unused-parameter \
+  -DLOG_NDEBUG=1 \
+  -DEXPORT_SYMBOL="__attribute__((visibility(\"default\")))"
+
+test-vendor_CONLYFLAGS += -std=c99
+
 include $(call all-subdir-makefiles)
+
+# Cleanup our locals
+test-vendor_CFLAGS :=
+test-vendor_CONLYFLAGS :=
diff --git a/vendor_libs/linux/Android.mk b/vendor_libs/linux/Android.mk
index 3cdaabc..818060f 100644
--- a/vendor_libs/linux/Android.mk
+++ b/vendor_libs/linux/Android.mk
@@ -38,9 +38,8 @@
 LOCAL_MODULE := libbt-vendor
 LOCAL_MODULE_TAGS := optional
 
-LOCAL_CFLAGS += $(bluetooth_CFLAGS)
-LOCAL_CONLYFLAGS += $(bluetooth_CONLYFLAGS)
-LOCAL_CPPFLAGS += $(bluetooth_CPPFLAGS)
+LOCAL_CFLAGS += $(test-vendor_CFLAGS)
+LOCAL_CONLYFLAGS += $(test-vendor_CONLYFLAGS)
 
 include $(BUILD_SHARED_LIBRARY)
 
diff --git a/vendor_libs/test_vendor_lib/Android.bp b/vendor_libs/test_vendor_lib/Android.bp
new file mode 100644
index 0000000..10f0a64
--- /dev/null
+++ b/vendor_libs/test_vendor_lib/Android.bp
@@ -0,0 +1,43 @@
+// test-vendor unit tests for host
+// ========================================================
+cc_test_host {
+    name: "test-vendor_test_host",
+    srcs: [
+        "src/async_manager.cc",
+        "src/bt_address.cc",
+        "src/command_packet.cc",
+        "src/event_packet.cc",
+        "src/hci_transport.cc",
+        "src/packet.cc",
+        "src/packet_stream.cc",
+        "test/async_manager_unittest.cc",
+        "test/bt_address_unittest.cc",
+        "test/hci_transport_unittest.cc",
+        "test/packet_stream_unittest.cc",
+    ],
+    local_include_dirs: [
+        "include",
+    ],
+    include_dirs: [
+        "system/bt",
+        "system/bt/utils/include",
+        "system/bt/hci/include",
+        "system/bt/stack/include",
+    ],
+    shared_libs: [
+        "liblog",
+        "libchrome",
+    ],
+    cflags: [
+        "-fvisibility=hidden",
+        "-Wall",
+        "-Wextra",
+        "-Werror",
+        "-DLOG_NDEBUG=1",
+    ],
+    target: {
+        darwin: {
+            enabled: false,
+        }
+    },
+}
diff --git a/vendor_libs/test_vendor_lib/Android.mk b/vendor_libs/test_vendor_lib/Android.mk
index 8ea93e9..8b7b812 100644
--- a/vendor_libs/test_vendor_lib/Android.mk
+++ b/vendor_libs/test_vendor_lib/Android.mk
@@ -55,58 +55,6 @@
 LOCAL_MODULE_TAGS := optional
 LOCAL_MODULE_CLASS := SHARED_LIBRARIES
 
-LOCAL_CFLAGS += \
-  -fvisibility=hidden \
-  -Wall \
-  -Wextra \
-  -Werror \
-  -UNDEBUG \
-  -DLOG_NDEBUG=1
-
-LOCAL_CFLAGS += -DEXPORT_SYMBOL="__attribute__((visibility(\"default\")))"
+LOCAL_CFLAGS += $(test-vendor_CFLAGS)
 
 include $(BUILD_SHARED_LIBRARY)
-
-# test-vendor unit tests for host
-# ========================================================
-ifeq ($(HOST_OS), linux)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
-    src/async_manager.cc \
-    src/bt_address.cc \
-    src/command_packet.cc \
-    src/event_packet.cc \
-    src/hci_transport.cc \
-    src/packet.cc \
-    src/packet_stream.cc \
-    test/async_manager_unittest.cc \
-    test/bt_address_unittest.cc \
-    test/hci_transport_unittest.cc \
-    test/packet_stream_unittest.cc
-
-LOCAL_C_INCLUDES := \
-    $(LOCAL_PATH)/include \
-    $(BT_DIR) \
-    $(BT_DIR)/utils/include \
-    $(BT_DIR)/hci/include \
-    $(BT_DIR)/stack/include
-
-LOCAL_SHARED_LIBRARIES := \
-    liblog \
-    libchrome
-
-LOCAL_CPP_EXTENSION := .cc
-LOCAL_MODULE := test-vendor_test_host
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_CFLAGS += \
-  -fvisibility=hidden \
-  -Wall \
-  -Wextra \
-  -Werror \
-  -UNDEBUG \
-  -DLOG_NDEBUG=1
-
-include $(BUILD_HOST_NATIVE_TEST)
-endif