axolotl: gps: Android mk to bp conversion

Change-Id: I206b4a5a2b7e88a6a20522611e7b2684594ef6f4
CRs-Fixed: 2559087
diff --git a/gps/Android.bp b/gps/Android.bp
new file mode 100644
index 0000000..395136c
--- /dev/null
+++ b/gps/Android.bp
@@ -0,0 +1,4 @@
+GNSS_CFLAGS = [
+    "-Werror",
+    "-Wno-undefined-bool-conversion",
+]
diff --git a/gps/Android.mk b/gps/Android.mk
index f1088a4..10a3610 100644
--- a/gps/Android.mk
+++ b/gps/Android.mk
@@ -1,5 +1,26 @@
 ifneq ($(BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE),)
-LOCAL_PATH := $(call my-dir)
-include $(LOCAL_PATH)/build/target_specific_features.mk
-include $(call all-makefiles-under,$(LOCAL_PATH))
+
+# Set required flags
+GNSS_CFLAGS := \
+    -Werror \
+    -Wno-undefined-bool-conversion
+
+GNSS_HIDL_VERSION = 2.0
+
+GNSS_HIDL_LEGACY_MEASURMENTS_TARGET_LIST += msm8937
+GNSS_HIDL_LEGACY_MEASURMENTS_TARGET_LIST += msm8953
+GNSS_HIDL_LEGACY_MEASURMENTS_TARGET_LIST += msm8998
+GNSS_HIDL_LEGACY_MEASURMENTS_TARGET_LIST += apq8098_latv
+GNSS_HIDL_LEGACY_MEASURMENTS_TARGET_LIST += sdm710
+GNSS_HIDL_LEGACY_MEASURMENTS_TARGET_LIST += qcs605
+GNSS_HIDL_LEGACY_MEASURMENTS_TARGET_LIST += sdm845
+GNSS_HIDL_LEGACY_MEASURMENTS_TARGET_LIST += sdm660
+
+ifneq (,$(filter $(GNSS_HIDL_LEGACY_MEASURMENTS_TARGET_LIST),$(TARGET_BOARD_PLATFORM)))
+GNSS_HIDL_LEGACY_MEASURMENTS = true
 endif
+
+LOCAL_PATH := $(call my-dir)
+include $(call all-makefiles-under,$(LOCAL_PATH))
+
+endif # ifneq ($(BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE),)
diff --git a/gps/android/Android.mk b/gps/android/Android.mk
index 3b5c01f..e220773 100644
--- a/gps/android/Android.mk
+++ b/gps/android/Android.mk
@@ -2,7 +2,6 @@
 ifneq ($(BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE),)
 include $(CLEAR_VARS)
 DIR_LIST := $(LOCAL_PATH)
-include $(DIR_LIST)/utils/Android.mk
 ifeq ($(GNSS_HIDL_VERSION),2.0)
 include $(DIR_LIST)/2.0/Android.mk
 else
diff --git a/gps/android/utils/Android.bp b/gps/android/utils/Android.bp
new file mode 100644
index 0000000..80efb91
--- /dev/null
+++ b/gps/android/utils/Android.bp
@@ -0,0 +1,36 @@
+cc_library_static {
+
+    name: "liblocbatterylistener",
+    vendor: true,
+
+
+
+    cflags: GNSS_CFLAGS + ["-DBATTERY_LISTENER_ENABLED"],
+    local_include_dirs: ["."],
+
+    srcs: ["battery_listener.cpp"],
+
+    shared_libs: [
+        "liblog",
+        "libhidlbase",
+        "libcutils",
+        "libutils",
+        "android.hardware.health@1.0",
+        "android.hardware.health@2.0",
+        "android.hardware.power@1.2",
+        "libbase",
+    ],
+
+    static_libs: ["libhealthhalutils"],
+
+    header_libs: [
+        "libgps.utils_headers",
+        "libloc_pla_headers",
+    ],
+}
+
+cc_library_headers {
+
+    name: "liblocbatterylistener_headers",
+    export_include_dirs: ["."],
+}
diff --git a/gps/android/utils/Android.mk b/gps/android/utils/Android.mk
deleted file mode 100644
index 9cb6f7b..0000000
--- a/gps/android/utils/Android.mk
+++ /dev/null
@@ -1,41 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := liblocbatterylistener
-LOCAL_SANITIZE += $(GNSS_SANITIZE)
-# activate the following line for debug purposes only, comment out for production
-#LOCAL_SANITIZE_DIAG += $(GNSS_SANITIZE_DIAG)
-LOCAL_VENDOR_MODULE := true
-
-LOCAL_CFLAGS += $(GNSS_CFLAGS)
-
-LOCAL_C_INCLUDES += \
-    $(LOCAL_PATH) \
-
-LOCAL_SRC_FILES:= \
-    battery_listener.cpp
-LOCAL_SHARED_LIBRARIES := \
-    liblog \
-    libhidlbase \
-    libcutils \
-    libutils \
-    android.hardware.health@1.0 \
-    android.hardware.health@2.0 \
-    android.hardware.power@1.2 \
-    libbase
-
-LOCAL_HEADER_LIBRARIES := \
-    libgps.utils_headers \
-
-LOCAL_STATIC_LIBRARIES := libhealthhalutils
-LOCAL_CFLAGS += -DBATTERY_LISTENER_ENABLED
-
-include $(BUILD_STATIC_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := liblocbatterylistener_headers
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
-
-include $(BUILD_HEADER_LIBRARY)
-
-
diff --git a/gps/batching/Android.bp b/gps/batching/Android.bp
new file mode 100644
index 0000000..ce794d1
--- /dev/null
+++ b/gps/batching/Android.bp
@@ -0,0 +1,31 @@
+
+cc_library_shared {
+
+    name: "libbatching",
+    vendor: true,
+
+
+
+    shared_libs: [
+        "libutils",
+        "libcutils",
+        "liblog",
+        "libloc_core",
+        "libgps.utils",
+        "libdl",
+    ],
+
+    srcs: [
+        "location_batching.cpp",
+        "BatchingAdapter.cpp",
+    ],
+
+    header_libs: [
+        "libgps.utils_headers",
+        "libloc_core_headers",
+        "libloc_pla_headers",
+        "liblocation_api_headers",
+    ],
+
+    cflags: GNSS_CFLAGS,
+}
diff --git a/gps/batching/Android.mk b/gps/batching/Android.mk
deleted file mode 100644
index f3e8fe4..0000000
--- a/gps/batching/Android.mk
+++ /dev/null
@@ -1,39 +0,0 @@
-ifneq ($(BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE),)
-ifneq ($(BUILD_TINY_ANDROID),true)
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := libbatching
-LOCAL_SANITIZE += $(GNSS_SANITIZE)
-# activate the following line for debug purposes only, comment out for production
-#LOCAL_SANITIZE_DIAG += $(GNSS_SANITIZE_DIAG)
-LOCAL_VENDOR_MODULE := true
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SHARED_LIBRARIES := \
-    libutils \
-    libcutils \
-    liblog \
-    libloc_core \
-    libgps.utils \
-    libdl
-
-LOCAL_SRC_FILES += \
-    location_batching.cpp \
-    BatchingAdapter.cpp
-
-LOCAL_HEADER_LIBRARIES := \
-    libgps.utils_headers \
-    libloc_core_headers \
-    libloc_pla_headers \
-    liblocation_api_headers
-
-LOCAL_PRELINK_MODULE := false
-
-LOCAL_CFLAGS += $(GNSS_CFLAGS)
-include $(BUILD_SHARED_LIBRARY)
-
-endif # not BUILD_TINY_ANDROID
-endif # BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE
diff --git a/gps/build/target_specific_features.mk b/gps/build/target_specific_features.mk
deleted file mode 100644
index c2ad0f2..0000000
--- a/gps/build/target_specific_features.mk
+++ /dev/null
@@ -1,59 +0,0 @@
-GNSS_CFLAGS := \
-    -Werror \
-    -Wno-undefined-bool-conversion
-
-# GPS-HIDL
-GNSS_HIDL_1_0_TARGET_LIST := msm8960
-GNSS_HIDL_1_0_TARGET_LIST += msm8974
-GNSS_HIDL_1_0_TARGET_LIST += msm8226
-GNSS_HIDL_1_0_TARGET_LIST += msm8610
-GNSS_HIDL_1_0_TARGET_LIST += apq8084
-GNSS_HIDL_1_0_TARGET_LIST += msm8916
-GNSS_HIDL_1_0_TARGET_LIST += msm8994
-GNSS_HIDL_2_0_TARGET_LIST := msm8909
-GNSS_HIDL_1_0_TARGET_LIST += msm8952
-GNSS_HIDL_1_0_TARGET_LIST += msm8992
-GNSS_HIDL_1_0_TARGET_LIST += msm8996
-GNSS_HIDL_2_0_TARGET_LIST += msm8937
-GNSS_HIDL_2_0_TARGET_LIST += msm8953
-GNSS_HIDL_2_0_TARGET_LIST += msm8998
-GNSS_HIDL_2_0_TARGET_LIST += apq8098_latv
-GNSS_HIDL_2_0_TARGET_LIST += sdm710
-GNSS_HIDL_2_0_TARGET_LIST += qcs605
-GNSS_HIDL_2_0_TARGET_LIST += sdm845
-GNSS_HIDL_2_0_TARGET_LIST += sdm660
-GNSS_HIDL_2_0_TARGET_LIST += msmnile
-GNSS_HIDL_2_0_TARGET_LIST += sdmshrike
-GNSS_HIDL_2_0_TARGET_LIST += $(MSMSTEPPE)
-GNSS_HIDL_2_0_TARGET_LIST += $(TRINKET)
-GNSS_HIDL_2_0_TARGET_LIST += kona
-GNSS_HIDL_2_0_TARGET_LIST += atoll
-GNSS_HIDL_2_0_TARGET_LIST += lito
-GNSS_HIDL_2_0_TARGET_LIST += bengal
-
-ifneq (,$(filter $(GNSS_HIDL_2_0_TARGET_LIST),$(TARGET_BOARD_PLATFORM)))
-GNSS_HIDL_VERSION = 2.0
-endif
-ifneq (,$(filter $(GNSS_HIDL_1_0_TARGET_LIST),$(TARGET_BOARD_PLATFORM)))
-GNSS_HIDL_VERSION = 1.0
-endif
-ifneq (,$(filter $(GNSS_HIDL_1_1_TARGET_LIST),$(TARGET_BOARD_PLATFORM)))
-GNSS_HIDL_VERSION = 1.1
-endif
-
-GNSS_HIDL_LEGACY_MEASURMENTS_TARGET_LIST := msm8937
-GNSS_HIDL_LEGACY_MEASURMENTS_TARGET_LIST += msm8953
-GNSS_HIDL_LEGACY_MEASURMENTS_TARGET_LIST += msm8998
-GNSS_HIDL_LEGACY_MEASURMENTS_TARGET_LIST += apq8098_latv
-GNSS_HIDL_LEGACY_MEASURMENTS_TARGET_LIST += sdm710
-GNSS_HIDL_LEGACY_MEASURMENTS_TARGET_LIST += qcs605
-GNSS_HIDL_LEGACY_MEASURMENTS_TARGET_LIST += sdm845
-GNSS_HIDL_LEGACY_MEASURMENTS_TARGET_LIST += sdm660
-
-ifneq (,$(filter $(GNSS_HIDL_LEGACY_MEASURMENTS_TARGET_LIST),$(TARGET_BOARD_PLATFORM)))
-GNSS_HIDL_LEGACY_MEASURMENTS = true
-endif
-
-# Activate the following two lines for regression testing
-#GNSS_SANITIZE := address cfi alignment bounds null unreachable integer
-#GNSS_SANITIZE_DIAG := address cfi alignment bounds null unreachable integer
diff --git a/gps/core/Android.bp b/gps/core/Android.bp
new file mode 100644
index 0000000..fe9f067
--- /dev/null
+++ b/gps/core/Android.bp
@@ -0,0 +1,56 @@
+
+cc_library_shared {
+
+    name: "libloc_core",
+    vendor: true,
+
+
+
+    shared_libs: [
+        "liblog",
+        "libutils",
+        "libcutils",
+        "libgps.utils",
+        "libdl",
+        "liblog",
+    ],
+
+    srcs: [
+        "LocApiBase.cpp",
+        "LocAdapterBase.cpp",
+        "ContextBase.cpp",
+        "LocContext.cpp",
+        "loc_core_log.cpp",
+        "data-items/DataItemsFactoryProxy.cpp",
+        "SystemStatusOsObserver.cpp",
+        "SystemStatus.cpp",
+    ],
+
+    cflags: [
+        "-fno-short-enums",
+        "-D_ANDROID_",
+    ] + GNSS_CFLAGS,
+
+    local_include_dirs: [
+        "data-items",
+        "observer",
+    ],
+
+    header_libs: [
+        "libutils_headers",
+        "libgps.utils_headers",
+        "libloc_pla_headers",
+        "liblocation_api_headers",
+    ],
+
+}
+
+cc_library_headers {
+
+    name: "libloc_core_headers",
+    vendor: true,
+    export_include_dirs: ["."] + [
+        "data-items",
+        "observer",
+    ],
+}
diff --git a/gps/core/Android.mk b/gps/core/Android.mk
deleted file mode 100644
index ce5d6a8..0000000
--- a/gps/core/Android.mk
+++ /dev/null
@@ -1,62 +0,0 @@
-ifneq ($(BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE),)
-ifneq ($(BUILD_TINY_ANDROID),true)
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := libloc_core
-LOCAL_SANITIZE += $(GNSS_SANITIZE)
-# activate the following line for debug purposes only, comment out for production
-#LOCAL_SANITIZE_DIAG += $(GNSS_SANITIZE_DIAG)
-LOCAL_VENDOR_MODULE := true
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SHARED_LIBRARIES := \
-    liblog \
-    libutils \
-    libcutils \
-    libgps.utils \
-    libdl \
-    liblog
-
-LOCAL_SRC_FILES += \
-    LocApiBase.cpp \
-    LocAdapterBase.cpp \
-    ContextBase.cpp \
-    LocContext.cpp \
-    loc_core_log.cpp \
-    data-items/DataItemsFactoryProxy.cpp \
-    SystemStatusOsObserver.cpp \
-    SystemStatus.cpp
-
-LOCAL_CFLAGS += \
-     -fno-short-enums \
-     -D_ANDROID_
-
-LOCAL_C_INCLUDES:= \
-    $(LOCAL_PATH)/data-items \
-    $(LOCAL_PATH)/data-items/common \
-    $(LOCAL_PATH)/observer \
-
-LOCAL_HEADER_LIBRARIES := \
-    libutils_headers \
-    libgps.utils_headers \
-    libloc_pla_headers \
-    liblocation_api_headers
-
-LOCAL_CFLAGS += $(GNSS_CFLAGS)
-
-include $(BUILD_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := libloc_core_headers
-LOCAL_EXPORT_C_INCLUDE_DIRS := \
-    $(LOCAL_PATH) \
-    $(LOCAL_PATH)/data-items \
-    $(LOCAL_PATH)/data-items/common \
-    $(LOCAL_PATH)/observer
-include $(BUILD_HEADER_LIBRARY)
-
-endif # not BUILD_TINY_ANDROID
-endif # BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE
diff --git a/gps/geofence/Android.bp b/gps/geofence/Android.bp
new file mode 100644
index 0000000..bf8474f
--- /dev/null
+++ b/gps/geofence/Android.bp
@@ -0,0 +1,31 @@
+
+
+cc_library_shared {
+
+    name: "libgeofencing",
+    vendor: true,
+
+
+
+    srcs: [
+        "GeofenceAdapter.cpp",
+        "location_geofence.cpp",
+    ],
+
+    shared_libs: [
+        "libutils",
+        "libcutils",
+        "libgps.utils",
+        "liblog",
+        "libloc_core",
+    ],
+
+    header_libs: [
+        "libgps.utils_headers",
+        "libloc_core_headers",
+        "libloc_pla_headers",
+        "liblocation_api_headers",
+    ],
+
+    cflags: GNSS_CFLAGS,
+}
diff --git a/gps/geofence/Android.mk b/gps/geofence/Android.mk
deleted file mode 100644
index 133d408..0000000
--- a/gps/geofence/Android.mk
+++ /dev/null
@@ -1,38 +0,0 @@
-ifneq ($(BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE),)
-ifneq ($(BUILD_TINY_ANDROID),true)
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := libgeofencing
-LOCAL_SANITIZE += $(GNSS_SANITIZE)
-# activate the following line for debug purposes only, comment out for production
-#LOCAL_SANITIZE_DIAG += $(GNSS_SANITIZE_DIAG)
-LOCAL_VENDOR_MODULE := true
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SRC_FILES:= \
-    GeofenceAdapter.cpp \
-    location_geofence.cpp
-
-LOCAL_SHARED_LIBRARIES := \
-        libutils \
-        libcutils \
-        libgps.utils \
-        liblog \
-        libloc_core
-
-LOCAL_HEADER_LIBRARIES := \
-    libgps.utils_headers \
-    libloc_core_headers \
-    libloc_pla_headers \
-    liblocation_api_headers
-
-LOCAL_PRELINK_MODULE := false
-LOCAL_CFLAGS += $(GNSS_CFLAGS)
-include $(BUILD_SHARED_LIBRARY)
-
-endif # not BUILD_TINY_ANDROID
-endif # BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE
-
diff --git a/gps/gnss/Android.bp b/gps/gnss/Android.bp
new file mode 100644
index 0000000..c11864d
--- /dev/null
+++ b/gps/gnss/Android.bp
@@ -0,0 +1,34 @@
+
+
+cc_library_shared {
+
+    name: "libgnss",
+    vendor: true,
+
+
+
+    shared_libs: [
+        "libutils",
+        "libcutils",
+        "libdl",
+        "liblog",
+        "libloc_core",
+        "libgps.utils",
+    ],
+
+    srcs: [
+        "location_gnss.cpp",
+        "GnssAdapter.cpp",
+        "Agps.cpp",
+        "XtraSystemStatusObserver.cpp",
+    ],
+
+    cflags: ["-fno-short-enums"] + GNSS_CFLAGS,
+    header_libs: [
+        "libgps.utils_headers",
+        "libloc_core_headers",
+        "libloc_pla_headers",
+        "liblocation_api_headers",
+    ],
+
+}
diff --git a/gps/gnss/Android.mk b/gps/gnss/Android.mk
deleted file mode 100644
index c1b5944..0000000
--- a/gps/gnss/Android.mk
+++ /dev/null
@@ -1,49 +0,0 @@
-ifneq ($(BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE),)
-ifneq ($(BUILD_TINY_ANDROID),true)
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := libgnss
-LOCAL_SANITIZE += $(GNSS_SANITIZE)
-# activate the following line for debug purposes only, comment out for production
-#LOCAL_SANITIZE_DIAG += $(GNSS_SANITIZE_DIAG)
-LOCAL_VENDOR_MODULE := true
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SHARED_LIBRARIES := \
-    libutils \
-    libcutils \
-    libdl \
-    liblog \
-    libloc_core \
-    libgps.utils
-
-LOCAL_SRC_FILES += \
-    location_gnss.cpp \
-    GnssAdapter.cpp \
-    Agps.cpp \
-    XtraSystemStatusObserver.cpp
-
-LOCAL_CFLAGS += \
-     -fno-short-enums \
-
-ifeq ($(TARGET_BUILD_VARIANT),user)
-   LOCAL_CFLAGS += -DTARGET_BUILD_VARIANT_USER
-endif
-
-LOCAL_HEADER_LIBRARIES := \
-    libgps.utils_headers \
-    libloc_core_headers \
-    libloc_pla_headers \
-    liblocation_api_headers
-
-LOCAL_CFLAGS += $(GNSS_CFLAGS)
-
-LOCAL_PRELINK_MODULE := false
-
-include $(BUILD_SHARED_LIBRARY)
-
-endif # not BUILD_TINY_ANDROID
-endif # BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE
diff --git a/gps/location/Android.bp b/gps/location/Android.bp
new file mode 100644
index 0000000..fb4af2d
--- /dev/null
+++ b/gps/location/Android.bp
@@ -0,0 +1,36 @@
+
+cc_library_shared {
+
+    name: "liblocation_api",
+    vendor: true,
+
+
+
+    shared_libs: [
+        "libutils",
+        "libcutils",
+        "libgps.utils",
+        "libdl",
+        "liblog",
+    ],
+
+    srcs: [
+        "LocationAPI.cpp",
+        "LocationAPIClientBase.cpp",
+    ],
+
+    cflags: ["-fno-short-enums"] + GNSS_CFLAGS,
+
+    header_libs: [
+        "libloc_pla_headers",
+        "libgps.utils_headers",
+    ],
+
+}
+
+cc_library_headers {
+
+    name: "liblocation_api_headers",
+    export_include_dirs: ["."],
+    vendor: true,
+}
diff --git a/gps/location/Android.mk b/gps/location/Android.mk
deleted file mode 100644
index 2a59541..0000000
--- a/gps/location/Android.mk
+++ /dev/null
@@ -1,44 +0,0 @@
-ifneq ($(BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE),)
-ifneq ($(BUILD_TINY_ANDROID),true)
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := liblocation_api
-LOCAL_SANITIZE += $(GNSS_SANITIZE)
-# activate the following line for debug purposes only, comment out for production
-#LOCAL_SANITIZE_DIAG += $(GNSS_SANITIZE_DIAG)
-LOCAL_VENDOR_MODULE := true
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SHARED_LIBRARIES := \
-    libutils \
-    libcutils \
-    libgps.utils \
-    libdl \
-    liblog
-
-LOCAL_SRC_FILES += \
-    LocationAPI.cpp \
-    LocationAPIClientBase.cpp
-
-LOCAL_CFLAGS += \
-     -fno-short-enums
-
-LOCAL_HEADER_LIBRARIES := \
-    libloc_pla_headers \
-    libgps.utils_headers
-
-LOCAL_PRELINK_MODULE := false
-
-LOCAL_CFLAGS += $(GNSS_CFLAGS)
-include $(BUILD_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := liblocation_api_headers
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
-include $(BUILD_HEADER_LIBRARY)
-
-endif # not BUILD_TINY_ANDROID
-endif # BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE
diff --git a/gps/pla/Android.bp b/gps/pla/Android.bp
new file mode 100644
index 0000000..5f240eb
--- /dev/null
+++ b/gps/pla/Android.bp
@@ -0,0 +1,7 @@
+
+cc_library_headers {
+
+    name: "libloc_pla_headers",
+    export_include_dirs: ["android"],
+    vendor: true,
+}
diff --git a/gps/pla/Android.mk b/gps/pla/Android.mk
deleted file mode 100644
index 5d6bb97..0000000
--- a/gps/pla/Android.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-GNSS_CFLAGS := \
-    -Werror \
-    -Wno-undefined-bool-conversion
-
-ifneq ($(BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE),)
-ifneq ($(BUILD_TINY_ANDROID),true)
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := libloc_pla_headers
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/android
-include $(BUILD_HEADER_LIBRARY)
-
-endif # not BUILD_TINY_ANDROID
-endif # BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE
diff --git a/gps/utils/Android.bp b/gps/utils/Android.bp
new file mode 100644
index 0000000..33d8440
--- /dev/null
+++ b/gps/utils/Android.bp
@@ -0,0 +1,54 @@
+
+cc_library_shared {
+
+    name: "libgps.utils",
+    vendor: true,
+
+
+
+    //# Libs
+    shared_libs: [
+        "libdl",
+        "libutils",
+        "libcutils",
+        "liblog",
+        "libprocessgroup",
+    ],
+
+    srcs: [
+        "loc_log.cpp",
+        "loc_cfg.cpp",
+        "msg_q.c",
+        "linked_list.c",
+        "loc_target.cpp",
+        "LocHeap.cpp",
+        "LocTimer.cpp",
+        "LocThread.cpp",
+        "MsgTask.cpp",
+        "loc_misc_utils.cpp",
+        "loc_nmea.cpp",
+        "LocIpc.cpp",
+        "LogBuffer.cpp",
+    ],
+
+    cflags: [
+        "-fno-short-enums",
+        "-D_ANDROID_",
+    ] + GNSS_CFLAGS,
+
+    //# Includes
+    ldflags: ["-Wl,--export-dynamic"],
+
+    header_libs: [
+        "libutils_headers",
+        "libloc_pla_headers",
+        "liblocation_api_headers",
+    ],
+}
+
+cc_library_headers {
+
+    name: "libgps.utils_headers",
+    export_include_dirs: ["."],
+    vendor: true,
+}
diff --git a/gps/utils/Android.mk b/gps/utils/Android.mk
deleted file mode 100644
index 57d485d..0000000
--- a/gps/utils/Android.mk
+++ /dev/null
@@ -1,69 +0,0 @@
-ifneq ($(BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE),)
-ifneq ($(BUILD_TINY_ANDROID),true)
-#Compile this library only for builds with the latest modem image
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-
-## Libs
-LOCAL_SHARED_LIBRARIES := \
-    libdl \
-    libutils \
-    libcutils \
-    liblog \
-    libprocessgroup
-
-LOCAL_SRC_FILES += \
-    loc_log.cpp \
-    loc_cfg.cpp \
-    msg_q.c \
-    linked_list.c \
-    loc_target.cpp \
-    LocHeap.cpp \
-    LocTimer.cpp \
-    LocThread.cpp \
-    MsgTask.cpp \
-    loc_misc_utils.cpp \
-    loc_nmea.cpp \
-    LocIpc.cpp \
-    LogBuffer.cpp
-
-# Flag -std=c++11 is not accepted by compiler when LOCAL_CLANG is set to true
-LOCAL_CFLAGS += \
-     -fno-short-enums \
-     -D_ANDROID_
-
-ifeq ($(TARGET_BUILD_VARIANT),user)
-   LOCAL_CFLAGS += -DTARGET_BUILD_VARIANT_USER
-endif
-
-LOCAL_LDFLAGS += -Wl,--export-dynamic
-
-## Includes
-LOCAL_HEADER_LIBRARIES := \
-    libutils_headers \
-    libloc_pla_headers \
-    liblocation_api_headers
-
-LOCAL_MODULE := libgps.utils
-LOCAL_SANITIZE += $(GNSS_SANITIZE)
-# activate the following line for debug purposes only, comment out for production
-#LOCAL_SANITIZE_DIAG += $(GNSS_SANITIZE_DIAG)
-LOCAL_VENDOR_MODULE := true
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_PRELINK_MODULE := false
-
-LOCAL_CFLAGS += $(GNSS_CFLAGS)
-
-include $(BUILD_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := libgps.utils_headers
-LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
-include $(BUILD_HEADER_LIBRARY)
-
-endif # not BUILD_TINY_ANDROID
-endif # BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE
diff --git a/gps/utils/loc_log.cpp b/gps/utils/loc_log.cpp
index 23601a6..c8bcbc3 100644
--- a/gps/utils/loc_log.cpp
+++ b/gps/utils/loc_log.cpp
@@ -52,6 +52,8 @@
 const char ENTRY_TAG[]  = "Entering";
 const char EXIT_ERROR_TAG[]  = "Exiting with error";
 
+int build_type_prop = BUILD_TYPE_PROP_NA;
+
 const string gEmptyStr = "";
 const string gUnknownStr = "UNKNOWN";
 /* Logging Mechanism */
diff --git a/gps/utils/log_util.h b/gps/utils/log_util.h
index 13c08bc..5cdcf25 100644
--- a/gps/utils/log_util.h
+++ b/gps/utils/log_util.h
@@ -31,6 +31,7 @@
 #define __LOG_UTIL_H__
 
 #include <stdbool.h>
+#include <loc_pla.h>
 
 #if defined (USE_ANDROID_LOGGING) || defined (ANDROID)
 // Android and LE targets with logcat support
@@ -119,6 +120,12 @@
 extern const char ENTRY_TAG[];
 extern const char EXIT_ERROR_TAG[];
 
+#define BUILD_TYPE_PROP_NA 0
+#define BUILD_TYPE_PROP_USER 1
+#define BUILD_TYPE_PROP_USERDEBUG 2
+#define BUILD_TYPE_PROP_INVALID 3
+extern int build_type_prop;
+
 /*=============================================================================
  *
  *                        MODULE EXPORTED FUNCTIONS
@@ -126,14 +133,28 @@
  *============================================================================*/
 inline void loc_logger_init(unsigned long debug, unsigned long timestamp)
 {
-   loc_logger.DEBUG_LEVEL = debug;
-#ifdef TARGET_BUILD_VARIANT_USER
-   // force user builds to 2 or less
-   if (loc_logger.DEBUG_LEVEL > 2) {
-       loc_logger.DEBUG_LEVEL = 2;
-   }
-#endif
-   loc_logger.TIMESTAMP   = timestamp;
+    loc_logger.DEBUG_LEVEL = debug;
+
+    if (BUILD_TYPE_PROP_NA == build_type_prop) {
+        char value[PROPERTY_VALUE_MAX] = "NA";
+        property_get("ro.build.type", value, "userdebug");
+        if (0 == strcmp(value, "user")) {
+            build_type_prop = BUILD_TYPE_PROP_USER;
+        } else if (0 == strcmp(value, "userdebug")) {
+            build_type_prop = BUILD_TYPE_PROP_USERDEBUG;
+        } else {
+            build_type_prop = BUILD_TYPE_PROP_INVALID;
+        }
+    }
+
+    if (BUILD_TYPE_PROP_USER == build_type_prop) {
+        // force user builds to 2 or less
+        if (loc_logger.DEBUG_LEVEL > 2) {
+            loc_logger.DEBUG_LEVEL = 2;
+        }
+     }
+
+    loc_logger.TIMESTAMP = timestamp;
 }
 
 inline void log_buffer_init(bool enabled) {