diff --git a/gps/android/1.0/AGnss.cpp b/gps/android/1.0/AGnss.cpp
deleted file mode 100644
index 64a44a8..0000000
--- a/gps/android/1.0/AGnss.cpp
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-#define LOG_TAG "LocSvc_AGnssInterface"
-
-#include <log_util.h>
-#include "Gnss.h"
-#include "AGnss.h"
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_0 {
-namespace implementation {
-
-static AGnss* spAGnss = nullptr;
-
-AGnss::AGnss(Gnss* gnss) : mGnss(gnss) {
-    spAGnss = this;
-}
-
-AGnss::~AGnss() {
-    spAGnss = nullptr;
-}
-
-void AGnss::agnssStatusIpV4Cb(AGnssExtStatusIpV4 status){
-    if (nullptr != spAGnss) {
-        spAGnss->statusIpV4Cb(status);
-    }
-}
-
-void AGnss::statusIpV4Cb(AGnssExtStatusIpV4 status) {
-    IAGnssCallback::AGnssStatusIpV4 st = {};
-
-    switch (status.type) {
-        case LOC_AGPS_TYPE_SUPL:
-            st.type = IAGnssCallback::AGnssType::TYPE_SUPL;
-            break;
-        case LOC_AGPS_TYPE_C2K:
-            st.type = IAGnssCallback::AGnssType::TYPE_C2K;
-            break;
-        default:
-            LOC_LOGE("invalid type: %d", status.type);
-            return;
-    }
-
-    switch (status.status) {
-        case LOC_GPS_REQUEST_AGPS_DATA_CONN:
-            st.status = IAGnssCallback::AGnssStatusValue::REQUEST_AGNSS_DATA_CONN;
-            break;
-        case LOC_GPS_RELEASE_AGPS_DATA_CONN:
-            st.status = IAGnssCallback::AGnssStatusValue::RELEASE_AGNSS_DATA_CONN;
-            break;
-        case LOC_GPS_AGPS_DATA_CONNECTED:
-            st.status = IAGnssCallback::AGnssStatusValue::AGNSS_DATA_CONNECTED;
-            break;
-        case LOC_GPS_AGPS_DATA_CONN_DONE:
-            st.status = IAGnssCallback::AGnssStatusValue::AGNSS_DATA_CONN_DONE;
-            break;
-        case LOC_GPS_AGPS_DATA_CONN_FAILED:
-            st.status = IAGnssCallback::AGnssStatusValue::AGNSS_DATA_CONN_FAILED;
-            break;
-        default:
-            LOC_LOGE("invalid status: %d", status.status);
-            return;
-    }
-    st.ipV4Addr = status.ipV4Addr;
-
-    mMutex.lock();
-    auto aGnssCbIface = mAGnssCbIface;
-    mMutex.unlock();
-    if (aGnssCbIface != nullptr) {
-        auto r = aGnssCbIface->agnssStatusIpV4Cb(st);
-        if (!r.isOk()) {
-            LOC_LOGw("Error invoking AGNSS status cb %s", r.description().c_str());
-        }
-    } else {
-        LOC_LOGw("setCallback has not been called yet");
-    }
-}
-
-Return<void> AGnss::setCallback(const sp<IAGnssCallback>& callback) {
-
-    if(mGnss == nullptr || mGnss->getGnssInterface() == nullptr){
-        LOC_LOGE("Null GNSS interface");
-        return Void();
-    }
-
-    // Save the interface
-    mMutex.lock();
-    mAGnssCbIface = callback;
-    mMutex.unlock();
-
-    AgpsCbInfo cbInfo = {};
-    cbInfo.statusV4Cb = (void*)agnssStatusIpV4Cb;
-    cbInfo.atlType = AGPS_ATL_TYPE_SUPL | AGPS_ATL_TYPE_SUPL_ES;
-
-    mGnss->getGnssInterface()->agpsInit(cbInfo);
-    return Void();
-}
-
-Return<bool> AGnss::dataConnClosed() {
-
-    if(mGnss == nullptr || mGnss->getGnssInterface() == nullptr){
-        LOC_LOGE("Null GNSS interface");
-        return false;
-    }
-
-    mGnss->getGnssInterface()->agpsDataConnClosed(LOC_AGPS_TYPE_SUPL);
-    return true;
-}
-
-Return<bool> AGnss::dataConnFailed() {
-
-    if(mGnss == nullptr || mGnss->getGnssInterface() == nullptr){
-        LOC_LOGE("Null GNSS interface");
-        return false;
-    }
-
-    mGnss->getGnssInterface()->agpsDataConnFailed(LOC_AGPS_TYPE_SUPL);
-    return true;
-}
-
-Return<bool> AGnss::dataConnOpen(const hidl_string& apn,
-        IAGnss::ApnIpType apnIpType) {
-
-    if(mGnss == nullptr || mGnss->getGnssInterface() == nullptr){
-        LOC_LOGE("Null GNSS interface");
-        return false;
-    }
-
-    /* Validate */
-    if(apn.empty()){
-        LOC_LOGE("Invalid APN");
-        return false;
-    }
-
-    LOC_LOGD("dataConnOpen APN name = [%s]", apn.c_str());
-
-    AGpsBearerType bearerType;
-    switch (apnIpType) {
-        case IAGnss::ApnIpType::IPV4:
-            bearerType = AGPS_APN_BEARER_IPV4;
-            break;
-        case IAGnss::ApnIpType::IPV6:
-            bearerType = AGPS_APN_BEARER_IPV6;
-            break;
-        case IAGnss::ApnIpType::IPV4V6:
-            bearerType = AGPS_APN_BEARER_IPV4V6;
-            break;
-        default:
-            bearerType = AGPS_APN_BEARER_IPV4;
-            break;
-    }
-
-    mGnss->getGnssInterface()->agpsDataConnOpen(
-            LOC_AGPS_TYPE_SUPL, apn.c_str(), apn.size(), (int)bearerType);
-    return true;
-}
-
-Return<bool> AGnss::setServer(IAGnssCallback::AGnssType type,
-                              const hidl_string& hostname,
-                              int32_t port) {
-    if (mGnss == nullptr) {
-        LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__);
-        return false;
-    }
-
-    GnssConfig config;
-    memset(&config, 0, sizeof(GnssConfig));
-    config.size = sizeof(GnssConfig);
-    config.flags = GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT;
-    config.assistanceServer.size = sizeof(GnssConfigSetAssistanceServer);
-    if (type == IAGnssCallback::AGnssType::TYPE_SUPL) {
-        config.assistanceServer.type = GNSS_ASSISTANCE_TYPE_SUPL;
-    } else if (type == IAGnssCallback::AGnssType::TYPE_C2K) {
-        config.assistanceServer.type = GNSS_ASSISTANCE_TYPE_C2K;
-    } else {
-        LOC_LOGE("%s]: invalid AGnssType: %d", __FUNCTION__, static_cast<int>(type));
-        return false;
-    }
-    config.assistanceServer.hostName = strdup(hostname.c_str());
-    config.assistanceServer.port = port;
-    return mGnss->updateConfiguration(config);
-}
-
-}  // namespace implementation
-}  // namespace V1_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
diff --git a/gps/android/1.0/AGnss.h b/gps/android/1.0/AGnss.h
deleted file mode 100644
index 1d4c58b..0000000
--- a/gps/android/1.0/AGnss.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-#ifndef ANDROID_HARDWARE_GNSS_V1_0_AGNSS_H
-#define ANDROID_HARDWARE_GNSS_V1_0_AGNSS_H
-
-#include <mutex>
-#include <android/hardware/gnss/1.0/IAGnss.h>
-#include <hidl/Status.h>
-#include <gps_extended_c.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_0 {
-namespace implementation {
-
-using ::android::hardware::gnss::V1_0::IAGnss;
-using ::android::hardware::gnss::V1_0::IAGnssCallback;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::sp;
-
-struct Gnss;
-struct AGnss : public IAGnss {
-
-    AGnss(Gnss* gnss);
-    ~AGnss();
-    /*
-     * Methods from ::android::hardware::gnss::V1_0::IAGnss interface follow.
-     * These declarations were generated from IAGnss.hal.
-     */
-    Return<void> setCallback(const sp<IAGnssCallback>& callback) override;
-
-    Return<bool> dataConnClosed() override;
-
-    Return<bool> dataConnFailed() override;
-
-    Return<bool> dataConnOpen(const hidl_string& apn,
-            IAGnss::ApnIpType apnIpType) override;
-
-    Return<bool> setServer(IAGnssCallback::AGnssType type,
-                         const hidl_string& hostname, int32_t port) override;
-
-    void statusIpV4Cb(AGnssExtStatusIpV4 status);
-
-    /* Data call setup callback passed down to GNSS HAL implementation */
-    static void agnssStatusIpV4Cb(AGnssExtStatusIpV4 status);
-
- private:
-    Gnss* mGnss = nullptr;
-    std::mutex mMutex;
-    sp<IAGnssCallback> mAGnssCbIface = nullptr;
-};
-
-}  // namespace implementation
-}  // namespace V1_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
-
-#endif  // ANDROID_HARDWARE_GNSS_V1_0_AGNSS_H
diff --git a/gps/android/1.0/AGnssRil.cpp b/gps/android/1.0/AGnssRil.cpp
deleted file mode 100644
index e2d5948..0000000
--- a/gps/android/1.0/AGnssRil.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-#define LOG_TAG "LocSvc__AGnssRilInterface"
-
-#include <log_util.h>
-#include <dlfcn.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <sstream>
-#include <string>
-#include "Gnss.h"
-#include "AGnssRil.h"
-#include <DataItemConcreteTypes.h>
-
-typedef void* (getLocationInterface)();
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_0 {
-namespace implementation {
-
-
-AGnssRil::AGnssRil(Gnss* gnss) : mGnss(gnss) {
-    ENTRY_LOG_CALLFLOW();
-}
-
-AGnssRil::~AGnssRil() {
-    ENTRY_LOG_CALLFLOW();
-}
-
-Return<bool> AGnssRil::updateNetworkState(bool connected, NetworkType type, bool /*roaming*/) {
-    ENTRY_LOG_CALLFLOW();
-    // Extra NetworkTypes not available in IAgnssRil enums
-    const int NetworkType_BLUETOOTH = 7;
-    const int NetworkType_ETHERNET = 9;
-    const int NetworkType_PROXY = 16;
-    std::string apn("");
-
-    // for XTRA
-    if (nullptr != mGnss && ( nullptr != mGnss->getGnssInterface() )) {
-        int8_t typeout = loc_core::TYPE_UNKNOWN;
-        switch(type)
-        {
-            case IAGnssRil::NetworkType::MOBILE:
-                typeout = loc_core::TYPE_MOBILE;
-                break;
-            case IAGnssRil::NetworkType::WIFI:
-                typeout = loc_core::TYPE_WIFI;
-                break;
-            case IAGnssRil::NetworkType::MMS:
-                typeout = loc_core::TYPE_MMS;
-                break;
-            case IAGnssRil::NetworkType::SUPL:
-                typeout = loc_core::TYPE_SUPL;
-                break;
-            case IAGnssRil::NetworkType::DUN:
-                typeout = loc_core::TYPE_DUN;
-                break;
-            case IAGnssRil::NetworkType::HIPRI:
-                typeout = loc_core::TYPE_HIPRI;
-                break;
-            case IAGnssRil::NetworkType::WIMAX:
-                typeout = loc_core::TYPE_WIMAX;
-                break;
-            default:
-                {
-                    int networkType = (int) type;
-                    // Handling network types not available in IAgnssRil
-                    switch(networkType)
-                    {
-                        case NetworkType_BLUETOOTH:
-                            typeout = loc_core::TYPE_BLUETOOTH;
-                            break;
-                        case NetworkType_ETHERNET:
-                            typeout = loc_core::TYPE_ETHERNET;
-                            break;
-                        case NetworkType_PROXY:
-                            typeout = loc_core::TYPE_PROXY;
-                            break;
-                        default:
-                            typeout = loc_core::TYPE_UNKNOWN;
-                    }
-                }
-                break;
-        }
-        mGnss->getGnssInterface()->updateConnectionStatus(connected, typeout, false, 0, apn);
-    }
-    return true;
-}
-
-}  // namespace implementation
-}  // namespace V1_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
diff --git a/gps/android/1.0/AGnssRil.h b/gps/android/1.0/AGnssRil.h
deleted file mode 100644
index 7f18c57..0000000
--- a/gps/android/1.0/AGnssRil.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-#ifndef ANDROID_HARDWARE_GNSS_V1_0_AGNSSRIL_H_
-#define ANDROID_HARDWARE_GNSS_V1_0_AGNSSRIL_H_
-
-#include <android/hardware/gnss/1.0/IAGnssRil.h>
-#include <hidl/Status.h>
-#include <location_interface.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_0 {
-namespace implementation {
-
-using ::android::hardware::gnss::V1_0::IAGnssRil;
-using ::android::hardware::gnss::V1_0::IAGnssRilCallback;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::sp;
-
-struct Gnss;
-/*
- * Extended interface for AGNSS RIL support. An Assisted GNSS Radio Interface Layer interface
- * allows the GNSS chipset to request radio interface layer information from Android platform.
- * Examples of such information are reference location, unique subscriber ID, phone number string
- * and network availability changes. Also contains wrapper methods to allow methods from
- * IAGnssiRilCallback interface to be passed into the conventional implementation of the GNSS HAL.
- */
-struct AGnssRil : public IAGnssRil {
-    AGnssRil(Gnss* gnss);
-    ~AGnssRil();
-
-    /*
-     * Methods from ::android::hardware::gnss::V1_0::IAGnssRil follow.
-     * These declarations were generated from IAGnssRil.hal.
-     */
-    Return<void> setCallback(const sp<IAGnssRilCallback>& /*callback*/) override {
-        return Void();
-    }
-    Return<void> setRefLocation(const IAGnssRil::AGnssRefLocation& /*agnssReflocation*/) override {
-        return Void();
-    }
-    Return<bool> setSetId(IAGnssRil::SetIDType /*type*/, const hidl_string& /*setid*/) override {
-        return false;
-    }
-    Return<bool> updateNetworkAvailability(bool /*available*/,
-                                    const hidl_string& /*apn*/) override {
-        return false;
-    }
-    Return<bool> updateNetworkState(bool connected, NetworkType type, bool roaming) override;
-
- private:
-    Gnss* mGnss = nullptr;
-};
-
-}  // namespace implementation
-}  // namespace V1_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
-
-#endif  // ANDROID_HARDWARE_GNSS_V1_0_AGNSSRIL_H_
diff --git a/gps/android/1.0/Android.mk b/gps/android/1.0/Android.mk
deleted file mode 100644
index 0c60fd4..0000000
--- a/gps/android/1.0/Android.mk
+++ /dev/null
@@ -1,95 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.gnss@1.0-impl-qti
-
-LOCAL_VENDOR_MODULE := true
-LOCAL_MODULE_RELATIVE_PATH := hw
-LOCAL_SRC_FILES := \
-    AGnss.cpp \
-    Gnss.cpp \
-    GnssBatching.cpp \
-    GnssGeofencing.cpp \
-    GnssMeasurement.cpp \
-    GnssNi.cpp \
-    GnssConfiguration.cpp \
-    GnssDebug.cpp \
-    AGnssRil.cpp
-
-LOCAL_SRC_FILES += \
-    location_api/LocationUtil.cpp \
-    location_api/GnssAPIClient.cpp \
-    location_api/GeofenceAPIClient.cpp \
-    location_api/BatchingAPIClient.cpp \
-    location_api/MeasurementAPIClient.cpp \
-
-LOCAL_C_INCLUDES:= \
-    $(LOCAL_PATH)/location_api
-LOCAL_HEADER_LIBRARIES := \
-    libgps.utils_headers \
-    libloc_core_headers \
-    libloc_pla_headers \
-    liblocation_api_headers \
-    liblocbatterylistener_headers
-
-LOCAL_SHARED_LIBRARIES := \
-    liblog \
-    libhidlbase \
-    libcutils \
-    libutils \
-    android.hardware.gnss@1.0 \
-    android.hardware.health@1.0 \
-    android.hardware.health@2.0 \
-    android.hardware.power@1.2 \
-    libbase
-
-LOCAL_SHARED_LIBRARIES += \
-    libloc_core \
-    libgps.utils \
-    libdl \
-    liblocation_api \
-
-LOCAL_CFLAGS += $(GNSS_CFLAGS)
-LOCAL_STATIC_LIBRARIES := liblocbatterylistener
-LOCAL_STATIC_LIBRARIES += libhealthhalutils
-include $(BUILD_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.gnss@1.0-service-qti
-
-LOCAL_VINTF_FRAGMENTS := android.hardware.gnss@1.0-service-qti.xml
-LOCAL_VENDOR_MODULE := true
-LOCAL_MODULE_RELATIVE_PATH := hw
-LOCAL_INIT_RC := android.hardware.gnss@1.0-service-qti.rc
-LOCAL_SRC_FILES := \
-    service.cpp \
-
-LOCAL_C_INCLUDES:= \
-    $(LOCAL_PATH)/location_api
-LOCAL_HEADER_LIBRARIES := \
-    libgps.utils_headers \
-    libloc_core_headers \
-    libloc_pla_headers \
-    liblocation_api_headers
-
-
-LOCAL_SHARED_LIBRARIES := \
-    liblog \
-    libcutils \
-    libdl \
-    libbase \
-    libutils \
-    libgps.utils \
-    libqti_vndfwk_detect \
-
-LOCAL_SHARED_LIBRARIES += \
-    libhidlbase \
-    android.hardware.gnss@1.0 \
-
-LOCAL_CFLAGS += $(GNSS_CFLAGS)
-
-ifneq ($(LOC_HIDL_VERSION),)
-LOCAL_CFLAGS += -DLOC_HIDL_VERSION='"$(LOC_HIDL_VERSION)"'
-endif
-
-include $(BUILD_EXECUTABLE)
diff --git a/gps/android/1.0/Gnss.cpp b/gps/android/1.0/Gnss.cpp
deleted file mode 100644
index 308cc7c..0000000
--- a/gps/android/1.0/Gnss.cpp
+++ /dev/null
@@ -1,346 +0,0 @@
-/*
- * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-#define LOG_TAG "LocSvc_GnssInterface"
-#define LOG_NDEBUG 0
-
-#include <fstream>
-#include <log_util.h>
-#include <dlfcn.h>
-#include <cutils/properties.h>
-#include "Gnss.h"
-#include <LocationUtil.h>
-#include "battery_listener.h"
-#include "loc_misc_utils.h"
-
-typedef const GnssInterface* (getLocationInterface)();
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_0 {
-namespace implementation {
-
-static sp<Gnss> sGnss;
-void Gnss::GnssDeathRecipient::serviceDied(uint64_t cookie, const wp<IBase>& who) {
-    LOC_LOGE("%s] service died. cookie: %llu, who: %p",
-            __FUNCTION__, static_cast<unsigned long long>(cookie), &who);
-    if (mGnss != nullptr) {
-        mGnss->getGnssInterface()->resetNetworkInfo();
-        mGnss->stop();
-        mGnss->cleanup();
-    }
-}
-
-void location_on_battery_status_changed(bool charging) {
-    LOC_LOGd("battery status changed to %s charging", charging ? "" : "not ");
-    if (sGnss != nullptr) {
-        sGnss->getGnssInterface()->updateBatteryStatus(charging);
-    }
-}
-Gnss::Gnss() {
-    ENTRY_LOG_CALLFLOW();
-    sGnss = this;
-    // initilize gnss interface at first in case needing notify battery status
-    sGnss->getGnssInterface()->initialize();
-    // register health client to listen on battery change
-    loc_extn_battery_properties_listener_init(location_on_battery_status_changed);
-    // clear pending GnssConfig
-    memset(&mPendingConfig, 0, sizeof(GnssConfig));
-
-    mGnssDeathRecipient = new GnssDeathRecipient(this);
-}
-
-Gnss::~Gnss() {
-    ENTRY_LOG_CALLFLOW();
-    if (mApi != nullptr) {
-        mApi->destroy();
-        mApi = nullptr;
-    }
-    sGnss = nullptr;
-}
-
-GnssAPIClient* Gnss::getApi() {
-    if (mApi == nullptr && (mGnssCbIface != nullptr || mGnssNiCbIface != nullptr)) {
-        mApi = new GnssAPIClient(mGnssCbIface, mGnssNiCbIface);
-        if (mApi == nullptr) {
-            LOC_LOGE("%s] faild to create GnssAPIClient", __FUNCTION__);
-            return mApi;
-        }
-
-        if (mPendingConfig.size == sizeof(GnssConfig)) {
-            // we have pending GnssConfig
-            mApi->gnssConfigurationUpdate(mPendingConfig);
-            // clear size to invalid mPendingConfig
-            mPendingConfig.size = 0;
-            if (mPendingConfig.assistanceServer.hostName != nullptr) {
-                free((void*)mPendingConfig.assistanceServer.hostName);
-            }
-        }
-    }
-    if (mApi == nullptr) {
-        LOC_LOGW("%s] GnssAPIClient is not ready", __FUNCTION__);
-    }
-    return mApi;
-}
-
-const GnssInterface* Gnss::getGnssInterface() {
-    static bool getGnssInterfaceFailed = false;
-    if (nullptr == mGnssInterface && !getGnssInterfaceFailed) {
-        void * libHandle = nullptr;
-        getLocationInterface* getter = (getLocationInterface*)
-                dlGetSymFromLib(libHandle, "libgnss.so", "getGnssInterface");
-
-        if (nullptr == getter) {
-            getGnssInterfaceFailed = true;
-        } else {
-            mGnssInterface = (const GnssInterface*)(*getter)();
-        }
-    }
-    return mGnssInterface;
-}
-
-Return<bool> Gnss::setCallback(const sp<V1_0::IGnssCallback>& callback)  {
-    ENTRY_LOG_CALLFLOW();
-    if (mGnssCbIface != nullptr) {
-        mGnssCbIface->unlinkToDeath(mGnssDeathRecipient);
-    }
-    mGnssCbIface = callback;
-    if (mGnssCbIface != nullptr) {
-        mGnssCbIface->linkToDeath(mGnssDeathRecipient, 0 /*cookie*/);
-    }
-
-    GnssAPIClient* api = getApi();
-    if (api != nullptr) {
-        api->gnssUpdateCallbacks(mGnssCbIface, mGnssNiCbIface);
-        api->gnssEnable(LOCATION_TECHNOLOGY_TYPE_GNSS);
-        api->requestCapabilities();
-    }
-    return true;
-}
-
-Return<bool> Gnss::setGnssNiCb(const sp<IGnssNiCallback>& callback) {
-    ENTRY_LOG_CALLFLOW();
-    mGnssNiCbIface = callback;
-    GnssAPIClient* api = getApi();
-    if (api != nullptr) {
-        api->gnssUpdateCallbacks(mGnssCbIface, mGnssNiCbIface);
-    }
-    return true;
-}
-
-Return<bool> Gnss::updateConfiguration(GnssConfig& gnssConfig) {
-    ENTRY_LOG_CALLFLOW();
-    GnssAPIClient* api = getApi();
-    if (api) {
-        api->gnssConfigurationUpdate(gnssConfig);
-    } else if (gnssConfig.flags != 0) {
-        // api is not ready yet, update mPendingConfig with gnssConfig
-        mPendingConfig.size = sizeof(GnssConfig);
-
-        if (gnssConfig.flags & GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT) {
-            mPendingConfig.flags |= GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT;
-            mPendingConfig.gpsLock = gnssConfig.gpsLock;
-        }
-        if (gnssConfig.flags & GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT) {
-            mPendingConfig.flags |= GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT;
-            mPendingConfig.suplVersion = gnssConfig.suplVersion;
-        }
-        if (gnssConfig.flags & GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT) {
-            mPendingConfig.flags |= GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT;
-            mPendingConfig.assistanceServer.size = sizeof(GnssConfigSetAssistanceServer);
-            mPendingConfig.assistanceServer.type = gnssConfig.assistanceServer.type;
-            if (mPendingConfig.assistanceServer.hostName != nullptr) {
-                free((void*)mPendingConfig.assistanceServer.hostName);
-                mPendingConfig.assistanceServer.hostName =
-                    strdup(gnssConfig.assistanceServer.hostName);
-            }
-            mPendingConfig.assistanceServer.port = gnssConfig.assistanceServer.port;
-        }
-        if (gnssConfig.flags & GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT) {
-            mPendingConfig.flags |= GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT;
-            mPendingConfig.lppProfileMask = gnssConfig.lppProfileMask;
-        }
-        if (gnssConfig.flags & GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT) {
-            mPendingConfig.flags |= GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT;
-            mPendingConfig.lppeControlPlaneMask = gnssConfig.lppeControlPlaneMask;
-        }
-        if (gnssConfig.flags & GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT) {
-            mPendingConfig.flags |= GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT;
-            mPendingConfig.lppeUserPlaneMask = gnssConfig.lppeUserPlaneMask;
-        }
-        if (gnssConfig.flags & GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT) {
-            mPendingConfig.flags |= GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT;
-            mPendingConfig.aGlonassPositionProtocolMask = gnssConfig.aGlonassPositionProtocolMask;
-        }
-        if (gnssConfig.flags & GNSS_CONFIG_FLAGS_EM_PDN_FOR_EM_SUPL_VALID_BIT) {
-            mPendingConfig.flags |= GNSS_CONFIG_FLAGS_EM_PDN_FOR_EM_SUPL_VALID_BIT;
-            mPendingConfig.emergencyPdnForEmergencySupl = gnssConfig.emergencyPdnForEmergencySupl;
-        }
-        if (gnssConfig.flags & GNSS_CONFIG_FLAGS_SUPL_EM_SERVICES_BIT) {
-            mPendingConfig.flags |= GNSS_CONFIG_FLAGS_SUPL_EM_SERVICES_BIT;
-            mPendingConfig.suplEmergencyServices = gnssConfig.suplEmergencyServices;
-        }
-        if (gnssConfig.flags & GNSS_CONFIG_FLAGS_SUPL_MODE_BIT) {
-            mPendingConfig.flags |= GNSS_CONFIG_FLAGS_SUPL_MODE_BIT;
-            mPendingConfig.suplModeMask = gnssConfig.suplModeMask;
-        }
-        if (gnssConfig.flags & GNSS_CONFIG_FLAGS_BLACKLISTED_SV_IDS_BIT) {
-            mPendingConfig.flags |= GNSS_CONFIG_FLAGS_BLACKLISTED_SV_IDS_BIT;
-            mPendingConfig.blacklistedSvIds = gnssConfig.blacklistedSvIds;
-        }
-    }
-    return true;
-}
-
-Return<bool> Gnss::start()  {
-    ENTRY_LOG_CALLFLOW();
-    bool retVal = false;
-    GnssAPIClient* api = getApi();
-    if (api) {
-        retVal = api->gnssStart();
-    }
-    return retVal;
-}
-
-Return<bool> Gnss::stop()  {
-    ENTRY_LOG_CALLFLOW();
-    bool retVal = false;
-    GnssAPIClient* api = getApi();
-    if (api) {
-        retVal = api->gnssStop();
-    }
-    return retVal;
-}
-
-Return<void> Gnss::cleanup()  {
-    ENTRY_LOG_CALLFLOW();
-
-    if (mApi != nullptr) {
-        mApi->gnssDisable();
-    }
-
-    return Void();
-}
-
-Return<bool> Gnss::injectLocation(double latitudeDegrees,
-                                  double longitudeDegrees,
-                                  float accuracyMeters)  {
-    ENTRY_LOG_CALLFLOW();
-    const GnssInterface* gnssInterface = getGnssInterface();
-    if (nullptr != gnssInterface) {
-        gnssInterface->injectLocation(latitudeDegrees, longitudeDegrees, accuracyMeters);
-        return true;
-    } else {
-        return false;
-    }
-}
-
-Return<bool> Gnss::injectTime(int64_t timeMs, int64_t timeReferenceMs,
-                              int32_t uncertaintyMs) {
-    return true;
-}
-
-Return<void> Gnss::deleteAidingData(V1_0::IGnss::GnssAidingData aidingDataFlags)  {
-    ENTRY_LOG_CALLFLOW();
-    GnssAPIClient* api = getApi();
-    if (api) {
-        api->gnssDeleteAidingData(aidingDataFlags);
-    }
-    return Void();
-}
-
-Return<bool> Gnss::setPositionMode(V1_0::IGnss::GnssPositionMode mode,
-                                   V1_0::IGnss::GnssPositionRecurrence recurrence,
-                                   uint32_t minIntervalMs,
-                                   uint32_t preferredAccuracyMeters,
-                                   uint32_t preferredTimeMs)  {
-    ENTRY_LOG_CALLFLOW();
-    bool retVal = false;
-    GnssAPIClient* api = getApi();
-    if (api) {
-        retVal = api->gnssSetPositionMode(mode, recurrence, minIntervalMs,
-                preferredAccuracyMeters, preferredTimeMs);
-    }
-    return retVal;
-}
-
-Return<sp<V1_0::IAGnss>> Gnss::getExtensionAGnss()  {
-    ENTRY_LOG_CALLFLOW();
-    mAGnssIface = new AGnss(this);
-    return mAGnssIface;
-}
-
-Return<sp<V1_0::IGnssNi>> Gnss::getExtensionGnssNi()  {
-    ENTRY_LOG_CALLFLOW();
-    mGnssNi = new GnssNi(this);
-    return mGnssNi;
-}
-
-Return<sp<V1_0::IGnssMeasurement>> Gnss::getExtensionGnssMeasurement() {
-    ENTRY_LOG_CALLFLOW();
-    if (mGnssMeasurement == nullptr)
-        mGnssMeasurement = new GnssMeasurement();
-    return mGnssMeasurement;
-}
-
-Return<sp<V1_0::IGnssConfiguration>> Gnss::getExtensionGnssConfiguration()  {
-    ENTRY_LOG_CALLFLOW();
-    mGnssConfig = new GnssConfiguration(this);
-    return mGnssConfig;
-}
-
-Return<sp<V1_0::IGnssGeofencing>> Gnss::getExtensionGnssGeofencing()  {
-    ENTRY_LOG_CALLFLOW();
-    mGnssGeofencingIface = new GnssGeofencing();
-    return mGnssGeofencingIface;
-}
-
-Return<sp<V1_0::IGnssBatching>> Gnss::getExtensionGnssBatching()  {
-    mGnssBatching = new GnssBatching();
-    return mGnssBatching;
-}
-
-Return<sp<V1_0::IGnssDebug>> Gnss::getExtensionGnssDebug() {
-    ENTRY_LOG_CALLFLOW();
-    mGnssDebug = new GnssDebug(this);
-    return mGnssDebug;
-}
-
-Return<sp<V1_0::IAGnssRil>> Gnss::getExtensionAGnssRil() {
-    mGnssRil = new AGnssRil(this);
-    return mGnssRil;
-}
-
-IGnss* HIDL_FETCH_IGnss(const char* hal) {
-    ENTRY_LOG_CALLFLOW();
-    IGnss* iface = nullptr;
-    iface = new Gnss();
-    if (iface == nullptr) {
-        LOC_LOGE("%s]: failed to get %s", __FUNCTION__, hal);
-    }
-    return iface;
-}
-
-}  // namespace implementation
-}  // namespace V1_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
diff --git a/gps/android/1.0/Gnss.h b/gps/android/1.0/Gnss.h
deleted file mode 100644
index 900a510..0000000
--- a/gps/android/1.0/Gnss.h
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-#ifndef ANDROID_HARDWARE_GNSS_V1_0_GNSS_H
-#define ANDROID_HARDWARE_GNSS_V1_0_GNSS_H
-
-#include <AGnss.h>
-#include <AGnssRil.h>
-#include <GnssBatching.h>
-#include <GnssConfiguration.h>
-#include <GnssGeofencing.h>
-#include <GnssMeasurement.h>
-#include <GnssNi.h>
-#include <GnssDebug.h>
-
-#include <android/hardware/gnss/1.0/IGnss.h>
-#include <hidl/MQDescriptor.h>
-#include <hidl/Status.h>
-
-#include <GnssAPIClient.h>
-#include <location_interface.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_0 {
-namespace implementation {
-
-using ::android::hardware::hidl_array;
-using ::android::hardware::hidl_memory;
-using ::android::hardware::hidl_string;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::sp;
-using ::android::hardware::gnss::V1_0::GnssLocation;
-
-struct Gnss : public IGnss {
-    Gnss();
-    ~Gnss();
-
-    /*
-     * Methods from ::android::hardware::gnss::V1_0::IGnss follow.
-     * These declarations were generated from Gnss.hal.
-     */
-    Return<bool> setCallback(const sp<V1_0::IGnssCallback>& callback)  override;
-    Return<bool> start()  override;
-    Return<bool> stop()  override;
-    Return<void> cleanup()  override;
-    Return<bool> injectLocation(double latitudeDegrees,
-                                double longitudeDegrees,
-                                float accuracyMeters)  override;
-    Return<bool> injectTime(int64_t timeMs,
-                            int64_t timeReferenceMs,
-                            int32_t uncertaintyMs) override;
-    Return<void> deleteAidingData(V1_0::IGnss::GnssAidingData aidingDataFlags)  override;
-    Return<bool> setPositionMode(V1_0::IGnss::GnssPositionMode mode,
-                                 V1_0::IGnss::GnssPositionRecurrence recurrence,
-                                 uint32_t minIntervalMs,
-                                 uint32_t preferredAccuracyMeters,
-                                 uint32_t preferredTimeMs)  override;
-    Return<sp<V1_0::IAGnss>> getExtensionAGnss() override;
-    Return<sp<V1_0::IGnssNi>> getExtensionGnssNi() override;
-    Return<sp<V1_0::IGnssMeasurement>> getExtensionGnssMeasurement() override;
-    Return<sp<V1_0::IGnssConfiguration>> getExtensionGnssConfiguration() override;
-    Return<sp<V1_0::IGnssGeofencing>> getExtensionGnssGeofencing() override;
-    Return<sp<V1_0::IGnssBatching>> getExtensionGnssBatching() override;
-
-    Return<sp<V1_0::IAGnssRil>> getExtensionAGnssRil() override;
-
-    inline Return<sp<V1_0::IGnssNavigationMessage>> getExtensionGnssNavigationMessage() override {
-        return nullptr;
-    }
-
-    inline Return<sp<V1_0::IGnssXtra>> getExtensionXtra() override {
-        return nullptr;
-    }
-
-    Return<sp<V1_0::IGnssDebug>> getExtensionGnssDebug() override;
-
-    // These methods are not part of the IGnss base class.
-    GnssAPIClient* getApi();
-    Return<bool> setGnssNiCb(const sp<IGnssNiCallback>& niCb);
-    Return<bool> updateConfiguration(GnssConfig& gnssConfig);
-    const GnssInterface* getGnssInterface();
-
-    // Callback for ODCPI request
-    void odcpiRequestCb(const OdcpiRequestInfo& request);
-
- private:
-    struct GnssDeathRecipient : hidl_death_recipient {
-        GnssDeathRecipient(sp<Gnss> gnss) : mGnss(gnss) {
-        }
-        ~GnssDeathRecipient() = default;
-        virtual void serviceDied(uint64_t cookie, const wp<IBase>& who) override;
-        sp<Gnss> mGnss;
-    };
-
- private:
-    sp<GnssDeathRecipient> mGnssDeathRecipient = nullptr;
-
-    sp<AGnss> mAGnssIface = nullptr;
-    sp<GnssNi> mGnssNi = nullptr;
-    sp<GnssMeasurement> mGnssMeasurement = nullptr;
-    sp<GnssConfiguration> mGnssConfig = nullptr;
-    sp<GnssGeofencing> mGnssGeofencingIface = nullptr;
-    sp<GnssBatching> mGnssBatching = nullptr;
-    sp<IGnssDebug> mGnssDebug = nullptr;
-    sp<AGnssRil> mGnssRil = nullptr;
-
-    GnssAPIClient* mApi = nullptr;
-    sp<V1_0::IGnssCallback> mGnssCbIface = nullptr;
-    sp<V1_0::IGnssNiCallback> mGnssNiCbIface = nullptr;
-    GnssConfig mPendingConfig;
-    const GnssInterface* mGnssInterface = nullptr;
-};
-
-extern "C" IGnss* HIDL_FETCH_IGnss(const char* name);
-
-}  // namespace implementation
-}  // namespace V1_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
-
-#endif  // ANDROID_HARDWARE_GNSS_V1_0_GNSS_H
diff --git a/gps/android/1.0/GnssBatching.cpp b/gps/android/1.0/GnssBatching.cpp
deleted file mode 100644
index f92697f..0000000
--- a/gps/android/1.0/GnssBatching.cpp
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-#define LOG_TAG "LocSvc_GnssBatchingInterface"
-
-#include <log_util.h>
-#include <BatchingAPIClient.h>
-#include "GnssBatching.h"
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_0 {
-namespace implementation {
-
-void GnssBatching::GnssBatchingDeathRecipient::serviceDied(
-        uint64_t cookie, const wp<IBase>& who) {
-    LOC_LOGE("%s] service died. cookie: %llu, who: %p",
-            __FUNCTION__, static_cast<unsigned long long>(cookie), &who);
-    if (mGnssBatching != nullptr) {
-        mGnssBatching->stop();
-        mGnssBatching->cleanup();
-    }
-}
-
-GnssBatching::GnssBatching() : mApi(nullptr) {
-    mGnssBatchingDeathRecipient = new GnssBatchingDeathRecipient(this);
-}
-
-GnssBatching::~GnssBatching() {
-    if (mApi != nullptr) {
-        mApi->destroy();
-        mApi = nullptr;
-    }
-}
-
-
-// Methods from ::android::hardware::gnss::V1_0::IGnssBatching follow.
-Return<bool> GnssBatching::init(const sp<IGnssBatchingCallback>& callback) {
-    if (mApi != nullptr) {
-        LOC_LOGD("%s]: mApi is NOT nullptr, delete it first", __FUNCTION__);
-        mApi->destroy();
-        mApi = nullptr;
-    }
-
-    mApi = new BatchingAPIClient(callback);
-    if (mApi == nullptr) {
-        LOC_LOGE("%s]: failed to create mApi", __FUNCTION__);
-        return false;
-    }
-
-    if (mGnssBatchingCbIface != nullptr) {
-        mGnssBatchingCbIface->unlinkToDeath(mGnssBatchingDeathRecipient);
-    }
-    mGnssBatchingCbIface = callback;
-    if (mGnssBatchingCbIface != nullptr) {
-        mGnssBatchingCbIface->linkToDeath(mGnssBatchingDeathRecipient, 0 /*cookie*/);
-    }
-
-    return true;
-}
-
-Return<uint16_t> GnssBatching::getBatchSize() {
-    uint16_t ret = 0;
-    if (mApi == nullptr) {
-        LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
-    } else {
-        ret = mApi->getBatchSize();
-    }
-    return ret;
-}
-
-Return<bool> GnssBatching::start(const IGnssBatching::Options& options) {
-    bool ret = false;
-    if (mApi == nullptr) {
-        LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
-    } else {
-        ret = mApi->startSession(options);
-    }
-    return ret;
-}
-
-Return<void> GnssBatching::flush() {
-    if (mApi == nullptr) {
-        LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
-    } else {
-        mApi->flushBatchedLocations();
-    }
-    return Void();
-}
-
-Return<bool> GnssBatching::stop() {
-    bool ret = false;
-    if (mApi == nullptr) {
-        LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
-    } else {
-        ret = mApi->stopSession();
-    }
-    return ret;
-}
-
-Return<void> GnssBatching::cleanup() {
-    if (mGnssBatchingCbIface != nullptr) {
-        mGnssBatchingCbIface->unlinkToDeath(mGnssBatchingDeathRecipient);
-    }
-    return Void();
-}
-
-}  // namespace implementation
-}  // namespace V1_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
diff --git a/gps/android/1.0/GnssBatching.h b/gps/android/1.0/GnssBatching.h
deleted file mode 100644
index 8fab857..0000000
--- a/gps/android/1.0/GnssBatching.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-#ifndef ANDROID_HARDWARE_GNSS_V1_0_GNSSBATCHING_H
-#define ANDROID_HARDWARE_GNSS_V1_0_GNSSBATCHING_H
-
-#include <android/hardware/gnss/1.0/IGnssBatching.h>
-#include <hidl/Status.h>
-
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_0 {
-namespace implementation {
-
-using ::android::hardware::gnss::V1_0::IGnssBatching;
-using ::android::hardware::gnss::V1_0::IGnssBatchingCallback;
-using ::android::hidl::base::V1_0::IBase;
-using ::android::hardware::hidl_array;
-using ::android::hardware::hidl_memory;
-using ::android::hardware::hidl_string;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::sp;
-
-class BatchingAPIClient;
-struct GnssBatching : public IGnssBatching {
-    GnssBatching();
-    ~GnssBatching();
-
-    // Methods from ::android::hardware::gnss::V1_0::IGnssBatching follow.
-    Return<bool> init(const sp<IGnssBatchingCallback>& callback) override;
-    Return<uint16_t> getBatchSize() override;
-    Return<bool> start(const IGnssBatching::Options& options ) override;
-    Return<void> flush() override;
-    Return<bool> stop() override;
-    Return<void> cleanup() override;
-
- private:
-    struct GnssBatchingDeathRecipient : hidl_death_recipient {
-        GnssBatchingDeathRecipient(sp<GnssBatching> gnssBatching) :
-            mGnssBatching(gnssBatching) {
-        }
-        ~GnssBatchingDeathRecipient() = default;
-        virtual void serviceDied(uint64_t cookie, const wp<IBase>& who) override;
-        sp<GnssBatching> mGnssBatching;
-    };
-
- private:
-    sp<GnssBatchingDeathRecipient> mGnssBatchingDeathRecipient = nullptr;
-    sp<IGnssBatchingCallback> mGnssBatchingCbIface = nullptr;
-    BatchingAPIClient* mApi = nullptr;
-};
-
-}  // namespace implementation
-}  // namespace V1_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
-
-#endif  // ANDROID_HARDWARE_GNSS_V1_0_GNSSBATCHING_H
diff --git a/gps/android/1.0/GnssConfiguration.cpp b/gps/android/1.0/GnssConfiguration.cpp
deleted file mode 100644
index a7f64fa..0000000
--- a/gps/android/1.0/GnssConfiguration.cpp
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-#define LOG_TAG "LocSvc_GnssConfigurationInterface"
-
-#include <log_util.h>
-#include "Gnss.h"
-#include "GnssConfiguration.h"
-#include <android/hardware/gnss/1.0/types.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_0 {
-namespace implementation {
-
-using ::android::hardware::gnss::V1_0::GnssConstellationType;
-
-GnssConfiguration::GnssConfiguration(Gnss* gnss) : mGnss(gnss) {
-}
-
-// Methods from ::android::hardware::gps::V1_0::IGnssConfiguration follow.
-Return<bool> GnssConfiguration::setSuplEs(bool enabled)  {
-    if (mGnss == nullptr) {
-        LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__);
-        return false;
-    }
-
-    GnssConfig config;
-    memset(&config, 0, sizeof(GnssConfig));
-    config.size = sizeof(GnssConfig);
-    config.flags = GNSS_CONFIG_FLAGS_SUPL_EM_SERVICES_BIT;
-    config.suplEmergencyServices = (enabled ?
-            GNSS_CONFIG_SUPL_EMERGENCY_SERVICES_YES :
-            GNSS_CONFIG_SUPL_EMERGENCY_SERVICES_NO);
-
-    return mGnss->updateConfiguration(config);
-}
-
-Return<bool> GnssConfiguration::setSuplVersion(uint32_t version)  {
-    if (mGnss == nullptr) {
-        LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__);
-        return false;
-    }
-
-    GnssConfig config;
-    memset(&config, 0, sizeof(GnssConfig));
-    config.size = sizeof(GnssConfig);
-    config.flags = GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT;
-    switch (version) {
-        case 0x00020004:
-            config.suplVersion = GNSS_CONFIG_SUPL_VERSION_2_0_4;
-            break;
-        case 0x00020002:
-            config.suplVersion = GNSS_CONFIG_SUPL_VERSION_2_0_2;
-            break;
-        case 0x00020000:
-            config.suplVersion = GNSS_CONFIG_SUPL_VERSION_2_0_0;
-            break;
-        case 0x00010000:
-            config.suplVersion = GNSS_CONFIG_SUPL_VERSION_1_0_0;
-            break;
-        default:
-            LOC_LOGE("%s]: invalid version: 0x%x.", __FUNCTION__, version);
-            return false;
-    }
-
-    return mGnss->updateConfiguration(config);
-}
-
-Return<bool> GnssConfiguration::setSuplMode(uint8_t mode)  {
-    if (mGnss == nullptr) {
-        LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__);
-        return false;
-    }
-
-    GnssConfig config;
-    memset(&config, 0, sizeof(GnssConfig));
-    config.size = sizeof(GnssConfig);
-    config.flags = GNSS_CONFIG_FLAGS_SUPL_MODE_BIT;
-    switch (mode) {
-        case 0:
-            config.suplModeMask = 0; // STANDALONE ONLY
-            break;
-        case 1:
-            config.suplModeMask = GNSS_CONFIG_SUPL_MODE_MSB_BIT;
-            break;
-        case 2:
-            config.suplModeMask = GNSS_CONFIG_SUPL_MODE_MSA_BIT;
-            break;
-        case 3:
-            config.suplModeMask = GNSS_CONFIG_SUPL_MODE_MSB_BIT | GNSS_CONFIG_SUPL_MODE_MSA_BIT;
-            break;
-        default:
-            LOC_LOGE("%s]: invalid mode: %d.", __FUNCTION__, mode);
-            return false;
-    }
-
-    return mGnss->updateConfiguration(config);
-}
-
-Return<bool> GnssConfiguration::setLppProfile(uint8_t lppProfileMask) {
-    if (mGnss == nullptr) {
-        LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__);
-        return false;
-    }
-
-    GnssConfig config = {};
-    config.size = sizeof(GnssConfig);
-    config.flags = GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT;
-    config.lppProfileMask = GNSS_CONFIG_LPP_PROFILE_RRLP_ON_LTE; //default
-
-    if (lppProfileMask & (1<<0)) {
-        config.lppProfileMask |= GNSS_CONFIG_LPP_PROFILE_USER_PLANE_BIT;
-    }
-    if (lppProfileMask & (1<<1)) {
-        config.lppProfileMask |= GNSS_CONFIG_LPP_PROFILE_CONTROL_PLANE_BIT;
-    }
-    if (lppProfileMask & (1<<2)) {
-        config.lppProfileMask |= GNSS_CONFIG_LPP_PROFILE_USER_PLANE_OVER_NR5G_SA_BIT;
-    }
-    if (lppProfileMask & (1<<3)) {
-        config.lppProfileMask |= GNSS_CONFIG_LPP_PROFILE_CONTROL_PLANE_OVER_NR5G_SA_BIT;
-    }
-
-    return mGnss->updateConfiguration(config);
-}
-
-Return<bool> GnssConfiguration::setGlonassPositioningProtocol(uint8_t protocol) {
-    if (mGnss == nullptr) {
-        LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__);
-        return false;
-    }
-
-    GnssConfig config;
-    memset(&config, 0, sizeof(GnssConfig));
-    config.size = sizeof(GnssConfig);
-
-    config.flags = GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT;
-    if (protocol & (1<<0)) {
-        config.aGlonassPositionProtocolMask |= GNSS_CONFIG_RRC_CONTROL_PLANE_BIT;
-    }
-    if (protocol & (1<<1)) {
-        config.aGlonassPositionProtocolMask |= GNSS_CONFIG_RRLP_USER_PLANE_BIT;
-    }
-    if (protocol & (1<<2)) {
-        config.aGlonassPositionProtocolMask |= GNSS_CONFIG_LLP_USER_PLANE_BIT;
-    }
-    if (protocol & (1<<3)) {
-        config.aGlonassPositionProtocolMask |= GNSS_CONFIG_LLP_CONTROL_PLANE_BIT;
-    }
-
-    return mGnss->updateConfiguration(config);
-}
-
-Return<bool> GnssConfiguration::setGpsLock(uint8_t lock) {
-    if (mGnss == nullptr) {
-        LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__);
-        return false;
-    }
-
-    GnssConfig config;
-    memset(&config, 0, sizeof(GnssConfig));
-    config.size = sizeof(GnssConfig);
-    config.flags = GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT;
-    switch (lock) {
-        case 0:
-            config.gpsLock = GNSS_CONFIG_GPS_LOCK_NONE;
-            break;
-        case 1:
-            config.gpsLock = GNSS_CONFIG_GPS_LOCK_MO;
-            break;
-        case 2:
-            config.gpsLock = GNSS_CONFIG_GPS_LOCK_NI;
-            break;
-        case 3:
-            config.gpsLock = GNSS_CONFIG_GPS_LOCK_MO_AND_NI;
-            break;
-        default:
-            LOC_LOGE("%s]: invalid lock: %d.", __FUNCTION__, lock);
-            return false;
-    }
-
-    return mGnss->updateConfiguration(config);
-}
-
-Return<bool> GnssConfiguration::setEmergencySuplPdn(bool enabled) {
-    if (mGnss == nullptr) {
-        LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__);
-        return false;
-    }
-
-    GnssConfig config;
-    memset(&config, 0, sizeof(GnssConfig));
-    config.size = sizeof(GnssConfig);
-    config.flags = GNSS_CONFIG_FLAGS_EM_PDN_FOR_EM_SUPL_VALID_BIT;
-    config.emergencyPdnForEmergencySupl = (enabled ?
-            GNSS_CONFIG_EMERGENCY_PDN_FOR_EMERGENCY_SUPL_YES :
-            GNSS_CONFIG_EMERGENCY_PDN_FOR_EMERGENCY_SUPL_NO);
-
-    return mGnss->updateConfiguration(config);
-}
-
-}  // namespace implementation
-}  // namespace V1_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
diff --git a/gps/android/1.0/GnssConfiguration.h b/gps/android/1.0/GnssConfiguration.h
deleted file mode 100644
index d0e2ba8..0000000
--- a/gps/android/1.0/GnssConfiguration.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-
- /* 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.
- */
-
-
-#ifndef ANDROID_HARDWARE_GNSS_V1_0_GNSSCONFIGURATION_H
-#define ANDROID_HARDWARE_GNSS_V1_0_GNSSCONFIGURATION_H
-
-#include <android/hardware/gnss/1.0/IGnssConfiguration.h>
-#include <hidl/Status.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_0 {
-namespace implementation {
-
-using ::android::hardware::gnss::V1_0::IGnssConfiguration;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::sp;
-
-/*
- * Interface for passing GNSS configuration info from platform to HAL.
- */
-struct Gnss;
-struct GnssConfiguration : public IGnssConfiguration {
-    GnssConfiguration(Gnss* gnss);
-    ~GnssConfiguration() = default;
-
-    /*
-     * Methods from ::android::hardware::gnss::V1_0::IGnssConfiguration follow.
-     * These declarations were generated from IGnssConfiguration.hal.
-     */
-    Return<bool> setSuplVersion(uint32_t version) override;
-    Return<bool> setSuplMode(uint8_t mode) override;
-    Return<bool> setSuplEs(bool enabled) override;
-    Return<bool> setLppProfile(uint8_t lppProfileMask) override;
-    Return<bool> setGlonassPositioningProtocol(uint8_t protocol) override;
-    Return<bool> setEmergencySuplPdn(bool enable) override;
-    Return<bool> setGpsLock(uint8_t lock) override;
-
- private:
-    Gnss* mGnss = nullptr;
-};
-
-}  // namespace implementation
-}  // namespace V1_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
-
-#endif  // ANDROID_HARDWARE_GNSS_V1_0_GNSSCONFIGURATION_H
diff --git a/gps/android/1.0/GnssDebug.cpp b/gps/android/1.0/GnssDebug.cpp
deleted file mode 100644
index ead72e1..0000000
--- a/gps/android/1.0/GnssDebug.cpp
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "LocSvc_GnssDebugInterface"
-
-#include <log/log.h>
-#include <log_util.h>
-#include "Gnss.h"
-#include "GnssDebug.h"
-#include "LocationUtil.h"
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_0 {
-namespace implementation {
-
-using ::android::hardware::hidl_vec;
-
-#define GNSS_DEBUG_UNKNOWN_HORIZONTAL_ACCURACY_METERS (20000000)
-#define GNSS_DEBUG_UNKNOWN_VERTICAL_ACCURACY_METERS   (20000)
-#define GNSS_DEBUG_UNKNOWN_SPEED_ACCURACY_PER_SEC     (500)
-#define GNSS_DEBUG_UNKNOWN_BEARING_ACCURACY_DEG       (180)
-
-#define GNSS_DEBUG_UNKNOWN_UTC_TIME            (1483228800000LL) // 1/1/2017 00:00 GMT
-#define GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC        (1.57783680E17) // 5 years in ns
-#define GNSS_DEBUG_UNKNOWN_FREQ_UNC_NS_PER_SEC (2.0e5)  // ppm
-
-GnssDebug::GnssDebug(Gnss* gnss) : mGnss(gnss)
-{
-}
-
-/*
- * This methods requests position, time and satellite ephemeris debug information
- * from the HAL.
- *
- * @return void
-*/
-Return<void> GnssDebug::getDebugData(getDebugData_cb _hidl_cb)
-{
-    LOC_LOGD("%s]: ", __func__);
-
-    DebugData data = { };
-
-    if((nullptr == mGnss) || (nullptr == mGnss->getGnssInterface())){
-        LOC_LOGE("GnssDebug - Null GNSS interface");
-        _hidl_cb(data);
-        return Void();
-    }
-
-    // get debug report snapshot via hal interface
-    GnssDebugReport reports = { };
-    mGnss->getGnssInterface()->getDebugReport(reports);
-
-    // location block
-    if (reports.mLocation.mValid) {
-        data.position.valid = true;
-        data.position.latitudeDegrees = reports.mLocation.mLocation.latitude;
-        data.position.longitudeDegrees = reports.mLocation.mLocation.longitude;
-        data.position.altitudeMeters = reports.mLocation.mLocation.altitude;
-
-        data.position.speedMetersPerSec =
-            (double)(reports.mLocation.mLocation.speed);
-        data.position.bearingDegrees =
-            (double)(reports.mLocation.mLocation.bearing);
-        data.position.horizontalAccuracyMeters =
-            (double)(reports.mLocation.mLocation.accuracy);
-        data.position.verticalAccuracyMeters =
-            reports.mLocation.verticalAccuracyMeters;
-        data.position.speedAccuracyMetersPerSecond =
-            reports.mLocation.speedAccuracyMetersPerSecond;
-        data.position.bearingAccuracyDegrees =
-            reports.mLocation.bearingAccuracyDegrees;
-
-        timeval tv_now, tv_report;
-        tv_report.tv_sec  = reports.mLocation.mUtcReported.tv_sec;
-        tv_report.tv_usec = reports.mLocation.mUtcReported.tv_nsec / 1000ULL;
-        gettimeofday(&tv_now, NULL);
-        data.position.ageSeconds =
-            (tv_now.tv_sec - tv_report.tv_sec) +
-            (float)((tv_now.tv_usec - tv_report.tv_usec)) / 1000000;
-    }
-    else {
-        data.position.valid = false;
-    }
-
-    if (data.position.horizontalAccuracyMeters <= 0 ||
-        data.position.horizontalAccuracyMeters > GNSS_DEBUG_UNKNOWN_HORIZONTAL_ACCURACY_METERS) {
-        data.position.horizontalAccuracyMeters = GNSS_DEBUG_UNKNOWN_HORIZONTAL_ACCURACY_METERS;
-    }
-    if (data.position.verticalAccuracyMeters <= 0 ||
-        data.position.verticalAccuracyMeters > GNSS_DEBUG_UNKNOWN_VERTICAL_ACCURACY_METERS) {
-        data.position.verticalAccuracyMeters = GNSS_DEBUG_UNKNOWN_VERTICAL_ACCURACY_METERS;
-    }
-    if (data.position.speedAccuracyMetersPerSecond <= 0 ||
-        data.position.speedAccuracyMetersPerSecond > GNSS_DEBUG_UNKNOWN_SPEED_ACCURACY_PER_SEC) {
-        data.position.speedAccuracyMetersPerSecond = GNSS_DEBUG_UNKNOWN_SPEED_ACCURACY_PER_SEC;
-    }
-    if (data.position.bearingAccuracyDegrees <= 0 ||
-        data.position.bearingAccuracyDegrees > GNSS_DEBUG_UNKNOWN_BEARING_ACCURACY_DEG) {
-        data.position.bearingAccuracyDegrees = GNSS_DEBUG_UNKNOWN_BEARING_ACCURACY_DEG;
-    }
-
-    // time block
-    if (reports.mTime.mValid) {
-        data.time.timeEstimate = reports.mTime.timeEstimate;
-        data.time.timeUncertaintyNs = reports.mTime.timeUncertaintyNs;
-        data.time.frequencyUncertaintyNsPerSec =
-            reports.mTime.frequencyUncertaintyNsPerSec;
-    }
-
-    if (data.time.timeEstimate < GNSS_DEBUG_UNKNOWN_UTC_TIME) {
-        data.time.timeEstimate = GNSS_DEBUG_UNKNOWN_UTC_TIME;
-    }
-    if (data.time.timeUncertaintyNs <= 0 ||
-        data.time.timeUncertaintyNs > (float)GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC) {
-        data.time.timeUncertaintyNs = (float)GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC;
-    }
-    if (data.time.frequencyUncertaintyNsPerSec <= 0 ||
-        data.time.frequencyUncertaintyNsPerSec > (float)GNSS_DEBUG_UNKNOWN_FREQ_UNC_NS_PER_SEC) {
-        data.time.frequencyUncertaintyNsPerSec = (float)GNSS_DEBUG_UNKNOWN_FREQ_UNC_NS_PER_SEC;
-    }
-
-    // satellite data block
-    SatelliteData s = { };
-    std::vector<SatelliteData> s_array = { };
-
-    for (uint32_t i=0; i<reports.mSatelliteInfo.size(); i++) {
-        memset(&s, 0, sizeof(s));
-        s.svid = reports.mSatelliteInfo[i].svid;
-        convertGnssConstellationType(
-            reports.mSatelliteInfo[i].constellation, s.constellation);
-        convertGnssEphemerisType(
-            reports.mSatelliteInfo[i].mEphemerisType, s.ephemerisType);
-        convertGnssEphemerisSource(
-            reports.mSatelliteInfo[i].mEphemerisSource, s.ephemerisSource);
-        convertGnssEphemerisHealth(
-            reports.mSatelliteInfo[i].mEphemerisHealth, s.ephemerisHealth);
-
-        s.ephemerisAgeSeconds =
-            reports.mSatelliteInfo[i].ephemerisAgeSeconds;
-        s.serverPredictionIsAvailable =
-            reports.mSatelliteInfo[i].serverPredictionIsAvailable;
-        s.serverPredictionAgeSeconds =
-            reports.mSatelliteInfo[i].serverPredictionAgeSeconds;
-
-        s_array.push_back(s);
-    }
-    data.satelliteDataArray = s_array;
-
-    // callback HIDL with collected debug data
-    _hidl_cb(data);
-    return Void();
-}
-
-}  // namespace implementation
-}  // namespace V1_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
diff --git a/gps/android/1.0/GnssDebug.h b/gps/android/1.0/GnssDebug.h
deleted file mode 100644
index a7116cb..0000000
--- a/gps/android/1.0/GnssDebug.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_GNSS_V1_0_GNSSDEBUG_H
-#define ANDROID_HARDWARE_GNSS_V1_0_GNSSDEBUG_H
-
-
-#include <android/hardware/gnss/1.0/IGnssDebug.h>
-#include <hidl/Status.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_0 {
-namespace implementation {
-
-using ::android::hardware::gnss::V1_0::IGnssDebug;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::sp;
-
-/* Interface for GNSS Debug support. */
-struct Gnss;
-struct GnssDebug : public IGnssDebug {
-    GnssDebug(Gnss* gnss);
-    ~GnssDebug() {};
-
-    /*
-     * Methods from ::android::hardware::gnss::V1_0::IGnssDebug follow.
-     * These declarations were generated from IGnssDebug.hal.
-     */
-    Return<void> getDebugData(getDebugData_cb _hidl_cb) override;
-
-private:
-    Gnss* mGnss = nullptr;
-};
-
-}  // namespace implementation
-}  // namespace V1_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
-
-#endif  // ANDROID_HARDWARE_GNSS_V1_0_GNSSDEBUG_H
diff --git a/gps/android/1.0/GnssGeofencing.cpp b/gps/android/1.0/GnssGeofencing.cpp
deleted file mode 100644
index 4be6d8a..0000000
--- a/gps/android/1.0/GnssGeofencing.cpp
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-#define LOG_TAG "GnssHal_GnssGeofencing"
-
-#include <log_util.h>
-#include <GeofenceAPIClient.h>
-#include "GnssGeofencing.h"
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_0 {
-namespace implementation {
-
-void GnssGeofencing::GnssGeofencingDeathRecipient::serviceDied(
-        uint64_t cookie, const wp<IBase>& who) {
-    LOC_LOGE("%s] service died. cookie: %llu, who: %p",
-            __FUNCTION__, static_cast<unsigned long long>(cookie), &who);
-    if (mGnssGeofencing != nullptr) {
-        mGnssGeofencing->removeAllGeofences();
-    }
-}
-
-GnssGeofencing::GnssGeofencing() : mApi(nullptr) {
-    mGnssGeofencingDeathRecipient = new GnssGeofencingDeathRecipient(this);
-}
-
-GnssGeofencing::~GnssGeofencing() {
-    if (mApi != nullptr) {
-        mApi->destroy();
-        mApi = nullptr;
-    }
-}
-
-// Methods from ::android::hardware::gnss::V1_0::IGnssGeofencing follow.
-Return<void> GnssGeofencing::setCallback(const sp<IGnssGeofenceCallback>& callback)  {
-    if (mApi != nullptr) {
-        LOC_LOGE("%s]: mApi is NOT nullptr", __FUNCTION__);
-        return Void();
-    }
-
-    mApi = new GeofenceAPIClient(callback);
-    if (mApi == nullptr) {
-        LOC_LOGE("%s]: failed to create mApi", __FUNCTION__);
-    }
-
-    if (mGnssGeofencingCbIface != nullptr) {
-        mGnssGeofencingCbIface->unlinkToDeath(mGnssGeofencingDeathRecipient);
-    }
-    mGnssGeofencingCbIface = callback;
-    if (mGnssGeofencingCbIface != nullptr) {
-        mGnssGeofencingCbIface->linkToDeath(mGnssGeofencingDeathRecipient, 0 /*cookie*/);
-    }
-
-    return Void();
-}
-
-Return<void> GnssGeofencing::addGeofence(
-        int32_t geofenceId,
-        double latitudeDegrees,
-        double longitudeDegrees,
-        double radiusMeters,
-        IGnssGeofenceCallback::GeofenceTransition lastTransition,
-        int32_t monitorTransitions,
-        uint32_t notificationResponsivenessMs,
-        uint32_t unknownTimerMs)  {
-    if (mApi == nullptr) {
-        LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
-    } else {
-        mApi->geofenceAdd(
-                geofenceId,
-                latitudeDegrees,
-                longitudeDegrees,
-                radiusMeters,
-                static_cast<int32_t>(lastTransition),
-                monitorTransitions,
-                notificationResponsivenessMs,
-                unknownTimerMs);
-    }
-    return Void();
-}
-
-Return<void> GnssGeofencing::pauseGeofence(int32_t geofenceId)  {
-    if (mApi == nullptr) {
-        LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
-    } else {
-        mApi->geofencePause(geofenceId);
-    }
-    return Void();
-}
-
-Return<void> GnssGeofencing::resumeGeofence(int32_t geofenceId, int32_t monitorTransitions)  {
-    if (mApi == nullptr) {
-        LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
-    } else {
-        mApi->geofenceResume(geofenceId, monitorTransitions);
-    }
-    return Void();
-}
-
-Return<void> GnssGeofencing::removeGeofence(int32_t geofenceId)  {
-    if (mApi == nullptr) {
-        LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
-    } else {
-        mApi->geofenceRemove(geofenceId);
-    }
-    return Void();
-}
-
-Return<void> GnssGeofencing::removeAllGeofences()  {
-    if (mApi == nullptr) {
-        LOC_LOGD("%s]: mApi is nullptr, do nothing", __FUNCTION__);
-    } else {
-        mApi->geofenceRemoveAll();
-    }
-    return Void();
-}
-
-}  // namespace implementation
-}  // namespace V1_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
diff --git a/gps/android/1.0/GnssGeofencing.h b/gps/android/1.0/GnssGeofencing.h
deleted file mode 100644
index db5f9d2..0000000
--- a/gps/android/1.0/GnssGeofencing.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-#ifndef ANDROID_HARDWARE_GNSS_V1_0_GNSSGEOFENCING_H
-#define ANDROID_HARDWARE_GNSS_V1_0_GNSSGEOFENCING_H
-
-#include <android/hardware/gnss/1.0/IGnssGeofencing.h>
-#include <hidl/Status.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_0 {
-namespace implementation {
-
-using ::android::hardware::gnss::V1_0::IGnssGeofenceCallback;
-using ::android::hardware::gnss::V1_0::IGnssGeofencing;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::sp;
-
-class GeofenceAPIClient;
-struct GnssGeofencing : public IGnssGeofencing {
-    GnssGeofencing();
-    ~GnssGeofencing();
-
-    /*
-     * Methods from ::android::hardware::gnss::V1_0::IGnssGeofencing follow.
-     * These declarations were generated from IGnssGeofencing.hal.
-     */
-    Return<void> setCallback(const sp<IGnssGeofenceCallback>& callback)  override;
-    Return<void> addGeofence(int32_t geofenceId,
-                             double latitudeDegrees,
-                             double longitudeDegrees,
-                             double radiusMeters,
-                             IGnssGeofenceCallback::GeofenceTransition lastTransition,
-                             int32_t monitorTransitions,
-                             uint32_t notificationResponsivenessMs,
-                             uint32_t unknownTimerMs)  override;
-
-    Return<void> pauseGeofence(int32_t geofenceId)  override;
-    Return<void> resumeGeofence(int32_t geofenceId, int32_t monitorTransitions)  override;
-    Return<void> removeGeofence(int32_t geofenceId)  override;
-
- private:
-    // This method is not part of the IGnss base class.
-    // It is called by GnssGeofencingDeathRecipient to remove all geofences added so far.
-    Return<void> removeAllGeofences();
-
- private:
-    struct GnssGeofencingDeathRecipient : hidl_death_recipient {
-        GnssGeofencingDeathRecipient(sp<GnssGeofencing> gnssGeofencing) :
-            mGnssGeofencing(gnssGeofencing) {
-        }
-        ~GnssGeofencingDeathRecipient() = default;
-        virtual void serviceDied(uint64_t cookie, const wp<IBase>& who) override;
-        sp<GnssGeofencing> mGnssGeofencing;
-    };
-
- private:
-    sp<GnssGeofencingDeathRecipient> mGnssGeofencingDeathRecipient = nullptr;
-    sp<IGnssGeofenceCallback> mGnssGeofencingCbIface = nullptr;
-    GeofenceAPIClient* mApi = nullptr;
-};
-
-}  // namespace implementation
-}  // namespace V1_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
-
-#endif  // ANDROID_HARDWARE_GNSS_V1_0_GNSSGEOFENCING_H
diff --git a/gps/android/1.0/GnssMeasurement.cpp b/gps/android/1.0/GnssMeasurement.cpp
deleted file mode 100644
index e24e1d2..0000000
--- a/gps/android/1.0/GnssMeasurement.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-/* ​​​​​Changes from Qualcomm Innovation Center are provided under the following license:
- * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
- * SPDX-License-Identifier: BSD-3-Clause-Clear
- */
-
-#define LOG_TAG "LocSvc_GnssMeasurementInterface"
-
-#include <log_util.h>
-#include <GnssMeasurement.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_0 {
-namespace implementation {
-
-void GnssMeasurement::GnssMeasurementDeathRecipient::serviceDied(
-        uint64_t cookie, const wp<IBase>& who) {
-    LOC_LOGE("%s] service died. cookie: %llu, who: %p",
-            __FUNCTION__, static_cast<unsigned long long>(cookie), &who);
-    if (mGnssMeasurement != nullptr) {
-        mGnssMeasurement->close();
-    }
-}
-
-GnssMeasurement::GnssMeasurement() {
-    mGnssMeasurementDeathRecipient = new GnssMeasurementDeathRecipient(this);
-    mApi = new MeasurementAPIClient();
-}
-
-GnssMeasurement::~GnssMeasurement() {
-    if (mApi) {
-        mApi->destroy();
-        mApi = nullptr;
-    }
-}
-
-// Methods from ::android::hardware::gnss::V1_0::IGnssMeasurement follow.
-Return<GnssMeasurement::GnssMeasurementStatus> GnssMeasurement::setCallback(
-        const sp<V1_0::IGnssMeasurementCallback>& callback)  {
-    return setCallback(callback, mGnssMeasurementCbIface, GNSS_POWER_MODE_INVALID);
-}
-
-template <typename T>
-Return<IGnssMeasurement::GnssMeasurementStatus> GnssMeasurement::setCallback(
-        const sp<T>& callback, sp<T>& myCallback, GnssPowerMode powerMode) {
-    Return<GnssMeasurement::GnssMeasurementStatus> ret =
-            IGnssMeasurement::GnssMeasurementStatus::ERROR_GENERIC;
-    if (mApi == nullptr) {
-        LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
-        return ret;
-    }
-    if (myCallback != callback) {
-        if (nullptr == callback) {
-            LOC_LOGE("%s]: callback is nullptr", __FUNCTION__);
-            mApi->measurementSetCallback(callback);
-            close();
-        } else {
-            if (nullptr != myCallback) {
-                myCallback->unlinkToDeath(mGnssMeasurementDeathRecipient);
-            }
-            myCallback = callback;
-            myCallback->linkToDeath(mGnssMeasurementDeathRecipient, 0);
-            ret = mApi->measurementSetCallback(callback, powerMode);
-        }
-    }
-
-    return ret;
-}
-
-Return<void> GnssMeasurement::close()  {
-    if (mApi != nullptr) {
-        mApi->measurementSetCallback<V1_0::IGnssMeasurementCallback>(nullptr);
-    }
-
-    if (mGnssMeasurementCbIface != nullptr) {
-        mGnssMeasurementCbIface->unlinkToDeath(mGnssMeasurementDeathRecipient);
-        mGnssMeasurementCbIface = nullptr;
-    }
-
-    return Void();
-}
-
-}  // namespace implementation
-}  // namespace V1_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
diff --git a/gps/android/1.0/GnssMeasurement.h b/gps/android/1.0/GnssMeasurement.h
deleted file mode 100644
index 245c697..0000000
--- a/gps/android/1.0/GnssMeasurement.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-/* ​​​​​Changes from Qualcomm Innovation Center are provided under the following license:
- * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
- * SPDX-License-Identifier: BSD-3-Clause-Clear
- */
-
-#ifndef ANDROID_HARDWARE_GNSS_V1_0_GNSSMEASUREMENT_H
-#define ANDROID_HARDWARE_GNSS_V1_0_GNSSMEASUREMENT_H
-
-#include <android/hardware/gnss/1.0/IGnssMeasurement.h>
-#include <hidl/MQDescriptor.h>
-#include <hidl/Status.h>
-#include "MeasurementAPIClient.h"
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_0 {
-namespace implementation {
-
-using ::android::hardware::gnss::V1_0::IGnssMeasurement;
-using ::android::hardware::gnss::V1_0::IGnssMeasurementCallback;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::sp;
-
-class MeasurementAPIClient;
-struct GnssMeasurement : public IGnssMeasurement {
-    GnssMeasurement();
-    ~GnssMeasurement();
-
-    /*
-     * Methods from ::android::hardware::gnss::V1_0::IGnssMeasurement follow.
-     * These declarations were generated from IGnssMeasurement.hal.
-     */
-    Return<GnssMeasurement::GnssMeasurementStatus> setCallback(
-        const sp<V1_0::IGnssMeasurementCallback>& callback) override;
-    Return<void> close() override;
-
- private:
-    struct GnssMeasurementDeathRecipient : hidl_death_recipient {
-        GnssMeasurementDeathRecipient(sp<GnssMeasurement> gnssMeasurement) :
-            mGnssMeasurement(gnssMeasurement) {
-        }
-        ~GnssMeasurementDeathRecipient() = default;
-        virtual void serviceDied(uint64_t cookie, const wp<IBase>& who) override;
-        sp<GnssMeasurement> mGnssMeasurement;
-    };
-
-    template <typename T>
-    Return<IGnssMeasurement::GnssMeasurementStatus> setCallback(
-            const sp<T>& callback, sp<T>& myCallback, GnssPowerMode powerMode);
-    sp<GnssMeasurementDeathRecipient> mGnssMeasurementDeathRecipient = nullptr;
-    sp<V1_0::IGnssMeasurementCallback> mGnssMeasurementCbIface = nullptr;
-    MeasurementAPIClient* mApi;
-};
-
-}  // namespace implementation
-}  // namespace V1_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
-
-#endif  // ANDROID_HARDWARE_GNSS_V1_0_GNSSMEASUREMENT_H
diff --git a/gps/android/1.0/GnssNi.cpp b/gps/android/1.0/GnssNi.cpp
deleted file mode 100644
index d06cc20..0000000
--- a/gps/android/1.0/GnssNi.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-#define LOG_TAG "LocSvc_GnssNiInterface"
-
-#include <log_util.h>
-#include "Gnss.h"
-#include "GnssNi.h"
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_0 {
-namespace implementation {
-
-void GnssNi::GnssNiDeathRecipient::serviceDied(uint64_t cookie, const wp<IBase>& who) {
-    LOC_LOGE("%s] service died. cookie: %llu, who: %p",
-            __FUNCTION__, static_cast<unsigned long long>(cookie), &who);
-    // we do nothing here
-    // Gnss::GnssDeathRecipient will stop the session
-}
-
-GnssNi::GnssNi(Gnss* gnss) : mGnss(gnss) {
-    mGnssNiDeathRecipient = new GnssNiDeathRecipient(this);
-}
-
-// Methods from ::android::hardware::gnss::V1_0::IGnssNi follow.
-Return<void> GnssNi::setCallback(const sp<IGnssNiCallback>& callback)  {
-    if (mGnss == nullptr) {
-        LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__);
-        return Void();
-    }
-
-    mGnss->setGnssNiCb(callback);
-
-    if (mGnssNiCbIface != nullptr) {
-        mGnssNiCbIface->unlinkToDeath(mGnssNiDeathRecipient);
-    }
-    mGnssNiCbIface = callback;
-    if (mGnssNiCbIface != nullptr) {
-        mGnssNiCbIface->linkToDeath(mGnssNiDeathRecipient, 0 /*cookie*/);
-    }
-
-    return Void();
-}
-
-Return<void> GnssNi::respond(int32_t notifId, IGnssNiCallback::GnssUserResponseType userResponse)  {
-    if (mGnss == nullptr) {
-        LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__);
-        return Void();
-    }
-
-    GnssAPIClient* api = mGnss->getApi();
-    if (api == nullptr) {
-        LOC_LOGE("%s]: api is nullptr", __FUNCTION__);
-        return Void();
-    }
-
-    api->gnssNiRespond(notifId, userResponse);
-
-    return Void();
-}
-
-}  // namespace implementation
-}  // namespace V1_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
diff --git a/gps/android/1.0/GnssNi.h b/gps/android/1.0/GnssNi.h
deleted file mode 100644
index 90f62d5..0000000
--- a/gps/android/1.0/GnssNi.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-#ifndef ANDROID_HARDWARE_GNSS_V1_0_GNSSNI_H
-#define ANDROID_HARDWARE_GNSS_V1_0_GNSSNI_H
-
-#include <android/hardware/gnss/1.0/IGnssNi.h>
-#include <hidl/Status.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_0 {
-namespace implementation {
-
-using ::android::hardware::gnss::V1_0::IGnssNi;
-using ::android::hardware::gnss::V1_0::IGnssNiCallback;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::sp;
-
-struct Gnss;
-struct GnssNi : public IGnssNi {
-    GnssNi(Gnss* gnss);
-    ~GnssNi() = default;
-
-    /*
-     * Methods from ::android::hardware::gnss::V1_0::IGnssNi follow.
-     * These declarations were generated from IGnssNi.hal.
-     */
-    Return<void> setCallback(const sp<IGnssNiCallback>& callback) override;
-    Return<void> respond(int32_t notifId,
-                         IGnssNiCallback::GnssUserResponseType userResponse) override;
-
- private:
-    struct GnssNiDeathRecipient : hidl_death_recipient {
-        GnssNiDeathRecipient(sp<GnssNi> gnssNi) : mGnssNi(gnssNi) {
-        }
-        ~GnssNiDeathRecipient() = default;
-        virtual void serviceDied(uint64_t cookie, const wp<IBase>& who) override;
-        sp<GnssNi> mGnssNi;
-    };
-
- private:
-    sp<GnssNiDeathRecipient> mGnssNiDeathRecipient = nullptr;
-    sp<IGnssNiCallback> mGnssNiCbIface = nullptr;
-    Gnss* mGnss = nullptr;
-};
-
-}  // namespace implementation
-}  // namespace V1_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
-
-#endif  // ANDROID_HARDWARE_GNSS_V1_0_GNSSNI_H
diff --git a/gps/android/1.0/android.hardware.gnss@1.0-service-qti.rc b/gps/android/1.0/android.hardware.gnss@1.0-service-qti.rc
deleted file mode 100644
index 1fbd893..0000000
--- a/gps/android/1.0/android.hardware.gnss@1.0-service-qti.rc
+++ /dev/null
@@ -1,4 +0,0 @@
-service gnss_service /vendor/bin/hw/android.hardware.gnss@1.0-service-qti
-    class hal
-    user gps
-    group system gps radio vendor_qti_diag
diff --git a/gps/android/1.0/android.hardware.gnss@1.0-service-qti.xml b/gps/android/1.0/android.hardware.gnss@1.0-service-qti.xml
deleted file mode 100644
index 46bcffb..0000000
--- a/gps/android/1.0/android.hardware.gnss@1.0-service-qti.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<!-- Copyright (c) 2019, The Linux Foundation. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-    * Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-    * Redistributions in binary form must reproduce the above
-      copyright notice, this list of conditions and the following
-      disclaimer in the documentation and/or other materials provided
-      with the distribution.
-    * Neither the name of The Linux Foundation nor the names of its
-      contributors may be used to endorse or promote products derived
-      from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
-WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
-ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
-BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
-BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
-IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--->
-<manifest version="1.0" type="device">
-    <hal format="hidl">
-        <name>android.hardware.gnss</name>
-        <transport>hwbinder</transport>
-        <fqname>@1.0::IGnss/default</fqname>
-    </hal>
-</manifest>
-
diff --git a/gps/android/1.0/location_api/BatchingAPIClient.cpp b/gps/android/1.0/location_api/BatchingAPIClient.cpp
deleted file mode 100644
index 94a234d..0000000
--- a/gps/android/1.0/location_api/BatchingAPIClient.cpp
+++ /dev/null
@@ -1,197 +0,0 @@
-/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- *       copyright notice, this list of conditions and the following
- *       disclaimer in the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of The Linux Foundation, nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#define LOG_NDEBUG 0
-#define LOG_TAG "LocSvc_BatchingAPIClient"
-
-#include <inttypes.h>
-#include <log_util.h>
-#include <loc_cfg.h>
-
-#include "LocationUtil.h"
-#include "BatchingAPIClient.h"
-
-#include "limits.h"
-
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_0 {
-namespace implementation {
-
-using ::android::hardware::gnss::V1_0::IGnssBatching;
-using ::android::hardware::gnss::V1_0::IGnssBatchingCallback;
-using ::android::hardware::gnss::V1_0::GnssLocation;
-
-static void convertBatchOption(const IGnssBatching::Options& in, LocationOptions& out,
-        LocationCapabilitiesMask mask);
-
-BatchingAPIClient::BatchingAPIClient(const sp<IGnssBatchingCallback>& callback) :
-    LocationAPIClientBase(),
-    mGnssBatchingCbIface(callback),
-    mDefaultId(UINT_MAX),
-    mLocationCapabilitiesMask(0)
-{
-    LOC_LOGD("%s]: (%p)", __FUNCTION__, &callback);
-
-    LocationCallbacks locationCallbacks;
-    memset(&locationCallbacks, 0, sizeof(LocationCallbacks));
-    locationCallbacks.size = sizeof(LocationCallbacks);
-
-    locationCallbacks.trackingCb = nullptr;
-    locationCallbacks.batchingCb = nullptr;
-    if (mGnssBatchingCbIface != nullptr) {
-        locationCallbacks.batchingCb = [this](size_t count, Location* location,
-            BatchingOptions batchOptions) {
-            onBatchingCb(count, location, batchOptions);
-        };
-    }
-    locationCallbacks.geofenceBreachCb = nullptr;
-    locationCallbacks.geofenceStatusCb = nullptr;
-    locationCallbacks.gnssLocationInfoCb = nullptr;
-    locationCallbacks.gnssNiCb = nullptr;
-    locationCallbacks.gnssSvCb = nullptr;
-    locationCallbacks.gnssNmeaCb = nullptr;
-    locationCallbacks.gnssMeasurementsCb = nullptr;
-
-    locAPISetCallbacks(locationCallbacks);
-}
-
-BatchingAPIClient::~BatchingAPIClient()
-{
-    LOC_LOGD("%s]: ()", __FUNCTION__);
-}
-
-int BatchingAPIClient::getBatchSize()
-{
-    LOC_LOGD("%s]: ()", __FUNCTION__);
-    return locAPIGetBatchSize();
-}
-
-int BatchingAPIClient::startSession(const IGnssBatching::Options& opts)
-{
-    LOC_LOGD("%s]: (%lld %d)", __FUNCTION__,
-            static_cast<long long>(opts.periodNanos), static_cast<uint8_t>(opts.flags));
-    int retVal = -1;
-    LocationOptions options;
-    convertBatchOption(opts, options, mLocationCapabilitiesMask);
-    uint32_t mode = 0;
-    if (opts.flags == static_cast<uint8_t>(IGnssBatching::Flag::WAKEUP_ON_FIFO_FULL)) {
-        mode = SESSION_MODE_ON_FULL;
-    }
-    if (locAPIStartSession(mDefaultId, mode, options) == LOCATION_ERROR_SUCCESS) {
-        retVal = 1;
-    }
-    return retVal;
-}
-
-int BatchingAPIClient::updateSessionOptions(const IGnssBatching::Options& opts)
-{
-    LOC_LOGD("%s]: (%lld %d)", __FUNCTION__,
-            static_cast<long long>(opts.periodNanos), static_cast<uint8_t>(opts.flags));
-    int retVal = -1;
-    LocationOptions options;
-    convertBatchOption(opts, options, mLocationCapabilitiesMask);
-
-    uint32_t mode = 0;
-    if (opts.flags == static_cast<uint8_t>(IGnssBatching::Flag::WAKEUP_ON_FIFO_FULL)) {
-        mode = SESSION_MODE_ON_FULL;
-    }
-    if (locAPIUpdateSessionOptions(mDefaultId, mode, options) == LOCATION_ERROR_SUCCESS) {
-        retVal = 1;
-    }
-    return retVal;
-}
-
-int BatchingAPIClient::stopSession()
-{
-    LOC_LOGD("%s]: ", __FUNCTION__);
-    int retVal = -1;
-    if (locAPIStopSession(mDefaultId) == LOCATION_ERROR_SUCCESS) {
-        retVal = 1;
-    }
-    return retVal;
-}
-
-void BatchingAPIClient::getBatchedLocation(int last_n_locations)
-{
-    LOC_LOGD("%s]: (%d)", __FUNCTION__, last_n_locations);
-    locAPIGetBatchedLocations(mDefaultId, last_n_locations);
-}
-
-void BatchingAPIClient::flushBatchedLocations()
-{
-    LOC_LOGD("%s]: ()", __FUNCTION__);
-    locAPIGetBatchedLocations(mDefaultId, SIZE_MAX);
-}
-
-void BatchingAPIClient::onCapabilitiesCb(LocationCapabilitiesMask capabilitiesMask)
-{
-    LOC_LOGD("%s]: (%" PRIu64 ")", __FUNCTION__, capabilitiesMask);
-    mLocationCapabilitiesMask = capabilitiesMask;
-}
-
-void BatchingAPIClient::onBatchingCb(size_t count, Location* location,
-        BatchingOptions /*batchOptions*/)
-{
-    LOC_LOGD("%s]: (count: %zu)", __FUNCTION__, count);
-    if (mGnssBatchingCbIface != nullptr && count > 0) {
-        hidl_vec<GnssLocation> locationVec;
-        locationVec.resize(count);
-        for (size_t i = 0; i < count; i++) {
-            convertGnssLocation(location[i], locationVec[i]);
-        }
-        auto r = mGnssBatchingCbIface->gnssLocationBatchCb(locationVec);
-        if (!r.isOk()) {
-            LOC_LOGE("%s] Error from gnssLocationBatchCb description=%s",
-                __func__, r.description().c_str());
-        }
-    }
-}
-
-static void convertBatchOption(const IGnssBatching::Options& in, LocationOptions& out,
-        LocationCapabilitiesMask mask)
-{
-    memset(&out, 0, sizeof(LocationOptions));
-    out.size = sizeof(LocationOptions);
-    out.minInterval = (uint32_t)(in.periodNanos / 1000000L);
-    out.minDistance = 0;
-    out.mode = GNSS_SUPL_MODE_STANDALONE;
-    if (mask & LOCATION_CAPABILITIES_GNSS_MSA_BIT)
-        out.mode = GNSS_SUPL_MODE_MSA;
-    if (mask & LOCATION_CAPABILITIES_GNSS_MSB_BIT)
-        out.mode = GNSS_SUPL_MODE_MSB;
-}
-
-}  // namespace implementation
-}  // namespace V1_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
diff --git a/gps/android/1.0/location_api/BatchingAPIClient.h b/gps/android/1.0/location_api/BatchingAPIClient.h
deleted file mode 100644
index c3b0a7b..0000000
--- a/gps/android/1.0/location_api/BatchingAPIClient.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- *       copyright notice, this list of conditions and the following
- *       disclaimer in the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of The Linux Foundation, nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#ifndef BATCHING_API_CLINET_H
-#define BATCHING_API_CLINET_H
-
-#include <android/hardware/gnss/1.0/IGnssBatching.h>
-#include <android/hardware/gnss/1.0/IGnssBatchingCallback.h>
-#include <pthread.h>
-
-#include <LocationAPIClientBase.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_0 {
-namespace implementation {
-
-class BatchingAPIClient : public LocationAPIClientBase
-{
-public:
-    BatchingAPIClient(const sp<V1_0::IGnssBatchingCallback>& callback);
-    int getBatchSize();
-    int startSession(const V1_0::IGnssBatching::Options& options);
-    int updateSessionOptions(const V1_0::IGnssBatching::Options& options);
-    int stopSession();
-    void getBatchedLocation(int last_n_locations);
-    void flushBatchedLocations();
-
-    inline LocationCapabilitiesMask getCapabilities() { return mLocationCapabilitiesMask; }
-
-    // callbacks
-    void onCapabilitiesCb(LocationCapabilitiesMask capabilitiesMask) final;
-    void onBatchingCb(size_t count, Location* location, BatchingOptions batchOptions) final;
-
-private:
-    ~BatchingAPIClient();
-
-    sp<V1_0::IGnssBatchingCallback> mGnssBatchingCbIface;
-    uint32_t mDefaultId;
-    LocationCapabilitiesMask mLocationCapabilitiesMask;
-};
-
-}  // namespace implementation
-}  // namespace V1_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
-#endif // BATCHING_API_CLINET_H
diff --git a/gps/android/1.0/location_api/GeofenceAPIClient.cpp b/gps/android/1.0/location_api/GeofenceAPIClient.cpp
deleted file mode 100644
index 774a049..0000000
--- a/gps/android/1.0/location_api/GeofenceAPIClient.cpp
+++ /dev/null
@@ -1,275 +0,0 @@
-/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- *       copyright notice, this list of conditions and the following
- *       disclaimer in the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of The Linux Foundation, nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#define LOG_NDEBUG 0
-#define LOG_TAG "LocSvc_GeofenceApiClient"
-
-#include <log_util.h>
-#include <loc_cfg.h>
-
-#include "LocationUtil.h"
-#include "GeofenceAPIClient.h"
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_0 {
-namespace implementation {
-
-using ::android::hardware::gnss::V1_0::IGnssGeofenceCallback;
-using ::android::hardware::gnss::V1_0::GnssLocation;
-
-GeofenceAPIClient::GeofenceAPIClient(const sp<IGnssGeofenceCallback>& callback) :
-    LocationAPIClientBase(),
-    mGnssGeofencingCbIface(callback)
-{
-    LOC_LOGD("%s]: (%p)", __FUNCTION__, &callback);
-
-    LocationCallbacks locationCallbacks;
-    memset(&locationCallbacks, 0, sizeof(LocationCallbacks));
-    locationCallbacks.size = sizeof(LocationCallbacks);
-
-    locationCallbacks.trackingCb = nullptr;
-    locationCallbacks.batchingCb = nullptr;
-
-    locationCallbacks.geofenceBreachCb = nullptr;
-    if (mGnssGeofencingCbIface != nullptr) {
-        locationCallbacks.geofenceBreachCb =
-            [this](GeofenceBreachNotification geofenceBreachNotification) {
-                onGeofenceBreachCb(geofenceBreachNotification);
-            };
-
-        locationCallbacks.geofenceStatusCb =
-            [this](GeofenceStatusNotification geofenceStatusNotification) {
-                onGeofenceStatusCb(geofenceStatusNotification);
-            };
-    }
-
-    locationCallbacks.gnssLocationInfoCb = nullptr;
-    locationCallbacks.gnssNiCb = nullptr;
-    locationCallbacks.gnssSvCb = nullptr;
-    locationCallbacks.gnssNmeaCb = nullptr;
-    locationCallbacks.gnssMeasurementsCb = nullptr;
-
-    locAPISetCallbacks(locationCallbacks);
-}
-
-void GeofenceAPIClient::geofenceAdd(uint32_t geofence_id, double latitude, double longitude,
-        double radius_meters, int32_t last_transition, int32_t monitor_transitions,
-        uint32_t notification_responsiveness_ms, uint32_t unknown_timer_ms)
-{
-    LOC_LOGD("%s]: (%d %f %f %f %d %d %d %d)", __FUNCTION__,
-            geofence_id, latitude, longitude, radius_meters,
-            last_transition, monitor_transitions, notification_responsiveness_ms, unknown_timer_ms);
-
-    GeofenceOption options;
-    memset(&options, 0, sizeof(GeofenceOption));
-    options.size = sizeof(GeofenceOption);
-    if (monitor_transitions & IGnssGeofenceCallback::GeofenceTransition::ENTERED)
-        options.breachTypeMask |= GEOFENCE_BREACH_ENTER_BIT;
-    if (monitor_transitions & IGnssGeofenceCallback::GeofenceTransition::EXITED)
-        options.breachTypeMask |=  GEOFENCE_BREACH_EXIT_BIT;
-    options.responsiveness = notification_responsiveness_ms;
-
-    GeofenceInfo data;
-    data.size = sizeof(GeofenceInfo);
-    data.latitude = latitude;
-    data.longitude = longitude;
-    data.radius = radius_meters;
-
-    LocationError err = (LocationError)locAPIAddGeofences(1, &geofence_id, &options, &data);
-    if (LOCATION_ERROR_SUCCESS != err) {
-        onAddGeofencesCb(1, &err, &geofence_id);
-    }
-}
-
-void GeofenceAPIClient::geofencePause(uint32_t geofence_id)
-{
-    LOC_LOGD("%s]: (%d)", __FUNCTION__, geofence_id);
-    locAPIPauseGeofences(1, &geofence_id);
-}
-
-void GeofenceAPIClient::geofenceResume(uint32_t geofence_id, int32_t monitor_transitions)
-{
-    LOC_LOGD("%s]: (%d %d)", __FUNCTION__, geofence_id, monitor_transitions);
-    GeofenceBreachTypeMask mask = 0;
-    if (monitor_transitions & IGnssGeofenceCallback::GeofenceTransition::ENTERED)
-        mask |= GEOFENCE_BREACH_ENTER_BIT;
-    if (monitor_transitions & IGnssGeofenceCallback::GeofenceTransition::EXITED)
-        mask |=  GEOFENCE_BREACH_EXIT_BIT;
-    locAPIResumeGeofences(1, &geofence_id, &mask);
-}
-
-void GeofenceAPIClient::geofenceRemove(uint32_t geofence_id)
-{
-    LOC_LOGD("%s]: (%d)", __FUNCTION__, geofence_id);
-    locAPIRemoveGeofences(1, &geofence_id);
-}
-
-void GeofenceAPIClient::geofenceRemoveAll()
-{
-    LOC_LOGD("%s]", __FUNCTION__);
-    // TODO locAPIRemoveAllGeofences();
-}
-
-// callbacks
-void GeofenceAPIClient::onGeofenceBreachCb(GeofenceBreachNotification geofenceBreachNotification)
-{
-    LOC_LOGD("%s]: (%zu)", __FUNCTION__, geofenceBreachNotification.count);
-    if (mGnssGeofencingCbIface != nullptr) {
-        for (size_t i = 0; i < geofenceBreachNotification.count; i++) {
-            GnssLocation gnssLocation;
-            convertGnssLocation(geofenceBreachNotification.location, gnssLocation);
-
-            IGnssGeofenceCallback::GeofenceTransition transition;
-            if (geofenceBreachNotification.type == GEOFENCE_BREACH_ENTER)
-                transition = IGnssGeofenceCallback::GeofenceTransition::ENTERED;
-            else if (geofenceBreachNotification.type == GEOFENCE_BREACH_EXIT)
-                transition = IGnssGeofenceCallback::GeofenceTransition::EXITED;
-            else {
-                // continue with other breach if transition is
-                // nether GPS_GEOFENCE_ENTERED nor GPS_GEOFENCE_EXITED
-                continue;
-            }
-
-            auto r = mGnssGeofencingCbIface->gnssGeofenceTransitionCb(
-                    geofenceBreachNotification.ids[i], gnssLocation, transition,
-                    static_cast<V1_0::GnssUtcTime>(geofenceBreachNotification.timestamp));
-            if (!r.isOk()) {
-                LOC_LOGE("%s] Error from gnssGeofenceTransitionCb description=%s",
-                    __func__, r.description().c_str());
-            }
-        }
-    }
-}
-
-void GeofenceAPIClient::onGeofenceStatusCb(GeofenceStatusNotification geofenceStatusNotification)
-{
-    LOC_LOGD("%s]: (%d)", __FUNCTION__, geofenceStatusNotification.available);
-    if (mGnssGeofencingCbIface != nullptr) {
-        IGnssGeofenceCallback::GeofenceAvailability status =
-            IGnssGeofenceCallback::GeofenceAvailability::UNAVAILABLE;
-        if (geofenceStatusNotification.available == GEOFENCE_STATUS_AVAILABILE_YES) {
-            status = IGnssGeofenceCallback::GeofenceAvailability::AVAILABLE;
-        }
-        GnssLocation gnssLocation;
-        memset(&gnssLocation, 0, sizeof(GnssLocation));
-        auto r = mGnssGeofencingCbIface->gnssGeofenceStatusCb(status, gnssLocation);
-        if (!r.isOk()) {
-            LOC_LOGE("%s] Error from gnssGeofenceStatusCb description=%s",
-                __func__, r.description().c_str());
-        }
-    }
-}
-
-void GeofenceAPIClient::onAddGeofencesCb(size_t count, LocationError* errors, uint32_t* ids)
-{
-    LOC_LOGD("%s]: (%zu)", __FUNCTION__, count);
-    if (mGnssGeofencingCbIface != nullptr) {
-        for (size_t i = 0; i < count; i++) {
-            IGnssGeofenceCallback::GeofenceStatus status =
-                IGnssGeofenceCallback::GeofenceStatus::ERROR_GENERIC;
-            if (errors[i] == LOCATION_ERROR_SUCCESS)
-                status = IGnssGeofenceCallback::GeofenceStatus::OPERATION_SUCCESS;
-            else if (errors[i] == LOCATION_ERROR_ID_EXISTS)
-                status = IGnssGeofenceCallback::GeofenceStatus::ERROR_ID_EXISTS;
-            auto r = mGnssGeofencingCbIface->gnssGeofenceAddCb(ids[i], status);
-            if (!r.isOk()) {
-                LOC_LOGE("%s] Error from gnssGeofenceAddCb description=%s",
-                    __func__, r.description().c_str());
-            }
-        }
-    }
-}
-
-void GeofenceAPIClient::onRemoveGeofencesCb(size_t count, LocationError* errors, uint32_t* ids)
-{
-    LOC_LOGD("%s]: (%zu)", __FUNCTION__, count);
-    if (mGnssGeofencingCbIface != nullptr) {
-        for (size_t i = 0; i < count; i++) {
-            IGnssGeofenceCallback::GeofenceStatus status =
-                IGnssGeofenceCallback::GeofenceStatus::ERROR_GENERIC;
-            if (errors[i] == LOCATION_ERROR_SUCCESS)
-                status = IGnssGeofenceCallback::GeofenceStatus::OPERATION_SUCCESS;
-            else if (errors[i] == LOCATION_ERROR_ID_UNKNOWN)
-                status = IGnssGeofenceCallback::GeofenceStatus::ERROR_ID_UNKNOWN;
-            auto r = mGnssGeofencingCbIface->gnssGeofenceRemoveCb(ids[i], status);
-            if (!r.isOk()) {
-                LOC_LOGE("%s] Error from gnssGeofenceRemoveCb description=%s",
-                    __func__, r.description().c_str());
-            }
-        }
-    }
-}
-
-void GeofenceAPIClient::onPauseGeofencesCb(size_t count, LocationError* errors, uint32_t* ids)
-{
-    LOC_LOGD("%s]: (%zu)", __FUNCTION__, count);
-    if (mGnssGeofencingCbIface != nullptr) {
-        for (size_t i = 0; i < count; i++) {
-            IGnssGeofenceCallback::GeofenceStatus status =
-                IGnssGeofenceCallback::GeofenceStatus::ERROR_GENERIC;
-            if (errors[i] == LOCATION_ERROR_SUCCESS)
-                status = IGnssGeofenceCallback::GeofenceStatus::OPERATION_SUCCESS;
-            else if (errors[i] == LOCATION_ERROR_ID_UNKNOWN)
-                status = IGnssGeofenceCallback::GeofenceStatus::ERROR_ID_UNKNOWN;
-            auto r = mGnssGeofencingCbIface->gnssGeofencePauseCb(ids[i], status);
-            if (!r.isOk()) {
-                LOC_LOGE("%s] Error from gnssGeofencePauseCb description=%s",
-                    __func__, r.description().c_str());
-            }
-        }
-    }
-}
-
-void GeofenceAPIClient::onResumeGeofencesCb(size_t count, LocationError* errors, uint32_t* ids)
-{
-    LOC_LOGD("%s]: (%zu)", __FUNCTION__, count);
-    if (mGnssGeofencingCbIface != nullptr) {
-        for (size_t i = 0; i < count; i++) {
-            IGnssGeofenceCallback::GeofenceStatus status =
-                IGnssGeofenceCallback::GeofenceStatus::ERROR_GENERIC;
-            if (errors[i] == LOCATION_ERROR_SUCCESS)
-                status = IGnssGeofenceCallback::GeofenceStatus::OPERATION_SUCCESS;
-            else if (errors[i] == LOCATION_ERROR_ID_UNKNOWN)
-                status = IGnssGeofenceCallback::GeofenceStatus::ERROR_ID_UNKNOWN;
-            auto r = mGnssGeofencingCbIface->gnssGeofenceResumeCb(ids[i], status);
-            if (!r.isOk()) {
-                LOC_LOGE("%s] Error from gnssGeofenceResumeCb description=%s",
-                    __func__, r.description().c_str());
-            }
-        }
-    }
-}
-
-}  // namespace implementation
-}  // namespace V1_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
diff --git a/gps/android/1.0/location_api/GeofenceAPIClient.h b/gps/android/1.0/location_api/GeofenceAPIClient.h
deleted file mode 100644
index b6a009b..0000000
--- a/gps/android/1.0/location_api/GeofenceAPIClient.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- *       copyright notice, this list of conditions and the following
- *       disclaimer in the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of The Linux Foundation, nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#ifndef GEOFENCE_API_CLINET_H
-#define GEOFENCE_API_CLINET_H
-
-
-#include <android/hardware/gnss/1.0/IGnssGeofenceCallback.h>
-#include <LocationAPIClientBase.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_0 {
-namespace implementation {
-
-using ::android::sp;
-
-class GeofenceAPIClient : public LocationAPIClientBase
-{
-public:
-    GeofenceAPIClient(const sp<V1_0::IGnssGeofenceCallback>& callback);
-
-    void geofenceAdd(uint32_t geofence_id, double latitude, double longitude,
-            double radius_meters, int32_t last_transition, int32_t monitor_transitions,
-            uint32_t notification_responsiveness_ms, uint32_t unknown_timer_ms);
-    void geofencePause(uint32_t geofence_id);
-    void geofenceResume(uint32_t geofence_id, int32_t monitor_transitions);
-    void geofenceRemove(uint32_t geofence_id);
-    void geofenceRemoveAll();
-
-    // callbacks
-    void onGeofenceBreachCb(GeofenceBreachNotification geofenceBreachNotification) final;
-    void onGeofenceStatusCb(GeofenceStatusNotification geofenceStatusNotification) final;
-    void onAddGeofencesCb(size_t count, LocationError* errors, uint32_t* ids) final;
-    void onRemoveGeofencesCb(size_t count, LocationError* errors, uint32_t* ids) final;
-    void onPauseGeofencesCb(size_t count, LocationError* errors, uint32_t* ids) final;
-    void onResumeGeofencesCb(size_t count, LocationError* errors, uint32_t* ids) final;
-
-private:
-    virtual ~GeofenceAPIClient() = default;
-
-    sp<V1_0::IGnssGeofenceCallback> mGnssGeofencingCbIface;
-};
-
-}  // namespace implementation
-}  // namespace V1_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
-#endif // GEOFENCE_API_CLINET_H
diff --git a/gps/android/1.0/location_api/GnssAPIClient.cpp b/gps/android/1.0/location_api/GnssAPIClient.cpp
deleted file mode 100644
index 4247258..0000000
--- a/gps/android/1.0/location_api/GnssAPIClient.cpp
+++ /dev/null
@@ -1,565 +0,0 @@
-/* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- *       copyright notice, this list of conditions and the following
- *       disclaimer in the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of The Linux Foundation, nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#define LOG_NDEBUG 0
-#define LOG_TAG "LocSvc_GnssAPIClient"
-#define SINGLE_SHOT_MIN_TRACKING_INTERVAL_MSEC (590 * 60 * 60 * 1000) // 590 hours
-
-#include <inttypes.h>
-#include <log_util.h>
-#include <loc_cfg.h>
-
-#include "LocationUtil.h"
-#include "GnssAPIClient.h"
-#include <LocContext.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_0 {
-namespace implementation {
-
-using ::android::hardware::gnss::V1_0::IGnss;
-using ::android::hardware::gnss::V1_0::IGnssCallback;
-using ::android::hardware::gnss::V1_0::IGnssNiCallback;
-using ::android::hardware::gnss::V1_0::GnssLocation;
-
-static void convertGnssSvStatus(GnssSvNotification& in, IGnssCallback::GnssSvStatus& out);
-
-GnssAPIClient::GnssAPIClient(const sp<IGnssCallback>& gpsCb,
-    const sp<IGnssNiCallback>& niCb) :
-    LocationAPIClientBase(),
-    mGnssCbIface(nullptr),
-    mGnssNiCbIface(nullptr),
-    mControlClient(new LocationAPIControlClient()),
-    mLocationCapabilitiesMask(0),
-    mLocationCapabilitiesCached(false)
-{
-    LOC_LOGD("%s]: (%p %p)", __FUNCTION__, &gpsCb, &niCb);
-
-    // set default LocationOptions.
-    memset(&mTrackingOptions, 0, sizeof(TrackingOptions));
-    mTrackingOptions.size = sizeof(TrackingOptions);
-    mTrackingOptions.minInterval = 1000;
-    mTrackingOptions.minDistance = 0;
-    mTrackingOptions.mode = GNSS_SUPL_MODE_STANDALONE;
-
-    gnssUpdateCallbacks(gpsCb, niCb);
-}
-
-GnssAPIClient::~GnssAPIClient()
-{
-    LOC_LOGD("%s]: ()", __FUNCTION__);
-    if (mControlClient) {
-        delete mControlClient;
-        mControlClient = nullptr;
-    }
-}
-
-// for GpsInterface
-void GnssAPIClient::gnssUpdateCallbacks(const sp<IGnssCallback>& gpsCb,
-    const sp<IGnssNiCallback>& niCb)
-{
-    LOC_LOGD("%s]: (%p %p)", __FUNCTION__, &gpsCb, &niCb);
-
-    mMutex.lock();
-    mGnssCbIface = gpsCb;
-    mGnssNiCbIface = niCb;
-    mMutex.unlock();
-
-    LocationCallbacks locationCallbacks;
-    memset(&locationCallbacks, 0, sizeof(LocationCallbacks));
-    locationCallbacks.size = sizeof(LocationCallbacks);
-
-    locationCallbacks.trackingCb = nullptr;
-    if (mGnssCbIface != nullptr) {
-        locationCallbacks.trackingCb = [this](Location location) {
-            onTrackingCb(location);
-        };
-    }
-
-    locationCallbacks.batchingCb = nullptr;
-    locationCallbacks.geofenceBreachCb = nullptr;
-    locationCallbacks.geofenceStatusCb = nullptr;
-    locationCallbacks.gnssLocationInfoCb = nullptr;
-
-    locationCallbacks.gnssNiCb = nullptr;
-    loc_core::ContextBase* context =
-            loc_core::LocContext::getLocContext(loc_core::LocContext::mLocationHalName);
-    if (mGnssNiCbIface != nullptr && !context->hasAgpsExtendedCapabilities()) {
-        LOC_LOGD("Registering NI CB");
-        locationCallbacks.gnssNiCb = [this](uint32_t id, GnssNiNotification gnssNiNotification) {
-            onGnssNiCb(id, gnssNiNotification);
-        };
-    }
-
-    locationCallbacks.gnssSvCb = nullptr;
-    if (mGnssCbIface != nullptr) {
-        locationCallbacks.gnssSvCb = [this](GnssSvNotification gnssSvNotification) {
-            onGnssSvCb(gnssSvNotification);
-        };
-    }
-
-    locationCallbacks.gnssNmeaCb = nullptr;
-    if (mGnssCbIface != nullptr) {
-        locationCallbacks.gnssNmeaCb = [this](GnssNmeaNotification gnssNmeaNotification) {
-            onGnssNmeaCb(gnssNmeaNotification);
-        };
-    }
-
-    locationCallbacks.gnssMeasurementsCb = nullptr;
-
-    locAPISetCallbacks(locationCallbacks);
-}
-
-bool GnssAPIClient::gnssStart()
-{
-    LOC_LOGD("%s]: ()", __FUNCTION__);
-    bool retVal = true;
-    locAPIStartTracking(mTrackingOptions);
-    return retVal;
-}
-
-bool GnssAPIClient::gnssStop()
-{
-    LOC_LOGD("%s]: ()", __FUNCTION__);
-    bool retVal = true;
-    locAPIStopTracking();
-    return retVal;
-}
-
-bool GnssAPIClient::gnssSetPositionMode(IGnss::GnssPositionMode mode,
-        IGnss::GnssPositionRecurrence recurrence, uint32_t minIntervalMs,
-        uint32_t preferredAccuracyMeters, uint32_t preferredTimeMs,
-        GnssPowerMode powerMode, uint32_t timeBetweenMeasurement)
-{
-    LOC_LOGD("%s]: (%d %d %d %d %d %d %d)", __FUNCTION__,
-            (int)mode, recurrence, minIntervalMs, preferredAccuracyMeters,
-            preferredTimeMs, (int)powerMode, timeBetweenMeasurement);
-    bool retVal = true;
-    memset(&mTrackingOptions, 0, sizeof(TrackingOptions));
-    mTrackingOptions.size = sizeof(TrackingOptions);
-    mTrackingOptions.minInterval = minIntervalMs;
-    if (IGnss::GnssPositionMode::MS_ASSISTED == mode ||
-            IGnss::GnssPositionRecurrence::RECURRENCE_SINGLE == recurrence) {
-        // We set a very large interval to simulate SINGLE mode. Once we report a fix,
-        // the caller should take the responsibility to stop the session.
-        // For MSA, we always treat it as SINGLE mode.
-        mTrackingOptions.minInterval = SINGLE_SHOT_MIN_TRACKING_INTERVAL_MSEC;
-    }
-    if (mode == IGnss::GnssPositionMode::STANDALONE)
-        mTrackingOptions.mode = GNSS_SUPL_MODE_STANDALONE;
-    else if (mode == IGnss::GnssPositionMode::MS_BASED)
-        mTrackingOptions.mode = GNSS_SUPL_MODE_MSB;
-    else if (mode ==  IGnss::GnssPositionMode::MS_ASSISTED)
-        mTrackingOptions.mode = GNSS_SUPL_MODE_MSA;
-    else {
-        LOC_LOGD("%s]: invalid GnssPositionMode: %d", __FUNCTION__, (int)mode);
-        retVal = false;
-    }
-    if (GNSS_POWER_MODE_INVALID != powerMode) {
-        mTrackingOptions.powerMode = powerMode;
-        mTrackingOptions.tbm = timeBetweenMeasurement;
-    }
-    locAPIUpdateTrackingOptions(mTrackingOptions);
-    return retVal;
-}
-
-// for GpsNiInterface
-void GnssAPIClient::gnssNiRespond(int32_t notifId,
-        IGnssNiCallback::GnssUserResponseType userResponse)
-{
-    LOC_LOGD("%s]: (%d %d)", __FUNCTION__, notifId, static_cast<int>(userResponse));
-    GnssNiResponse data;
-    switch (userResponse) {
-    case IGnssNiCallback::GnssUserResponseType::RESPONSE_ACCEPT:
-        data = GNSS_NI_RESPONSE_ACCEPT;
-        break;
-    case IGnssNiCallback::GnssUserResponseType::RESPONSE_DENY:
-        data = GNSS_NI_RESPONSE_DENY;
-        break;
-    case IGnssNiCallback::GnssUserResponseType::RESPONSE_NORESP:
-        data = GNSS_NI_RESPONSE_NO_RESPONSE;
-        break;
-    default:
-        data = GNSS_NI_RESPONSE_IGNORE;
-        break;
-    }
-
-    locAPIGnssNiResponse(notifId, data);
-}
-
-// these apis using LocationAPIControlClient
-void GnssAPIClient::gnssDeleteAidingData(IGnss::GnssAidingData aidingDataFlags)
-{
-    LOC_LOGD("%s]: (%02hx)", __FUNCTION__, aidingDataFlags);
-    if (mControlClient == nullptr) {
-        return;
-    }
-    GnssAidingData data;
-    memset(&data, 0, sizeof (GnssAidingData));
-    data.sv.svTypeMask = GNSS_AIDING_DATA_SV_TYPE_GPS_BIT |
-        GNSS_AIDING_DATA_SV_TYPE_GLONASS_BIT |
-        GNSS_AIDING_DATA_SV_TYPE_QZSS_BIT |
-        GNSS_AIDING_DATA_SV_TYPE_BEIDOU_BIT |
-        GNSS_AIDING_DATA_SV_TYPE_GALILEO_BIT;
-    data.posEngineMask = STANDARD_POSITIONING_ENGINE;
-
-    if (aidingDataFlags == IGnss::GnssAidingData::DELETE_ALL)
-        data.deleteAll = true;
-    else {
-        if (aidingDataFlags & IGnss::GnssAidingData::DELETE_EPHEMERIS)
-            data.sv.svMask |= GNSS_AIDING_DATA_SV_EPHEMERIS_BIT;
-        if (aidingDataFlags & IGnss::GnssAidingData::DELETE_ALMANAC)
-            data.sv.svMask |= GNSS_AIDING_DATA_SV_ALMANAC_BIT;
-        if (aidingDataFlags & IGnss::GnssAidingData::DELETE_POSITION)
-            data.common.mask |= GNSS_AIDING_DATA_COMMON_POSITION_BIT;
-        if (aidingDataFlags & IGnss::GnssAidingData::DELETE_TIME)
-            data.common.mask |= GNSS_AIDING_DATA_COMMON_TIME_BIT;
-        if (aidingDataFlags & IGnss::GnssAidingData::DELETE_IONO)
-            data.sv.svMask |= GNSS_AIDING_DATA_SV_IONOSPHERE_BIT;
-        if (aidingDataFlags & IGnss::GnssAidingData::DELETE_UTC)
-            data.common.mask |= GNSS_AIDING_DATA_COMMON_UTC_BIT;
-        if (aidingDataFlags & IGnss::GnssAidingData::DELETE_HEALTH)
-            data.sv.svMask |= GNSS_AIDING_DATA_SV_HEALTH_BIT;
-        if (aidingDataFlags & IGnss::GnssAidingData::DELETE_SVDIR)
-            data.sv.svMask |= GNSS_AIDING_DATA_SV_DIRECTION_BIT;
-        if (aidingDataFlags & IGnss::GnssAidingData::DELETE_SVSTEER)
-            data.sv.svMask |= GNSS_AIDING_DATA_SV_STEER_BIT;
-        if (aidingDataFlags & IGnss::GnssAidingData::DELETE_SADATA)
-            data.sv.svMask |= GNSS_AIDING_DATA_SV_SA_DATA_BIT;
-        if (aidingDataFlags & IGnss::GnssAidingData::DELETE_RTI)
-            data.common.mask |= GNSS_AIDING_DATA_COMMON_RTI_BIT;
-        if (aidingDataFlags & IGnss::GnssAidingData::DELETE_CELLDB_INFO)
-            data.common.mask |= GNSS_AIDING_DATA_COMMON_CELLDB_BIT;
-    }
-    mControlClient->locAPIGnssDeleteAidingData(data);
-}
-
-void GnssAPIClient::gnssEnable(LocationTechnologyType techType)
-{
-    LOC_LOGD("%s]: (%0d)", __FUNCTION__, techType);
-    if (mControlClient == nullptr) {
-        return;
-    }
-    mControlClient->locAPIEnable(techType);
-}
-
-void GnssAPIClient::gnssDisable()
-{
-    LOC_LOGD("%s]: ()", __FUNCTION__);
-    if (mControlClient == nullptr) {
-        return;
-    }
-    mControlClient->locAPIDisable();
-}
-
-void GnssAPIClient::gnssConfigurationUpdate(const GnssConfig& gnssConfig)
-{
-    LOC_LOGD("%s]: (%02x)", __FUNCTION__, gnssConfig.flags);
-    if (mControlClient == nullptr) {
-        return;
-    }
-    mControlClient->locAPIGnssUpdateConfig(gnssConfig);
-}
-
-void GnssAPIClient::requestCapabilities() {
-    // only send capablities if it's already cached, otherwise the first time LocationAPI
-    // is initialized, capabilities will be sent by LocationAPI
-    if (mLocationCapabilitiesCached) {
-        onCapabilitiesCb(mLocationCapabilitiesMask);
-    }
-}
-
-// callbacks
-void GnssAPIClient::onCapabilitiesCb(LocationCapabilitiesMask capabilitiesMask)
-{
-    LOC_LOGD("%s]: (%" PRIu64 ")", __FUNCTION__, capabilitiesMask);
-    mLocationCapabilitiesMask = capabilitiesMask;
-    mLocationCapabilitiesCached = true;
-
-    mMutex.lock();
-    auto gnssCbIface(mGnssCbIface);
-    mMutex.unlock();
-
-    if (gnssCbIface != nullptr) {
-        uint32_t data = 0;
-        if ((capabilitiesMask & LOCATION_CAPABILITIES_TIME_BASED_TRACKING_BIT) ||
-                (capabilitiesMask & LOCATION_CAPABILITIES_TIME_BASED_BATCHING_BIT) ||
-                (capabilitiesMask & LOCATION_CAPABILITIES_DISTANCE_BASED_TRACKING_BIT) ||
-                (capabilitiesMask & LOCATION_CAPABILITIES_DISTANCE_BASED_BATCHING_BIT))
-            data |= IGnssCallback::Capabilities::SCHEDULING;
-        if (capabilitiesMask & LOCATION_CAPABILITIES_GEOFENCE_BIT)
-            data |= IGnssCallback::Capabilities::GEOFENCING;
-        if (capabilitiesMask & LOCATION_CAPABILITIES_GNSS_MEASUREMENTS_BIT)
-            data |= IGnssCallback::Capabilities::MEASUREMENTS;
-        if (capabilitiesMask & LOCATION_CAPABILITIES_GNSS_MSB_BIT)
-            data |= IGnssCallback::Capabilities::MSB;
-        if (capabilitiesMask & LOCATION_CAPABILITIES_GNSS_MSA_BIT)
-            data |= IGnssCallback::Capabilities::MSA;
-        auto r = gnssCbIface->gnssSetCapabilitesCb(data);
-        if (!r.isOk()) {
-            LOC_LOGE("%s] Error from gnssSetCapabilitesCb description=%s",
-                __func__, r.description().c_str());
-        }
-    }
-    if (gnssCbIface != nullptr) {
-        IGnssCallback::GnssSystemInfo gnssInfo = { .yearOfHw = 2015 };
-
-        if (capabilitiesMask & LOCATION_CAPABILITIES_GNSS_MEASUREMENTS_BIT) {
-            gnssInfo.yearOfHw++; // 2016
-            if (capabilitiesMask & LOCATION_CAPABILITIES_DEBUG_NMEA_BIT) {
-                gnssInfo.yearOfHw++; // 2017
-                if (capabilitiesMask & LOCATION_CAPABILITIES_CONSTELLATION_ENABLEMENT_BIT ||
-                    capabilitiesMask & LOCATION_CAPABILITIES_AGPM_BIT) {
-                    gnssInfo.yearOfHw++; // 2018
-                }
-            }
-        }
-        LOC_LOGV("%s:%d] set_system_info_cb (%d)", __FUNCTION__, __LINE__, gnssInfo.yearOfHw);
-        auto r = gnssCbIface->gnssSetSystemInfoCb(gnssInfo);
-        if (!r.isOk()) {
-            LOC_LOGE("%s] Error from gnssSetSystemInfoCb description=%s",
-                __func__, r.description().c_str());
-        }
-    }
-}
-
-void GnssAPIClient::onTrackingCb(Location location)
-{
-    LOC_LOGD("%s]: (flags: %02x)", __FUNCTION__, location.flags);
-    mMutex.lock();
-    auto gnssCbIface(mGnssCbIface);
-    mMutex.unlock();
-
-    if (gnssCbIface != nullptr) {
-        GnssLocation gnssLocation;
-        convertGnssLocation(location, gnssLocation);
-        auto r = gnssCbIface->gnssLocationCb(gnssLocation);
-        if (!r.isOk()) {
-            LOC_LOGE("%s] Error from gnssLocationCb description=%s",
-                __func__, r.description().c_str());
-        }
-    }
-}
-
-void GnssAPIClient::onGnssNiCb(uint32_t id, GnssNiNotification gnssNiNotification)
-{
-    LOC_LOGD("%s]: (id: %d)", __FUNCTION__, id);
-    mMutex.lock();
-    auto gnssNiCbIface(mGnssNiCbIface);
-    mMutex.unlock();
-
-    if (gnssNiCbIface == nullptr) {
-        LOC_LOGE("%s]: mGnssNiCbIface is nullptr", __FUNCTION__);
-        return;
-    }
-
-    IGnssNiCallback::GnssNiNotification notificationGnss = {};
-
-    notificationGnss.notificationId = id;
-
-    if (gnssNiNotification.type == GNSS_NI_TYPE_VOICE)
-        notificationGnss.niType = IGnssNiCallback::GnssNiType::VOICE;
-    else if (gnssNiNotification.type == GNSS_NI_TYPE_SUPL)
-        notificationGnss.niType = IGnssNiCallback::GnssNiType::UMTS_SUPL;
-    else if (gnssNiNotification.type == GNSS_NI_TYPE_CONTROL_PLANE)
-        notificationGnss.niType = IGnssNiCallback::GnssNiType::UMTS_CTRL_PLANE;
-    else if (gnssNiNotification.type == GNSS_NI_TYPE_EMERGENCY_SUPL)
-        notificationGnss.niType = IGnssNiCallback::GnssNiType::EMERGENCY_SUPL;
-
-    if (gnssNiNotification.options & GNSS_NI_OPTIONS_NOTIFICATION_BIT)
-        notificationGnss.notifyFlags |= IGnssNiCallback::GnssNiNotifyFlags::NEED_NOTIFY;
-    if (gnssNiNotification.options & GNSS_NI_OPTIONS_VERIFICATION_BIT)
-        notificationGnss.notifyFlags |= IGnssNiCallback::GnssNiNotifyFlags::NEED_VERIFY;
-    if (gnssNiNotification.options & GNSS_NI_OPTIONS_PRIVACY_OVERRIDE_BIT)
-        notificationGnss.notifyFlags |= IGnssNiCallback::GnssNiNotifyFlags::PRIVACY_OVERRIDE;
-
-    notificationGnss.timeoutSec = gnssNiNotification.timeout;
-
-    if (gnssNiNotification.timeoutResponse == GNSS_NI_RESPONSE_ACCEPT)
-        notificationGnss.defaultResponse = IGnssNiCallback::GnssUserResponseType::RESPONSE_ACCEPT;
-    else if (gnssNiNotification.timeoutResponse == GNSS_NI_RESPONSE_DENY)
-        notificationGnss.defaultResponse = IGnssNiCallback::GnssUserResponseType::RESPONSE_DENY;
-    else if (gnssNiNotification.timeoutResponse == GNSS_NI_RESPONSE_NO_RESPONSE ||
-            gnssNiNotification.timeoutResponse == GNSS_NI_RESPONSE_IGNORE)
-        notificationGnss.defaultResponse = IGnssNiCallback::GnssUserResponseType::RESPONSE_NORESP;
-
-    notificationGnss.requestorId = gnssNiNotification.requestor;
-
-    notificationGnss.notificationMessage = gnssNiNotification.message;
-
-    if (gnssNiNotification.requestorEncoding == GNSS_NI_ENCODING_TYPE_NONE)
-        notificationGnss.requestorIdEncoding =
-            IGnssNiCallback::GnssNiEncodingType::ENC_NONE;
-    else if (gnssNiNotification.requestorEncoding == GNSS_NI_ENCODING_TYPE_GSM_DEFAULT)
-        notificationGnss.requestorIdEncoding =
-            IGnssNiCallback::GnssNiEncodingType::ENC_SUPL_GSM_DEFAULT;
-    else if (gnssNiNotification.requestorEncoding == GNSS_NI_ENCODING_TYPE_UTF8)
-        notificationGnss.requestorIdEncoding =
-            IGnssNiCallback::GnssNiEncodingType::ENC_SUPL_UTF8;
-    else if (gnssNiNotification.requestorEncoding == GNSS_NI_ENCODING_TYPE_UCS2)
-        notificationGnss.requestorIdEncoding =
-            IGnssNiCallback::GnssNiEncodingType::ENC_SUPL_UCS2;
-
-    if (gnssNiNotification.messageEncoding == GNSS_NI_ENCODING_TYPE_NONE)
-        notificationGnss.notificationIdEncoding =
-            IGnssNiCallback::GnssNiEncodingType::ENC_NONE;
-    else if (gnssNiNotification.messageEncoding == GNSS_NI_ENCODING_TYPE_GSM_DEFAULT)
-        notificationGnss.notificationIdEncoding =
-            IGnssNiCallback::GnssNiEncodingType::ENC_SUPL_GSM_DEFAULT;
-    else if (gnssNiNotification.messageEncoding == GNSS_NI_ENCODING_TYPE_UTF8)
-        notificationGnss.notificationIdEncoding =
-            IGnssNiCallback::GnssNiEncodingType::ENC_SUPL_UTF8;
-    else if (gnssNiNotification.messageEncoding == GNSS_NI_ENCODING_TYPE_UCS2)
-        notificationGnss.notificationIdEncoding =
-            IGnssNiCallback::GnssNiEncodingType::ENC_SUPL_UCS2;
-
-    gnssNiCbIface->niNotifyCb(notificationGnss);
-}
-
-void GnssAPIClient::onGnssSvCb(GnssSvNotification gnssSvNotification)
-{
-    LOC_LOGD("%s]: (count: %zu)", __FUNCTION__, gnssSvNotification.count);
-    mMutex.lock();
-    auto gnssCbIface(mGnssCbIface);
-    mMutex.unlock();
-
-    if (gnssCbIface != nullptr) {
-        IGnssCallback::GnssSvStatus svStatus;
-        convertGnssSvStatus(gnssSvNotification, svStatus);
-        auto r = gnssCbIface->gnssSvStatusCb(svStatus);
-        if (!r.isOk()) {
-            LOC_LOGE("%s] Error from gnssSvStatusCb description=%s",
-                __func__, r.description().c_str());
-        }
-    }
-}
-
-void GnssAPIClient::onGnssNmeaCb(GnssNmeaNotification gnssNmeaNotification)
-{
-    mMutex.lock();
-    auto gnssCbIface(mGnssCbIface);
-    mMutex.unlock();
-
-    if (gnssCbIface != nullptr) {
-        const std::string s(gnssNmeaNotification.nmea);
-        std::stringstream ss(s);
-        std::string each;
-        while(std::getline(ss, each, '\n')) {
-            each += '\n';
-            android::hardware::hidl_string nmeaString;
-            nmeaString.setToExternal(each.c_str(), each.length());
-            auto r = gnssCbIface->gnssNmeaCb(
-                    static_cast<V1_0::GnssUtcTime>(gnssNmeaNotification.timestamp), nmeaString);
-            if (!r.isOk()) {
-                LOC_LOGE("%s] Error from gnssNmeaCb nmea=%s length=%zu description=%s", __func__,
-                            gnssNmeaNotification.nmea, gnssNmeaNotification.length,
-                            r.description().c_str());
-            }
-        }
-    }
-}
-
-void GnssAPIClient::onStartTrackingCb(LocationError error)
-{
-    LOC_LOGD("%s]: (%d)", __FUNCTION__, error);
-    mMutex.lock();
-    auto gnssCbIface(mGnssCbIface);
-    mMutex.unlock();
-
-    if (error == LOCATION_ERROR_SUCCESS && gnssCbIface != nullptr) {
-        auto r = gnssCbIface->gnssStatusCb(IGnssCallback::GnssStatusValue::ENGINE_ON);
-        if (!r.isOk()) {
-            LOC_LOGE("%s] Error from gnssStatusCb ENGINE_ON description=%s",
-                __func__, r.description().c_str());
-        }
-        r = gnssCbIface->gnssStatusCb(IGnssCallback::GnssStatusValue::SESSION_BEGIN);
-        if (!r.isOk()) {
-            LOC_LOGE("%s] Error from gnssStatusCb SESSION_BEGIN description=%s",
-                __func__, r.description().c_str());
-        }
-    }
-}
-
-void GnssAPIClient::onStopTrackingCb(LocationError error)
-{
-    LOC_LOGD("%s]: (%d)", __FUNCTION__, error);
-    mMutex.lock();
-    auto gnssCbIface(mGnssCbIface);
-    mMutex.unlock();
-
-    if (error == LOCATION_ERROR_SUCCESS && gnssCbIface != nullptr) {
-        auto r = gnssCbIface->gnssStatusCb(IGnssCallback::GnssStatusValue::SESSION_END);
-        if (!r.isOk()) {
-            LOC_LOGE("%s] Error from gnssStatusCb SESSION_END description=%s",
-                __func__, r.description().c_str());
-        }
-        r = gnssCbIface->gnssStatusCb(IGnssCallback::GnssStatusValue::ENGINE_OFF);
-        if (!r.isOk()) {
-            LOC_LOGE("%s] Error from gnssStatusCb ENGINE_OFF description=%s",
-                __func__, r.description().c_str());
-        }
-    }
-}
-
-static void convertGnssSvStatus(GnssSvNotification& in, IGnssCallback::GnssSvStatus& out)
-{
-    memset(&out, 0, sizeof(IGnssCallback::GnssSvStatus));
-    out.numSvs = in.count;
-    if (out.numSvs > static_cast<uint32_t>(V1_0::GnssMax::SVS_COUNT)) {
-        LOC_LOGW("%s]: Too many satellites %u. Clamps to %d.",
-                __FUNCTION__,  out.numSvs, V1_0::GnssMax::SVS_COUNT);
-        out.numSvs = static_cast<uint32_t>(V1_0::GnssMax::SVS_COUNT);
-    }
-    for (size_t i = 0; i < out.numSvs; i++) {
-        IGnssCallback::GnssSvInfo& info = out.gnssSvList[i];
-        convertGnssSvid(in.gnssSvs[i], info.svid);
-        convertGnssConstellationType(in.gnssSvs[i].type, info.constellation);
-        info.cN0Dbhz = in.gnssSvs[i].cN0Dbhz;
-        info.elevationDegrees = in.gnssSvs[i].elevation;
-        info.azimuthDegrees = in.gnssSvs[i].azimuth;
-        info.carrierFrequencyHz = in.gnssSvs[i].carrierFrequencyHz;
-        info.svFlag = static_cast<uint8_t>(IGnssCallback::GnssSvFlags::NONE);
-        if (in.gnssSvs[i].gnssSvOptionsMask & GNSS_SV_OPTIONS_HAS_EPHEMER_BIT)
-            info.svFlag |= IGnssCallback::GnssSvFlags::HAS_EPHEMERIS_DATA;
-        if (in.gnssSvs[i].gnssSvOptionsMask & GNSS_SV_OPTIONS_HAS_ALMANAC_BIT)
-            info.svFlag |= IGnssCallback::GnssSvFlags::HAS_ALMANAC_DATA;
-        if (in.gnssSvs[i].gnssSvOptionsMask & GNSS_SV_OPTIONS_USED_IN_FIX_BIT)
-            info.svFlag |= IGnssCallback::GnssSvFlags::USED_IN_FIX;
-        if (in.gnssSvs[i].gnssSvOptionsMask & GNSS_SV_OPTIONS_HAS_CARRIER_FREQUENCY_BIT)
-            info.svFlag |= IGnssCallback::GnssSvFlags::HAS_CARRIER_FREQUENCY;
-    }
-}
-
-}  // namespace implementation
-}  // namespace V1_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
diff --git a/gps/android/1.0/location_api/GnssAPIClient.h b/gps/android/1.0/location_api/GnssAPIClient.h
deleted file mode 100644
index 427b0db..0000000
--- a/gps/android/1.0/location_api/GnssAPIClient.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- *       copyright notice, this list of conditions and the following
- *       disclaimer in the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of The Linux Foundation, nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#ifndef GNSS_API_CLINET_H
-#define GNSS_API_CLINET_H
-
-
-#include <mutex>
-#include <android/hardware/gnss/1.0/IGnss.h>
-#include <android/hardware/gnss/1.0/IGnssCallback.h>
-#include <android/hardware/gnss/1.0/IGnssNiCallback.h>
-#include <LocationAPIClientBase.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_0 {
-namespace implementation {
-
-using ::android::sp;
-
-class GnssAPIClient : public LocationAPIClientBase
-{
-public:
-    GnssAPIClient(const sp<V1_0::IGnssCallback>& gpsCb,
-            const sp<V1_0::IGnssNiCallback>& niCb);
-    GnssAPIClient(const GnssAPIClient&) = delete;
-    GnssAPIClient& operator=(const GnssAPIClient&) = delete;
-
-    // for GpsInterface
-    void gnssUpdateCallbacks(const sp<V1_0::IGnssCallback>& gpsCb,
-            const sp<V1_0::IGnssNiCallback>& niCb);
-    bool gnssStart();
-    bool gnssStop();
-    bool gnssSetPositionMode(V1_0::IGnss::GnssPositionMode mode,
-            V1_0::IGnss::GnssPositionRecurrence recurrence,
-            uint32_t minIntervalMs,
-            uint32_t preferredAccuracyMeters,
-            uint32_t preferredTimeMs,
-            GnssPowerMode powerMode = GNSS_POWER_MODE_INVALID,
-            uint32_t timeBetweenMeasurement = 0);
-
-    // for GpsNiInterface
-    void gnssNiRespond(int32_t notifId, V1_0::IGnssNiCallback::GnssUserResponseType userResponse);
-
-    // these apis using LocationAPIControlClient
-    void gnssDeleteAidingData(V1_0::IGnss::GnssAidingData aidingDataFlags);
-    void gnssEnable(LocationTechnologyType techType);
-    void gnssDisable();
-    void gnssConfigurationUpdate(const GnssConfig& gnssConfig);
-
-    inline LocationCapabilitiesMask gnssGetCapabilities() const {
-        return mLocationCapabilitiesMask;
-    }
-    void requestCapabilities();
-
-    // callbacks we are interested in
-    void onCapabilitiesCb(LocationCapabilitiesMask capabilitiesMask) final;
-    void onTrackingCb(Location location) final;
-    void onGnssNiCb(uint32_t id, GnssNiNotification gnssNiNotification) final;
-    void onGnssSvCb(GnssSvNotification gnssSvNotification) final;
-    void onGnssNmeaCb(GnssNmeaNotification gnssNmeaNotification) final;
-
-    void onStartTrackingCb(LocationError error) final;
-    void onStopTrackingCb(LocationError error) final;
-
-private:
-    virtual ~GnssAPIClient();
-
-    sp<V1_0::IGnssCallback> mGnssCbIface;
-    sp<V1_0::IGnssNiCallback> mGnssNiCbIface;
-    std::mutex mMutex;
-    LocationAPIControlClient* mControlClient;
-    LocationCapabilitiesMask mLocationCapabilitiesMask;
-    bool mLocationCapabilitiesCached;
-    TrackingOptions mTrackingOptions;
-};
-
-}  // namespace implementation
-}  // namespace V1_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
-#endif // GNSS_API_CLINET_H
diff --git a/gps/android/1.0/location_api/LocationUtil.cpp b/gps/android/1.0/location_api/LocationUtil.cpp
deleted file mode 100644
index 870a8aa..0000000
--- a/gps/android/1.0/location_api/LocationUtil.cpp
+++ /dev/null
@@ -1,274 +0,0 @@
-/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- *       copyright notice, this list of conditions and the following
- *       disclaimer in the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of The Linux Foundation, nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#include <LocationUtil.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_0 {
-namespace implementation {
-
-using ::android::hardware::gnss::V1_0::GnssLocation;
-using ::android::hardware::gnss::V1_0::GnssConstellationType;
-using ::android::hardware::gnss::V1_0::GnssLocationFlags;
-
-void convertGnssLocation(Location& in, GnssLocation& out)
-{
-    memset(&out, 0, sizeof(GnssLocation));
-    if (in.flags & LOCATION_HAS_LAT_LONG_BIT) {
-        out.gnssLocationFlags |= GnssLocationFlags::HAS_LAT_LONG;
-        out.latitudeDegrees = in.latitude;
-        out.longitudeDegrees = in.longitude;
-    }
-    if (in.flags & LOCATION_HAS_ALTITUDE_BIT) {
-        out.gnssLocationFlags |= GnssLocationFlags::HAS_ALTITUDE;
-        out.altitudeMeters = in.altitude;
-    }
-    if (in.flags & LOCATION_HAS_SPEED_BIT) {
-        out.gnssLocationFlags |= GnssLocationFlags::HAS_SPEED;
-        out.speedMetersPerSec = in.speed;
-    }
-    if (in.flags & LOCATION_HAS_BEARING_BIT) {
-        out.gnssLocationFlags |= GnssLocationFlags::HAS_BEARING;
-        out.bearingDegrees = in.bearing;
-    }
-    if (in.flags & LOCATION_HAS_ACCURACY_BIT) {
-        out.gnssLocationFlags |= GnssLocationFlags::HAS_HORIZONTAL_ACCURACY;
-        out.horizontalAccuracyMeters = in.accuracy;
-    }
-    if (in.flags & LOCATION_HAS_VERTICAL_ACCURACY_BIT) {
-        out.gnssLocationFlags |= GnssLocationFlags::HAS_VERTICAL_ACCURACY;
-        out.verticalAccuracyMeters = in.verticalAccuracy;
-    }
-    if (in.flags & LOCATION_HAS_SPEED_ACCURACY_BIT) {
-        out.gnssLocationFlags |= GnssLocationFlags::HAS_SPEED_ACCURACY;
-        out.speedAccuracyMetersPerSecond = in.speedAccuracy;
-    }
-    if (in.flags & LOCATION_HAS_BEARING_ACCURACY_BIT) {
-        out.gnssLocationFlags |= GnssLocationFlags::HAS_BEARING_ACCURACY;
-        out.bearingAccuracyDegrees = in.bearingAccuracy;
-    }
-
-    out.timestamp = static_cast<V1_0::GnssUtcTime>(in.timestamp);
-}
-
-void convertGnssLocation(const GnssLocation& in, Location& out)
-{
-    memset(&out, 0, sizeof(out));
-    if (in.gnssLocationFlags & GnssLocationFlags::HAS_LAT_LONG) {
-        out.flags |= LOCATION_HAS_LAT_LONG_BIT;
-        out.latitude = in.latitudeDegrees;
-        out.longitude = in.longitudeDegrees;
-    }
-    if (in.gnssLocationFlags & GnssLocationFlags::HAS_ALTITUDE) {
-        out.flags |= LOCATION_HAS_ALTITUDE_BIT;
-        out.altitude = in.altitudeMeters;
-    }
-    if (in.gnssLocationFlags & GnssLocationFlags::HAS_SPEED) {
-        out.flags |= LOCATION_HAS_SPEED_BIT;
-        out.speed = in.speedMetersPerSec;
-    }
-    if (in.gnssLocationFlags & GnssLocationFlags::HAS_BEARING) {
-        out.flags |= LOCATION_HAS_BEARING_BIT;
-        out.bearing = in.bearingDegrees;
-    }
-    if (in.gnssLocationFlags & GnssLocationFlags::HAS_HORIZONTAL_ACCURACY) {
-        out.flags |= LOCATION_HAS_ACCURACY_BIT;
-        out.accuracy = in.horizontalAccuracyMeters;
-    }
-    if (in.gnssLocationFlags & GnssLocationFlags::HAS_VERTICAL_ACCURACY) {
-        out.flags |= LOCATION_HAS_VERTICAL_ACCURACY_BIT;
-        out.verticalAccuracy = in.verticalAccuracyMeters;
-    }
-    if (in.gnssLocationFlags & GnssLocationFlags::HAS_SPEED_ACCURACY) {
-        out.flags |= LOCATION_HAS_SPEED_ACCURACY_BIT;
-        out.speedAccuracy = in.speedAccuracyMetersPerSecond;
-    }
-    if (in.gnssLocationFlags & GnssLocationFlags::HAS_BEARING_ACCURACY) {
-        out.flags |= LOCATION_HAS_BEARING_ACCURACY_BIT;
-        out.bearingAccuracy = in.bearingAccuracyDegrees;
-    }
-
-    out.timestamp = static_cast<uint64_t>(in.timestamp);
-}
-
-void convertGnssConstellationType(GnssSvType& in, GnssConstellationType& out)
-{
-    switch(in) {
-        case GNSS_SV_TYPE_GPS:
-            out = GnssConstellationType::GPS;
-            break;
-        case GNSS_SV_TYPE_SBAS:
-            out = GnssConstellationType::SBAS;
-            break;
-        case GNSS_SV_TYPE_GLONASS:
-            out = GnssConstellationType::GLONASS;
-            break;
-        case GNSS_SV_TYPE_QZSS:
-            out = GnssConstellationType::QZSS;
-            break;
-        case GNSS_SV_TYPE_BEIDOU:
-            out = GnssConstellationType::BEIDOU;
-            break;
-        case GNSS_SV_TYPE_GALILEO:
-            out = GnssConstellationType::GALILEO;
-            break;
-        case GNSS_SV_TYPE_UNKNOWN:
-        default:
-            out = GnssConstellationType::UNKNOWN;
-            break;
-    }
-}
-
-void convertGnssSvid(GnssSv& in, int16_t& out)
-{
-    switch(in.type){
-        case GNSS_SV_TYPE_GPS:
-            out = in.svId;
-            break;
-        case GNSS_SV_TYPE_SBAS:
-            out = in.svId;
-            break;
-        case GNSS_SV_TYPE_GLONASS:
-            if (!isGloSlotUnknown(in.svId)) { // OSN is known
-                out = in.svId - GLO_SV_PRN_MIN + 1;
-            } else { // OSN is not known, report FCN
-                out = in.gloFrequency + 92;
-            }
-            break;
-        case GNSS_SV_TYPE_QZSS:
-            out = in.svId;
-            break;
-        case GNSS_SV_TYPE_BEIDOU:
-            out = in.svId - BDS_SV_PRN_MIN + 1;
-            break;
-        case GNSS_SV_TYPE_GALILEO:
-            out = in.svId - GAL_SV_PRN_MIN + 1;
-            break;
-        case GNSS_SV_TYPE_NAVIC:
-            out = in.svId - NAVIC_SV_PRN_MIN + 1;
-            break;
-        default:
-            out = in.svId;
-            break;
-    }
-}
-
-void convertGnssSvid(GnssMeasurementsData& in, int16_t& out)
-{
-    switch (in.svType) {
-        case GNSS_SV_TYPE_GPS:
-            out = in.svId;
-            break;
-        case GNSS_SV_TYPE_SBAS:
-            out = in.svId;
-            break;
-        case GNSS_SV_TYPE_GLONASS:
-            if (!isGloSlotUnknown(in.svId)) { // OSN is known
-                out = in.svId - GLO_SV_PRN_MIN + 1;
-            } else { // OSN is not known, report FCN
-                out = in.gloFrequency + 92;
-            }
-            break;
-        case GNSS_SV_TYPE_QZSS:
-            out = in.svId;
-            break;
-        case GNSS_SV_TYPE_BEIDOU:
-            out = in.svId - BDS_SV_PRN_MIN + 1;
-            break;
-        case GNSS_SV_TYPE_GALILEO:
-            out = in.svId - GAL_SV_PRN_MIN + 1;
-            break;
-        case GNSS_SV_TYPE_NAVIC:
-            out = in.svId - NAVIC_SV_PRN_MIN + 1;
-            break;
-        default:
-            out = in.svId;
-            break;
-    }
-}
-
-void convertGnssEphemerisType(GnssEphemerisType& in, GnssDebug::SatelliteEphemerisType& out)
-{
-    switch(in) {
-        case GNSS_EPH_TYPE_EPHEMERIS:
-            out = GnssDebug::SatelliteEphemerisType::EPHEMERIS;
-            break;
-        case GNSS_EPH_TYPE_ALMANAC:
-            out = GnssDebug::SatelliteEphemerisType::ALMANAC_ONLY;
-            break;
-        case GNSS_EPH_TYPE_UNKNOWN:
-        default:
-            out = GnssDebug::SatelliteEphemerisType::NOT_AVAILABLE;
-            break;
-    }
-}
-
-void convertGnssEphemerisSource(GnssEphemerisSource& in, GnssDebug::SatelliteEphemerisSource& out)
-{
-    switch(in) {
-        case GNSS_EPH_SOURCE_DEMODULATED:
-            out = GnssDebug::SatelliteEphemerisSource::DEMODULATED;
-            break;
-        case GNSS_EPH_SOURCE_SUPL_PROVIDED:
-            out = GnssDebug::SatelliteEphemerisSource::SUPL_PROVIDED;
-            break;
-        case GNSS_EPH_SOURCE_OTHER_SERVER_PROVIDED:
-            out = GnssDebug::SatelliteEphemerisSource::OTHER_SERVER_PROVIDED;
-            break;
-        case GNSS_EPH_SOURCE_LOCAL:
-        case GNSS_EPH_SOURCE_UNKNOWN:
-        default:
-            out = GnssDebug::SatelliteEphemerisSource::OTHER;
-            break;
-    }
-}
-
-void convertGnssEphemerisHealth(GnssEphemerisHealth& in, GnssDebug::SatelliteEphemerisHealth& out)
-{
-    switch(in) {
-        case GNSS_EPH_HEALTH_GOOD:
-            out = GnssDebug::SatelliteEphemerisHealth::GOOD;
-            break;
-        case GNSS_EPH_HEALTH_BAD:
-            out = GnssDebug::SatelliteEphemerisHealth::BAD;
-            break;
-        case GNSS_EPH_HEALTH_UNKNOWN:
-        default:
-            out = GnssDebug::SatelliteEphemerisHealth::UNKNOWN;
-            break;
-    }
-}
-
-}  // namespace implementation
-}  // namespace V1_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
diff --git a/gps/android/1.0/location_api/LocationUtil.h b/gps/android/1.0/location_api/LocationUtil.h
deleted file mode 100644
index f6760e5..0000000
--- a/gps/android/1.0/location_api/LocationUtil.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- *       copyright notice, this list of conditions and the following
- *       disclaimer in the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of The Linux Foundation, nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#ifndef LOCATION_UTIL_H
-#define LOCATION_UTIL_H
-
-#include <android/hardware/gnss/1.0/types.h>
-#include <LocationAPI.h>
-#include <GnssDebug.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_0 {
-namespace implementation {
-
-void convertGnssLocation(Location& in, V1_0::GnssLocation& out);
-void convertGnssLocation(const V1_0::GnssLocation& in, Location& out);
-void convertGnssConstellationType(GnssSvType& in, V1_0::GnssConstellationType& out);
-void convertGnssSvid(GnssSv& in, int16_t& out);
-void convertGnssSvid(GnssMeasurementsData& in, int16_t& out);
-void convertGnssEphemerisType(GnssEphemerisType& in, GnssDebug::SatelliteEphemerisType& out);
-void convertGnssEphemerisSource(GnssEphemerisSource& in, GnssDebug::SatelliteEphemerisSource& out);
-void convertGnssEphemerisHealth(GnssEphemerisHealth& in, GnssDebug::SatelliteEphemerisHealth& out);
-
-}  // namespace implementation
-}  // namespace V1_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
-#endif // LOCATION_UTIL_H
diff --git a/gps/android/1.0/location_api/MeasurementAPIClient.cpp b/gps/android/1.0/location_api/MeasurementAPIClient.cpp
deleted file mode 100644
index 41ba582..0000000
--- a/gps/android/1.0/location_api/MeasurementAPIClient.cpp
+++ /dev/null
@@ -1,253 +0,0 @@
-/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- *       copyright notice, this list of conditions and the following
- *       disclaimer in the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of The Linux Foundation, nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#define LOG_NDEBUG 0
-#define LOG_TAG "LocSvc_MeasurementAPIClient"
-
-#include <log_util.h>
-#include <loc_cfg.h>
-
-#include "LocationUtil.h"
-#include "MeasurementAPIClient.h"
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_0 {
-namespace implementation {
-
-using ::android::hardware::gnss::V1_0::IGnssMeasurement;
-using ::android::hardware::gnss::V1_0::IGnssMeasurementCallback;
-
-static void convertGnssData(GnssMeasurementsNotification& in,
-        V1_0::IGnssMeasurementCallback::GnssData& out);
-static void convertGnssMeasurement(GnssMeasurementsData& in,
-        V1_0::IGnssMeasurementCallback::GnssMeasurement& out);
-static void convertGnssClock(GnssMeasurementsClock& in, IGnssMeasurementCallback::GnssClock& out);
-
-MeasurementAPIClient::MeasurementAPIClient() :
-    mGnssMeasurementCbIface(nullptr),
-    mTracking(false)
-{
-    LOC_LOGD("%s]: ()", __FUNCTION__);
-}
-
-MeasurementAPIClient::~MeasurementAPIClient()
-{
-    LOC_LOGD("%s]: ()", __FUNCTION__);
-}
-
-Return<IGnssMeasurement::GnssMeasurementStatus>
-MeasurementAPIClient::startTracking()
-{
-    LocationCallbacks locationCallbacks;
-    memset(&locationCallbacks, 0, sizeof(LocationCallbacks));
-    locationCallbacks.size = sizeof(LocationCallbacks);
-
-    if (mGnssMeasurementCbIface != nullptr) {
-        locationCallbacks.gnssMeasurementsCb =
-            [this](GnssMeasurementsNotification gnssMeasurementsNotification) {
-                onGnssMeasurementsCb(gnssMeasurementsNotification);
-            };
-    }
-
-    locAPISetCallbacks(locationCallbacks);
-
-    TrackingOptions options = {};
-    memset(&options, 0, sizeof(TrackingOptions));
-    options.size = sizeof(TrackingOptions);
-    options.minInterval = 1000;
-    options.mode = GNSS_SUPL_MODE_STANDALONE;
-
-    mTracking = true;
-    LOC_LOGd();
-    locAPIStartTracking(options);
-    return IGnssMeasurement::GnssMeasurementStatus::SUCCESS;
-}
-
-// for GpsMeasurementInterface
-void MeasurementAPIClient::measurementClose() {
-    LOC_LOGD("%s]: ()", __FUNCTION__);
-    mTracking = false;
-    locAPIStopTracking();
-}
-
-// callbacks
-void MeasurementAPIClient::onGnssMeasurementsCb(
-        GnssMeasurementsNotification gnssMeasurementsNotification)
-{
-    LOC_LOGD("%s]: (count: %zu active: %d)",
-            __FUNCTION__, gnssMeasurementsNotification.count, mTracking);
-    if (mTracking) {
-        mMutex.lock();
-        sp<V1_0::IGnssMeasurementCallback> gnssMeasurementCbIface = nullptr;
-        if (mGnssMeasurementCbIface != nullptr) {
-            gnssMeasurementCbIface = mGnssMeasurementCbIface;
-        }
-        mMutex.unlock();
-
-        if (gnssMeasurementCbIface != nullptr) {
-            V1_0::IGnssMeasurementCallback::GnssData gnssData;
-            convertGnssData(gnssMeasurementsNotification, gnssData);
-            auto r = gnssMeasurementCbIface->GnssMeasurementCb(gnssData);
-            if (!r.isOk()) {
-                LOC_LOGE("%s] Error from GnssMeasurementCb description=%s",
-                    __func__, r.description().c_str());
-            }
-        }
-    }
-}
-
-static void convertGnssMeasurement(GnssMeasurementsData& in,
-        V1_0::IGnssMeasurementCallback::GnssMeasurement& out)
-{
-    memset(&out, 0, sizeof(IGnssMeasurementCallback::GnssMeasurement));
-    if (in.flags & GNSS_MEASUREMENTS_DATA_SIGNAL_TO_NOISE_RATIO_BIT)
-        out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_SNR;
-    if (in.flags & GNSS_MEASUREMENTS_DATA_CARRIER_FREQUENCY_BIT)
-        out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_CARRIER_FREQUENCY;
-    if (in.flags & GNSS_MEASUREMENTS_DATA_CARRIER_CYCLES_BIT)
-        out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_CARRIER_CYCLES;
-    if (in.flags & GNSS_MEASUREMENTS_DATA_CARRIER_PHASE_BIT)
-        out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_CARRIER_PHASE;
-    if (in.flags & GNSS_MEASUREMENTS_DATA_CARRIER_PHASE_UNCERTAINTY_BIT)
-        out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_CARRIER_PHASE_UNCERTAINTY;
-    if (in.flags & GNSS_MEASUREMENTS_DATA_AUTOMATIC_GAIN_CONTROL_BIT)
-        out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_AUTOMATIC_GAIN_CONTROL;
-    convertGnssSvid(in, out.svid);
-    convertGnssConstellationType(in.svType, out.constellation);
-    out.timeOffsetNs = in.timeOffsetNs;
-    if (in.stateMask & GNSS_MEASUREMENTS_STATE_CODE_LOCK_BIT)
-        out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_CODE_LOCK;
-    if (in.stateMask & GNSS_MEASUREMENTS_STATE_BIT_SYNC_BIT)
-        out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_BIT_SYNC;
-    if (in.stateMask & GNSS_MEASUREMENTS_STATE_SUBFRAME_SYNC_BIT)
-        out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_SUBFRAME_SYNC;
-    if (in.stateMask & GNSS_MEASUREMENTS_STATE_TOW_DECODED_BIT)
-        out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_TOW_DECODED;
-    if (in.stateMask & GNSS_MEASUREMENTS_STATE_MSEC_AMBIGUOUS_BIT)
-        out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_MSEC_AMBIGUOUS;
-    if (in.stateMask & GNSS_MEASUREMENTS_STATE_SYMBOL_SYNC_BIT)
-        out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_SYMBOL_SYNC;
-    if (in.stateMask & GNSS_MEASUREMENTS_STATE_GLO_STRING_SYNC_BIT)
-        out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GLO_STRING_SYNC;
-    if (in.stateMask & GNSS_MEASUREMENTS_STATE_GLO_TOD_DECODED_BIT)
-        out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GLO_TOD_DECODED;
-    if (in.stateMask & GNSS_MEASUREMENTS_STATE_BDS_D2_BIT_SYNC_BIT)
-        out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_BDS_D2_BIT_SYNC;
-    if (in.stateMask & GNSS_MEASUREMENTS_STATE_BDS_D2_SUBFRAME_SYNC_BIT)
-        out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_BDS_D2_SUBFRAME_SYNC;
-    if (in.stateMask & GNSS_MEASUREMENTS_STATE_GAL_E1BC_CODE_LOCK_BIT)
-        out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GAL_E1BC_CODE_LOCK;
-    if (in.stateMask & GNSS_MEASUREMENTS_STATE_GAL_E1C_2ND_CODE_LOCK_BIT)
-        out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GAL_E1C_2ND_CODE_LOCK;
-    if (in.stateMask & GNSS_MEASUREMENTS_STATE_GAL_E1B_PAGE_SYNC_BIT)
-        out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GAL_E1B_PAGE_SYNC;
-    if (in.stateMask &  GNSS_MEASUREMENTS_STATE_SBAS_SYNC_BIT)
-        out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_SBAS_SYNC;
-    out.receivedSvTimeInNs = in.receivedSvTimeNs;
-    out.receivedSvTimeUncertaintyInNs = in.receivedSvTimeUncertaintyNs;
-    out.cN0DbHz = in.carrierToNoiseDbHz;
-    out.pseudorangeRateMps = in.pseudorangeRateMps;
-    out.pseudorangeRateUncertaintyMps = in.pseudorangeRateUncertaintyMps;
-    if (in.adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_VALID_BIT)
-        out.accumulatedDeltaRangeState |=
-            IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_VALID;
-    if (in.adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_RESET_BIT)
-        out.accumulatedDeltaRangeState |=
-            IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_RESET;
-    if (in.adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_CYCLE_SLIP_BIT)
-        out.accumulatedDeltaRangeState |=
-            IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_CYCLE_SLIP;
-    out.accumulatedDeltaRangeM = in.adrMeters;
-    out.accumulatedDeltaRangeUncertaintyM = in.adrUncertaintyMeters;
-    out.carrierFrequencyHz = in.carrierFrequencyHz;
-    out.carrierCycles = in.carrierCycles;
-    out.carrierPhase = in.carrierPhase;
-    out.carrierPhaseUncertainty = in.carrierPhaseUncertainty;
-    uint8_t indicator =
-        static_cast<uint8_t>(IGnssMeasurementCallback::GnssMultipathIndicator::INDICATOR_UNKNOWN);
-    if (in.multipathIndicator & GNSS_MEASUREMENTS_MULTIPATH_INDICATOR_PRESENT)
-        indicator |= IGnssMeasurementCallback::GnssMultipathIndicator::INDICATOR_PRESENT;
-    if (in.multipathIndicator & GNSS_MEASUREMENTS_MULTIPATH_INDICATOR_NOT_PRESENT)
-        indicator |= IGnssMeasurementCallback::GnssMultipathIndicator::INDICATIOR_NOT_PRESENT;
-    out.multipathIndicator =
-        static_cast<IGnssMeasurementCallback::GnssMultipathIndicator>(indicator);
-    out.snrDb = in.signalToNoiseRatioDb;
-    out.agcLevelDb = in.agcLevelDb;
-}
-
-static void convertGnssClock(GnssMeasurementsClock& in, IGnssMeasurementCallback::GnssClock& out)
-{
-    memset(&out, 0, sizeof(IGnssMeasurementCallback::GnssClock));
-    if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_LEAP_SECOND_BIT)
-        out.gnssClockFlags |= IGnssMeasurementCallback::GnssClockFlags::HAS_LEAP_SECOND;
-    if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_TIME_UNCERTAINTY_BIT)
-        out.gnssClockFlags |= IGnssMeasurementCallback::GnssClockFlags::HAS_TIME_UNCERTAINTY;
-    if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_FULL_BIAS_BIT)
-        out.gnssClockFlags |= IGnssMeasurementCallback::GnssClockFlags::HAS_FULL_BIAS;
-    if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_BIAS_BIT)
-        out.gnssClockFlags |= IGnssMeasurementCallback::GnssClockFlags::HAS_BIAS;
-    if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_BIAS_UNCERTAINTY_BIT)
-        out.gnssClockFlags |= IGnssMeasurementCallback::GnssClockFlags::HAS_BIAS_UNCERTAINTY;
-    if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_DRIFT_BIT)
-        out.gnssClockFlags |= IGnssMeasurementCallback::GnssClockFlags::HAS_DRIFT;
-    if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_DRIFT_UNCERTAINTY_BIT)
-        out.gnssClockFlags |= IGnssMeasurementCallback::GnssClockFlags::HAS_DRIFT_UNCERTAINTY;
-    out.leapSecond = in.leapSecond;
-    out.timeNs = in.timeNs;
-    out.timeUncertaintyNs = in.timeUncertaintyNs;
-    out.fullBiasNs = in.fullBiasNs;
-    out.biasNs = in.biasNs;
-    out.biasUncertaintyNs = in.biasUncertaintyNs;
-    out.driftNsps = in.driftNsps;
-    out.driftUncertaintyNsps = in.driftUncertaintyNsps;
-    out.hwClockDiscontinuityCount = in.hwClockDiscontinuityCount;
-}
-
-static void convertGnssData(GnssMeasurementsNotification& in,
-        V1_0::IGnssMeasurementCallback::GnssData& out)
-{
-    out.measurementCount = in.count;
-    if (out.measurementCount > static_cast<uint32_t>(V1_0::GnssMax::SVS_COUNT)) {
-        LOC_LOGW("%s]: Too many measurement %u. Clamps to %d.",
-                __FUNCTION__,  out.measurementCount, V1_0::GnssMax::SVS_COUNT);
-        out.measurementCount = static_cast<uint32_t>(V1_0::GnssMax::SVS_COUNT);
-    }
-    for (size_t i = 0; i < out.measurementCount; i++) {
-        convertGnssMeasurement(in.measurements[i], out.measurements[i]);
-    }
-    convertGnssClock(in.clock, out.clock);
-}
-
-}  // namespace implementation
-}  // namespace V1_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
diff --git a/gps/android/1.0/location_api/MeasurementAPIClient.h b/gps/android/1.0/location_api/MeasurementAPIClient.h
deleted file mode 100644
index 1c86882..0000000
--- a/gps/android/1.0/location_api/MeasurementAPIClient.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- *       copyright notice, this list of conditions and the following
- *       disclaimer in the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of The Linux Foundation, nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#ifndef MEASUREMENT_API_CLINET_H
-#define MEASUREMENT_API_CLINET_H
-
-#include <mutex>
-#include <android/hardware/gnss/1.0/IGnssMeasurement.h>
-#include <android/hardware/gnss/1.0/IGnssMeasurementCallback.h>
-#include <LocationAPIClientBase.h>
-#include <hidl/Status.h>
-#include <gps_extended_c.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_0 {
-namespace implementation {
-
-using ::android::sp;
-
-class MeasurementAPIClient : public LocationAPIClientBase
-{
-public:
-    MeasurementAPIClient();
-    MeasurementAPIClient(const MeasurementAPIClient&) = delete;
-    MeasurementAPIClient& operator=(const MeasurementAPIClient&) = delete;
-
-    // for GpsMeasurementInterface
-    template <typename T>
-    Return<IGnssMeasurement::GnssMeasurementStatus> measurementSetCallback(
-            const sp<T>& callback, GnssPowerMode powerMode = GNSS_POWER_MODE_INVALID) {
-        mMutex.lock();
-        setCallbackLocked(callback);
-        mMutex.unlock();
-
-        return startTracking();
-    }
-    void measurementClose();
-    Return<IGnssMeasurement::GnssMeasurementStatus> startTracking();
-
-    // callbacks we are interested in
-    void onGnssMeasurementsCb(GnssMeasurementsNotification gnssMeasurementsNotification) final;
-
-private:
-    inline void setCallbackLocked(const sp<V1_0::IGnssMeasurementCallback>& callback) {
-        mGnssMeasurementCbIface = callback;
-    }
-    virtual ~MeasurementAPIClient();
-
-    std::mutex mMutex;
-    sp<V1_0::IGnssMeasurementCallback> mGnssMeasurementCbIface;
-
-    bool mTracking;
-};
-
-}  // namespace implementation
-}  // namespace V1_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
-#endif // MEASUREMENT_API_CLINET_H
diff --git a/gps/android/1.0/service.cpp b/gps/android/1.0/service.cpp
deleted file mode 100644
index 2a6f60f..0000000
--- a/gps/android/1.0/service.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-#define LOG_TAG "android.hardware.gnss@1.0-service-qti"
-
-#include <android/hardware/gnss/1.0/IGnss.h>
-#include <hidl/LegacySupport.h>
-#include "loc_cfg.h"
-#include "loc_misc_utils.h"
-
-extern "C" {
-#include "vndfwk-detect.h"
-}
-
-#ifdef ARCH_ARM_32
-#define DEFAULT_HW_BINDER_MEM_SIZE 65536
-#endif
-
-using android::hardware::gnss::V1_0::IGnss;
-
-using android::hardware::configureRpcThreadpool;
-using android::hardware::registerPassthroughServiceImplementation;
-using android::hardware::joinRpcThreadpool;
-
-using android::status_t;
-using android::OK;
-
-typedef int vendorEnhancedServiceMain(int /* argc */, char* /* argv */ []);
-
-int main() {
-
-    ALOGI("%s", __FUNCTION__);
-
-    int vendorInfo = getVendorEnhancedInfo();
-    bool vendorEnhanced = ( 1 == vendorInfo || 3 == vendorInfo );
-    setVendorEnhanced(vendorEnhanced);
-
-#ifdef ARCH_ARM_32
-    android::hardware::ProcessState::initWithMmapSize((size_t)(DEFAULT_HW_BINDER_MEM_SIZE));
-#endif
-    configureRpcThreadpool(1, true);
-    status_t status;
-
-    status = registerPassthroughServiceImplementation<IGnss>();
-    if (status == OK) {
-        if (vendorEnhanced) {
-    #ifdef LOC_HIDL_VERSION
-            #define VENDOR_ENHANCED_LIB "vendor.qti.gnss@" LOC_HIDL_VERSION "-service.so"
-
-            void* libHandle = NULL;
-            vendorEnhancedServiceMain* vendorEnhancedMainMethod = (vendorEnhancedServiceMain*)
-                    dlGetSymFromLib(libHandle, VENDOR_ENHANCED_LIB, "main");
-            if (NULL != vendorEnhancedMainMethod) {
-                (*vendorEnhancedMainMethod)(0, NULL);
-            }
-    #else
-            ALOGE("LOC_HIDL_VERSION not defined.");
-    #endif
-        }
-
-        joinRpcThreadpool();
-
-    } else {
-        ALOGE("Error while registering IGnss 1.0 service: %d", status);
-    }
-
-    return 0;
-}
diff --git a/gps/android/1.1/AGnss.cpp b/gps/android/1.1/AGnss.cpp
deleted file mode 100644
index c633cc1..0000000
--- a/gps/android/1.1/AGnss.cpp
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-#define LOG_TAG "LocSvc_AGnssInterface"
-
-#include <log_util.h>
-#include "Gnss.h"
-#include "AGnss.h"
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_1 {
-namespace implementation {
-
-static AGnss* spAGnss = nullptr;
-
-AGnss::AGnss(Gnss* gnss) : mGnss(gnss) {
-    spAGnss = this;
-}
-
-AGnss::~AGnss() {
-    spAGnss = nullptr;
-}
-
-void AGnss::agnssStatusIpV4Cb(AGnssExtStatusIpV4 status){
-    if (nullptr != spAGnss) {
-        spAGnss->statusIpV4Cb(status);
-    }
-}
-
-void AGnss::statusIpV4Cb(AGnssExtStatusIpV4 status) {
-    IAGnssCallback::AGnssStatusIpV4 st = {};
-
-    switch (status.type) {
-        case LOC_AGPS_TYPE_SUPL:
-            st.type = IAGnssCallback::AGnssType::TYPE_SUPL;
-            break;
-        case LOC_AGPS_TYPE_C2K:
-            st.type = IAGnssCallback::AGnssType::TYPE_C2K;
-            break;
-        default:
-            LOC_LOGE("invalid type: %d", status.type);
-            return;
-    }
-
-    switch (status.status) {
-        case LOC_GPS_REQUEST_AGPS_DATA_CONN:
-            st.status = IAGnssCallback::AGnssStatusValue::REQUEST_AGNSS_DATA_CONN;
-            break;
-        case LOC_GPS_RELEASE_AGPS_DATA_CONN:
-            st.status = IAGnssCallback::AGnssStatusValue::RELEASE_AGNSS_DATA_CONN;
-            break;
-        case LOC_GPS_AGPS_DATA_CONNECTED:
-            st.status = IAGnssCallback::AGnssStatusValue::AGNSS_DATA_CONNECTED;
-            break;
-        case LOC_GPS_AGPS_DATA_CONN_DONE:
-            st.status = IAGnssCallback::AGnssStatusValue::AGNSS_DATA_CONN_DONE;
-            break;
-        case LOC_GPS_AGPS_DATA_CONN_FAILED:
-            st.status = IAGnssCallback::AGnssStatusValue::AGNSS_DATA_CONN_FAILED;
-            break;
-        default:
-            LOC_LOGE("invalid status: %d", status.status);
-            return;
-    }
-    st.ipV4Addr = status.ipV4Addr;
-
-    mMutex.lock();
-    auto aGnssCbIface = mAGnssCbIface;
-    mMutex.unlock();
-    if (aGnssCbIface != nullptr) {
-        auto r = aGnssCbIface->agnssStatusIpV4Cb(st);
-        if (!r.isOk()) {
-            LOC_LOGw("Error invoking AGNSS status cb %s", r.description().c_str());
-        }
-    } else {
-        LOC_LOGw("setCallback has not been called yet");
-    }
-}
-
-Return<void> AGnss::setCallback(const sp<IAGnssCallback>& callback) {
-
-    if(mGnss == nullptr || mGnss->getGnssInterface() == nullptr){
-        LOC_LOGE("Null GNSS interface");
-        return Void();
-    }
-
-    // Save the interface
-    mMutex.lock();
-    mAGnssCbIface = callback;
-    mMutex.unlock();
-
-    AgpsCbInfo cbInfo = {};
-    cbInfo.statusV4Cb = (void*)agnssStatusIpV4Cb;
-    cbInfo.atlType = AGPS_ATL_TYPE_SUPL | AGPS_ATL_TYPE_SUPL_ES;
-
-    mGnss->getGnssInterface()->agpsInit(cbInfo);
-    return Void();
-}
-
-Return<bool> AGnss::dataConnClosed() {
-
-    if(mGnss == nullptr || mGnss->getGnssInterface() == nullptr){
-        LOC_LOGE("Null GNSS interface");
-        return false;
-    }
-
-    mGnss->getGnssInterface()->agpsDataConnClosed(LOC_AGPS_TYPE_SUPL);
-    return true;
-}
-
-Return<bool> AGnss::dataConnFailed() {
-
-    if(mGnss == nullptr || mGnss->getGnssInterface() == nullptr){
-        LOC_LOGE("Null GNSS interface");
-        return false;
-    }
-
-    mGnss->getGnssInterface()->agpsDataConnFailed(LOC_AGPS_TYPE_SUPL);
-    return true;
-}
-
-Return<bool> AGnss::dataConnOpen(const hidl_string& apn,
-        IAGnss::ApnIpType apnIpType) {
-
-    if(mGnss == nullptr || mGnss->getGnssInterface() == nullptr){
-        LOC_LOGE("Null GNSS interface");
-        return false;
-    }
-
-    /* Validate */
-    if(apn.empty()){
-        LOC_LOGE("Invalid APN");
-        return false;
-    }
-
-    LOC_LOGD("dataConnOpen APN name = [%s]", apn.c_str());
-
-    AGpsBearerType bearerType;
-    switch (apnIpType) {
-        case IAGnss::ApnIpType::IPV4:
-            bearerType = AGPS_APN_BEARER_IPV4;
-            break;
-        case IAGnss::ApnIpType::IPV6:
-            bearerType = AGPS_APN_BEARER_IPV6;
-            break;
-        case IAGnss::ApnIpType::IPV4V6:
-            bearerType = AGPS_APN_BEARER_IPV4V6;
-            break;
-        default:
-            bearerType = AGPS_APN_BEARER_IPV4;
-            break;
-    }
-
-    mGnss->getGnssInterface()->agpsDataConnOpen(
-            LOC_AGPS_TYPE_SUPL, apn.c_str(), apn.size(), (int)bearerType);
-    return true;
-}
-
-Return<bool> AGnss::setServer(IAGnssCallback::AGnssType type,
-                              const hidl_string& hostname,
-                              int32_t port) {
-    if (mGnss == nullptr) {
-        LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__);
-        return false;
-    }
-
-    GnssConfig config;
-    memset(&config, 0, sizeof(GnssConfig));
-    config.size = sizeof(GnssConfig);
-    config.flags = GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT;
-    config.assistanceServer.size = sizeof(GnssConfigSetAssistanceServer);
-    if (type == IAGnssCallback::AGnssType::TYPE_SUPL) {
-        config.assistanceServer.type = GNSS_ASSISTANCE_TYPE_SUPL;
-    } else if (type == IAGnssCallback::AGnssType::TYPE_C2K) {
-        config.assistanceServer.type = GNSS_ASSISTANCE_TYPE_C2K;
-    } else {
-        LOC_LOGE("%s]: invalid AGnssType: %d", __FUNCTION__, static_cast<int>(type));
-        return false;
-    }
-    config.assistanceServer.hostName = strdup(hostname.c_str());
-    config.assistanceServer.port = port;
-    return mGnss->updateConfiguration(config);
-}
-
-}  // namespace implementation
-}  // namespace V1_1
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
diff --git a/gps/android/1.1/AGnss.h b/gps/android/1.1/AGnss.h
deleted file mode 100644
index 1783b24..0000000
--- a/gps/android/1.1/AGnss.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-#ifndef ANDROID_HARDWARE_GNSS_V1_1_AGNSS_H
-#define ANDROID_HARDWARE_GNSS_V1_1_AGNSS_H
-
-#include <mutex>
-#include <android/hardware/gnss/1.0/IAGnss.h>
-#include <hidl/Status.h>
-#include <gps_extended_c.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_1 {
-namespace implementation {
-
-using ::android::hardware::gnss::V1_0::IAGnss;
-using ::android::hardware::gnss::V1_0::IAGnssCallback;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::sp;
-
-struct Gnss;
-struct AGnss : public IAGnss {
-
-    AGnss(Gnss* gnss);
-    ~AGnss();
-    /*
-     * Methods from ::android::hardware::gnss::V1_0::IAGnss interface follow.
-     * These declarations were generated from IAGnss.hal.
-     */
-    Return<void> setCallback(const sp<IAGnssCallback>& callback) override;
-
-    Return<bool> dataConnClosed() override;
-
-    Return<bool> dataConnFailed() override;
-
-    Return<bool> dataConnOpen(const hidl_string& apn,
-            IAGnss::ApnIpType apnIpType) override;
-
-    Return<bool> setServer(IAGnssCallback::AGnssType type,
-                         const hidl_string& hostname, int32_t port) override;
-
-    void statusIpV4Cb(AGnssExtStatusIpV4 status);
-
-    /* Data call setup callback passed down to GNSS HAL implementation */
-    static void agnssStatusIpV4Cb(AGnssExtStatusIpV4 status);
-
- private:
-    Gnss* mGnss = nullptr;
-    std::mutex mMutex;
-    sp<IAGnssCallback> mAGnssCbIface = nullptr;
-};
-
-}  // namespace implementation
-}  // namespace V1_1
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
-
-#endif  // ANDROID_HARDWARE_GNSS_V1_1_AGNSS_H
diff --git a/gps/android/1.1/AGnssRil.cpp b/gps/android/1.1/AGnssRil.cpp
deleted file mode 100644
index 26254e5..0000000
--- a/gps/android/1.1/AGnssRil.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-#define LOG_TAG "LocSvc__AGnssRilInterface"
-
-#include <log_util.h>
-#include <dlfcn.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <sstream>
-#include <string>
-#include "Gnss.h"
-#include "AGnssRil.h"
-#include <DataItemConcreteTypes.h>
-
-typedef void* (getLocationInterface)();
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_1 {
-namespace implementation {
-
-
-AGnssRil::AGnssRil(Gnss* gnss) : mGnss(gnss) {
-    ENTRY_LOG_CALLFLOW();
-}
-
-AGnssRil::~AGnssRil() {
-    ENTRY_LOG_CALLFLOW();
-}
-
-Return<bool> AGnssRil::updateNetworkState(bool connected, NetworkType type, bool /*roaming*/) {
-    ENTRY_LOG_CALLFLOW();
-    // Extra NetworkTypes not available in IAgnssRil enums
-    const int NetworkType_BLUETOOTH = 7;
-    const int NetworkType_ETHERNET = 9;
-    const int NetworkType_PROXY = 16;
-    std::string apn("");
-
-    // for XTRA
-    if (nullptr != mGnss && ( nullptr != mGnss->getGnssInterface() )) {
-        int8_t typeout = loc_core::TYPE_UNKNOWN;
-        switch(type)
-        {
-            case IAGnssRil::NetworkType::MOBILE:
-                typeout = loc_core::TYPE_MOBILE;
-                break;
-            case IAGnssRil::NetworkType::WIFI:
-                typeout = loc_core::TYPE_WIFI;
-                break;
-            case IAGnssRil::NetworkType::MMS:
-                typeout = loc_core::TYPE_MMS;
-                break;
-            case IAGnssRil::NetworkType::SUPL:
-                typeout = loc_core::TYPE_SUPL;
-                break;
-            case IAGnssRil::NetworkType::DUN:
-                typeout = loc_core::TYPE_DUN;
-                break;
-            case IAGnssRil::NetworkType::HIPRI:
-                typeout = loc_core::TYPE_HIPRI;
-                break;
-            case IAGnssRil::NetworkType::WIMAX:
-                typeout = loc_core::TYPE_WIMAX;
-                break;
-            default:
-                {
-                    int networkType = (int) type;
-                    // Handling network types not available in IAgnssRil
-                    switch(networkType)
-                    {
-                        case NetworkType_BLUETOOTH:
-                            typeout = loc_core::TYPE_BLUETOOTH;
-                            break;
-                        case NetworkType_ETHERNET:
-                            typeout = loc_core::TYPE_ETHERNET;
-                            break;
-                        case NetworkType_PROXY:
-                            typeout = loc_core::TYPE_PROXY;
-                            break;
-                        default:
-                            typeout = loc_core::TYPE_UNKNOWN;
-                    }
-                }
-                break;
-        }
-        mGnss->getGnssInterface()->updateConnectionStatus(connected, typeout, false, 0, apn);
-    }
-    return true;
-}
-
-}  // namespace implementation
-}  // namespace V1_1
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
diff --git a/gps/android/1.1/AGnssRil.h b/gps/android/1.1/AGnssRil.h
deleted file mode 100644
index 5c9298a..0000000
--- a/gps/android/1.1/AGnssRil.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-#ifndef ANDROID_HARDWARE_GNSS_V1_0_AGNSSRIL_H_
-#define ANDROID_HARDWARE_GNSS_V1_0_AGNSSRIL_H_
-
-#include <android/hardware/gnss/1.0/IAGnssRil.h>
-#include <hidl/Status.h>
-#include <location_interface.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_1 {
-namespace implementation {
-
-using ::android::hardware::gnss::V1_0::IAGnssRil;
-using ::android::hardware::gnss::V1_0::IAGnssRilCallback;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::sp;
-
-struct Gnss;
-/*
- * Extended interface for AGNSS RIL support. An Assisted GNSS Radio Interface Layer interface
- * allows the GNSS chipset to request radio interface layer information from Android platform.
- * Examples of such information are reference location, unique subscriber ID, phone number string
- * and network availability changes. Also contains wrapper methods to allow methods from
- * IAGnssiRilCallback interface to be passed into the conventional implementation of the GNSS HAL.
- */
-struct AGnssRil : public IAGnssRil {
-    AGnssRil(Gnss* gnss);
-    ~AGnssRil();
-
-    /*
-     * Methods from ::android::hardware::gnss::V1_0::IAGnssRil follow.
-     * These declarations were generated from IAGnssRil.hal.
-     */
-    Return<void> setCallback(const sp<IAGnssRilCallback>& /*callback*/) override {
-        return Void();
-    }
-    Return<void> setRefLocation(const IAGnssRil::AGnssRefLocation& /*agnssReflocation*/) override {
-        return Void();
-    }
-    Return<bool> setSetId(IAGnssRil::SetIDType /*type*/, const hidl_string& /*setid*/) override {
-        return false;
-    }
-    Return<bool> updateNetworkAvailability(bool /*available*/,
-                                    const hidl_string& /*apn*/) override {
-        return false;
-    }
-    Return<bool> updateNetworkState(bool connected, NetworkType type, bool roaming) override;
-
- private:
-    Gnss* mGnss = nullptr;
-};
-
-}  // namespace implementation
-}  // namespace V1_1
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
-
-#endif  // ANDROID_HARDWARE_GNSS_V1_0_AGNSSRIL_H_
diff --git a/gps/android/1.1/Android.mk b/gps/android/1.1/Android.mk
deleted file mode 100644
index 27272ae..0000000
--- a/gps/android/1.1/Android.mk
+++ /dev/null
@@ -1,97 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.gnss@1.1-impl-qti
-
-LOCAL_VENDOR_MODULE := true
-LOCAL_MODULE_RELATIVE_PATH := hw
-LOCAL_SRC_FILES := \
-    AGnss.cpp \
-    Gnss.cpp \
-    GnssBatching.cpp \
-    GnssGeofencing.cpp \
-    GnssMeasurement.cpp \
-    GnssNi.cpp \
-    GnssConfiguration.cpp \
-    GnssDebug.cpp \
-    AGnssRil.cpp
-
-LOCAL_SRC_FILES += \
-    location_api/LocationUtil.cpp \
-    location_api/GnssAPIClient.cpp \
-    location_api/GeofenceAPIClient.cpp \
-    location_api/BatchingAPIClient.cpp \
-    location_api/MeasurementAPIClient.cpp \
-
-LOCAL_C_INCLUDES:= \
-    $(LOCAL_PATH)/location_api
-LOCAL_HEADER_LIBRARIES := \
-    libgps.utils_headers \
-    libloc_core_headers \
-    libloc_pla_headers \
-    liblocation_api_headers \
-    liblocbatterylistener_headers
-
-LOCAL_SHARED_LIBRARIES := \
-    liblog \
-    libhidlbase \
-    libcutils \
-    libutils \
-    android.hardware.gnss@1.0 \
-    android.hardware.gnss@1.1 \
-    android.hardware.health@1.0 \
-    android.hardware.health@2.0 \
-    android.hardware.power@1.2 \
-    libbase
-
-LOCAL_SHARED_LIBRARIES += \
-    libloc_core \
-    libgps.utils \
-    libdl \
-    liblocation_api \
-
-LOCAL_CFLAGS += $(GNSS_CFLAGS)
-LOCAL_STATIC_LIBRARIES := liblocbatterylistener
-LOCAL_STATIC_LIBRARIES += libhealthhalutils
-include $(BUILD_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.gnss@1.1-service-qti
-
-LOCAL_VINTF_FRAGMENTS := android.hardware.gnss@1.1-service-qti.xml
-LOCAL_VENDOR_MODULE := true
-LOCAL_MODULE_RELATIVE_PATH := hw
-LOCAL_INIT_RC := android.hardware.gnss@1.1-service-qti.rc
-LOCAL_SRC_FILES := \
-    service.cpp \
-
-LOCAL_C_INCLUDES:= \
-    $(LOCAL_PATH)/location_api
-LOCAL_HEADER_LIBRARIES := \
-    libgps.utils_headers \
-    libloc_core_headers \
-    libloc_pla_headers \
-    liblocation_api_headers
-
-
-LOCAL_SHARED_LIBRARIES := \
-    liblog \
-    libcutils \
-    libdl \
-    libbase \
-    libutils \
-    libgps.utils \
-    libqti_vndfwk_detect \
-
-LOCAL_SHARED_LIBRARIES += \
-    libhidlbase \
-    android.hardware.gnss@1.0 \
-    android.hardware.gnss@1.1 \
-
-LOCAL_CFLAGS += $(GNSS_CFLAGS)
-
-ifneq ($(LOC_HIDL_VERSION),)
-LOCAL_CFLAGS += -DLOC_HIDL_VERSION='"$(LOC_HIDL_VERSION)"'
-endif
-
-include $(BUILD_EXECUTABLE)
diff --git a/gps/android/1.1/Gnss.cpp b/gps/android/1.1/Gnss.cpp
deleted file mode 100644
index b5ce11a..0000000
--- a/gps/android/1.1/Gnss.cpp
+++ /dev/null
@@ -1,467 +0,0 @@
-/*
- * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-#define LOG_TAG "LocSvc_GnssInterface"
-#define LOG_NDEBUG 0
-
-#include <fstream>
-#include <log_util.h>
-#include <dlfcn.h>
-#include <cutils/properties.h>
-#include "Gnss.h"
-#include <LocationUtil.h>
-
-#include "battery_listener.h"
-#include "loc_misc_utils.h"
-
-typedef const GnssInterface* (getLocationInterface)();
-
-#define IMAGES_INFO_FILE "/sys/devices/soc0/images"
-#define DELIMITER ";"
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_1 {
-namespace implementation {
-
-static sp<Gnss> sGnss;
-static std::string getVersionString() {
-    static std::string version;
-    if (!version.empty())
-        return version;
-
-    char value[PROPERTY_VALUE_MAX] = {0};
-    property_get("ro.hardware", value, "unknown");
-    version.append(value).append(DELIMITER);
-
-    std::ifstream in(IMAGES_INFO_FILE);
-    std::string s;
-    while(getline(in, s)) {
-        std::size_t found = s.find("CRM:");
-        if (std::string::npos == found) {
-            continue;
-        }
-
-        // skip over space characters after "CRM:"
-        const char* substr = s.c_str();
-        found += 4;
-        while (0 != substr[found] && isspace(substr[found])) {
-            found++;
-        }
-        if (s.find("11:") != found) {
-            continue;
-        }
-        s.erase(0, found + 3);
-
-        found = s.find_first_of("\r\n");
-        if (std::string::npos != found) {
-            s.erase(s.begin() + found, s.end());
-        }
-        version.append(s).append(DELIMITER);
-    }
-    return version;
-}
-
-void Gnss::GnssDeathRecipient::serviceDied(uint64_t cookie, const wp<IBase>& who) {
-    LOC_LOGE("%s] service died. cookie: %llu, who: %p",
-            __FUNCTION__, static_cast<unsigned long long>(cookie), &who);
-    if (mGnss != nullptr) {
-        mGnss->getGnssInterface()->resetNetworkInfo();
-        mGnss->stop();
-        mGnss->cleanup();
-    }
-}
-
-void location_on_battery_status_changed(bool charging) {
-    LOC_LOGd("battery status changed to %s charging", charging ? "" : "not");
-    if (sGnss != nullptr) {
-        sGnss->getGnssInterface()->updateBatteryStatus(charging);
-    }
-}
-Gnss::Gnss() {
-    ENTRY_LOG_CALLFLOW();
-    sGnss = this;
-    // initilize gnss interface at first in case needing notify battery status
-    sGnss->getGnssInterface()->initialize();
-    // register health client to listen on battery change
-    loc_extn_battery_properties_listener_init(location_on_battery_status_changed);
-    // clear pending GnssConfig
-    memset(&mPendingConfig, 0, sizeof(GnssConfig));
-
-    mGnssDeathRecipient = new GnssDeathRecipient(this);
-}
-
-Gnss::~Gnss() {
-    ENTRY_LOG_CALLFLOW();
-    if (mApi != nullptr) {
-        mApi->destroy();
-        mApi = nullptr;
-    }
-    sGnss = nullptr;
-}
-
-GnssAPIClient* Gnss::getApi() {
-    if (mApi == nullptr && (mGnssCbIface != nullptr || mGnssNiCbIface != nullptr)) {
-        mApi = new GnssAPIClient(mGnssCbIface, mGnssNiCbIface);
-        if (mApi == nullptr) {
-            LOC_LOGE("%s] faild to create GnssAPIClient", __FUNCTION__);
-            return mApi;
-        }
-
-        if (mPendingConfig.size == sizeof(GnssConfig)) {
-            // we have pending GnssConfig
-            mApi->gnssConfigurationUpdate(mPendingConfig);
-            // clear size to invalid mPendingConfig
-            mPendingConfig.size = 0;
-            if (mPendingConfig.assistanceServer.hostName != nullptr) {
-                free((void*)mPendingConfig.assistanceServer.hostName);
-            }
-        }
-    }
-    if (mApi == nullptr) {
-        LOC_LOGW("%s] GnssAPIClient is not ready", __FUNCTION__);
-    }
-    return mApi;
-}
-
-const GnssInterface* Gnss::getGnssInterface() {
-    static bool getGnssInterfaceFailed = false;
-    if (nullptr == mGnssInterface && !getGnssInterfaceFailed) {
-        void * libHandle = nullptr;
-        getLocationInterface* getter = (getLocationInterface*)
-                dlGetSymFromLib(libHandle, "libgnss.so", "getGnssInterface");
-
-        if (nullptr == getter) {
-            getGnssInterfaceFailed = true;
-        } else {
-            mGnssInterface = (const GnssInterface*)(*getter)();
-        }
-    }
-    return mGnssInterface;
-}
-
-Return<bool> Gnss::setCallback(const sp<V1_0::IGnssCallback>& callback)  {
-    ENTRY_LOG_CALLFLOW();
-    if (mGnssCbIface != nullptr) {
-        mGnssCbIface->unlinkToDeath(mGnssDeathRecipient);
-    }
-    mGnssCbIface = callback;
-    if (mGnssCbIface != nullptr) {
-        mGnssCbIface->linkToDeath(mGnssDeathRecipient, 0 /*cookie*/);
-    }
-
-    GnssAPIClient* api = getApi();
-    if (api != nullptr) {
-        api->gnssUpdateCallbacks(mGnssCbIface, mGnssNiCbIface);
-        api->gnssEnable(LOCATION_TECHNOLOGY_TYPE_GNSS);
-        api->requestCapabilities();
-    }
-    return true;
-}
-
-Return<bool> Gnss::setGnssNiCb(const sp<IGnssNiCallback>& callback) {
-    ENTRY_LOG_CALLFLOW();
-    mGnssNiCbIface = callback;
-    GnssAPIClient* api = getApi();
-    if (api != nullptr) {
-        api->gnssUpdateCallbacks(mGnssCbIface, mGnssNiCbIface);
-    }
-    return true;
-}
-
-Return<bool> Gnss::updateConfiguration(GnssConfig& gnssConfig) {
-    ENTRY_LOG_CALLFLOW();
-    GnssAPIClient* api = getApi();
-    if (api) {
-        api->gnssConfigurationUpdate(gnssConfig);
-    } else if (gnssConfig.flags != 0) {
-        // api is not ready yet, update mPendingConfig with gnssConfig
-        mPendingConfig.size = sizeof(GnssConfig);
-
-        if (gnssConfig.flags & GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT) {
-            mPendingConfig.flags |= GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT;
-            mPendingConfig.gpsLock = gnssConfig.gpsLock;
-        }
-        if (gnssConfig.flags & GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT) {
-            mPendingConfig.flags |= GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT;
-            mPendingConfig.suplVersion = gnssConfig.suplVersion;
-        }
-        if (gnssConfig.flags & GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT) {
-            mPendingConfig.flags |= GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT;
-            mPendingConfig.assistanceServer.size = sizeof(GnssConfigSetAssistanceServer);
-            mPendingConfig.assistanceServer.type = gnssConfig.assistanceServer.type;
-            if (mPendingConfig.assistanceServer.hostName != nullptr) {
-                free((void*)mPendingConfig.assistanceServer.hostName);
-                mPendingConfig.assistanceServer.hostName =
-                    strdup(gnssConfig.assistanceServer.hostName);
-            }
-            mPendingConfig.assistanceServer.port = gnssConfig.assistanceServer.port;
-        }
-        if (gnssConfig.flags & GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT) {
-            mPendingConfig.flags |= GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT;
-            mPendingConfig.lppProfileMask = gnssConfig.lppProfileMask;
-        }
-        if (gnssConfig.flags & GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT) {
-            mPendingConfig.flags |= GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT;
-            mPendingConfig.lppeControlPlaneMask = gnssConfig.lppeControlPlaneMask;
-        }
-        if (gnssConfig.flags & GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT) {
-            mPendingConfig.flags |= GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT;
-            mPendingConfig.lppeUserPlaneMask = gnssConfig.lppeUserPlaneMask;
-        }
-        if (gnssConfig.flags & GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT) {
-            mPendingConfig.flags |= GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT;
-            mPendingConfig.aGlonassPositionProtocolMask = gnssConfig.aGlonassPositionProtocolMask;
-        }
-        if (gnssConfig.flags & GNSS_CONFIG_FLAGS_EM_PDN_FOR_EM_SUPL_VALID_BIT) {
-            mPendingConfig.flags |= GNSS_CONFIG_FLAGS_EM_PDN_FOR_EM_SUPL_VALID_BIT;
-            mPendingConfig.emergencyPdnForEmergencySupl = gnssConfig.emergencyPdnForEmergencySupl;
-        }
-        if (gnssConfig.flags & GNSS_CONFIG_FLAGS_SUPL_EM_SERVICES_BIT) {
-            mPendingConfig.flags |= GNSS_CONFIG_FLAGS_SUPL_EM_SERVICES_BIT;
-            mPendingConfig.suplEmergencyServices = gnssConfig.suplEmergencyServices;
-        }
-        if (gnssConfig.flags & GNSS_CONFIG_FLAGS_SUPL_MODE_BIT) {
-            mPendingConfig.flags |= GNSS_CONFIG_FLAGS_SUPL_MODE_BIT;
-            mPendingConfig.suplModeMask = gnssConfig.suplModeMask;
-        }
-        if (gnssConfig.flags & GNSS_CONFIG_FLAGS_BLACKLISTED_SV_IDS_BIT) {
-            mPendingConfig.flags |= GNSS_CONFIG_FLAGS_BLACKLISTED_SV_IDS_BIT;
-            mPendingConfig.blacklistedSvIds = gnssConfig.blacklistedSvIds;
-        }
-    }
-    return true;
-}
-
-Return<bool> Gnss::start()  {
-    ENTRY_LOG_CALLFLOW();
-    bool retVal = false;
-    GnssAPIClient* api = getApi();
-    if (api) {
-        retVal = api->gnssStart();
-    }
-    return retVal;
-}
-
-Return<bool> Gnss::stop()  {
-    ENTRY_LOG_CALLFLOW();
-    bool retVal = false;
-    GnssAPIClient* api = getApi();
-    if (api) {
-        retVal = api->gnssStop();
-    }
-    return retVal;
-}
-
-Return<void> Gnss::cleanup()  {
-    ENTRY_LOG_CALLFLOW();
-
-    if (mApi != nullptr) {
-        mApi->gnssDisable();
-    }
-
-    return Void();
-}
-
-Return<bool> Gnss::injectLocation(double latitudeDegrees,
-                                  double longitudeDegrees,
-                                  float accuracyMeters)  {
-    ENTRY_LOG_CALLFLOW();
-    const GnssInterface* gnssInterface = getGnssInterface();
-    if (nullptr != gnssInterface) {
-        gnssInterface->injectLocation(latitudeDegrees, longitudeDegrees, accuracyMeters);
-        return true;
-    } else {
-        return false;
-    }
-}
-
-Return<bool> Gnss::injectTime(int64_t timeMs, int64_t timeReferenceMs,
-                              int32_t uncertaintyMs) {
-    return true;
-}
-
-Return<void> Gnss::deleteAidingData(V1_0::IGnss::GnssAidingData aidingDataFlags)  {
-    ENTRY_LOG_CALLFLOW();
-    GnssAPIClient* api = getApi();
-    if (api) {
-        api->gnssDeleteAidingData(aidingDataFlags);
-    }
-    return Void();
-}
-
-Return<bool> Gnss::setPositionMode(V1_0::IGnss::GnssPositionMode mode,
-                                   V1_0::IGnss::GnssPositionRecurrence recurrence,
-                                   uint32_t minIntervalMs,
-                                   uint32_t preferredAccuracyMeters,
-                                   uint32_t preferredTimeMs)  {
-    ENTRY_LOG_CALLFLOW();
-    bool retVal = false;
-    GnssAPIClient* api = getApi();
-    if (api) {
-        retVal = api->gnssSetPositionMode(mode, recurrence, minIntervalMs,
-                preferredAccuracyMeters, preferredTimeMs);
-    }
-    return retVal;
-}
-
-Return<sp<V1_0::IAGnss>> Gnss::getExtensionAGnss()  {
-    ENTRY_LOG_CALLFLOW();
-    mAGnssIface = new AGnss(this);
-    return mAGnssIface;
-}
-
-Return<sp<V1_0::IGnssNi>> Gnss::getExtensionGnssNi()  {
-    ENTRY_LOG_CALLFLOW();
-    mGnssNi = new GnssNi(this);
-    return mGnssNi;
-}
-
-Return<sp<V1_0::IGnssMeasurement>> Gnss::getExtensionGnssMeasurement() {
-    ENTRY_LOG_CALLFLOW();
-    if (mGnssMeasurement == nullptr)
-        mGnssMeasurement = new GnssMeasurement();
-    return mGnssMeasurement;
-}
-
-Return<sp<V1_0::IGnssConfiguration>> Gnss::getExtensionGnssConfiguration()  {
-    ENTRY_LOG_CALLFLOW();
-    mGnssConfig = new GnssConfiguration(this);
-    return mGnssConfig;
-}
-
-Return<sp<V1_0::IGnssGeofencing>> Gnss::getExtensionGnssGeofencing()  {
-    ENTRY_LOG_CALLFLOW();
-    mGnssGeofencingIface = new GnssGeofencing();
-    return mGnssGeofencingIface;
-}
-
-Return<sp<V1_0::IGnssBatching>> Gnss::getExtensionGnssBatching()  {
-    mGnssBatching = new GnssBatching();
-    return mGnssBatching;
-}
-
-Return<sp<V1_0::IGnssDebug>> Gnss::getExtensionGnssDebug() {
-    ENTRY_LOG_CALLFLOW();
-    mGnssDebug = new GnssDebug(this);
-    return mGnssDebug;
-}
-
-Return<sp<V1_0::IAGnssRil>> Gnss::getExtensionAGnssRil() {
-    mGnssRil = new AGnssRil(this);
-    return mGnssRil;
-}
-
-// Methods from ::android::hardware::gnss::V1_1::IGnss follow.
-Return<bool> Gnss::setCallback_1_1(const sp<V1_1::IGnssCallback>& callback) {
-    ENTRY_LOG_CALLFLOW();
-    callback->gnssNameCb(getVersionString());
-    mGnssCbIface_1_1 = callback;
-    const GnssInterface* gnssInterface = getGnssInterface();
-    if (nullptr != gnssInterface) {
-        OdcpiRequestCallback cb = [this](const OdcpiRequestInfo& odcpiRequest) {
-            odcpiRequestCb(odcpiRequest);
-        };
-        gnssInterface->odcpiInit(cb, OdcpiPrioritytype::ODCPI_HANDLER_PRIORITY_LOW,
-               (EMERGENCY_ODCPI | NON_EMERGENCY_ODCPI));
-    }
-    return setCallback(callback);
-}
-
-Return<bool> Gnss::setPositionMode_1_1(V1_0::IGnss::GnssPositionMode mode,
-        V1_0::IGnss::GnssPositionRecurrence recurrence,
-        uint32_t minIntervalMs,
-        uint32_t preferredAccuracyMeters,
-        uint32_t preferredTimeMs,
-        bool lowPowerMode) {
-    ENTRY_LOG_CALLFLOW();
-    bool retVal = false;
-    GnssAPIClient* api = getApi();
-    if (api) {
-        GnssPowerMode powerMode = lowPowerMode?
-                GNSS_POWER_MODE_M4 : GNSS_POWER_MODE_M2;
-        retVal = api->gnssSetPositionMode(mode, recurrence, minIntervalMs,
-                preferredAccuracyMeters, preferredTimeMs, powerMode, minIntervalMs);
-    }
-    return retVal;
-}
-
-Return<sp<V1_1::IGnssMeasurement>> Gnss::getExtensionGnssMeasurement_1_1() {
-    ENTRY_LOG_CALLFLOW();
-    if (mGnssMeasurement == nullptr)
-        mGnssMeasurement = new GnssMeasurement();
-    return mGnssMeasurement;
-}
-
-Return<sp<V1_1::IGnssConfiguration>> Gnss::getExtensionGnssConfiguration_1_1() {
-    ENTRY_LOG_CALLFLOW();
-    if (mGnssConfig == nullptr)
-        mGnssConfig = new GnssConfiguration(this);
-    return mGnssConfig;
-}
-
-Return<bool> Gnss::injectBestLocation(const GnssLocation& gnssLocation) {
-    ENTRY_LOG_CALLFLOW();
-    const GnssInterface* gnssInterface = getGnssInterface();
-    if (nullptr != gnssInterface) {
-        Location location = {};
-        convertGnssLocation(gnssLocation, location);
-        gnssInterface->odcpiInject(location);
-    }
-    return true;
-}
-
-void Gnss::odcpiRequestCb(const OdcpiRequestInfo& request) {
-    ENTRY_LOG_CALLFLOW();
-    if (ODCPI_REQUEST_TYPE_STOP == request.type) {
-        return;
-    }
-    if (mGnssCbIface_1_1 != nullptr) {
-        // For emergency mode, request DBH (Device based hybrid) location
-        // Mark Independent from GNSS flag to false.
-        if (ODCPI_REQUEST_TYPE_START == request.type) {
-            auto r = mGnssCbIface_1_1->gnssRequestLocationCb(!request.isEmergencyMode);
-            if (!r.isOk()) {
-                LOC_LOGe("Error invoking gnssRequestLocationCb %s", r.description().c_str());
-            }
-        } else {
-            LOC_LOGv("Unsupported ODCPI request type: %d", request.type);
-        }
-    } else {
-        LOC_LOGe("ODCPI request not supported.");
-    }
-}
-
-V1_0::IGnss* HIDL_FETCH_IGnss(const char* hal) {
-    ENTRY_LOG_CALLFLOW();
-    V1_0::IGnss* iface = nullptr;
-    iface = new Gnss();
-    if (iface == nullptr) {
-        LOC_LOGE("%s]: failed to get %s", __FUNCTION__, hal);
-    }
-    return iface;
-}
-
-}  // namespace implementation
-}  // namespace V1_1
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
diff --git a/gps/android/1.1/Gnss.h b/gps/android/1.1/Gnss.h
deleted file mode 100644
index 15645eb..0000000
--- a/gps/android/1.1/Gnss.h
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Copyright (c) 2017-2018-2018-2018, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-#ifndef ANDROID_HARDWARE_GNSS_V1_1_GNSS_H
-#define ANDROID_HARDWARE_GNSS_V1_1_GNSS_H
-
-#include <AGnss.h>
-#include <AGnssRil.h>
-#include <GnssBatching.h>
-#include <GnssConfiguration.h>
-#include <GnssGeofencing.h>
-#include <GnssMeasurement.h>
-#include <GnssNi.h>
-#include <GnssDebug.h>
-
-#include <android/hardware/gnss/1.1/IGnss.h>
-#include <hidl/MQDescriptor.h>
-#include <hidl/Status.h>
-
-#include <GnssAPIClient.h>
-#include <location_interface.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_1 {
-namespace implementation {
-
-using ::android::hardware::hidl_array;
-using ::android::hardware::hidl_memory;
-using ::android::hardware::hidl_string;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::sp;
-using ::android::hardware::gnss::V1_0::GnssLocation;
-
-struct Gnss : public IGnss {
-    Gnss();
-    ~Gnss();
-
-    /*
-     * Methods from ::android::hardware::gnss::V1_0::IGnss follow.
-     * These declarations were generated from Gnss.hal.
-     */
-    Return<bool> setCallback(const sp<V1_0::IGnssCallback>& callback)  override;
-    Return<bool> start()  override;
-    Return<bool> stop()  override;
-    Return<void> cleanup()  override;
-    Return<bool> injectLocation(double latitudeDegrees,
-                                double longitudeDegrees,
-                                float accuracyMeters)  override;
-    Return<bool> injectTime(int64_t timeMs,
-                            int64_t timeReferenceMs,
-                            int32_t uncertaintyMs) override;
-    Return<void> deleteAidingData(V1_0::IGnss::GnssAidingData aidingDataFlags)  override;
-    Return<bool> setPositionMode(V1_0::IGnss::GnssPositionMode mode,
-                                 V1_0::IGnss::GnssPositionRecurrence recurrence,
-                                 uint32_t minIntervalMs,
-                                 uint32_t preferredAccuracyMeters,
-                                 uint32_t preferredTimeMs)  override;
-    Return<sp<V1_0::IAGnss>> getExtensionAGnss() override;
-    Return<sp<V1_0::IGnssNi>> getExtensionGnssNi() override;
-    Return<sp<V1_0::IGnssMeasurement>> getExtensionGnssMeasurement() override;
-    Return<sp<V1_0::IGnssConfiguration>> getExtensionGnssConfiguration() override;
-    Return<sp<V1_0::IGnssGeofencing>> getExtensionGnssGeofencing() override;
-    Return<sp<V1_0::IGnssBatching>> getExtensionGnssBatching() override;
-
-    Return<sp<V1_0::IAGnssRil>> getExtensionAGnssRil() override;
-
-    inline Return<sp<V1_0::IGnssNavigationMessage>> getExtensionGnssNavigationMessage() override {
-        return nullptr;
-    }
-
-    inline Return<sp<V1_0::IGnssXtra>> getExtensionXtra() override {
-        return nullptr;
-    }
-
-    Return<sp<V1_0::IGnssDebug>> getExtensionGnssDebug() override;
-
-    // Methods from ::android::hardware::gnss::V1_1::IGnss follow.
-    Return<bool> setCallback_1_1(const sp<V1_1::IGnssCallback>& callback) override;
-    Return<bool> setPositionMode_1_1(V1_0::IGnss::GnssPositionMode mode,
-            V1_0::IGnss::GnssPositionRecurrence recurrence,
-            uint32_t minIntervalMs, uint32_t preferredAccuracyMeters,
-            uint32_t preferredTimeMs, bool lowPowerMode) override;
-    Return<sp<V1_1::IGnssMeasurement>> getExtensionGnssMeasurement_1_1() override;
-    Return<sp<V1_1::IGnssConfiguration>> getExtensionGnssConfiguration_1_1() override;
-    Return<bool> injectBestLocation(const GnssLocation& location) override;
-
-    // These methods are not part of the IGnss base class.
-    GnssAPIClient* getApi();
-    Return<bool> setGnssNiCb(const sp<IGnssNiCallback>& niCb);
-    Return<bool> updateConfiguration(GnssConfig& gnssConfig);
-    const GnssInterface* getGnssInterface();
-
-    // Callback for ODCPI request
-    void odcpiRequestCb(const OdcpiRequestInfo& request);
-
- private:
-    struct GnssDeathRecipient : hidl_death_recipient {
-        GnssDeathRecipient(sp<Gnss> gnss) : mGnss(gnss) {
-        }
-        ~GnssDeathRecipient() = default;
-        virtual void serviceDied(uint64_t cookie, const wp<IBase>& who) override;
-        sp<Gnss> mGnss;
-    };
-
- private:
-    sp<GnssDeathRecipient> mGnssDeathRecipient = nullptr;
-
-    sp<AGnss> mAGnssIface = nullptr;
-    sp<GnssNi> mGnssNi = nullptr;
-    sp<GnssMeasurement> mGnssMeasurement = nullptr;
-    sp<GnssConfiguration> mGnssConfig = nullptr;
-    sp<GnssGeofencing> mGnssGeofencingIface = nullptr;
-    sp<GnssBatching> mGnssBatching = nullptr;
-    sp<IGnssDebug> mGnssDebug = nullptr;
-    sp<AGnssRil> mGnssRil = nullptr;
-
-    GnssAPIClient* mApi = nullptr;
-    sp<V1_0::IGnssCallback> mGnssCbIface = nullptr;
-    sp<V1_1::IGnssCallback> mGnssCbIface_1_1 = nullptr;
-    sp<V1_0::IGnssNiCallback> mGnssNiCbIface = nullptr;
-    GnssConfig mPendingConfig;
-    const GnssInterface* mGnssInterface = nullptr;
-};
-
-extern "C" V1_0::IGnss* HIDL_FETCH_IGnss(const char* name);
-
-}  // namespace implementation
-}  // namespace V1_1
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
-
-#endif  // ANDROID_HARDWARE_GNSS_V1_1_GNSS_H
diff --git a/gps/android/1.1/GnssBatching.cpp b/gps/android/1.1/GnssBatching.cpp
deleted file mode 100644
index 8ab264d..0000000
--- a/gps/android/1.1/GnssBatching.cpp
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-#define LOG_TAG "LocSvc_GnssBatchingInterface"
-
-#include <log_util.h>
-#include <BatchingAPIClient.h>
-#include "GnssBatching.h"
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_1 {
-namespace implementation {
-
-void GnssBatching::GnssBatchingDeathRecipient::serviceDied(
-        uint64_t cookie, const wp<IBase>& who) {
-    LOC_LOGE("%s] service died. cookie: %llu, who: %p",
-            __FUNCTION__, static_cast<unsigned long long>(cookie), &who);
-    if (mGnssBatching != nullptr) {
-        mGnssBatching->stop();
-        mGnssBatching->cleanup();
-    }
-}
-
-GnssBatching::GnssBatching() : mApi(nullptr) {
-    mGnssBatchingDeathRecipient = new GnssBatchingDeathRecipient(this);
-}
-
-GnssBatching::~GnssBatching() {
-    if (mApi != nullptr) {
-        mApi->destroy();
-        mApi = nullptr;
-    }
-}
-
-
-// Methods from ::android::hardware::gnss::V1_0::IGnssBatching follow.
-Return<bool> GnssBatching::init(const sp<IGnssBatchingCallback>& callback) {
-    if (mApi != nullptr) {
-        LOC_LOGD("%s]: mApi is NOT nullptr, delete it first", __FUNCTION__);
-        mApi->destroy();
-        mApi = nullptr;
-    }
-
-    mApi = new BatchingAPIClient(callback);
-    if (mApi == nullptr) {
-        LOC_LOGE("%s]: failed to create mApi", __FUNCTION__);
-        return false;
-    }
-
-    if (mGnssBatchingCbIface != nullptr) {
-        mGnssBatchingCbIface->unlinkToDeath(mGnssBatchingDeathRecipient);
-    }
-    mGnssBatchingCbIface = callback;
-    if (mGnssBatchingCbIface != nullptr) {
-        mGnssBatchingCbIface->linkToDeath(mGnssBatchingDeathRecipient, 0 /*cookie*/);
-    }
-
-    return true;
-}
-
-Return<uint16_t> GnssBatching::getBatchSize() {
-    uint16_t ret = 0;
-    if (mApi == nullptr) {
-        LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
-    } else {
-        ret = mApi->getBatchSize();
-    }
-    return ret;
-}
-
-Return<bool> GnssBatching::start(const IGnssBatching::Options& options) {
-    bool ret = false;
-    if (mApi == nullptr) {
-        LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
-    } else {
-        ret = mApi->startSession(options);
-    }
-    return ret;
-}
-
-Return<void> GnssBatching::flush() {
-    if (mApi == nullptr) {
-        LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
-    } else {
-        mApi->flushBatchedLocations();
-    }
-    return Void();
-}
-
-Return<bool> GnssBatching::stop() {
-    bool ret = false;
-    if (mApi == nullptr) {
-        LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
-    } else {
-        ret = mApi->stopSession();
-    }
-    return ret;
-}
-
-Return<void> GnssBatching::cleanup() {
-    if (mGnssBatchingCbIface != nullptr) {
-        mGnssBatchingCbIface->unlinkToDeath(mGnssBatchingDeathRecipient);
-    }
-    return Void();
-}
-
-}  // namespace implementation
-}  // namespace V1_1
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
diff --git a/gps/android/1.1/GnssBatching.h b/gps/android/1.1/GnssBatching.h
deleted file mode 100644
index 8e235d8..0000000
--- a/gps/android/1.1/GnssBatching.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-#ifndef ANDROID_HARDWARE_GNSS_V1_1_GNSSBATCHING_H
-#define ANDROID_HARDWARE_GNSS_V1_1_GNSSBATCHING_H
-
-#include <android/hardware/gnss/1.0/IGnssBatching.h>
-#include <hidl/Status.h>
-
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_1 {
-namespace implementation {
-
-using ::android::hardware::gnss::V1_0::IGnssBatching;
-using ::android::hardware::gnss::V1_0::IGnssBatchingCallback;
-using ::android::hidl::base::V1_0::IBase;
-using ::android::hardware::hidl_array;
-using ::android::hardware::hidl_memory;
-using ::android::hardware::hidl_string;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::sp;
-
-class BatchingAPIClient;
-struct GnssBatching : public IGnssBatching {
-    GnssBatching();
-    ~GnssBatching();
-
-    // Methods from ::android::hardware::gnss::V1_0::IGnssBatching follow.
-    Return<bool> init(const sp<IGnssBatchingCallback>& callback) override;
-    Return<uint16_t> getBatchSize() override;
-    Return<bool> start(const IGnssBatching::Options& options ) override;
-    Return<void> flush() override;
-    Return<bool> stop() override;
-    Return<void> cleanup() override;
-
- private:
-    struct GnssBatchingDeathRecipient : hidl_death_recipient {
-        GnssBatchingDeathRecipient(sp<GnssBatching> gnssBatching) :
-            mGnssBatching(gnssBatching) {
-        }
-        ~GnssBatchingDeathRecipient() = default;
-        virtual void serviceDied(uint64_t cookie, const wp<IBase>& who) override;
-        sp<GnssBatching> mGnssBatching;
-    };
-
- private:
-    sp<GnssBatchingDeathRecipient> mGnssBatchingDeathRecipient = nullptr;
-    sp<IGnssBatchingCallback> mGnssBatchingCbIface = nullptr;
-    BatchingAPIClient* mApi = nullptr;
-};
-
-}  // namespace implementation
-}  // namespace V1_1
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
-
-#endif  // ANDROID_HARDWARE_GNSS_V1_1_GNSSBATCHING_H
diff --git a/gps/android/1.1/GnssConfiguration.cpp b/gps/android/1.1/GnssConfiguration.cpp
deleted file mode 100644
index ad255d1..0000000
--- a/gps/android/1.1/GnssConfiguration.cpp
+++ /dev/null
@@ -1,308 +0,0 @@
-/*
- * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-#define LOG_TAG "LocSvc_GnssConfigurationInterface"
-
-#include <log_util.h>
-#include "Gnss.h"
-#include "GnssConfiguration.h"
-#include <android/hardware/gnss/1.0/types.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_1 {
-namespace implementation {
-
-using ::android::hardware::gnss::V1_0::GnssConstellationType;
-
-GnssConfiguration::GnssConfiguration(Gnss* gnss) : mGnss(gnss) {
-}
-
-// Methods from ::android::hardware::gps::V1_0::IGnssConfiguration follow.
-Return<bool> GnssConfiguration::setSuplEs(bool enabled)  {
-    if (mGnss == nullptr) {
-        LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__);
-        return false;
-    }
-
-    GnssConfig config;
-    memset(&config, 0, sizeof(GnssConfig));
-    config.size = sizeof(GnssConfig);
-    config.flags = GNSS_CONFIG_FLAGS_SUPL_EM_SERVICES_BIT;
-    config.suplEmergencyServices = (enabled ?
-            GNSS_CONFIG_SUPL_EMERGENCY_SERVICES_YES :
-            GNSS_CONFIG_SUPL_EMERGENCY_SERVICES_NO);
-
-    return mGnss->updateConfiguration(config);
-}
-
-Return<bool> GnssConfiguration::setSuplVersion(uint32_t version)  {
-    if (mGnss == nullptr) {
-        LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__);
-        return false;
-    }
-
-    GnssConfig config;
-    memset(&config, 0, sizeof(GnssConfig));
-    config.size = sizeof(GnssConfig);
-    config.flags = GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT;
-    switch (version) {
-        case 0x00020004:
-            config.suplVersion = GNSS_CONFIG_SUPL_VERSION_2_0_4;
-            break;
-        case 0x00020002:
-            config.suplVersion = GNSS_CONFIG_SUPL_VERSION_2_0_2;
-            break;
-        case 0x00020000:
-            config.suplVersion = GNSS_CONFIG_SUPL_VERSION_2_0_0;
-            break;
-        case 0x00010000:
-            config.suplVersion = GNSS_CONFIG_SUPL_VERSION_1_0_0;
-            break;
-        default:
-            LOC_LOGE("%s]: invalid version: 0x%x.", __FUNCTION__, version);
-            return false;
-    }
-
-    return mGnss->updateConfiguration(config);
-}
-
-Return<bool> GnssConfiguration::setSuplMode(uint8_t mode)  {
-    if (mGnss == nullptr) {
-        LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__);
-        return false;
-    }
-
-    GnssConfig config;
-    memset(&config, 0, sizeof(GnssConfig));
-    config.size = sizeof(GnssConfig);
-    config.flags = GNSS_CONFIG_FLAGS_SUPL_MODE_BIT;
-    switch (mode) {
-        case 0:
-            config.suplModeMask = 0; // STANDALONE ONLY
-            break;
-        case 1:
-            config.suplModeMask = GNSS_CONFIG_SUPL_MODE_MSB_BIT;
-            break;
-        case 2:
-            config.suplModeMask = GNSS_CONFIG_SUPL_MODE_MSA_BIT;
-            break;
-        case 3:
-            config.suplModeMask = GNSS_CONFIG_SUPL_MODE_MSB_BIT | GNSS_CONFIG_SUPL_MODE_MSA_BIT;
-            break;
-        default:
-            LOC_LOGE("%s]: invalid mode: %d.", __FUNCTION__, mode);
-            return false;
-    }
-
-    return mGnss->updateConfiguration(config);
-}
-
-Return<bool> GnssConfiguration::setLppProfile(uint8_t lppProfileMask) {
-    if (mGnss == nullptr) {
-        LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__);
-        return false;
-    }
-
-    GnssConfig config = {};
-    config.size = sizeof(GnssConfig);
-    config.flags = GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT;
-    config.lppProfileMask = GNSS_CONFIG_LPP_PROFILE_RRLP_ON_LTE; //default
-
-    if (lppProfileMask & (1<<0)) {
-        config.lppProfileMask |= GNSS_CONFIG_LPP_PROFILE_USER_PLANE_BIT;
-    }
-    if (lppProfileMask & (1<<1)) {
-        config.lppProfileMask |= GNSS_CONFIG_LPP_PROFILE_CONTROL_PLANE_BIT;
-    }
-    if (lppProfileMask & (1<<2)) {
-        config.lppProfileMask |= GNSS_CONFIG_LPP_PROFILE_USER_PLANE_OVER_NR5G_SA_BIT;
-    }
-    if (lppProfileMask & (1<<3)) {
-        config.lppProfileMask |= GNSS_CONFIG_LPP_PROFILE_CONTROL_PLANE_OVER_NR5G_SA_BIT;
-    }
-
-    return mGnss->updateConfiguration(config);
-}
-
-Return<bool> GnssConfiguration::setGlonassPositioningProtocol(uint8_t protocol) {
-    if (mGnss == nullptr) {
-        LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__);
-        return false;
-    }
-
-    GnssConfig config;
-    memset(&config, 0, sizeof(GnssConfig));
-    config.size = sizeof(GnssConfig);
-
-    config.flags = GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT;
-    if (protocol & (1<<0)) {
-        config.aGlonassPositionProtocolMask |= GNSS_CONFIG_RRC_CONTROL_PLANE_BIT;
-    }
-    if (protocol & (1<<1)) {
-        config.aGlonassPositionProtocolMask |= GNSS_CONFIG_RRLP_USER_PLANE_BIT;
-    }
-    if (protocol & (1<<2)) {
-        config.aGlonassPositionProtocolMask |= GNSS_CONFIG_LLP_USER_PLANE_BIT;
-    }
-    if (protocol & (1<<3)) {
-        config.aGlonassPositionProtocolMask |= GNSS_CONFIG_LLP_CONTROL_PLANE_BIT;
-    }
-
-    return mGnss->updateConfiguration(config);
-}
-
-Return<bool> GnssConfiguration::setGpsLock(uint8_t lock) {
-    if (mGnss == nullptr) {
-        LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__);
-        return false;
-    }
-
-    GnssConfig config;
-    memset(&config, 0, sizeof(GnssConfig));
-    config.size = sizeof(GnssConfig);
-    config.flags = GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT;
-    switch (lock) {
-        case 0:
-            config.gpsLock = GNSS_CONFIG_GPS_LOCK_NONE;
-            break;
-        case 1:
-            config.gpsLock = GNSS_CONFIG_GPS_LOCK_MO;
-            break;
-        case 2:
-            config.gpsLock = GNSS_CONFIG_GPS_LOCK_NI;
-            break;
-        case 3:
-            config.gpsLock = GNSS_CONFIG_GPS_LOCK_MO_AND_NI;
-            break;
-        default:
-            LOC_LOGE("%s]: invalid lock: %d.", __FUNCTION__, lock);
-            return false;
-    }
-
-    return mGnss->updateConfiguration(config);
-}
-
-Return<bool> GnssConfiguration::setEmergencySuplPdn(bool enabled) {
-    if (mGnss == nullptr) {
-        LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__);
-        return false;
-    }
-
-    GnssConfig config;
-    memset(&config, 0, sizeof(GnssConfig));
-    config.size = sizeof(GnssConfig);
-    config.flags = GNSS_CONFIG_FLAGS_EM_PDN_FOR_EM_SUPL_VALID_BIT;
-    config.emergencyPdnForEmergencySupl = (enabled ?
-            GNSS_CONFIG_EMERGENCY_PDN_FOR_EMERGENCY_SUPL_YES :
-            GNSS_CONFIG_EMERGENCY_PDN_FOR_EMERGENCY_SUPL_NO);
-
-    return mGnss->updateConfiguration(config);
-}
-
-// Methods from ::android::hardware::gnss::V1_1::IGnssConfiguration follow.
-Return<bool> GnssConfiguration::setBlacklist(
-            const hidl_vec<GnssConfiguration::BlacklistedSource>& blacklist) {
-
-    ENTRY_LOG_CALLFLOW();
-    if (nullptr == mGnss) {
-        LOC_LOGe("mGnss is null");
-        return false;
-    }
-
-    // blValid is true if blacklist is empty, i.e. clearing the BL;
-    // if blacklist is not empty, blValid is initialied to false, and later
-    // updated in the for loop to become true only if there is at least
-    // one {constellation, svid} in the list that is valid.
-    bool blValid = (0 == blacklist.size());
-    GnssConfig config;
-    memset(&config, 0, sizeof(GnssConfig));
-    config.size = sizeof(GnssConfig);
-    config.flags = GNSS_CONFIG_FLAGS_BLACKLISTED_SV_IDS_BIT;
-    config.blacklistedSvIds.clear();
-
-    GnssSvIdSource source = {};
-    for (int idx = 0; idx < (int)blacklist.size(); idx++) {
-        // Set blValid true if any one source is valid
-        blValid = setBlacklistedSource(source, blacklist[idx]) || blValid;
-        config.blacklistedSvIds.push_back(source);
-    }
-
-    // Update configuration only if blValid is true
-    // i.e. only if atleast one source is valid for blacklisting
-    return (blValid && mGnss->updateConfiguration(config));
-}
-
-bool GnssConfiguration::setBlacklistedSource(
-        GnssSvIdSource& copyToSource,
-        const GnssConfiguration::BlacklistedSource& copyFromSource) {
-
-    bool retVal = true;
-    uint16_t svIdOffset = 0;
-    copyToSource.size = sizeof(GnssSvIdSource);
-    copyToSource.svId = copyFromSource.svid;
-
-    switch(copyFromSource.constellation) {
-    case GnssConstellationType::GPS:
-        copyToSource.constellation = GNSS_SV_TYPE_GPS;
-        LOC_LOGe("GPS SVs can't be blacklisted.");
-        retVal = false;
-        break;
-    case GnssConstellationType::SBAS:
-        copyToSource.constellation = GNSS_SV_TYPE_SBAS;
-        LOC_LOGe("SBAS SVs can't be blacklisted.");
-        retVal = false;
-        break;
-    case GnssConstellationType::GLONASS:
-        copyToSource.constellation = GNSS_SV_TYPE_GLONASS;
-        svIdOffset = GNSS_SV_CONFIG_GLO_INITIAL_SV_ID - 1;
-        break;
-    case GnssConstellationType::QZSS:
-        copyToSource.constellation = GNSS_SV_TYPE_QZSS;
-        svIdOffset = 0;
-        break;
-    case GnssConstellationType::BEIDOU:
-        copyToSource.constellation = GNSS_SV_TYPE_BEIDOU;
-        svIdOffset = GNSS_SV_CONFIG_BDS_INITIAL_SV_ID - 1;
-        break;
-    case GnssConstellationType::GALILEO:
-        copyToSource.constellation = GNSS_SV_TYPE_GALILEO;
-        svIdOffset = GNSS_SV_CONFIG_GAL_INITIAL_SV_ID - 1;
-        break;
-    default:
-        copyToSource.constellation = GNSS_SV_TYPE_UNKNOWN;
-        LOC_LOGe("Invalid constellation %d", copyFromSource.constellation);
-        retVal = false;
-        break;
-    }
-
-    if (copyToSource.svId > 0 && svIdOffset > 0) {
-        copyToSource.svId += svIdOffset;
-    }
-
-    return retVal;
-}
-
-}  // namespace implementation
-}  // namespace V1_1
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
diff --git a/gps/android/1.1/GnssConfiguration.h b/gps/android/1.1/GnssConfiguration.h
deleted file mode 100644
index daea159..0000000
--- a/gps/android/1.1/GnssConfiguration.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-
- /* 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.
- */
-
-
-#ifndef ANDROID_HARDWARE_GNSS_V1_1_GNSSCONFIGURATION_H
-#define ANDROID_HARDWARE_GNSS_V1_1_GNSSCONFIGURATION_H
-
-#include <android/hardware/gnss/1.1/IGnssConfiguration.h>
-#include <hidl/Status.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_1 {
-namespace implementation {
-
-using ::android::hardware::gnss::V1_1::IGnssConfiguration;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::sp;
-
-/*
- * Interface for passing GNSS configuration info from platform to HAL.
- */
-struct Gnss;
-struct GnssConfiguration : public IGnssConfiguration {
-    GnssConfiguration(Gnss* gnss);
-    ~GnssConfiguration() = default;
-
-    /*
-     * Methods from ::android::hardware::gnss::V1_0::IGnssConfiguration follow.
-     * These declarations were generated from IGnssConfiguration.hal.
-     */
-    Return<bool> setSuplVersion(uint32_t version) override;
-    Return<bool> setSuplMode(uint8_t mode) override;
-    Return<bool> setSuplEs(bool enabled) override;
-    Return<bool> setLppProfile(uint8_t lppProfileMask) override;
-    Return<bool> setGlonassPositioningProtocol(uint8_t protocol) override;
-    Return<bool> setEmergencySuplPdn(bool enable) override;
-    Return<bool> setGpsLock(uint8_t lock) override;
-
-    // Methods from ::android::hardware::gnss::V1_1::IGnssConfiguration follow.
-    Return<bool> setBlacklist(
-            const hidl_vec<GnssConfiguration::BlacklistedSource>& blacklist) override;
-
- private:
-    Gnss* mGnss = nullptr;
-    bool setBlacklistedSource(
-            GnssSvIdSource& copyToSource,
-            const GnssConfiguration::BlacklistedSource& copyFromSource);
-};
-
-}  // namespace implementation
-}  // namespace V1_1
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
-
-#endif  // ANDROID_HARDWARE_GNSS_V1_1_GNSSCONFIGURATION_H
diff --git a/gps/android/1.1/GnssDebug.cpp b/gps/android/1.1/GnssDebug.cpp
deleted file mode 100644
index f164c54..0000000
--- a/gps/android/1.1/GnssDebug.cpp
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "LocSvc_GnssDebugInterface"
-
-#include <log/log.h>
-#include <log_util.h>
-#include "Gnss.h"
-#include "GnssDebug.h"
-#include "LocationUtil.h"
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_1 {
-namespace implementation {
-
-using ::android::hardware::hidl_vec;
-
-#define GNSS_DEBUG_UNKNOWN_HORIZONTAL_ACCURACY_METERS (20000000)
-#define GNSS_DEBUG_UNKNOWN_VERTICAL_ACCURACY_METERS   (20000)
-#define GNSS_DEBUG_UNKNOWN_SPEED_ACCURACY_PER_SEC     (500)
-#define GNSS_DEBUG_UNKNOWN_BEARING_ACCURACY_DEG       (180)
-
-#define GNSS_DEBUG_UNKNOWN_UTC_TIME            (1483228800000LL) // 1/1/2017 00:00 GMT
-#define GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC_MIN    (999) // 999 ns
-#define GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC_MAX    (1.57783680E17) // 5 years in ns
-#define GNSS_DEBUG_UNKNOWN_FREQ_UNC_NS_PER_SEC (2.0e5)  // ppm
-
-GnssDebug::GnssDebug(Gnss* gnss) : mGnss(gnss)
-{
-}
-
-/*
- * This methods requests position, time and satellite ephemeris debug information
- * from the HAL.
- *
- * @return void
-*/
-Return<void> GnssDebug::getDebugData(getDebugData_cb _hidl_cb)
-{
-    LOC_LOGD("%s]: ", __func__);
-
-    DebugData data = { };
-
-    if((nullptr == mGnss) || (nullptr == mGnss->getGnssInterface())){
-        LOC_LOGE("GnssDebug - Null GNSS interface");
-        _hidl_cb(data);
-        return Void();
-    }
-
-    // get debug report snapshot via hal interface
-    GnssDebugReport reports = { };
-    mGnss->getGnssInterface()->getDebugReport(reports);
-
-    // location block
-    if (reports.mLocation.mValid) {
-        data.position.valid = true;
-        data.position.latitudeDegrees = reports.mLocation.mLocation.latitude;
-        data.position.longitudeDegrees = reports.mLocation.mLocation.longitude;
-        data.position.altitudeMeters = reports.mLocation.mLocation.altitude;
-
-        data.position.speedMetersPerSec =
-            (double)(reports.mLocation.mLocation.speed);
-        data.position.bearingDegrees =
-            (double)(reports.mLocation.mLocation.bearing);
-        data.position.horizontalAccuracyMeters =
-            (double)(reports.mLocation.mLocation.accuracy);
-        data.position.verticalAccuracyMeters =
-            reports.mLocation.verticalAccuracyMeters;
-        data.position.speedAccuracyMetersPerSecond =
-            reports.mLocation.speedAccuracyMetersPerSecond;
-        data.position.bearingAccuracyDegrees =
-            reports.mLocation.bearingAccuracyDegrees;
-
-        timeval tv_now, tv_report;
-        tv_report.tv_sec  = reports.mLocation.mUtcReported.tv_sec;
-        tv_report.tv_usec = reports.mLocation.mUtcReported.tv_nsec / 1000ULL;
-        gettimeofday(&tv_now, NULL);
-        data.position.ageSeconds =
-            (tv_now.tv_sec - tv_report.tv_sec) +
-            (float)((tv_now.tv_usec - tv_report.tv_usec)) / 1000000;
-    }
-    else {
-        data.position.valid = false;
-    }
-
-    if (data.position.horizontalAccuracyMeters <= 0 ||
-        data.position.horizontalAccuracyMeters > GNSS_DEBUG_UNKNOWN_HORIZONTAL_ACCURACY_METERS) {
-        data.position.horizontalAccuracyMeters = GNSS_DEBUG_UNKNOWN_HORIZONTAL_ACCURACY_METERS;
-    }
-    if (data.position.verticalAccuracyMeters <= 0 ||
-        data.position.verticalAccuracyMeters > GNSS_DEBUG_UNKNOWN_VERTICAL_ACCURACY_METERS) {
-        data.position.verticalAccuracyMeters = GNSS_DEBUG_UNKNOWN_VERTICAL_ACCURACY_METERS;
-    }
-    if (data.position.speedAccuracyMetersPerSecond <= 0 ||
-        data.position.speedAccuracyMetersPerSecond > GNSS_DEBUG_UNKNOWN_SPEED_ACCURACY_PER_SEC) {
-        data.position.speedAccuracyMetersPerSecond = GNSS_DEBUG_UNKNOWN_SPEED_ACCURACY_PER_SEC;
-    }
-    if (data.position.bearingAccuracyDegrees <= 0 ||
-        data.position.bearingAccuracyDegrees > GNSS_DEBUG_UNKNOWN_BEARING_ACCURACY_DEG) {
-        data.position.bearingAccuracyDegrees = GNSS_DEBUG_UNKNOWN_BEARING_ACCURACY_DEG;
-    }
-
-    // time block
-    if (reports.mTime.mValid) {
-        data.time.timeEstimate = reports.mTime.timeEstimate;
-        data.time.timeUncertaintyNs = reports.mTime.timeUncertaintyNs;
-        data.time.frequencyUncertaintyNsPerSec =
-            reports.mTime.frequencyUncertaintyNsPerSec;
-    }
-
-    if (data.time.timeEstimate < GNSS_DEBUG_UNKNOWN_UTC_TIME) {
-        data.time.timeEstimate = GNSS_DEBUG_UNKNOWN_UTC_TIME;
-    }
-    if (data.time.timeUncertaintyNs <= 0) {
-        data.time.timeUncertaintyNs = (float)GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC_MIN;
-    } else if (data.time.timeUncertaintyNs > GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC_MAX) {
-        data.time.timeUncertaintyNs = (float)GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC_MAX;
-    }
-    if (data.time.frequencyUncertaintyNsPerSec <= 0 ||
-        data.time.frequencyUncertaintyNsPerSec > (float)GNSS_DEBUG_UNKNOWN_FREQ_UNC_NS_PER_SEC) {
-        data.time.frequencyUncertaintyNsPerSec = (float)GNSS_DEBUG_UNKNOWN_FREQ_UNC_NS_PER_SEC;
-    }
-
-    // satellite data block
-    SatelliteData s = { };
-    std::vector<SatelliteData> s_array = { };
-
-    for (uint32_t i=0; i<reports.mSatelliteInfo.size(); i++) {
-        memset(&s, 0, sizeof(s));
-        s.svid = reports.mSatelliteInfo[i].svid;
-        convertGnssConstellationType(
-            reports.mSatelliteInfo[i].constellation, s.constellation);
-        convertGnssEphemerisType(
-            reports.mSatelliteInfo[i].mEphemerisType, s.ephemerisType);
-        convertGnssEphemerisSource(
-            reports.mSatelliteInfo[i].mEphemerisSource, s.ephemerisSource);
-        convertGnssEphemerisHealth(
-            reports.mSatelliteInfo[i].mEphemerisHealth, s.ephemerisHealth);
-
-        s.ephemerisAgeSeconds =
-            reports.mSatelliteInfo[i].ephemerisAgeSeconds;
-        s.serverPredictionIsAvailable =
-            reports.mSatelliteInfo[i].serverPredictionIsAvailable;
-        s.serverPredictionAgeSeconds =
-            reports.mSatelliteInfo[i].serverPredictionAgeSeconds;
-
-        s_array.push_back(s);
-    }
-    data.satelliteDataArray = s_array;
-
-    // callback HIDL with collected debug data
-    _hidl_cb(data);
-    return Void();
-}
-
-}  // namespace implementation
-}  // namespace V1_1
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
diff --git a/gps/android/1.1/GnssDebug.h b/gps/android/1.1/GnssDebug.h
deleted file mode 100644
index cb818ac..0000000
--- a/gps/android/1.1/GnssDebug.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ANDROID_HARDWARE_GNSS_V1_1_GNSSDEBUG_H
-#define ANDROID_HARDWARE_GNSS_V1_1_GNSSDEBUG_H
-
-
-#include <android/hardware/gnss/1.0/IGnssDebug.h>
-#include <hidl/Status.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_1 {
-namespace implementation {
-
-using ::android::hardware::gnss::V1_0::IGnssDebug;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::sp;
-
-/* Interface for GNSS Debug support. */
-struct Gnss;
-struct GnssDebug : public IGnssDebug {
-    GnssDebug(Gnss* gnss);
-    ~GnssDebug() {};
-
-    /*
-     * Methods from ::android::hardware::gnss::V1_0::IGnssDebug follow.
-     * These declarations were generated from IGnssDebug.hal.
-     */
-    Return<void> getDebugData(getDebugData_cb _hidl_cb) override;
-
-private:
-    Gnss* mGnss = nullptr;
-};
-
-}  // namespace implementation
-}  // namespace V1_1
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
-
-#endif  // ANDROID_HARDWARE_GNSS_V1_1_GNSSDEBUG_H
diff --git a/gps/android/1.1/GnssGeofencing.cpp b/gps/android/1.1/GnssGeofencing.cpp
deleted file mode 100644
index a4aaf88..0000000
--- a/gps/android/1.1/GnssGeofencing.cpp
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-#define LOG_TAG "GnssHal_GnssGeofencing"
-
-#include <log_util.h>
-#include <GeofenceAPIClient.h>
-#include "GnssGeofencing.h"
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_1 {
-namespace implementation {
-
-void GnssGeofencing::GnssGeofencingDeathRecipient::serviceDied(
-        uint64_t cookie, const wp<IBase>& who) {
-    LOC_LOGE("%s] service died. cookie: %llu, who: %p",
-            __FUNCTION__, static_cast<unsigned long long>(cookie), &who);
-    if (mGnssGeofencing != nullptr) {
-        mGnssGeofencing->removeAllGeofences();
-    }
-}
-
-GnssGeofencing::GnssGeofencing() : mApi(nullptr) {
-    mGnssGeofencingDeathRecipient = new GnssGeofencingDeathRecipient(this);
-}
-
-GnssGeofencing::~GnssGeofencing() {
-    if (mApi != nullptr) {
-        mApi->destroy();
-        mApi = nullptr;
-    }
-}
-
-// Methods from ::android::hardware::gnss::V1_0::IGnssGeofencing follow.
-Return<void> GnssGeofencing::setCallback(const sp<IGnssGeofenceCallback>& callback)  {
-    if (mApi != nullptr) {
-        LOC_LOGd("mApi is NOT nullptr");
-        return Void();
-    }
-
-    mApi = new GeofenceAPIClient(callback);
-    if (mApi == nullptr) {
-        LOC_LOGE("%s]: failed to create mApi", __FUNCTION__);
-    }
-
-    if (mGnssGeofencingCbIface != nullptr) {
-        mGnssGeofencingCbIface->unlinkToDeath(mGnssGeofencingDeathRecipient);
-    }
-    mGnssGeofencingCbIface = callback;
-    if (mGnssGeofencingCbIface != nullptr) {
-        mGnssGeofencingCbIface->linkToDeath(mGnssGeofencingDeathRecipient, 0 /*cookie*/);
-    }
-
-    return Void();
-}
-
-Return<void> GnssGeofencing::addGeofence(
-        int32_t geofenceId,
-        double latitudeDegrees,
-        double longitudeDegrees,
-        double radiusMeters,
-        IGnssGeofenceCallback::GeofenceTransition lastTransition,
-        int32_t monitorTransitions,
-        uint32_t notificationResponsivenessMs,
-        uint32_t unknownTimerMs)  {
-    if (mApi == nullptr) {
-        LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
-    } else {
-        mApi->geofenceAdd(
-                geofenceId,
-                latitudeDegrees,
-                longitudeDegrees,
-                radiusMeters,
-                static_cast<int32_t>(lastTransition),
-                monitorTransitions,
-                notificationResponsivenessMs,
-                unknownTimerMs);
-    }
-    return Void();
-}
-
-Return<void> GnssGeofencing::pauseGeofence(int32_t geofenceId)  {
-    if (mApi == nullptr) {
-        LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
-    } else {
-        mApi->geofencePause(geofenceId);
-    }
-    return Void();
-}
-
-Return<void> GnssGeofencing::resumeGeofence(int32_t geofenceId, int32_t monitorTransitions)  {
-    if (mApi == nullptr) {
-        LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
-    } else {
-        mApi->geofenceResume(geofenceId, monitorTransitions);
-    }
-    return Void();
-}
-
-Return<void> GnssGeofencing::removeGeofence(int32_t geofenceId)  {
-    if (mApi == nullptr) {
-        LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
-    } else {
-        mApi->geofenceRemove(geofenceId);
-    }
-    return Void();
-}
-
-Return<void> GnssGeofencing::removeAllGeofences()  {
-    if (mApi == nullptr) {
-        LOC_LOGD("%s]: mApi is nullptr, do nothing", __FUNCTION__);
-    } else {
-        mApi->geofenceRemoveAll();
-    }
-    return Void();
-}
-
-}  // namespace implementation
-}  // namespace V1_1
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
diff --git a/gps/android/1.1/GnssGeofencing.h b/gps/android/1.1/GnssGeofencing.h
deleted file mode 100644
index 94a73de..0000000
--- a/gps/android/1.1/GnssGeofencing.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-#ifndef ANDROID_HARDWARE_GNSS_V1_1_GNSSGEOFENCING_H
-#define ANDROID_HARDWARE_GNSS_V1_1_GNSSGEOFENCING_H
-
-#include <android/hardware/gnss/1.0/IGnssGeofencing.h>
-#include <hidl/Status.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_1 {
-namespace implementation {
-
-using ::android::hardware::gnss::V1_0::IGnssGeofenceCallback;
-using ::android::hardware::gnss::V1_0::IGnssGeofencing;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::sp;
-
-class GeofenceAPIClient;
-struct GnssGeofencing : public IGnssGeofencing {
-    GnssGeofencing();
-    ~GnssGeofencing();
-
-    /*
-     * Methods from ::android::hardware::gnss::V1_0::IGnssGeofencing follow.
-     * These declarations were generated from IGnssGeofencing.hal.
-     */
-    Return<void> setCallback(const sp<IGnssGeofenceCallback>& callback)  override;
-    Return<void> addGeofence(int32_t geofenceId,
-                             double latitudeDegrees,
-                             double longitudeDegrees,
-                             double radiusMeters,
-                             IGnssGeofenceCallback::GeofenceTransition lastTransition,
-                             int32_t monitorTransitions,
-                             uint32_t notificationResponsivenessMs,
-                             uint32_t unknownTimerMs)  override;
-
-    Return<void> pauseGeofence(int32_t geofenceId)  override;
-    Return<void> resumeGeofence(int32_t geofenceId, int32_t monitorTransitions)  override;
-    Return<void> removeGeofence(int32_t geofenceId)  override;
-
- private:
-    // This method is not part of the IGnss base class.
-    // It is called by GnssGeofencingDeathRecipient to remove all geofences added so far.
-    Return<void> removeAllGeofences();
-
- private:
-    struct GnssGeofencingDeathRecipient : hidl_death_recipient {
-        GnssGeofencingDeathRecipient(sp<GnssGeofencing> gnssGeofencing) :
-            mGnssGeofencing(gnssGeofencing) {
-        }
-        ~GnssGeofencingDeathRecipient() = default;
-        virtual void serviceDied(uint64_t cookie, const wp<IBase>& who) override;
-        sp<GnssGeofencing> mGnssGeofencing;
-    };
-
- private:
-    sp<GnssGeofencingDeathRecipient> mGnssGeofencingDeathRecipient = nullptr;
-    sp<IGnssGeofenceCallback> mGnssGeofencingCbIface = nullptr;
-    GeofenceAPIClient* mApi = nullptr;
-};
-
-}  // namespace implementation
-}  // namespace V1_1
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
-
-#endif  // ANDROID_HARDWARE_GNSS_V1_1_GNSSGEOFENCING_H
diff --git a/gps/android/1.1/GnssMeasurement.cpp b/gps/android/1.1/GnssMeasurement.cpp
deleted file mode 100644
index 4f35a49..0000000
--- a/gps/android/1.1/GnssMeasurement.cpp
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-/* ​​​​​Changes from Qualcomm Innovation Center are provided under the following license:
- * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
- * SPDX-License-Identifier: BSD-3-Clause-Clear
- */
-
-#define LOG_TAG "LocSvc_GnssMeasurementInterface"
-
-#include <log_util.h>
-#include "GnssMeasurement.h"
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_1 {
-namespace implementation {
-
-void GnssMeasurement::GnssMeasurementDeathRecipient::serviceDied(
-        uint64_t cookie, const wp<IBase>& who) {
-    LOC_LOGE("%s] service died. cookie: %llu, who: %p",
-            __FUNCTION__, static_cast<unsigned long long>(cookie), &who);
-    if (mGnssMeasurement != nullptr) {
-        mGnssMeasurement->close();
-    }
-}
-
-GnssMeasurement::GnssMeasurement() {
-    mGnssMeasurementDeathRecipient = new GnssMeasurementDeathRecipient(this);
-    mApi = new MeasurementAPIClient();
-}
-
-GnssMeasurement::~GnssMeasurement() {
-    if (mApi) {
-        mApi->destroy();
-        mApi = nullptr;
-    }
-}
-
-// Methods from ::android::hardware::gnss::V1_0::IGnssMeasurement follow.
-Return<GnssMeasurement::GnssMeasurementStatus> GnssMeasurement::setCallback(
-        const sp<V1_0::IGnssMeasurementCallback>& callback)  {
-    return setCallback(callback, mGnssMeasurementCbIface, GNSS_POWER_MODE_INVALID);
-}
-
-template <typename T>
-Return<IGnssMeasurement::GnssMeasurementStatus> GnssMeasurement::setCallback(
-        const sp<T>& callback, sp<T>& myCallback, GnssPowerMode powerMode) {
-    Return<GnssMeasurement::GnssMeasurementStatus> ret =
-            IGnssMeasurement::GnssMeasurementStatus::ERROR_GENERIC;
-    if (mApi == nullptr) {
-        LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
-        return ret;
-    }
-    if (myCallback != callback) {
-        if (nullptr == callback) {
-            LOC_LOGE("%s]: callback is nullptr", __FUNCTION__);
-            mApi->measurementSetCallback(callback);
-            close();
-        } else {
-            if (nullptr != myCallback) {
-                myCallback->unlinkToDeath(mGnssMeasurementDeathRecipient);
-            }
-            myCallback = callback;
-            myCallback->linkToDeath(mGnssMeasurementDeathRecipient, 0);
-            ret = mApi->measurementSetCallback(callback, powerMode);
-        }
-    }
-
-    return ret;
-}
-
-Return<void> GnssMeasurement::close()  {
-    if (mApi != nullptr) {
-        mApi->measurementSetCallback<V1_0::IGnssMeasurementCallback>(nullptr);
-        mApi->measurementSetCallback<V1_1::IGnssMeasurementCallback>(nullptr);
-    }
-
-    if (mGnssMeasurementCbIface != nullptr) {
-        mGnssMeasurementCbIface->unlinkToDeath(mGnssMeasurementDeathRecipient);
-        mGnssMeasurementCbIface = nullptr;
-    }
-    if (mGnssMeasurementCbIface_1_1 != nullptr) {
-        mGnssMeasurementCbIface_1_1->unlinkToDeath(mGnssMeasurementDeathRecipient);
-        mGnssMeasurementCbIface_1_1 = nullptr;
-    }
-
-    return Void();
-}
-
-// Methods from ::android::hardware::gnss::V1_1::IGnssMeasurement follow.
-Return<GnssMeasurement::GnssMeasurementStatus> GnssMeasurement::setCallback_1_1(
-        const sp<IGnssMeasurementCallback>& callback, bool enableFullTracking) {
-    return setCallback(callback, mGnssMeasurementCbIface_1_1,
-                       enableFullTracking ? GNSS_POWER_MODE_M1 : GNSS_POWER_MODE_M2);
-}
-
-}  // namespace implementation
-}  // namespace V1_1
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
diff --git a/gps/android/1.1/GnssMeasurement.h b/gps/android/1.1/GnssMeasurement.h
deleted file mode 100644
index ccafff2..0000000
--- a/gps/android/1.1/GnssMeasurement.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-/* ​​​​​Changes from Qualcomm Innovation Center are provided under the following license:
- * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
- * SPDX-License-Identifier: BSD-3-Clause-Clear
- */
-
-#ifndef ANDROID_HARDWARE_GNSS_V1_1_GNSSMEASUREMENT_H
-#define ANDROID_HARDWARE_GNSS_V1_1_GNSSMEASUREMENT_H
-
-#include <android/hardware/gnss/1.1/IGnssMeasurement.h>
-#include <hidl/MQDescriptor.h>
-#include <hidl/Status.h>
-#include "MeasurementAPIClient.h"
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_1 {
-namespace implementation {
-
-using ::android::hardware::gnss::V1_1::IGnssMeasurement;
-using ::android::hardware::gnss::V1_1::IGnssMeasurementCallback;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::sp;
-
-class MeasurementAPIClient;
-struct GnssMeasurement : public IGnssMeasurement {
-    GnssMeasurement();
-    ~GnssMeasurement();
-
-    /*
-     * Methods from ::android::hardware::gnss::V1_0::IGnssMeasurement follow.
-     * These declarations were generated from IGnssMeasurement.hal.
-     */
-    Return<GnssMeasurement::GnssMeasurementStatus> setCallback(
-        const sp<V1_0::IGnssMeasurementCallback>& callback) override;
-    Return<void> close() override;
-
-    // Methods from ::android::hardware::gnss::V1_1::IGnssMeasurement follow.
-    Return<GnssMeasurement::GnssMeasurementStatus> setCallback_1_1(
-            const sp<IGnssMeasurementCallback>& callback,
-            bool enableFullTracking) override;
-
- private:
-    struct GnssMeasurementDeathRecipient : hidl_death_recipient {
-        GnssMeasurementDeathRecipient(sp<GnssMeasurement> gnssMeasurement) :
-            mGnssMeasurement(gnssMeasurement) {
-        }
-        ~GnssMeasurementDeathRecipient() = default;
-        virtual void serviceDied(uint64_t cookie, const wp<IBase>& who) override;
-        sp<GnssMeasurement> mGnssMeasurement;
-    };
-
-    template <typename T>
-    Return<IGnssMeasurement::GnssMeasurementStatus> setCallback(
-            const sp<T>& callback, sp<T>& myCallback, GnssPowerMode powerMode);
-    sp<GnssMeasurementDeathRecipient> mGnssMeasurementDeathRecipient = nullptr;
-    sp<V1_0::IGnssMeasurementCallback> mGnssMeasurementCbIface = nullptr;
-    sp<IGnssMeasurementCallback> mGnssMeasurementCbIface_1_1 = nullptr;
-    MeasurementAPIClient* mApi;
-};
-
-}  // namespace implementation
-}  // namespace V1_1
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
-
-#endif  // ANDROID_HARDWARE_GNSS_V1_1_GNSSMEASUREMENT_H
diff --git a/gps/android/1.1/GnssNi.cpp b/gps/android/1.1/GnssNi.cpp
deleted file mode 100644
index 5ce9569..0000000
--- a/gps/android/1.1/GnssNi.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-#define LOG_TAG "LocSvc_GnssNiInterface"
-
-#include <log_util.h>
-#include "Gnss.h"
-#include "GnssNi.h"
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_1 {
-namespace implementation {
-
-void GnssNi::GnssNiDeathRecipient::serviceDied(uint64_t cookie, const wp<IBase>& who) {
-    LOC_LOGE("%s] service died. cookie: %llu, who: %p",
-            __FUNCTION__, static_cast<unsigned long long>(cookie), &who);
-    // we do nothing here
-    // Gnss::GnssDeathRecipient will stop the session
-}
-
-GnssNi::GnssNi(Gnss* gnss) : mGnss(gnss) {
-    mGnssNiDeathRecipient = new GnssNiDeathRecipient(this);
-}
-
-// Methods from ::android::hardware::gnss::V1_0::IGnssNi follow.
-Return<void> GnssNi::setCallback(const sp<IGnssNiCallback>& callback)  {
-    if (mGnss == nullptr) {
-        LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__);
-        return Void();
-    }
-
-    mGnss->setGnssNiCb(callback);
-
-    if (mGnssNiCbIface != nullptr) {
-        mGnssNiCbIface->unlinkToDeath(mGnssNiDeathRecipient);
-    }
-    mGnssNiCbIface = callback;
-    if (mGnssNiCbIface != nullptr) {
-        mGnssNiCbIface->linkToDeath(mGnssNiDeathRecipient, 0 /*cookie*/);
-    }
-
-    return Void();
-}
-
-Return<void> GnssNi::respond(int32_t notifId, IGnssNiCallback::GnssUserResponseType userResponse)  {
-    if (mGnss == nullptr) {
-        LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__);
-        return Void();
-    }
-
-    GnssAPIClient* api = mGnss->getApi();
-    if (api == nullptr) {
-        LOC_LOGE("%s]: api is nullptr", __FUNCTION__);
-        return Void();
-    }
-
-    api->gnssNiRespond(notifId, userResponse);
-
-    return Void();
-}
-
-}  // namespace implementation
-}  // namespace V1_1
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
diff --git a/gps/android/1.1/GnssNi.h b/gps/android/1.1/GnssNi.h
deleted file mode 100644
index 6733e5b..0000000
--- a/gps/android/1.1/GnssNi.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-#ifndef ANDROID_HARDWARE_GNSS_V1_1_GNSSNI_H
-#define ANDROID_HARDWARE_GNSS_V1_1_GNSSNI_H
-
-#include <android/hardware/gnss/1.0/IGnssNi.h>
-#include <hidl/Status.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_1 {
-namespace implementation {
-
-using ::android::hardware::gnss::V1_0::IGnssNi;
-using ::android::hardware::gnss::V1_0::IGnssNiCallback;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::sp;
-
-struct Gnss;
-struct GnssNi : public IGnssNi {
-    GnssNi(Gnss* gnss);
-    ~GnssNi() = default;
-
-    /*
-     * Methods from ::android::hardware::gnss::V1_0::IGnssNi follow.
-     * These declarations were generated from IGnssNi.hal.
-     */
-    Return<void> setCallback(const sp<IGnssNiCallback>& callback) override;
-    Return<void> respond(int32_t notifId,
-                         IGnssNiCallback::GnssUserResponseType userResponse) override;
-
- private:
-    struct GnssNiDeathRecipient : hidl_death_recipient {
-        GnssNiDeathRecipient(sp<GnssNi> gnssNi) : mGnssNi(gnssNi) {
-        }
-        ~GnssNiDeathRecipient() = default;
-        virtual void serviceDied(uint64_t cookie, const wp<IBase>& who) override;
-        sp<GnssNi> mGnssNi;
-    };
-
- private:
-    sp<GnssNiDeathRecipient> mGnssNiDeathRecipient = nullptr;
-    sp<IGnssNiCallback> mGnssNiCbIface = nullptr;
-    Gnss* mGnss = nullptr;
-};
-
-}  // namespace implementation
-}  // namespace V1_1
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
-
-#endif  // ANDROID_HARDWARE_GNSS_V1_1_GNSSNI_H
diff --git a/gps/android/1.1/android.hardware.gnss@1.1-service-qti.rc b/gps/android/1.1/android.hardware.gnss@1.1-service-qti.rc
deleted file mode 100644
index bd65584..0000000
--- a/gps/android/1.1/android.hardware.gnss@1.1-service-qti.rc
+++ /dev/null
@@ -1,4 +0,0 @@
-service gnss_service /vendor/bin/hw/android.hardware.gnss@1.1-service-qti
-    class hal
-    user gps
-    group system gps radio vendor_qti_diag
diff --git a/gps/android/1.1/android.hardware.gnss@1.1-service-qti.xml b/gps/android/1.1/android.hardware.gnss@1.1-service-qti.xml
deleted file mode 100644
index c9c83fb..0000000
--- a/gps/android/1.1/android.hardware.gnss@1.1-service-qti.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<!-- Copyright (c) 2019, The Linux Foundation. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-    * Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-    * Redistributions in binary form must reproduce the above
-      copyright notice, this list of conditions and the following
-      disclaimer in the documentation and/or other materials provided
-      with the distribution.
-    * Neither the name of The Linux Foundation nor the names of its
-      contributors may be used to endorse or promote products derived
-      from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
-WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
-ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
-BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
-BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
-IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--->
-<manifest version="1.0" type="device">
-    <hal format="hidl">
-        <name>android.hardware.gnss</name>
-        <transport>hwbinder</transport>
-        <fqname>@1.1::IGnss/default</fqname>
-    </hal>
-</manifest>
-
diff --git a/gps/android/1.1/location_api/BatchingAPIClient.cpp b/gps/android/1.1/location_api/BatchingAPIClient.cpp
deleted file mode 100644
index 6ec27a9..0000000
--- a/gps/android/1.1/location_api/BatchingAPIClient.cpp
+++ /dev/null
@@ -1,197 +0,0 @@
-/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- *       copyright notice, this list of conditions and the following
- *       disclaimer in the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of The Linux Foundation, nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#define LOG_NDEBUG 0
-#define LOG_TAG "LocSvc_BatchingAPIClient"
-
-#include <inttypes.h>
-#include <log_util.h>
-#include <loc_cfg.h>
-
-#include "LocationUtil.h"
-#include "BatchingAPIClient.h"
-
-#include "limits.h"
-
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_1 {
-namespace implementation {
-
-using ::android::hardware::gnss::V1_0::IGnssBatching;
-using ::android::hardware::gnss::V1_0::IGnssBatchingCallback;
-using ::android::hardware::gnss::V1_0::GnssLocation;
-
-static void convertBatchOption(const IGnssBatching::Options& in, LocationOptions& out,
-        LocationCapabilitiesMask mask);
-
-BatchingAPIClient::BatchingAPIClient(const sp<IGnssBatchingCallback>& callback) :
-    LocationAPIClientBase(),
-    mGnssBatchingCbIface(callback),
-    mDefaultId(UINT_MAX),
-    mLocationCapabilitiesMask(0)
-{
-    LOC_LOGD("%s]: (%p)", __FUNCTION__, &callback);
-
-    LocationCallbacks locationCallbacks;
-    memset(&locationCallbacks, 0, sizeof(LocationCallbacks));
-    locationCallbacks.size = sizeof(LocationCallbacks);
-
-    locationCallbacks.trackingCb = nullptr;
-    locationCallbacks.batchingCb = nullptr;
-    if (mGnssBatchingCbIface != nullptr) {
-        locationCallbacks.batchingCb = [this](size_t count, Location* location,
-            BatchingOptions batchOptions) {
-            onBatchingCb(count, location, batchOptions);
-        };
-    }
-    locationCallbacks.geofenceBreachCb = nullptr;
-    locationCallbacks.geofenceStatusCb = nullptr;
-    locationCallbacks.gnssLocationInfoCb = nullptr;
-    locationCallbacks.gnssNiCb = nullptr;
-    locationCallbacks.gnssSvCb = nullptr;
-    locationCallbacks.gnssNmeaCb = nullptr;
-    locationCallbacks.gnssMeasurementsCb = nullptr;
-
-    locAPISetCallbacks(locationCallbacks);
-}
-
-BatchingAPIClient::~BatchingAPIClient()
-{
-    LOC_LOGD("%s]: ()", __FUNCTION__);
-}
-
-int BatchingAPIClient::getBatchSize()
-{
-    LOC_LOGD("%s]: ()", __FUNCTION__);
-    return locAPIGetBatchSize();
-}
-
-int BatchingAPIClient::startSession(const IGnssBatching::Options& opts)
-{
-    LOC_LOGD("%s]: (%lld %d)", __FUNCTION__,
-            static_cast<long long>(opts.periodNanos), static_cast<uint8_t>(opts.flags));
-    int retVal = -1;
-    LocationOptions options;
-    convertBatchOption(opts, options, mLocationCapabilitiesMask);
-    uint32_t mode = 0;
-    if (opts.flags == static_cast<uint8_t>(IGnssBatching::Flag::WAKEUP_ON_FIFO_FULL)) {
-        mode = SESSION_MODE_ON_FULL;
-    }
-    if (locAPIStartSession(mDefaultId, mode, options) == LOCATION_ERROR_SUCCESS) {
-        retVal = 1;
-    }
-    return retVal;
-}
-
-int BatchingAPIClient::updateSessionOptions(const IGnssBatching::Options& opts)
-{
-    LOC_LOGD("%s]: (%lld %d)", __FUNCTION__,
-            static_cast<long long>(opts.periodNanos), static_cast<uint8_t>(opts.flags));
-    int retVal = -1;
-    LocationOptions options;
-    convertBatchOption(opts, options, mLocationCapabilitiesMask);
-
-    uint32_t mode = 0;
-    if (opts.flags == static_cast<uint8_t>(IGnssBatching::Flag::WAKEUP_ON_FIFO_FULL)) {
-        mode = SESSION_MODE_ON_FULL;
-    }
-    if (locAPIUpdateSessionOptions(mDefaultId, mode, options) == LOCATION_ERROR_SUCCESS) {
-        retVal = 1;
-    }
-    return retVal;
-}
-
-int BatchingAPIClient::stopSession()
-{
-    LOC_LOGD("%s]: ", __FUNCTION__);
-    int retVal = -1;
-    if (locAPIStopSession(mDefaultId) == LOCATION_ERROR_SUCCESS) {
-        retVal = 1;
-    }
-    return retVal;
-}
-
-void BatchingAPIClient::getBatchedLocation(int last_n_locations)
-{
-    LOC_LOGD("%s]: (%d)", __FUNCTION__, last_n_locations);
-    locAPIGetBatchedLocations(mDefaultId, last_n_locations);
-}
-
-void BatchingAPIClient::flushBatchedLocations()
-{
-    LOC_LOGD("%s]: ()", __FUNCTION__);
-    locAPIGetBatchedLocations(mDefaultId, SIZE_MAX);
-}
-
-void BatchingAPIClient::onCapabilitiesCb(LocationCapabilitiesMask capabilitiesMask)
-{
-    LOC_LOGD("%s]: (%" PRIu64 ")", __FUNCTION__, capabilitiesMask);
-    mLocationCapabilitiesMask = capabilitiesMask;
-}
-
-void BatchingAPIClient::onBatchingCb(size_t count, Location* location,
-        BatchingOptions /*batchOptions*/)
-{
-    LOC_LOGD("%s]: (count: %zu)", __FUNCTION__, count);
-    if (mGnssBatchingCbIface != nullptr && count > 0) {
-        hidl_vec<GnssLocation> locationVec;
-        locationVec.resize(count);
-        for (size_t i = 0; i < count; i++) {
-            convertGnssLocation(location[i], locationVec[i]);
-        }
-        auto r = mGnssBatchingCbIface->gnssLocationBatchCb(locationVec);
-        if (!r.isOk()) {
-            LOC_LOGE("%s] Error from gnssLocationBatchCb description=%s",
-                __func__, r.description().c_str());
-        }
-    }
-}
-
-static void convertBatchOption(const IGnssBatching::Options& in, LocationOptions& out,
-        LocationCapabilitiesMask mask)
-{
-    memset(&out, 0, sizeof(LocationOptions));
-    out.size = sizeof(LocationOptions);
-    out.minInterval = (uint32_t)(in.periodNanos / 1000000L);
-    out.minDistance = 0;
-    out.mode = GNSS_SUPL_MODE_STANDALONE;
-    if (mask & LOCATION_CAPABILITIES_GNSS_MSA_BIT)
-        out.mode = GNSS_SUPL_MODE_MSA;
-    if (mask & LOCATION_CAPABILITIES_GNSS_MSB_BIT)
-        out.mode = GNSS_SUPL_MODE_MSB;
-}
-
-}  // namespace implementation
-}  // namespace V1_1
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
diff --git a/gps/android/1.1/location_api/BatchingAPIClient.h b/gps/android/1.1/location_api/BatchingAPIClient.h
deleted file mode 100644
index 4c90626..0000000
--- a/gps/android/1.1/location_api/BatchingAPIClient.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- *       copyright notice, this list of conditions and the following
- *       disclaimer in the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of The Linux Foundation, nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#ifndef BATCHING_API_CLINET_H
-#define BATCHING_API_CLINET_H
-
-#include <android/hardware/gnss/1.0/IGnssBatching.h>
-#include <android/hardware/gnss/1.0/IGnssBatchingCallback.h>
-#include <pthread.h>
-
-#include <LocationAPIClientBase.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_1 {
-namespace implementation {
-
-class BatchingAPIClient : public LocationAPIClientBase
-{
-public:
-    BatchingAPIClient(const sp<V1_0::IGnssBatchingCallback>& callback);
-    int getBatchSize();
-    int startSession(const V1_0::IGnssBatching::Options& options);
-    int updateSessionOptions(const V1_0::IGnssBatching::Options& options);
-    int stopSession();
-    void getBatchedLocation(int last_n_locations);
-    void flushBatchedLocations();
-
-    inline LocationCapabilitiesMask getCapabilities() { return mLocationCapabilitiesMask; }
-
-    // callbacks
-    void onCapabilitiesCb(LocationCapabilitiesMask capabilitiesMask) final;
-    void onBatchingCb(size_t count, Location* location, BatchingOptions batchOptions) final;
-
-private:
-    ~BatchingAPIClient();
-
-    sp<V1_0::IGnssBatchingCallback> mGnssBatchingCbIface;
-    uint32_t mDefaultId;
-    LocationCapabilitiesMask mLocationCapabilitiesMask;
-};
-
-}  // namespace implementation
-}  // namespace V1_1
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
-#endif // BATCHING_API_CLINET_H
diff --git a/gps/android/1.1/location_api/GeofenceAPIClient.cpp b/gps/android/1.1/location_api/GeofenceAPIClient.cpp
deleted file mode 100644
index 93d175e..0000000
--- a/gps/android/1.1/location_api/GeofenceAPIClient.cpp
+++ /dev/null
@@ -1,275 +0,0 @@
-/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- *       copyright notice, this list of conditions and the following
- *       disclaimer in the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of The Linux Foundation, nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#define LOG_NDEBUG 0
-#define LOG_TAG "LocSvc_GeofenceApiClient"
-
-#include <log_util.h>
-#include <loc_cfg.h>
-
-#include "LocationUtil.h"
-#include "GeofenceAPIClient.h"
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_1 {
-namespace implementation {
-
-using ::android::hardware::gnss::V1_0::IGnssGeofenceCallback;
-using ::android::hardware::gnss::V1_0::GnssLocation;
-
-GeofenceAPIClient::GeofenceAPIClient(const sp<IGnssGeofenceCallback>& callback) :
-    LocationAPIClientBase(),
-    mGnssGeofencingCbIface(callback)
-{
-    LOC_LOGD("%s]: (%p)", __FUNCTION__, &callback);
-
-    LocationCallbacks locationCallbacks;
-    memset(&locationCallbacks, 0, sizeof(LocationCallbacks));
-    locationCallbacks.size = sizeof(LocationCallbacks);
-
-    locationCallbacks.trackingCb = nullptr;
-    locationCallbacks.batchingCb = nullptr;
-
-    locationCallbacks.geofenceBreachCb = nullptr;
-    if (mGnssGeofencingCbIface != nullptr) {
-        locationCallbacks.geofenceBreachCb =
-            [this](GeofenceBreachNotification geofenceBreachNotification) {
-                onGeofenceBreachCb(geofenceBreachNotification);
-            };
-
-        locationCallbacks.geofenceStatusCb =
-            [this](GeofenceStatusNotification geofenceStatusNotification) {
-                onGeofenceStatusCb(geofenceStatusNotification);
-            };
-    }
-
-    locationCallbacks.gnssLocationInfoCb = nullptr;
-    locationCallbacks.gnssNiCb = nullptr;
-    locationCallbacks.gnssSvCb = nullptr;
-    locationCallbacks.gnssNmeaCb = nullptr;
-    locationCallbacks.gnssMeasurementsCb = nullptr;
-
-    locAPISetCallbacks(locationCallbacks);
-}
-
-void GeofenceAPIClient::geofenceAdd(uint32_t geofence_id, double latitude, double longitude,
-        double radius_meters, int32_t last_transition, int32_t monitor_transitions,
-        uint32_t notification_responsiveness_ms, uint32_t unknown_timer_ms)
-{
-    LOC_LOGD("%s]: (%d %f %f %f %d %d %d %d)", __FUNCTION__,
-            geofence_id, latitude, longitude, radius_meters,
-            last_transition, monitor_transitions, notification_responsiveness_ms, unknown_timer_ms);
-
-    GeofenceOption options;
-    memset(&options, 0, sizeof(GeofenceOption));
-    options.size = sizeof(GeofenceOption);
-    if (monitor_transitions & IGnssGeofenceCallback::GeofenceTransition::ENTERED)
-        options.breachTypeMask |= GEOFENCE_BREACH_ENTER_BIT;
-    if (monitor_transitions & IGnssGeofenceCallback::GeofenceTransition::EXITED)
-        options.breachTypeMask |=  GEOFENCE_BREACH_EXIT_BIT;
-    options.responsiveness = notification_responsiveness_ms;
-
-    GeofenceInfo data;
-    data.size = sizeof(GeofenceInfo);
-    data.latitude = latitude;
-    data.longitude = longitude;
-    data.radius = radius_meters;
-
-    LocationError err = (LocationError)locAPIAddGeofences(1, &geofence_id, &options, &data);
-    if (LOCATION_ERROR_SUCCESS != err) {
-        onAddGeofencesCb(1, &err, &geofence_id);
-    }
-}
-
-void GeofenceAPIClient::geofencePause(uint32_t geofence_id)
-{
-    LOC_LOGD("%s]: (%d)", __FUNCTION__, geofence_id);
-    locAPIPauseGeofences(1, &geofence_id);
-}
-
-void GeofenceAPIClient::geofenceResume(uint32_t geofence_id, int32_t monitor_transitions)
-{
-    LOC_LOGD("%s]: (%d %d)", __FUNCTION__, geofence_id, monitor_transitions);
-    GeofenceBreachTypeMask mask = 0;
-    if (monitor_transitions & IGnssGeofenceCallback::GeofenceTransition::ENTERED)
-        mask |= GEOFENCE_BREACH_ENTER_BIT;
-    if (monitor_transitions & IGnssGeofenceCallback::GeofenceTransition::EXITED)
-        mask |=  GEOFENCE_BREACH_EXIT_BIT;
-    locAPIResumeGeofences(1, &geofence_id, &mask);
-}
-
-void GeofenceAPIClient::geofenceRemove(uint32_t geofence_id)
-{
-    LOC_LOGD("%s]: (%d)", __FUNCTION__, geofence_id);
-    locAPIRemoveGeofences(1, &geofence_id);
-}
-
-void GeofenceAPIClient::geofenceRemoveAll()
-{
-    LOC_LOGD("%s]", __FUNCTION__);
-    // TODO locAPIRemoveAllGeofences();
-}
-
-// callbacks
-void GeofenceAPIClient::onGeofenceBreachCb(GeofenceBreachNotification geofenceBreachNotification)
-{
-    LOC_LOGD("%s]: (%zu)", __FUNCTION__, geofenceBreachNotification.count);
-    if (mGnssGeofencingCbIface != nullptr) {
-        for (size_t i = 0; i < geofenceBreachNotification.count; i++) {
-            GnssLocation gnssLocation;
-            convertGnssLocation(geofenceBreachNotification.location, gnssLocation);
-
-            IGnssGeofenceCallback::GeofenceTransition transition;
-            if (geofenceBreachNotification.type == GEOFENCE_BREACH_ENTER)
-                transition = IGnssGeofenceCallback::GeofenceTransition::ENTERED;
-            else if (geofenceBreachNotification.type == GEOFENCE_BREACH_EXIT)
-                transition = IGnssGeofenceCallback::GeofenceTransition::EXITED;
-            else {
-                // continue with other breach if transition is
-                // nether GPS_GEOFENCE_ENTERED nor GPS_GEOFENCE_EXITED
-                continue;
-            }
-
-            auto r = mGnssGeofencingCbIface->gnssGeofenceTransitionCb(
-                    geofenceBreachNotification.ids[i], gnssLocation, transition,
-                    static_cast<V1_0::GnssUtcTime>(geofenceBreachNotification.timestamp));
-            if (!r.isOk()) {
-                LOC_LOGE("%s] Error from gnssGeofenceTransitionCb description=%s",
-                    __func__, r.description().c_str());
-            }
-        }
-    }
-}
-
-void GeofenceAPIClient::onGeofenceStatusCb(GeofenceStatusNotification geofenceStatusNotification)
-{
-    LOC_LOGD("%s]: (%d)", __FUNCTION__, geofenceStatusNotification.available);
-    if (mGnssGeofencingCbIface != nullptr) {
-        IGnssGeofenceCallback::GeofenceAvailability status =
-            IGnssGeofenceCallback::GeofenceAvailability::UNAVAILABLE;
-        if (geofenceStatusNotification.available == GEOFENCE_STATUS_AVAILABILE_YES) {
-            status = IGnssGeofenceCallback::GeofenceAvailability::AVAILABLE;
-        }
-        GnssLocation gnssLocation;
-        memset(&gnssLocation, 0, sizeof(GnssLocation));
-        auto r = mGnssGeofencingCbIface->gnssGeofenceStatusCb(status, gnssLocation);
-        if (!r.isOk()) {
-            LOC_LOGE("%s] Error from gnssGeofenceStatusCb description=%s",
-                __func__, r.description().c_str());
-        }
-    }
-}
-
-void GeofenceAPIClient::onAddGeofencesCb(size_t count, LocationError* errors, uint32_t* ids)
-{
-    LOC_LOGD("%s]: (%zu)", __FUNCTION__, count);
-    if (mGnssGeofencingCbIface != nullptr) {
-        for (size_t i = 0; i < count; i++) {
-            IGnssGeofenceCallback::GeofenceStatus status =
-                IGnssGeofenceCallback::GeofenceStatus::ERROR_GENERIC;
-            if (errors[i] == LOCATION_ERROR_SUCCESS)
-                status = IGnssGeofenceCallback::GeofenceStatus::OPERATION_SUCCESS;
-            else if (errors[i] == LOCATION_ERROR_ID_EXISTS)
-                status = IGnssGeofenceCallback::GeofenceStatus::ERROR_ID_EXISTS;
-            auto r = mGnssGeofencingCbIface->gnssGeofenceAddCb(ids[i], status);
-            if (!r.isOk()) {
-                LOC_LOGE("%s] Error from gnssGeofenceAddCb description=%s",
-                    __func__, r.description().c_str());
-            }
-        }
-    }
-}
-
-void GeofenceAPIClient::onRemoveGeofencesCb(size_t count, LocationError* errors, uint32_t* ids)
-{
-    LOC_LOGD("%s]: (%zu)", __FUNCTION__, count);
-    if (mGnssGeofencingCbIface != nullptr) {
-        for (size_t i = 0; i < count; i++) {
-            IGnssGeofenceCallback::GeofenceStatus status =
-                IGnssGeofenceCallback::GeofenceStatus::ERROR_GENERIC;
-            if (errors[i] == LOCATION_ERROR_SUCCESS)
-                status = IGnssGeofenceCallback::GeofenceStatus::OPERATION_SUCCESS;
-            else if (errors[i] == LOCATION_ERROR_ID_UNKNOWN)
-                status = IGnssGeofenceCallback::GeofenceStatus::ERROR_ID_UNKNOWN;
-            auto r = mGnssGeofencingCbIface->gnssGeofenceRemoveCb(ids[i], status);
-            if (!r.isOk()) {
-                LOC_LOGE("%s] Error from gnssGeofenceRemoveCb description=%s",
-                    __func__, r.description().c_str());
-            }
-        }
-    }
-}
-
-void GeofenceAPIClient::onPauseGeofencesCb(size_t count, LocationError* errors, uint32_t* ids)
-{
-    LOC_LOGD("%s]: (%zu)", __FUNCTION__, count);
-    if (mGnssGeofencingCbIface != nullptr) {
-        for (size_t i = 0; i < count; i++) {
-            IGnssGeofenceCallback::GeofenceStatus status =
-                IGnssGeofenceCallback::GeofenceStatus::ERROR_GENERIC;
-            if (errors[i] == LOCATION_ERROR_SUCCESS)
-                status = IGnssGeofenceCallback::GeofenceStatus::OPERATION_SUCCESS;
-            else if (errors[i] == LOCATION_ERROR_ID_UNKNOWN)
-                status = IGnssGeofenceCallback::GeofenceStatus::ERROR_ID_UNKNOWN;
-            auto r = mGnssGeofencingCbIface->gnssGeofencePauseCb(ids[i], status);
-            if (!r.isOk()) {
-                LOC_LOGE("%s] Error from gnssGeofencePauseCb description=%s",
-                    __func__, r.description().c_str());
-            }
-        }
-    }
-}
-
-void GeofenceAPIClient::onResumeGeofencesCb(size_t count, LocationError* errors, uint32_t* ids)
-{
-    LOC_LOGD("%s]: (%zu)", __FUNCTION__, count);
-    if (mGnssGeofencingCbIface != nullptr) {
-        for (size_t i = 0; i < count; i++) {
-            IGnssGeofenceCallback::GeofenceStatus status =
-                IGnssGeofenceCallback::GeofenceStatus::ERROR_GENERIC;
-            if (errors[i] == LOCATION_ERROR_SUCCESS)
-                status = IGnssGeofenceCallback::GeofenceStatus::OPERATION_SUCCESS;
-            else if (errors[i] == LOCATION_ERROR_ID_UNKNOWN)
-                status = IGnssGeofenceCallback::GeofenceStatus::ERROR_ID_UNKNOWN;
-            auto r = mGnssGeofencingCbIface->gnssGeofenceResumeCb(ids[i], status);
-            if (!r.isOk()) {
-                LOC_LOGE("%s] Error from gnssGeofenceResumeCb description=%s",
-                    __func__, r.description().c_str());
-            }
-        }
-    }
-}
-
-}  // namespace implementation
-}  // namespace V1_1
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
diff --git a/gps/android/1.1/location_api/GeofenceAPIClient.h b/gps/android/1.1/location_api/GeofenceAPIClient.h
deleted file mode 100644
index 0ffff91..0000000
--- a/gps/android/1.1/location_api/GeofenceAPIClient.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- *       copyright notice, this list of conditions and the following
- *       disclaimer in the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of The Linux Foundation, nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#ifndef GEOFENCE_API_CLINET_H
-#define GEOFENCE_API_CLINET_H
-
-
-#include <android/hardware/gnss/1.0/IGnssGeofenceCallback.h>
-#include <LocationAPIClientBase.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_1 {
-namespace implementation {
-
-using ::android::sp;
-
-class GeofenceAPIClient : public LocationAPIClientBase
-{
-public:
-    GeofenceAPIClient(const sp<V1_0::IGnssGeofenceCallback>& callback);
-
-    void geofenceAdd(uint32_t geofence_id, double latitude, double longitude,
-            double radius_meters, int32_t last_transition, int32_t monitor_transitions,
-            uint32_t notification_responsiveness_ms, uint32_t unknown_timer_ms);
-    void geofencePause(uint32_t geofence_id);
-    void geofenceResume(uint32_t geofence_id, int32_t monitor_transitions);
-    void geofenceRemove(uint32_t geofence_id);
-    void geofenceRemoveAll();
-
-    // callbacks
-    void onGeofenceBreachCb(GeofenceBreachNotification geofenceBreachNotification) final;
-    void onGeofenceStatusCb(GeofenceStatusNotification geofenceStatusNotification) final;
-    void onAddGeofencesCb(size_t count, LocationError* errors, uint32_t* ids) final;
-    void onRemoveGeofencesCb(size_t count, LocationError* errors, uint32_t* ids) final;
-    void onPauseGeofencesCb(size_t count, LocationError* errors, uint32_t* ids) final;
-    void onResumeGeofencesCb(size_t count, LocationError* errors, uint32_t* ids) final;
-
-private:
-    virtual ~GeofenceAPIClient() = default;
-
-    sp<V1_0::IGnssGeofenceCallback> mGnssGeofencingCbIface;
-};
-
-}  // namespace implementation
-}  // namespace V1_1
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
-#endif // GEOFENCE_API_CLINET_H
diff --git a/gps/android/1.1/location_api/GnssAPIClient.cpp b/gps/android/1.1/location_api/GnssAPIClient.cpp
deleted file mode 100644
index a2c4eec..0000000
--- a/gps/android/1.1/location_api/GnssAPIClient.cpp
+++ /dev/null
@@ -1,565 +0,0 @@
-/* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- *       copyright notice, this list of conditions and the following
- *       disclaimer in the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of The Linux Foundation, nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#define LOG_NDEBUG 0
-#define LOG_TAG "LocSvc_GnssAPIClient"
-#define SINGLE_SHOT_MIN_TRACKING_INTERVAL_MSEC (590 * 60 * 60 * 1000) // 590 hours
-
-#include <inttypes.h>
-#include <log_util.h>
-#include <loc_cfg.h>
-
-#include "LocationUtil.h"
-#include "GnssAPIClient.h"
-#include <LocContext.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_1 {
-namespace implementation {
-
-using ::android::hardware::gnss::V1_0::IGnss;
-using ::android::hardware::gnss::V1_0::IGnssCallback;
-using ::android::hardware::gnss::V1_0::IGnssNiCallback;
-using ::android::hardware::gnss::V1_0::GnssLocation;
-
-static void convertGnssSvStatus(GnssSvNotification& in, IGnssCallback::GnssSvStatus& out);
-
-GnssAPIClient::GnssAPIClient(const sp<IGnssCallback>& gpsCb,
-    const sp<IGnssNiCallback>& niCb) :
-    LocationAPIClientBase(),
-    mGnssCbIface(nullptr),
-    mGnssNiCbIface(nullptr),
-    mControlClient(new LocationAPIControlClient()),
-    mLocationCapabilitiesMask(0),
-    mLocationCapabilitiesCached(false)
-{
-    LOC_LOGD("%s]: (%p %p)", __FUNCTION__, &gpsCb, &niCb);
-
-    // set default LocationOptions.
-    memset(&mTrackingOptions, 0, sizeof(TrackingOptions));
-    mTrackingOptions.size = sizeof(TrackingOptions);
-    mTrackingOptions.minInterval = 1000;
-    mTrackingOptions.minDistance = 0;
-    mTrackingOptions.mode = GNSS_SUPL_MODE_STANDALONE;
-
-    gnssUpdateCallbacks(gpsCb, niCb);
-}
-
-GnssAPIClient::~GnssAPIClient()
-{
-    LOC_LOGD("%s]: ()", __FUNCTION__);
-    if (mControlClient) {
-        delete mControlClient;
-        mControlClient = nullptr;
-    }
-}
-
-// for GpsInterface
-void GnssAPIClient::gnssUpdateCallbacks(const sp<IGnssCallback>& gpsCb,
-    const sp<IGnssNiCallback>& niCb)
-{
-    LOC_LOGD("%s]: (%p %p)", __FUNCTION__, &gpsCb, &niCb);
-
-    mMutex.lock();
-    mGnssCbIface = gpsCb;
-    mGnssNiCbIface = niCb;
-    mMutex.unlock();
-
-    LocationCallbacks locationCallbacks;
-    memset(&locationCallbacks, 0, sizeof(LocationCallbacks));
-    locationCallbacks.size = sizeof(LocationCallbacks);
-
-    locationCallbacks.trackingCb = nullptr;
-    if (mGnssCbIface != nullptr) {
-        locationCallbacks.trackingCb = [this](Location location) {
-            onTrackingCb(location);
-        };
-    }
-
-    locationCallbacks.batchingCb = nullptr;
-    locationCallbacks.geofenceBreachCb = nullptr;
-    locationCallbacks.geofenceStatusCb = nullptr;
-    locationCallbacks.gnssLocationInfoCb = nullptr;
-
-    locationCallbacks.gnssNiCb = nullptr;
-    loc_core::ContextBase* context =
-            loc_core::LocContext::getLocContext(loc_core::LocContext::mLocationHalName);
-    if (mGnssNiCbIface != nullptr && !context->hasAgpsExtendedCapabilities()) {
-        LOC_LOGD("Registering NI CB");
-        locationCallbacks.gnssNiCb = [this](uint32_t id, GnssNiNotification gnssNiNotification) {
-            onGnssNiCb(id, gnssNiNotification);
-        };
-    }
-
-    locationCallbacks.gnssSvCb = nullptr;
-    if (mGnssCbIface != nullptr) {
-        locationCallbacks.gnssSvCb = [this](GnssSvNotification gnssSvNotification) {
-            onGnssSvCb(gnssSvNotification);
-        };
-    }
-
-    locationCallbacks.gnssNmeaCb = nullptr;
-    if (mGnssCbIface != nullptr) {
-        locationCallbacks.gnssNmeaCb = [this](GnssNmeaNotification gnssNmeaNotification) {
-            onGnssNmeaCb(gnssNmeaNotification);
-        };
-    }
-
-    locationCallbacks.gnssMeasurementsCb = nullptr;
-
-    locAPISetCallbacks(locationCallbacks);
-}
-
-bool GnssAPIClient::gnssStart()
-{
-    LOC_LOGD("%s]: ()", __FUNCTION__);
-    bool retVal = true;
-    locAPIStartTracking(mTrackingOptions);
-    return retVal;
-}
-
-bool GnssAPIClient::gnssStop()
-{
-    LOC_LOGD("%s]: ()", __FUNCTION__);
-    bool retVal = true;
-    locAPIStopTracking();
-    return retVal;
-}
-
-bool GnssAPIClient::gnssSetPositionMode(IGnss::GnssPositionMode mode,
-        IGnss::GnssPositionRecurrence recurrence, uint32_t minIntervalMs,
-        uint32_t preferredAccuracyMeters, uint32_t preferredTimeMs,
-        GnssPowerMode powerMode, uint32_t timeBetweenMeasurement)
-{
-    LOC_LOGD("%s]: (%d %d %d %d %d %d %d)", __FUNCTION__,
-            (int)mode, recurrence, minIntervalMs, preferredAccuracyMeters,
-            preferredTimeMs, (int)powerMode, timeBetweenMeasurement);
-    bool retVal = true;
-    memset(&mTrackingOptions, 0, sizeof(TrackingOptions));
-    mTrackingOptions.size = sizeof(TrackingOptions);
-    mTrackingOptions.minInterval = minIntervalMs;
-    if (IGnss::GnssPositionMode::MS_ASSISTED == mode ||
-            IGnss::GnssPositionRecurrence::RECURRENCE_SINGLE == recurrence) {
-        // We set a very large interval to simulate SINGLE mode. Once we report a fix,
-        // the caller should take the responsibility to stop the session.
-        // For MSA, we always treat it as SINGLE mode.
-        mTrackingOptions.minInterval = SINGLE_SHOT_MIN_TRACKING_INTERVAL_MSEC;
-    }
-    if (mode == IGnss::GnssPositionMode::STANDALONE)
-        mTrackingOptions.mode = GNSS_SUPL_MODE_STANDALONE;
-    else if (mode == IGnss::GnssPositionMode::MS_BASED)
-        mTrackingOptions.mode = GNSS_SUPL_MODE_MSB;
-    else if (mode ==  IGnss::GnssPositionMode::MS_ASSISTED)
-        mTrackingOptions.mode = GNSS_SUPL_MODE_MSA;
-    else {
-        LOC_LOGD("%s]: invalid GnssPositionMode: %d", __FUNCTION__, (int)mode);
-        retVal = false;
-    }
-    if (GNSS_POWER_MODE_INVALID != powerMode) {
-        mTrackingOptions.powerMode = powerMode;
-        mTrackingOptions.tbm = timeBetweenMeasurement;
-    }
-    locAPIUpdateTrackingOptions(mTrackingOptions);
-    return retVal;
-}
-
-// for GpsNiInterface
-void GnssAPIClient::gnssNiRespond(int32_t notifId,
-        IGnssNiCallback::GnssUserResponseType userResponse)
-{
-    LOC_LOGD("%s]: (%d %d)", __FUNCTION__, notifId, static_cast<int>(userResponse));
-    GnssNiResponse data;
-    switch (userResponse) {
-    case IGnssNiCallback::GnssUserResponseType::RESPONSE_ACCEPT:
-        data = GNSS_NI_RESPONSE_ACCEPT;
-        break;
-    case IGnssNiCallback::GnssUserResponseType::RESPONSE_DENY:
-        data = GNSS_NI_RESPONSE_DENY;
-        break;
-    case IGnssNiCallback::GnssUserResponseType::RESPONSE_NORESP:
-        data = GNSS_NI_RESPONSE_NO_RESPONSE;
-        break;
-    default:
-        data = GNSS_NI_RESPONSE_IGNORE;
-        break;
-    }
-
-    locAPIGnssNiResponse(notifId, data);
-}
-
-// these apis using LocationAPIControlClient
-void GnssAPIClient::gnssDeleteAidingData(IGnss::GnssAidingData aidingDataFlags)
-{
-    LOC_LOGD("%s]: (%02hx)", __FUNCTION__, aidingDataFlags);
-    if (mControlClient == nullptr) {
-        return;
-    }
-    GnssAidingData data;
-    memset(&data, 0, sizeof (GnssAidingData));
-    data.sv.svTypeMask = GNSS_AIDING_DATA_SV_TYPE_GPS_BIT |
-        GNSS_AIDING_DATA_SV_TYPE_GLONASS_BIT |
-        GNSS_AIDING_DATA_SV_TYPE_QZSS_BIT |
-        GNSS_AIDING_DATA_SV_TYPE_BEIDOU_BIT |
-        GNSS_AIDING_DATA_SV_TYPE_GALILEO_BIT;
-    data.posEngineMask = STANDARD_POSITIONING_ENGINE;
-
-    if (aidingDataFlags == IGnss::GnssAidingData::DELETE_ALL)
-        data.deleteAll = true;
-    else {
-        if (aidingDataFlags & IGnss::GnssAidingData::DELETE_EPHEMERIS)
-            data.sv.svMask |= GNSS_AIDING_DATA_SV_EPHEMERIS_BIT;
-        if (aidingDataFlags & IGnss::GnssAidingData::DELETE_ALMANAC)
-            data.sv.svMask |= GNSS_AIDING_DATA_SV_ALMANAC_BIT;
-        if (aidingDataFlags & IGnss::GnssAidingData::DELETE_POSITION)
-            data.common.mask |= GNSS_AIDING_DATA_COMMON_POSITION_BIT;
-        if (aidingDataFlags & IGnss::GnssAidingData::DELETE_TIME)
-            data.common.mask |= GNSS_AIDING_DATA_COMMON_TIME_BIT;
-        if (aidingDataFlags & IGnss::GnssAidingData::DELETE_IONO)
-            data.sv.svMask |= GNSS_AIDING_DATA_SV_IONOSPHERE_BIT;
-        if (aidingDataFlags & IGnss::GnssAidingData::DELETE_UTC)
-            data.common.mask |= GNSS_AIDING_DATA_COMMON_UTC_BIT;
-        if (aidingDataFlags & IGnss::GnssAidingData::DELETE_HEALTH)
-            data.sv.svMask |= GNSS_AIDING_DATA_SV_HEALTH_BIT;
-        if (aidingDataFlags & IGnss::GnssAidingData::DELETE_SVDIR)
-            data.sv.svMask |= GNSS_AIDING_DATA_SV_DIRECTION_BIT;
-        if (aidingDataFlags & IGnss::GnssAidingData::DELETE_SVSTEER)
-            data.sv.svMask |= GNSS_AIDING_DATA_SV_STEER_BIT;
-        if (aidingDataFlags & IGnss::GnssAidingData::DELETE_SADATA)
-            data.sv.svMask |= GNSS_AIDING_DATA_SV_SA_DATA_BIT;
-        if (aidingDataFlags & IGnss::GnssAidingData::DELETE_RTI)
-            data.common.mask |= GNSS_AIDING_DATA_COMMON_RTI_BIT;
-        if (aidingDataFlags & IGnss::GnssAidingData::DELETE_CELLDB_INFO)
-            data.common.mask |= GNSS_AIDING_DATA_COMMON_CELLDB_BIT;
-    }
-    mControlClient->locAPIGnssDeleteAidingData(data);
-}
-
-void GnssAPIClient::gnssEnable(LocationTechnologyType techType)
-{
-    LOC_LOGD("%s]: (%0d)", __FUNCTION__, techType);
-    if (mControlClient == nullptr) {
-        return;
-    }
-    mControlClient->locAPIEnable(techType);
-}
-
-void GnssAPIClient::gnssDisable()
-{
-    LOC_LOGD("%s]: ()", __FUNCTION__);
-    if (mControlClient == nullptr) {
-        return;
-    }
-    mControlClient->locAPIDisable();
-}
-
-void GnssAPIClient::gnssConfigurationUpdate(const GnssConfig& gnssConfig)
-{
-    LOC_LOGD("%s]: (%02x)", __FUNCTION__, gnssConfig.flags);
-    if (mControlClient == nullptr) {
-        return;
-    }
-    mControlClient->locAPIGnssUpdateConfig(gnssConfig);
-}
-
-void GnssAPIClient::requestCapabilities() {
-    // only send capablities if it's already cached, otherwise the first time LocationAPI
-    // is initialized, capabilities will be sent by LocationAPI
-    if (mLocationCapabilitiesCached) {
-        onCapabilitiesCb(mLocationCapabilitiesMask);
-    }
-}
-
-// callbacks
-void GnssAPIClient::onCapabilitiesCb(LocationCapabilitiesMask capabilitiesMask)
-{
-    LOC_LOGD("%s]: (%" PRIu64 ")", __FUNCTION__, capabilitiesMask);
-    mLocationCapabilitiesMask = capabilitiesMask;
-    mLocationCapabilitiesCached = true;
-
-    mMutex.lock();
-    auto gnssCbIface(mGnssCbIface);
-    mMutex.unlock();
-
-    if (gnssCbIface != nullptr) {
-        uint32_t data = 0;
-        if ((capabilitiesMask & LOCATION_CAPABILITIES_TIME_BASED_TRACKING_BIT) ||
-                (capabilitiesMask & LOCATION_CAPABILITIES_TIME_BASED_BATCHING_BIT) ||
-                (capabilitiesMask & LOCATION_CAPABILITIES_DISTANCE_BASED_TRACKING_BIT) ||
-                (capabilitiesMask & LOCATION_CAPABILITIES_DISTANCE_BASED_BATCHING_BIT))
-            data |= IGnssCallback::Capabilities::SCHEDULING;
-        if (capabilitiesMask & LOCATION_CAPABILITIES_GEOFENCE_BIT)
-            data |= IGnssCallback::Capabilities::GEOFENCING;
-        if (capabilitiesMask & LOCATION_CAPABILITIES_GNSS_MEASUREMENTS_BIT)
-            data |= IGnssCallback::Capabilities::MEASUREMENTS;
-        if (capabilitiesMask & LOCATION_CAPABILITIES_GNSS_MSB_BIT)
-            data |= IGnssCallback::Capabilities::MSB;
-        if (capabilitiesMask & LOCATION_CAPABILITIES_GNSS_MSA_BIT)
-            data |= IGnssCallback::Capabilities::MSA;
-        auto r = gnssCbIface->gnssSetCapabilitesCb(data);
-        if (!r.isOk()) {
-            LOC_LOGE("%s] Error from gnssSetCapabilitesCb description=%s",
-                __func__, r.description().c_str());
-        }
-    }
-    if (gnssCbIface != nullptr) {
-        IGnssCallback::GnssSystemInfo gnssInfo = { .yearOfHw = 2015 };
-
-        if (capabilitiesMask & LOCATION_CAPABILITIES_GNSS_MEASUREMENTS_BIT) {
-            gnssInfo.yearOfHw++; // 2016
-            if (capabilitiesMask & LOCATION_CAPABILITIES_DEBUG_NMEA_BIT) {
-                gnssInfo.yearOfHw++; // 2017
-                if (capabilitiesMask & LOCATION_CAPABILITIES_CONSTELLATION_ENABLEMENT_BIT ||
-                    capabilitiesMask & LOCATION_CAPABILITIES_AGPM_BIT) {
-                    gnssInfo.yearOfHw++; // 2018
-                }
-            }
-        }
-        LOC_LOGV("%s:%d] set_system_info_cb (%d)", __FUNCTION__, __LINE__, gnssInfo.yearOfHw);
-        auto r = gnssCbIface->gnssSetSystemInfoCb(gnssInfo);
-        if (!r.isOk()) {
-            LOC_LOGE("%s] Error from gnssSetSystemInfoCb description=%s",
-                __func__, r.description().c_str());
-        }
-    }
-}
-
-void GnssAPIClient::onTrackingCb(Location location)
-{
-    LOC_LOGD("%s]: (flags: %02x)", __FUNCTION__, location.flags);
-    mMutex.lock();
-    auto gnssCbIface(mGnssCbIface);
-    mMutex.unlock();
-
-    if (gnssCbIface != nullptr) {
-        GnssLocation gnssLocation;
-        convertGnssLocation(location, gnssLocation);
-        auto r = gnssCbIface->gnssLocationCb(gnssLocation);
-        if (!r.isOk()) {
-            LOC_LOGE("%s] Error from gnssLocationCb description=%s",
-                __func__, r.description().c_str());
-        }
-    }
-}
-
-void GnssAPIClient::onGnssNiCb(uint32_t id, GnssNiNotification gnssNiNotification)
-{
-    LOC_LOGD("%s]: (id: %d)", __FUNCTION__, id);
-    mMutex.lock();
-    auto gnssNiCbIface(mGnssNiCbIface);
-    mMutex.unlock();
-
-    if (gnssNiCbIface == nullptr) {
-        LOC_LOGE("%s]: mGnssNiCbIface is nullptr", __FUNCTION__);
-        return;
-    }
-
-    IGnssNiCallback::GnssNiNotification notificationGnss = {};
-
-    notificationGnss.notificationId = id;
-
-    if (gnssNiNotification.type == GNSS_NI_TYPE_VOICE)
-        notificationGnss.niType = IGnssNiCallback::GnssNiType::VOICE;
-    else if (gnssNiNotification.type == GNSS_NI_TYPE_SUPL)
-        notificationGnss.niType = IGnssNiCallback::GnssNiType::UMTS_SUPL;
-    else if (gnssNiNotification.type == GNSS_NI_TYPE_CONTROL_PLANE)
-        notificationGnss.niType = IGnssNiCallback::GnssNiType::UMTS_CTRL_PLANE;
-    else if (gnssNiNotification.type == GNSS_NI_TYPE_EMERGENCY_SUPL)
-        notificationGnss.niType = IGnssNiCallback::GnssNiType::EMERGENCY_SUPL;
-
-    if (gnssNiNotification.options & GNSS_NI_OPTIONS_NOTIFICATION_BIT)
-        notificationGnss.notifyFlags |= IGnssNiCallback::GnssNiNotifyFlags::NEED_NOTIFY;
-    if (gnssNiNotification.options & GNSS_NI_OPTIONS_VERIFICATION_BIT)
-        notificationGnss.notifyFlags |= IGnssNiCallback::GnssNiNotifyFlags::NEED_VERIFY;
-    if (gnssNiNotification.options & GNSS_NI_OPTIONS_PRIVACY_OVERRIDE_BIT)
-        notificationGnss.notifyFlags |= IGnssNiCallback::GnssNiNotifyFlags::PRIVACY_OVERRIDE;
-
-    notificationGnss.timeoutSec = gnssNiNotification.timeout;
-
-    if (gnssNiNotification.timeoutResponse == GNSS_NI_RESPONSE_ACCEPT)
-        notificationGnss.defaultResponse = IGnssNiCallback::GnssUserResponseType::RESPONSE_ACCEPT;
-    else if (gnssNiNotification.timeoutResponse == GNSS_NI_RESPONSE_DENY)
-        notificationGnss.defaultResponse = IGnssNiCallback::GnssUserResponseType::RESPONSE_DENY;
-    else if (gnssNiNotification.timeoutResponse == GNSS_NI_RESPONSE_NO_RESPONSE ||
-            gnssNiNotification.timeoutResponse == GNSS_NI_RESPONSE_IGNORE)
-        notificationGnss.defaultResponse = IGnssNiCallback::GnssUserResponseType::RESPONSE_NORESP;
-
-    notificationGnss.requestorId = gnssNiNotification.requestor;
-
-    notificationGnss.notificationMessage = gnssNiNotification.message;
-
-    if (gnssNiNotification.requestorEncoding == GNSS_NI_ENCODING_TYPE_NONE)
-        notificationGnss.requestorIdEncoding =
-            IGnssNiCallback::GnssNiEncodingType::ENC_NONE;
-    else if (gnssNiNotification.requestorEncoding == GNSS_NI_ENCODING_TYPE_GSM_DEFAULT)
-        notificationGnss.requestorIdEncoding =
-            IGnssNiCallback::GnssNiEncodingType::ENC_SUPL_GSM_DEFAULT;
-    else if (gnssNiNotification.requestorEncoding == GNSS_NI_ENCODING_TYPE_UTF8)
-        notificationGnss.requestorIdEncoding =
-            IGnssNiCallback::GnssNiEncodingType::ENC_SUPL_UTF8;
-    else if (gnssNiNotification.requestorEncoding == GNSS_NI_ENCODING_TYPE_UCS2)
-        notificationGnss.requestorIdEncoding =
-            IGnssNiCallback::GnssNiEncodingType::ENC_SUPL_UCS2;
-
-    if (gnssNiNotification.messageEncoding == GNSS_NI_ENCODING_TYPE_NONE)
-        notificationGnss.notificationIdEncoding =
-            IGnssNiCallback::GnssNiEncodingType::ENC_NONE;
-    else if (gnssNiNotification.messageEncoding == GNSS_NI_ENCODING_TYPE_GSM_DEFAULT)
-        notificationGnss.notificationIdEncoding =
-            IGnssNiCallback::GnssNiEncodingType::ENC_SUPL_GSM_DEFAULT;
-    else if (gnssNiNotification.messageEncoding == GNSS_NI_ENCODING_TYPE_UTF8)
-        notificationGnss.notificationIdEncoding =
-            IGnssNiCallback::GnssNiEncodingType::ENC_SUPL_UTF8;
-    else if (gnssNiNotification.messageEncoding == GNSS_NI_ENCODING_TYPE_UCS2)
-        notificationGnss.notificationIdEncoding =
-            IGnssNiCallback::GnssNiEncodingType::ENC_SUPL_UCS2;
-
-    gnssNiCbIface->niNotifyCb(notificationGnss);
-}
-
-void GnssAPIClient::onGnssSvCb(GnssSvNotification gnssSvNotification)
-{
-    LOC_LOGD("%s]: (count: %zu)", __FUNCTION__, gnssSvNotification.count);
-    mMutex.lock();
-    auto gnssCbIface(mGnssCbIface);
-    mMutex.unlock();
-
-    if (gnssCbIface != nullptr) {
-        IGnssCallback::GnssSvStatus svStatus;
-        convertGnssSvStatus(gnssSvNotification, svStatus);
-        auto r = gnssCbIface->gnssSvStatusCb(svStatus);
-        if (!r.isOk()) {
-            LOC_LOGE("%s] Error from gnssSvStatusCb description=%s",
-                __func__, r.description().c_str());
-        }
-    }
-}
-
-void GnssAPIClient::onGnssNmeaCb(GnssNmeaNotification gnssNmeaNotification)
-{
-    mMutex.lock();
-    auto gnssCbIface(mGnssCbIface);
-    mMutex.unlock();
-
-    if (gnssCbIface != nullptr) {
-        const std::string s(gnssNmeaNotification.nmea);
-        std::stringstream ss(s);
-        std::string each;
-        while(std::getline(ss, each, '\n')) {
-            each += '\n';
-            android::hardware::hidl_string nmeaString;
-            nmeaString.setToExternal(each.c_str(), each.length());
-            auto r = gnssCbIface->gnssNmeaCb(
-                    static_cast<V1_0::GnssUtcTime>(gnssNmeaNotification.timestamp), nmeaString);
-            if (!r.isOk()) {
-                LOC_LOGE("%s] Error from gnssNmeaCb nmea=%s length=%zu description=%s", __func__,
-                            gnssNmeaNotification.nmea, gnssNmeaNotification.length,
-                            r.description().c_str());
-            }
-        }
-    }
-}
-
-void GnssAPIClient::onStartTrackingCb(LocationError error)
-{
-    LOC_LOGD("%s]: (%d)", __FUNCTION__, error);
-    mMutex.lock();
-    auto gnssCbIface(mGnssCbIface);
-    mMutex.unlock();
-
-    if (error == LOCATION_ERROR_SUCCESS && gnssCbIface != nullptr) {
-        auto r = gnssCbIface->gnssStatusCb(IGnssCallback::GnssStatusValue::ENGINE_ON);
-        if (!r.isOk()) {
-            LOC_LOGE("%s] Error from gnssStatusCb ENGINE_ON description=%s",
-                __func__, r.description().c_str());
-        }
-        r = gnssCbIface->gnssStatusCb(IGnssCallback::GnssStatusValue::SESSION_BEGIN);
-        if (!r.isOk()) {
-            LOC_LOGE("%s] Error from gnssStatusCb SESSION_BEGIN description=%s",
-                __func__, r.description().c_str());
-        }
-    }
-}
-
-void GnssAPIClient::onStopTrackingCb(LocationError error)
-{
-    LOC_LOGD("%s]: (%d)", __FUNCTION__, error);
-    mMutex.lock();
-    auto gnssCbIface(mGnssCbIface);
-    mMutex.unlock();
-
-    if (error == LOCATION_ERROR_SUCCESS && gnssCbIface != nullptr) {
-        auto r = gnssCbIface->gnssStatusCb(IGnssCallback::GnssStatusValue::SESSION_END);
-        if (!r.isOk()) {
-            LOC_LOGE("%s] Error from gnssStatusCb SESSION_END description=%s",
-                __func__, r.description().c_str());
-        }
-        r = gnssCbIface->gnssStatusCb(IGnssCallback::GnssStatusValue::ENGINE_OFF);
-        if (!r.isOk()) {
-            LOC_LOGE("%s] Error from gnssStatusCb ENGINE_OFF description=%s",
-                __func__, r.description().c_str());
-        }
-    }
-}
-
-static void convertGnssSvStatus(GnssSvNotification& in, IGnssCallback::GnssSvStatus& out)
-{
-    memset(&out, 0, sizeof(IGnssCallback::GnssSvStatus));
-    out.numSvs = in.count;
-    if (out.numSvs > static_cast<uint32_t>(V1_0::GnssMax::SVS_COUNT)) {
-        LOC_LOGW("%s]: Too many satellites %u. Clamps to %d.",
-                __FUNCTION__,  out.numSvs, V1_0::GnssMax::SVS_COUNT);
-        out.numSvs = static_cast<uint32_t>(V1_0::GnssMax::SVS_COUNT);
-    }
-    for (size_t i = 0; i < out.numSvs; i++) {
-        IGnssCallback::GnssSvInfo& info = out.gnssSvList[i];
-        convertGnssSvid(in.gnssSvs[i], info.svid);
-        convertGnssConstellationType(in.gnssSvs[i].type, info.constellation);
-        info.cN0Dbhz = in.gnssSvs[i].cN0Dbhz;
-        info.elevationDegrees = in.gnssSvs[i].elevation;
-        info.azimuthDegrees = in.gnssSvs[i].azimuth;
-        info.carrierFrequencyHz = in.gnssSvs[i].carrierFrequencyHz;
-        info.svFlag = static_cast<uint8_t>(IGnssCallback::GnssSvFlags::NONE);
-        if (in.gnssSvs[i].gnssSvOptionsMask & GNSS_SV_OPTIONS_HAS_EPHEMER_BIT)
-            info.svFlag |= IGnssCallback::GnssSvFlags::HAS_EPHEMERIS_DATA;
-        if (in.gnssSvs[i].gnssSvOptionsMask & GNSS_SV_OPTIONS_HAS_ALMANAC_BIT)
-            info.svFlag |= IGnssCallback::GnssSvFlags::HAS_ALMANAC_DATA;
-        if (in.gnssSvs[i].gnssSvOptionsMask & GNSS_SV_OPTIONS_USED_IN_FIX_BIT)
-            info.svFlag |= IGnssCallback::GnssSvFlags::USED_IN_FIX;
-        if (in.gnssSvs[i].gnssSvOptionsMask & GNSS_SV_OPTIONS_HAS_CARRIER_FREQUENCY_BIT)
-            info.svFlag |= IGnssCallback::GnssSvFlags::HAS_CARRIER_FREQUENCY;
-    }
-}
-
-}  // namespace implementation
-}  // namespace V1_1
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
diff --git a/gps/android/1.1/location_api/GnssAPIClient.h b/gps/android/1.1/location_api/GnssAPIClient.h
deleted file mode 100644
index 3829265..0000000
--- a/gps/android/1.1/location_api/GnssAPIClient.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- *       copyright notice, this list of conditions and the following
- *       disclaimer in the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of The Linux Foundation, nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#ifndef GNSS_API_CLINET_H
-#define GNSS_API_CLINET_H
-
-
-#include <mutex>
-#include <android/hardware/gnss/1.1/IGnss.h>
-#include <android/hardware/gnss/1.1/IGnssCallback.h>
-#include <android/hardware/gnss/1.0/IGnssNiCallback.h>
-#include <LocationAPIClientBase.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_1 {
-namespace implementation {
-
-using ::android::sp;
-
-class GnssAPIClient : public LocationAPIClientBase
-{
-public:
-    GnssAPIClient(const sp<V1_0::IGnssCallback>& gpsCb,
-            const sp<V1_0::IGnssNiCallback>& niCb);
-    GnssAPIClient(const GnssAPIClient&) = delete;
-    GnssAPIClient& operator=(const GnssAPIClient&) = delete;
-
-    // for GpsInterface
-    void gnssUpdateCallbacks(const sp<V1_0::IGnssCallback>& gpsCb,
-            const sp<V1_0::IGnssNiCallback>& niCb);
-    bool gnssStart();
-    bool gnssStop();
-    bool gnssSetPositionMode(V1_0::IGnss::GnssPositionMode mode,
-            V1_0::IGnss::GnssPositionRecurrence recurrence,
-            uint32_t minIntervalMs,
-            uint32_t preferredAccuracyMeters,
-            uint32_t preferredTimeMs,
-            GnssPowerMode powerMode = GNSS_POWER_MODE_INVALID,
-            uint32_t timeBetweenMeasurement = 0);
-
-    // for GpsNiInterface
-    void gnssNiRespond(int32_t notifId, V1_0::IGnssNiCallback::GnssUserResponseType userResponse);
-
-    // these apis using LocationAPIControlClient
-    void gnssDeleteAidingData(V1_0::IGnss::GnssAidingData aidingDataFlags);
-    void gnssEnable(LocationTechnologyType techType);
-    void gnssDisable();
-    void gnssConfigurationUpdate(const GnssConfig& gnssConfig);
-
-    inline LocationCapabilitiesMask gnssGetCapabilities() const {
-        return mLocationCapabilitiesMask;
-    }
-    void requestCapabilities();
-
-    // callbacks we are interested in
-    void onCapabilitiesCb(LocationCapabilitiesMask capabilitiesMask) final;
-    void onTrackingCb(Location location) final;
-    void onGnssNiCb(uint32_t id, GnssNiNotification gnssNiNotification) final;
-    void onGnssSvCb(GnssSvNotification gnssSvNotification) final;
-    void onGnssNmeaCb(GnssNmeaNotification gnssNmeaNotification) final;
-
-    void onStartTrackingCb(LocationError error) final;
-    void onStopTrackingCb(LocationError error) final;
-
-private:
-    virtual ~GnssAPIClient();
-
-    sp<V1_0::IGnssCallback> mGnssCbIface;
-    sp<V1_0::IGnssNiCallback> mGnssNiCbIface;
-    std::mutex mMutex;
-    LocationAPIControlClient* mControlClient;
-    LocationCapabilitiesMask mLocationCapabilitiesMask;
-    bool mLocationCapabilitiesCached;
-    TrackingOptions mTrackingOptions;
-};
-
-}  // namespace implementation
-}  // namespace V1_1
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
-#endif // GNSS_API_CLINET_H
diff --git a/gps/android/1.1/location_api/LocationUtil.cpp b/gps/android/1.1/location_api/LocationUtil.cpp
deleted file mode 100644
index 26fd920..0000000
--- a/gps/android/1.1/location_api/LocationUtil.cpp
+++ /dev/null
@@ -1,274 +0,0 @@
-/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- *       copyright notice, this list of conditions and the following
- *       disclaimer in the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of The Linux Foundation, nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#include <LocationUtil.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_1 {
-namespace implementation {
-
-using ::android::hardware::gnss::V1_0::GnssLocation;
-using ::android::hardware::gnss::V1_0::GnssConstellationType;
-using ::android::hardware::gnss::V1_0::GnssLocationFlags;
-
-void convertGnssLocation(Location& in, GnssLocation& out)
-{
-    memset(&out, 0, sizeof(GnssLocation));
-    if (in.flags & LOCATION_HAS_LAT_LONG_BIT) {
-        out.gnssLocationFlags |= GnssLocationFlags::HAS_LAT_LONG;
-        out.latitudeDegrees = in.latitude;
-        out.longitudeDegrees = in.longitude;
-    }
-    if (in.flags & LOCATION_HAS_ALTITUDE_BIT) {
-        out.gnssLocationFlags |= GnssLocationFlags::HAS_ALTITUDE;
-        out.altitudeMeters = in.altitude;
-    }
-    if (in.flags & LOCATION_HAS_SPEED_BIT) {
-        out.gnssLocationFlags |= GnssLocationFlags::HAS_SPEED;
-        out.speedMetersPerSec = in.speed;
-    }
-    if (in.flags & LOCATION_HAS_BEARING_BIT) {
-        out.gnssLocationFlags |= GnssLocationFlags::HAS_BEARING;
-        out.bearingDegrees = in.bearing;
-    }
-    if (in.flags & LOCATION_HAS_ACCURACY_BIT) {
-        out.gnssLocationFlags |= GnssLocationFlags::HAS_HORIZONTAL_ACCURACY;
-        out.horizontalAccuracyMeters = in.accuracy;
-    }
-    if (in.flags & LOCATION_HAS_VERTICAL_ACCURACY_BIT) {
-        out.gnssLocationFlags |= GnssLocationFlags::HAS_VERTICAL_ACCURACY;
-        out.verticalAccuracyMeters = in.verticalAccuracy;
-    }
-    if (in.flags & LOCATION_HAS_SPEED_ACCURACY_BIT) {
-        out.gnssLocationFlags |= GnssLocationFlags::HAS_SPEED_ACCURACY;
-        out.speedAccuracyMetersPerSecond = in.speedAccuracy;
-    }
-    if (in.flags & LOCATION_HAS_BEARING_ACCURACY_BIT) {
-        out.gnssLocationFlags |= GnssLocationFlags::HAS_BEARING_ACCURACY;
-        out.bearingAccuracyDegrees = in.bearingAccuracy;
-    }
-
-    out.timestamp = static_cast<V1_0::GnssUtcTime>(in.timestamp);
-}
-
-void convertGnssLocation(const GnssLocation& in, Location& out)
-{
-    memset(&out, 0, sizeof(out));
-    if (in.gnssLocationFlags & GnssLocationFlags::HAS_LAT_LONG) {
-        out.flags |= LOCATION_HAS_LAT_LONG_BIT;
-        out.latitude = in.latitudeDegrees;
-        out.longitude = in.longitudeDegrees;
-    }
-    if (in.gnssLocationFlags & GnssLocationFlags::HAS_ALTITUDE) {
-        out.flags |= LOCATION_HAS_ALTITUDE_BIT;
-        out.altitude = in.altitudeMeters;
-    }
-    if (in.gnssLocationFlags & GnssLocationFlags::HAS_SPEED) {
-        out.flags |= LOCATION_HAS_SPEED_BIT;
-        out.speed = in.speedMetersPerSec;
-    }
-    if (in.gnssLocationFlags & GnssLocationFlags::HAS_BEARING) {
-        out.flags |= LOCATION_HAS_BEARING_BIT;
-        out.bearing = in.bearingDegrees;
-    }
-    if (in.gnssLocationFlags & GnssLocationFlags::HAS_HORIZONTAL_ACCURACY) {
-        out.flags |= LOCATION_HAS_ACCURACY_BIT;
-        out.accuracy = in.horizontalAccuracyMeters;
-    }
-    if (in.gnssLocationFlags & GnssLocationFlags::HAS_VERTICAL_ACCURACY) {
-        out.flags |= LOCATION_HAS_VERTICAL_ACCURACY_BIT;
-        out.verticalAccuracy = in.verticalAccuracyMeters;
-    }
-    if (in.gnssLocationFlags & GnssLocationFlags::HAS_SPEED_ACCURACY) {
-        out.flags |= LOCATION_HAS_SPEED_ACCURACY_BIT;
-        out.speedAccuracy = in.speedAccuracyMetersPerSecond;
-    }
-    if (in.gnssLocationFlags & GnssLocationFlags::HAS_BEARING_ACCURACY) {
-        out.flags |= LOCATION_HAS_BEARING_ACCURACY_BIT;
-        out.bearingAccuracy = in.bearingAccuracyDegrees;
-    }
-
-    out.timestamp = static_cast<uint64_t>(in.timestamp);
-}
-
-void convertGnssConstellationType(GnssSvType& in, GnssConstellationType& out)
-{
-    switch(in) {
-        case GNSS_SV_TYPE_GPS:
-            out = GnssConstellationType::GPS;
-            break;
-        case GNSS_SV_TYPE_SBAS:
-            out = GnssConstellationType::SBAS;
-            break;
-        case GNSS_SV_TYPE_GLONASS:
-            out = GnssConstellationType::GLONASS;
-            break;
-        case GNSS_SV_TYPE_QZSS:
-            out = GnssConstellationType::QZSS;
-            break;
-        case GNSS_SV_TYPE_BEIDOU:
-            out = GnssConstellationType::BEIDOU;
-            break;
-        case GNSS_SV_TYPE_GALILEO:
-            out = GnssConstellationType::GALILEO;
-            break;
-        case GNSS_SV_TYPE_UNKNOWN:
-        default:
-            out = GnssConstellationType::UNKNOWN;
-            break;
-    }
-}
-
-void convertGnssSvid(GnssSv& in, int16_t& out)
-{
-    switch(in.type){
-        case GNSS_SV_TYPE_GPS:
-            out = in.svId;
-            break;
-        case GNSS_SV_TYPE_SBAS:
-            out = in.svId;
-            break;
-        case GNSS_SV_TYPE_GLONASS:
-            if (!isGloSlotUnknown(in.svId)) { // OSN is known
-                out = in.svId - GLO_SV_PRN_MIN + 1;
-            } else { //OSN is not known, report FCN
-                out = in.gloFrequency + 92;
-            }
-            break;
-        case GNSS_SV_TYPE_QZSS:
-            out = in.svId;
-            break;
-        case GNSS_SV_TYPE_BEIDOU:
-            out = in.svId - BDS_SV_PRN_MIN + 1;
-            break;
-        case GNSS_SV_TYPE_GALILEO:
-            out = in.svId - GAL_SV_PRN_MIN + 1;
-            break;
-        case GNSS_SV_TYPE_NAVIC:
-            out = in.svId - NAVIC_SV_PRN_MIN + 1;
-            break;
-        default:
-            out = in.svId;
-            break;
-    }
-}
-
-void convertGnssSvid(GnssMeasurementsData& in, int16_t& out)
-{
-    switch (in.svType) {
-        case GNSS_SV_TYPE_GPS:
-            out = in.svId;
-            break;
-        case GNSS_SV_TYPE_SBAS:
-            out = in.svId;
-            break;
-        case GNSS_SV_TYPE_GLONASS:
-            if (!isGloSlotUnknown(in.svId)) { // OSN is known
-                out = in.svId - GLO_SV_PRN_MIN + 1;
-            } else { // OSN is not known, report FCN
-                out = in.gloFrequency + 92;
-            }
-            break;
-        case GNSS_SV_TYPE_QZSS:
-            out = in.svId;
-            break;
-        case GNSS_SV_TYPE_BEIDOU:
-            out = in.svId - BDS_SV_PRN_MIN + 1;
-            break;
-        case GNSS_SV_TYPE_GALILEO:
-            out = in.svId - GAL_SV_PRN_MIN + 1;
-            break;
-        case GNSS_SV_TYPE_NAVIC:
-            out = in.svId - NAVIC_SV_PRN_MIN + 1;
-            break;
-        default:
-            out = in.svId;
-            break;
-    }
-}
-
-void convertGnssEphemerisType(GnssEphemerisType& in, GnssDebug::SatelliteEphemerisType& out)
-{
-    switch(in) {
-        case GNSS_EPH_TYPE_EPHEMERIS:
-            out = GnssDebug::SatelliteEphemerisType::EPHEMERIS;
-            break;
-        case GNSS_EPH_TYPE_ALMANAC:
-            out = GnssDebug::SatelliteEphemerisType::ALMANAC_ONLY;
-            break;
-        case GNSS_EPH_TYPE_UNKNOWN:
-        default:
-            out = GnssDebug::SatelliteEphemerisType::NOT_AVAILABLE;
-            break;
-    }
-}
-
-void convertGnssEphemerisSource(GnssEphemerisSource& in, GnssDebug::SatelliteEphemerisSource& out)
-{
-    switch(in) {
-        case GNSS_EPH_SOURCE_DEMODULATED:
-            out = GnssDebug::SatelliteEphemerisSource::DEMODULATED;
-            break;
-        case GNSS_EPH_SOURCE_SUPL_PROVIDED:
-            out = GnssDebug::SatelliteEphemerisSource::SUPL_PROVIDED;
-            break;
-        case GNSS_EPH_SOURCE_OTHER_SERVER_PROVIDED:
-            out = GnssDebug::SatelliteEphemerisSource::OTHER_SERVER_PROVIDED;
-            break;
-        case GNSS_EPH_SOURCE_LOCAL:
-        case GNSS_EPH_SOURCE_UNKNOWN:
-        default:
-            out = GnssDebug::SatelliteEphemerisSource::OTHER;
-            break;
-    }
-}
-
-void convertGnssEphemerisHealth(GnssEphemerisHealth& in, GnssDebug::SatelliteEphemerisHealth& out)
-{
-    switch(in) {
-        case GNSS_EPH_HEALTH_GOOD:
-            out = GnssDebug::SatelliteEphemerisHealth::GOOD;
-            break;
-        case GNSS_EPH_HEALTH_BAD:
-            out = GnssDebug::SatelliteEphemerisHealth::BAD;
-            break;
-        case GNSS_EPH_HEALTH_UNKNOWN:
-        default:
-            out = GnssDebug::SatelliteEphemerisHealth::UNKNOWN;
-            break;
-    }
-}
-
-}  // namespace implementation
-}  // namespace V1_1
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
diff --git a/gps/android/1.1/location_api/LocationUtil.h b/gps/android/1.1/location_api/LocationUtil.h
deleted file mode 100644
index af3c93f..0000000
--- a/gps/android/1.1/location_api/LocationUtil.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- *       copyright notice, this list of conditions and the following
- *       disclaimer in the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of The Linux Foundation, nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#ifndef LOCATION_UTIL_H
-#define LOCATION_UTIL_H
-
-#include <android/hardware/gnss/1.0/types.h>
-#include <LocationAPI.h>
-#include <GnssDebug.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_1 {
-namespace implementation {
-
-void convertGnssLocation(Location& in, V1_0::GnssLocation& out);
-void convertGnssLocation(const V1_0::GnssLocation& in, Location& out);
-void convertGnssConstellationType(GnssSvType& in, V1_0::GnssConstellationType& out);
-void convertGnssSvid(GnssSv& in, int16_t& out);
-void convertGnssSvid(GnssMeasurementsData& in, int16_t& out);
-void convertGnssEphemerisType(GnssEphemerisType& in, GnssDebug::SatelliteEphemerisType& out);
-void convertGnssEphemerisSource(GnssEphemerisSource& in, GnssDebug::SatelliteEphemerisSource& out);
-void convertGnssEphemerisHealth(GnssEphemerisHealth& in, GnssDebug::SatelliteEphemerisHealth& out);
-
-}  // namespace implementation
-}  // namespace V1_1
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
-#endif // LOCATION_UTIL_H
diff --git a/gps/android/1.1/location_api/MeasurementAPIClient.cpp b/gps/android/1.1/location_api/MeasurementAPIClient.cpp
deleted file mode 100644
index 7764851..0000000
--- a/gps/android/1.1/location_api/MeasurementAPIClient.cpp
+++ /dev/null
@@ -1,294 +0,0 @@
-/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- *       copyright notice, this list of conditions and the following
- *       disclaimer in the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of The Linux Foundation, nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#define LOG_NDEBUG 0
-#define LOG_TAG "LocSvc_MeasurementAPIClient"
-
-#include <log_util.h>
-#include <loc_cfg.h>
-
-#include "LocationUtil.h"
-#include "MeasurementAPIClient.h"
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_1 {
-namespace implementation {
-
-using ::android::hardware::gnss::V1_0::IGnssMeasurement;
-using ::android::hardware::gnss::V1_1::IGnssMeasurementCallback;
-
-static void convertGnssData(GnssMeasurementsNotification& in,
-        V1_0::IGnssMeasurementCallback::GnssData& out);
-static void convertGnssData_1_1(GnssMeasurementsNotification& in,
-        IGnssMeasurementCallback::GnssData& out);
-static void convertGnssMeasurement(GnssMeasurementsData& in,
-        V1_0::IGnssMeasurementCallback::GnssMeasurement& out);
-static void convertGnssClock(GnssMeasurementsClock& in, IGnssMeasurementCallback::GnssClock& out);
-
-MeasurementAPIClient::MeasurementAPIClient() :
-    mGnssMeasurementCbIface(nullptr),
-    mGnssMeasurementCbIface_1_1(nullptr),
-    mTracking(false)
-{
-    LOC_LOGD("%s]: ()", __FUNCTION__);
-}
-
-MeasurementAPIClient::~MeasurementAPIClient()
-{
-    LOC_LOGD("%s]: ()", __FUNCTION__);
-}
-
-Return<IGnssMeasurement::GnssMeasurementStatus>
-MeasurementAPIClient::startTracking(
-        GnssPowerMode powerMode, uint32_t timeBetweenMeasurement)
-{
-    LocationCallbacks locationCallbacks;
-    memset(&locationCallbacks, 0, sizeof(LocationCallbacks));
-    locationCallbacks.size = sizeof(LocationCallbacks);
-
-    if (mGnssMeasurementCbIface_1_1 != nullptr || mGnssMeasurementCbIface != nullptr) {
-        locationCallbacks.gnssMeasurementsCb =
-            [this](GnssMeasurementsNotification gnssMeasurementsNotification) {
-                onGnssMeasurementsCb(gnssMeasurementsNotification);
-            };
-    }
-
-    locAPISetCallbacks(locationCallbacks);
-
-    TrackingOptions options = {};
-    memset(&options, 0, sizeof(TrackingOptions));
-    options.size = sizeof(TrackingOptions);
-    options.minInterval = 1000;
-    options.mode = GNSS_SUPL_MODE_STANDALONE;
-    if (GNSS_POWER_MODE_INVALID != powerMode) {
-        options.powerMode = powerMode;
-        options.tbm = timeBetweenMeasurement;
-    }
-
-    mTracking = true;
-    LOC_LOGd("(powermode: %d) (tbm %d)", (int)powerMode, timeBetweenMeasurement);
-    locAPIStartTracking(options);
-    return IGnssMeasurement::GnssMeasurementStatus::SUCCESS;
-}
-
-// for GpsMeasurementInterface
-void MeasurementAPIClient::measurementClose() {
-    LOC_LOGD("%s]: ()", __FUNCTION__);
-    mTracking = false;
-    locAPIStopTracking();
-}
-
-// callbacks
-void MeasurementAPIClient::onGnssMeasurementsCb(
-        GnssMeasurementsNotification gnssMeasurementsNotification)
-{
-    LOC_LOGD("%s]: (count: %zu active: %d)",
-            __FUNCTION__, gnssMeasurementsNotification.count, mTracking);
-    if (mTracking) {
-        mMutex.lock();
-        sp<V1_0::IGnssMeasurementCallback> gnssMeasurementCbIface = nullptr;
-        sp<IGnssMeasurementCallback> gnssMeasurementCbIface_1_1 = nullptr;
-        if (mGnssMeasurementCbIface_1_1 != nullptr) {
-            gnssMeasurementCbIface_1_1 = mGnssMeasurementCbIface_1_1;
-        } else if (mGnssMeasurementCbIface != nullptr) {
-            gnssMeasurementCbIface = mGnssMeasurementCbIface;
-        }
-        mMutex.unlock();
-
-        if (gnssMeasurementCbIface_1_1 != nullptr) {
-            IGnssMeasurementCallback::GnssData gnssData;
-            convertGnssData_1_1(gnssMeasurementsNotification, gnssData);
-            auto r = gnssMeasurementCbIface_1_1->gnssMeasurementCb(gnssData);
-            if (!r.isOk()) {
-                LOC_LOGE("%s] Error from gnssMeasurementCb description=%s",
-                    __func__, r.description().c_str());
-            }
-        } else if (gnssMeasurementCbIface != nullptr) {
-            V1_0::IGnssMeasurementCallback::GnssData gnssData;
-            convertGnssData(gnssMeasurementsNotification, gnssData);
-            auto r = gnssMeasurementCbIface->GnssMeasurementCb(gnssData);
-            if (!r.isOk()) {
-                LOC_LOGE("%s] Error from GnssMeasurementCb description=%s",
-                    __func__, r.description().c_str());
-            }
-        }
-    }
-}
-
-static void convertGnssMeasurement(GnssMeasurementsData& in,
-        V1_0::IGnssMeasurementCallback::GnssMeasurement& out)
-{
-    memset(&out, 0, sizeof(IGnssMeasurementCallback::GnssMeasurement));
-    if (in.flags & GNSS_MEASUREMENTS_DATA_SIGNAL_TO_NOISE_RATIO_BIT)
-        out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_SNR;
-    if (in.flags & GNSS_MEASUREMENTS_DATA_CARRIER_FREQUENCY_BIT)
-        out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_CARRIER_FREQUENCY;
-    if (in.flags & GNSS_MEASUREMENTS_DATA_CARRIER_CYCLES_BIT)
-        out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_CARRIER_CYCLES;
-    if (in.flags & GNSS_MEASUREMENTS_DATA_CARRIER_PHASE_BIT)
-        out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_CARRIER_PHASE;
-    if (in.flags & GNSS_MEASUREMENTS_DATA_CARRIER_PHASE_UNCERTAINTY_BIT)
-        out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_CARRIER_PHASE_UNCERTAINTY;
-    if (in.flags & GNSS_MEASUREMENTS_DATA_AUTOMATIC_GAIN_CONTROL_BIT)
-        out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_AUTOMATIC_GAIN_CONTROL;
-    convertGnssSvid(in, out.svid);
-    convertGnssConstellationType(in.svType, out.constellation);
-    out.timeOffsetNs = in.timeOffsetNs;
-    if (in.stateMask & GNSS_MEASUREMENTS_STATE_CODE_LOCK_BIT)
-        out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_CODE_LOCK;
-    if (in.stateMask & GNSS_MEASUREMENTS_STATE_BIT_SYNC_BIT)
-        out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_BIT_SYNC;
-    if (in.stateMask & GNSS_MEASUREMENTS_STATE_SUBFRAME_SYNC_BIT)
-        out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_SUBFRAME_SYNC;
-    if (in.stateMask & GNSS_MEASUREMENTS_STATE_TOW_DECODED_BIT)
-        out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_TOW_DECODED;
-    if (in.stateMask & GNSS_MEASUREMENTS_STATE_MSEC_AMBIGUOUS_BIT)
-        out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_MSEC_AMBIGUOUS;
-    if (in.stateMask & GNSS_MEASUREMENTS_STATE_SYMBOL_SYNC_BIT)
-        out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_SYMBOL_SYNC;
-    if (in.stateMask & GNSS_MEASUREMENTS_STATE_GLO_STRING_SYNC_BIT)
-        out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GLO_STRING_SYNC;
-    if (in.stateMask & GNSS_MEASUREMENTS_STATE_GLO_TOD_DECODED_BIT)
-        out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GLO_TOD_DECODED;
-    if (in.stateMask & GNSS_MEASUREMENTS_STATE_BDS_D2_BIT_SYNC_BIT)
-        out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_BDS_D2_BIT_SYNC;
-    if (in.stateMask & GNSS_MEASUREMENTS_STATE_BDS_D2_SUBFRAME_SYNC_BIT)
-        out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_BDS_D2_SUBFRAME_SYNC;
-    if (in.stateMask & GNSS_MEASUREMENTS_STATE_GAL_E1BC_CODE_LOCK_BIT)
-        out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GAL_E1BC_CODE_LOCK;
-    if (in.stateMask & GNSS_MEASUREMENTS_STATE_GAL_E1C_2ND_CODE_LOCK_BIT)
-        out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GAL_E1C_2ND_CODE_LOCK;
-    if (in.stateMask & GNSS_MEASUREMENTS_STATE_GAL_E1B_PAGE_SYNC_BIT)
-        out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GAL_E1B_PAGE_SYNC;
-    if (in.stateMask &  GNSS_MEASUREMENTS_STATE_SBAS_SYNC_BIT)
-        out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_SBAS_SYNC;
-    out.receivedSvTimeInNs = in.receivedSvTimeNs;
-    out.receivedSvTimeUncertaintyInNs = in.receivedSvTimeUncertaintyNs;
-    out.cN0DbHz = in.carrierToNoiseDbHz;
-    out.pseudorangeRateMps = in.pseudorangeRateMps;
-    out.pseudorangeRateUncertaintyMps = in.pseudorangeRateUncertaintyMps;
-    if (in.adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_VALID_BIT)
-        out.accumulatedDeltaRangeState |=
-            IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_VALID;
-    if (in.adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_RESET_BIT)
-        out.accumulatedDeltaRangeState |=
-            IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_RESET;
-    if (in.adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_CYCLE_SLIP_BIT)
-        out.accumulatedDeltaRangeState |=
-            IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_CYCLE_SLIP;
-    out.accumulatedDeltaRangeM = in.adrMeters;
-    out.accumulatedDeltaRangeUncertaintyM = in.adrUncertaintyMeters;
-    out.carrierFrequencyHz = in.carrierFrequencyHz;
-    out.carrierCycles = in.carrierCycles;
-    out.carrierPhase = in.carrierPhase;
-    out.carrierPhaseUncertainty = in.carrierPhaseUncertainty;
-    uint8_t indicator =
-        static_cast<uint8_t>(IGnssMeasurementCallback::GnssMultipathIndicator::INDICATOR_UNKNOWN);
-    if (in.multipathIndicator & GNSS_MEASUREMENTS_MULTIPATH_INDICATOR_PRESENT)
-        indicator |= IGnssMeasurementCallback::GnssMultipathIndicator::INDICATOR_PRESENT;
-    if (in.multipathIndicator & GNSS_MEASUREMENTS_MULTIPATH_INDICATOR_NOT_PRESENT)
-        indicator |= IGnssMeasurementCallback::GnssMultipathIndicator::INDICATIOR_NOT_PRESENT;
-    out.multipathIndicator =
-        static_cast<IGnssMeasurementCallback::GnssMultipathIndicator>(indicator);
-    out.snrDb = in.signalToNoiseRatioDb;
-    out.agcLevelDb = in.agcLevelDb;
-}
-
-static void convertGnssClock(GnssMeasurementsClock& in, IGnssMeasurementCallback::GnssClock& out)
-{
-    memset(&out, 0, sizeof(IGnssMeasurementCallback::GnssClock));
-    if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_LEAP_SECOND_BIT)
-        out.gnssClockFlags |= IGnssMeasurementCallback::GnssClockFlags::HAS_LEAP_SECOND;
-    if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_TIME_UNCERTAINTY_BIT)
-        out.gnssClockFlags |= IGnssMeasurementCallback::GnssClockFlags::HAS_TIME_UNCERTAINTY;
-    if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_FULL_BIAS_BIT)
-        out.gnssClockFlags |= IGnssMeasurementCallback::GnssClockFlags::HAS_FULL_BIAS;
-    if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_BIAS_BIT)
-        out.gnssClockFlags |= IGnssMeasurementCallback::GnssClockFlags::HAS_BIAS;
-    if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_BIAS_UNCERTAINTY_BIT)
-        out.gnssClockFlags |= IGnssMeasurementCallback::GnssClockFlags::HAS_BIAS_UNCERTAINTY;
-    if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_DRIFT_BIT)
-        out.gnssClockFlags |= IGnssMeasurementCallback::GnssClockFlags::HAS_DRIFT;
-    if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_DRIFT_UNCERTAINTY_BIT)
-        out.gnssClockFlags |= IGnssMeasurementCallback::GnssClockFlags::HAS_DRIFT_UNCERTAINTY;
-    out.leapSecond = in.leapSecond;
-    out.timeNs = in.timeNs;
-    out.timeUncertaintyNs = in.timeUncertaintyNs;
-    out.fullBiasNs = in.fullBiasNs;
-    out.biasNs = in.biasNs;
-    out.biasUncertaintyNs = in.biasUncertaintyNs;
-    out.driftNsps = in.driftNsps;
-    out.driftUncertaintyNsps = in.driftUncertaintyNsps;
-    out.hwClockDiscontinuityCount = in.hwClockDiscontinuityCount;
-}
-
-static void convertGnssData(GnssMeasurementsNotification& in,
-        V1_0::IGnssMeasurementCallback::GnssData& out)
-{
-    out.measurementCount = in.count;
-    if (out.measurementCount > static_cast<uint32_t>(V1_0::GnssMax::SVS_COUNT)) {
-        LOC_LOGW("%s]: Too many measurement %u. Clamps to %d.",
-                __FUNCTION__,  out.measurementCount, V1_0::GnssMax::SVS_COUNT);
-        out.measurementCount = static_cast<uint32_t>(V1_0::GnssMax::SVS_COUNT);
-    }
-    for (size_t i = 0; i < out.measurementCount; i++) {
-        convertGnssMeasurement(in.measurements[i], out.measurements[i]);
-    }
-    convertGnssClock(in.clock, out.clock);
-}
-
-static void convertGnssData_1_1(GnssMeasurementsNotification& in,
-        IGnssMeasurementCallback::GnssData& out)
-{
-    out.measurements.resize(in.count);
-    for (size_t i = 0; i < in.count; i++) {
-        convertGnssMeasurement(in.measurements[i], out.measurements[i].v1_0);
-        if (in.measurements[i].adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_VALID_BIT)
-            out.measurements[i].accumulatedDeltaRangeState |=
-            IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_VALID;
-        if (in.measurements[i].adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_RESET_BIT)
-            out.measurements[i].accumulatedDeltaRangeState |=
-            IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_RESET;
-        if (in.measurements[i].adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_CYCLE_SLIP_BIT)
-            out.measurements[i].accumulatedDeltaRangeState |=
-            IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_CYCLE_SLIP;
-        if (in.measurements[i].adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_HALF_CYCLE_RESOLVED_BIT)
-            out.measurements[i].accumulatedDeltaRangeState |=
-            IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_HALF_CYCLE_RESOLVED;
-    }
-    convertGnssClock(in.clock, out.clock);
-}
-
-}  // namespace implementation
-}  // namespace V1_1
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
diff --git a/gps/android/1.1/location_api/MeasurementAPIClient.h b/gps/android/1.1/location_api/MeasurementAPIClient.h
deleted file mode 100644
index e768e77..0000000
--- a/gps/android/1.1/location_api/MeasurementAPIClient.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- *       copyright notice, this list of conditions and the following
- *       disclaimer in the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of The Linux Foundation, nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#ifndef MEASUREMENT_API_CLINET_H
-#define MEASUREMENT_API_CLINET_H
-
-#include <mutex>
-#include <android/hardware/gnss/1.1/IGnssMeasurement.h>
-#include <android/hardware/gnss/1.1/IGnssMeasurementCallback.h>
-#include <LocationAPIClientBase.h>
-#include <hidl/Status.h>
-#include <gps_extended_c.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V1_1 {
-namespace implementation {
-
-using ::android::sp;
-
-class MeasurementAPIClient : public LocationAPIClientBase
-{
-public:
-    MeasurementAPIClient();
-    MeasurementAPIClient(const MeasurementAPIClient&) = delete;
-    MeasurementAPIClient& operator=(const MeasurementAPIClient&) = delete;
-
-    // for GpsMeasurementInterface
-    template <typename T>
-    Return<IGnssMeasurement::GnssMeasurementStatus> measurementSetCallback(
-            const sp<T>& callback, GnssPowerMode powerMode = GNSS_POWER_MODE_INVALID) {
-        mMutex.lock();
-        setCallbackLocked(callback);
-        mMutex.unlock();
-
-        return startTracking(powerMode);
-    }
-    void measurementClose();
-    Return<IGnssMeasurement::GnssMeasurementStatus> startTracking(
-            GnssPowerMode powerMode = GNSS_POWER_MODE_INVALID,
-            uint32_t timeBetweenMeasurement = GPS_DEFAULT_FIX_INTERVAL_MS);
-
-    // callbacks we are interested in
-    void onGnssMeasurementsCb(GnssMeasurementsNotification gnssMeasurementsNotification) final;
-
-private:
-    inline void setCallbackLocked(const sp<V1_0::IGnssMeasurementCallback>& callback) {
-        mGnssMeasurementCbIface = callback;
-    }
-    inline void setCallbackLocked(const sp<V1_1::IGnssMeasurementCallback>& callback) {
-        mGnssMeasurementCbIface_1_1 = callback;
-    }
-    virtual ~MeasurementAPIClient();
-
-    std::mutex mMutex;
-    sp<V1_0::IGnssMeasurementCallback> mGnssMeasurementCbIface;
-    sp<IGnssMeasurementCallback> mGnssMeasurementCbIface_1_1;
-
-    bool mTracking;
-};
-
-}  // namespace implementation
-}  // namespace V1_1
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
-#endif // MEASUREMENT_API_CLINET_H
diff --git a/gps/android/1.1/service.cpp b/gps/android/1.1/service.cpp
deleted file mode 100644
index 0cb91f7..0000000
--- a/gps/android/1.1/service.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-#define LOG_TAG "android.hardware.gnss@1.1-service-qti"
-
-#include <android/hardware/gnss/1.1/IGnss.h>
-#include <hidl/LegacySupport.h>
-#include "loc_cfg.h"
-#include "loc_misc_utils.h"
-
-extern "C" {
-#include "vndfwk-detect.h"
-}
-
-#ifdef ARCH_ARM_32
-#define DEFAULT_HW_BINDER_MEM_SIZE 65536
-#endif
-
-using android::hardware::gnss::V1_1::IGnss;
-
-using android::hardware::configureRpcThreadpool;
-using android::hardware::registerPassthroughServiceImplementation;
-using android::hardware::joinRpcThreadpool;
-
-using android::status_t;
-using android::OK;
-
-typedef int vendorEnhancedServiceMain(int /* argc */, char* /* argv */ []);
-
-int main() {
-
-    ALOGI("%s", __FUNCTION__);
-
-    int vendorInfo = getVendorEnhancedInfo();
-    bool vendorEnhanced = ( 1 == vendorInfo || 3 == vendorInfo );
-    setVendorEnhanced(vendorEnhanced);
-
-#ifdef ARCH_ARM_32
-    android::hardware::ProcessState::initWithMmapSize((size_t)(DEFAULT_HW_BINDER_MEM_SIZE));
-#endif
-    configureRpcThreadpool(1, true);
-    status_t status;
-
-    status = registerPassthroughServiceImplementation<IGnss>();
-    if (status == OK) {
-        if (vendorEnhanced) {
-    #ifdef LOC_HIDL_VERSION
-            #define VENDOR_ENHANCED_LIB "vendor.qti.gnss@" LOC_HIDL_VERSION "-service.so"
-
-            void* libHandle = NULL;
-            vendorEnhancedServiceMain* vendorEnhancedMainMethod = (vendorEnhancedServiceMain*)
-                    dlGetSymFromLib(libHandle, VENDOR_ENHANCED_LIB, "main");
-            if (NULL != vendorEnhancedMainMethod) {
-                (*vendorEnhancedMainMethod)(0, NULL);
-            }
-    #else
-            ALOGE("LOC_HIDL_VERSION not defined.");
-    #endif
-        }
-
-        joinRpcThreadpool();
-
-    } else {
-        ALOGE("Error while registering IGnss 1.1 service: %d", status);
-    }
-
-    return 0;
-}
diff --git a/gps/android/2.0/AGnss.cpp b/gps/android/2.0/AGnss.cpp
deleted file mode 100644
index df2fe20..0000000
--- a/gps/android/2.0/AGnss.cpp
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-#define LOG_TAG "LocSvc_AGnssInterface"
-
-#include <log_util.h>
-#include "Gnss.h"
-#include "AGnss.h"
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V2_0 {
-namespace implementation {
-
-static AGnss* spAGnss = nullptr;
-
-AGnss::AGnss(Gnss* gnss) : mGnss(gnss) {
-    spAGnss = this;
-}
-
-AGnss::~AGnss() {
-    spAGnss = nullptr;
-}
-
-void AGnss::agnssStatusIpV4Cb(AGnssExtStatusIpV4 status) {
-    if (nullptr != spAGnss) {
-        spAGnss->statusCb(status.type, status.status);
-    }
-}
-
-void AGnss::statusCb(AGpsExtType type, LocAGpsStatusValue status) {
-
-    V2_0::IAGnssCallback::AGnssType  aType;
-    IAGnssCallback::AGnssStatusValue aStatus;
-
-    switch (type) {
-    case LOC_AGPS_TYPE_SUPL:
-        aType = IAGnssCallback::AGnssType::SUPL;
-        break;
-    case LOC_AGPS_TYPE_SUPL_ES:
-        aType = IAGnssCallback::AGnssType::SUPL_EIMS;
-        break;
-    default:
-        LOC_LOGE("invalid type: %d", type);
-        return;
-    }
-
-    switch (status) {
-    case LOC_GPS_REQUEST_AGPS_DATA_CONN:
-        aStatus = IAGnssCallback::AGnssStatusValue::REQUEST_AGNSS_DATA_CONN;
-        break;
-    case LOC_GPS_RELEASE_AGPS_DATA_CONN:
-        aStatus = IAGnssCallback::AGnssStatusValue::RELEASE_AGNSS_DATA_CONN;
-        break;
-    case LOC_GPS_AGPS_DATA_CONNECTED:
-        aStatus = IAGnssCallback::AGnssStatusValue::AGNSS_DATA_CONNECTED;
-        break;
-    case LOC_GPS_AGPS_DATA_CONN_DONE:
-        aStatus = IAGnssCallback::AGnssStatusValue::AGNSS_DATA_CONN_DONE;
-        break;
-    case LOC_GPS_AGPS_DATA_CONN_FAILED:
-        aStatus = IAGnssCallback::AGnssStatusValue::AGNSS_DATA_CONN_FAILED;
-        break;
-    default:
-        LOC_LOGE("invalid status: %d", status);
-        return;
-    }
-
-    mMutex.lock();
-    auto aGnssCbIface = mAGnssCbIface;
-    mMutex.unlock();
-    if (aGnssCbIface != nullptr) {
-        auto r = aGnssCbIface->agnssStatusCb(aType, aStatus);
-        if (!r.isOk()) {
-            LOC_LOGw("Error invoking AGNSS status cb %s", r.description().c_str());
-        }
-    }
-    else {
-        LOC_LOGw("setCallback has not been called yet");
-    }
-}
-
-Return<void> AGnss::setCallback(const sp<V2_0::IAGnssCallback>& callback) {
-
-    if(mGnss == nullptr || mGnss->getGnssInterface() == nullptr){
-        LOC_LOGE("Null GNSS interface");
-        return Void();
-    }
-
-    // Save the interface
-    mMutex.lock();
-    mAGnssCbIface = callback;
-    mMutex.unlock();
-
-    AgpsCbInfo cbInfo = {};
-    cbInfo.statusV4Cb = (void*)agnssStatusIpV4Cb;
-    cbInfo.atlType = AGPS_ATL_TYPE_SUPL | AGPS_ATL_TYPE_SUPL_ES;
-
-    mGnss->getGnssInterface()->agpsInit(cbInfo);
-    return Void();
-}
-
-Return<bool> AGnss::dataConnClosed() {
-
-    if(mGnss == nullptr || mGnss->getGnssInterface() == nullptr){
-        LOC_LOGE("Null GNSS interface");
-        return false;
-    }
-
-    mGnss->getGnssInterface()->agpsDataConnClosed(LOC_AGPS_TYPE_SUPL);
-    return true;
-}
-
-Return<bool> AGnss::dataConnFailed() {
-
-    if(mGnss == nullptr || mGnss->getGnssInterface() == nullptr){
-        LOC_LOGE("Null GNSS interface");
-        return false;
-    }
-
-    mGnss->getGnssInterface()->agpsDataConnFailed(LOC_AGPS_TYPE_SUPL);
-    return true;
-}
-
-Return<bool> AGnss::dataConnOpen(uint64_t /*networkHandle*/, const hidl_string& apn,
-        V2_0::IAGnss::ApnIpType apnIpType) {
-
-    if(mGnss == nullptr || mGnss->getGnssInterface() == nullptr){
-        LOC_LOGE("Null GNSS interface");
-        return false;
-    }
-
-    /* Validate */
-    if(apn.empty()){
-        LOC_LOGE("Invalid APN");
-        return false;
-    }
-
-    LOC_LOGD("dataConnOpen APN name = [%s]", apn.c_str());
-
-    AGpsBearerType bearerType;
-    switch (apnIpType) {
-    case IAGnss::ApnIpType::IPV4:
-        bearerType = AGPS_APN_BEARER_IPV4;
-        break;
-    case IAGnss::ApnIpType::IPV6:
-        bearerType = AGPS_APN_BEARER_IPV6;
-        break;
-    case IAGnss::ApnIpType::IPV4V6:
-        bearerType = AGPS_APN_BEARER_IPV4V6;
-        break;
-    default:
-        bearerType = AGPS_APN_BEARER_IPV4;
-        break;
-    }
-
-    mGnss->getGnssInterface()->agpsDataConnOpen(
-        LOC_AGPS_TYPE_SUPL, apn.c_str(), apn.size(), (int)bearerType);
-    return true;
-}
-
-Return<bool> AGnss::setServer(V2_0::IAGnssCallback::AGnssType type,
-                              const hidl_string& hostname,
-                              int32_t port) {
-    if (mGnss == nullptr) {
-        LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__);
-        return false;
-    }
-
-    GnssConfig config;
-    memset(&config, 0, sizeof(GnssConfig));
-    config.size = sizeof(GnssConfig);
-    config.flags = GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT;
-    config.assistanceServer.size = sizeof(GnssConfigSetAssistanceServer);
-    if (type == IAGnssCallback::AGnssType::SUPL) {
-        config.assistanceServer.type = GNSS_ASSISTANCE_TYPE_SUPL;
-    } else if (type == IAGnssCallback::AGnssType::C2K) {
-        config.assistanceServer.type = GNSS_ASSISTANCE_TYPE_C2K;
-    } else if (type == IAGnssCallback::AGnssType::SUPL_EIMS) {
-        config.assistanceServer.type = GNSS_ASSISTANCE_TYPE_SUPL_EIMS;
-    } else if (type == IAGnssCallback::AGnssType::SUPL_IMS) {
-        config.assistanceServer.type = GNSS_ASSISTANCE_TYPE_SUPL_IMS;
-    } else {
-        LOC_LOGE("%s]: invalid AGnssType: %d", __FUNCTION__, static_cast<uint8_t>(type));
-        return false;
-    }
-    config.assistanceServer.hostName = strdup(hostname.c_str());
-    config.assistanceServer.port = port;
-    return mGnss->updateConfiguration(config);
-}
-
-}  // namespace implementation
-}  // namespace V2_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
diff --git a/gps/android/2.0/AGnss.h b/gps/android/2.0/AGnss.h
deleted file mode 100644
index ab653aa..0000000
--- a/gps/android/2.0/AGnss.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-#ifndef ANDROID_HARDWARE_GNSS_V2_0_AGNSS_H
-#define ANDROID_HARDWARE_GNSS_V2_0_AGNSS_H
-
-#include <mutex>
-#include <android/hardware/gnss/2.0/IAGnss.h>
-#include <hidl/Status.h>
-#include <gps_extended_c.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V2_0 {
-namespace implementation {
-
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::sp;
-
-struct Gnss;
-struct AGnss : public V2_0::IAGnss {
-
-    AGnss(Gnss* gnss);
-    ~AGnss();
-    /*
-     * Methods from ::android::hardware::gnss::V2_0::IAGnss interface follow.
-     * These declarations were generated from IAGnss.hal.
-     */
-    Return<void> setCallback(const sp<V2_0::IAGnssCallback>& callback) override;
-
-    Return<bool> dataConnClosed() override;
-
-    Return<bool> dataConnFailed() override;
-
-    Return<bool> dataConnOpen(uint64_t networkHandle, const hidl_string& apn,
-            V2_0::IAGnss::ApnIpType apnIpType) override;
-
-    Return<bool> setServer(V2_0::IAGnssCallback::AGnssType type,
-                         const hidl_string& hostname, int32_t port) override;
-
-    void statusCb(AGpsExtType type, LocAGpsStatusValue status);
-
-    /* Data call setup callback passed down to GNSS HAL implementation */
-    static void agnssStatusIpV4Cb(AGnssExtStatusIpV4 status);
-
- private:
-    Gnss* mGnss = nullptr;
-    std::mutex mMutex;
-    sp<IAGnssCallback> mAGnssCbIface = nullptr;
-};
-
-}  // namespace implementation
-}  // namespace V2_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
-
-#endif  // ANDROID_HARDWARE_GNSS_V2_0_AGNSS_H
diff --git a/gps/android/2.0/AGnssRil.cpp b/gps/android/2.0/AGnssRil.cpp
deleted file mode 100644
index 84ea252..0000000
--- a/gps/android/2.0/AGnssRil.cpp
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-#define LOG_TAG "LocSvc__AGnssRilInterface"
-
-#include <log_util.h>
-#include <dlfcn.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <sstream>
-#include <string>
-#include "Gnss.h"
-#include "AGnssRil.h"
-#include <DataItemConcreteTypes.h>
-
-typedef void* (getLocationInterface)();
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V2_0 {
-namespace implementation {
-
-
-AGnssRil::AGnssRil(Gnss* gnss) : mGnss(gnss) {
-    ENTRY_LOG_CALLFLOW();
-}
-
-AGnssRil::~AGnssRil() {
-    ENTRY_LOG_CALLFLOW();
-}
-
-Return<bool> AGnssRil::updateNetworkState(bool connected, NetworkType type, bool /*roaming*/) {
-    ENTRY_LOG_CALLFLOW();
-    // Extra NetworkTypes not available in IAgnssRil enums
-    const int NetworkType_BLUETOOTH = 7;
-    const int NetworkType_ETHERNET = 9;
-    const int NetworkType_PROXY = 16;
-    std::string apn("");
-
-    // for XTRA
-    if (nullptr != mGnss && ( nullptr != mGnss->getGnssInterface() )) {
-        int8_t typeout = loc_core::TYPE_UNKNOWN;
-        switch(type)
-        {
-            case IAGnssRil::NetworkType::MOBILE:
-                typeout = loc_core::TYPE_MOBILE;
-                break;
-            case IAGnssRil::NetworkType::WIFI:
-                typeout = loc_core::TYPE_WIFI;
-                break;
-            case IAGnssRil::NetworkType::MMS:
-                typeout = loc_core::TYPE_MMS;
-                break;
-            case IAGnssRil::NetworkType::SUPL:
-                typeout = loc_core::TYPE_SUPL;
-                break;
-            case IAGnssRil::NetworkType::DUN:
-                typeout = loc_core::TYPE_DUN;
-                break;
-            case IAGnssRil::NetworkType::HIPRI:
-                typeout = loc_core::TYPE_HIPRI;
-                break;
-            case IAGnssRil::NetworkType::WIMAX:
-                typeout = loc_core::TYPE_WIMAX;
-                break;
-            default:
-                {
-                    int networkType = (int) type;
-                    // Handling network types not available in IAgnssRil
-                    switch(networkType)
-                    {
-                        case NetworkType_BLUETOOTH:
-                            typeout = loc_core::TYPE_BLUETOOTH;
-                            break;
-                        case NetworkType_ETHERNET:
-                            typeout = loc_core::TYPE_ETHERNET;
-                            break;
-                        case NetworkType_PROXY:
-                            typeout = loc_core::TYPE_PROXY;
-                            break;
-                        default:
-                            typeout = loc_core::TYPE_UNKNOWN;
-                    }
-                }
-                break;
-        }
-        mGnss->getGnssInterface()->updateConnectionStatus(connected, typeout, false, 0, apn);
-    }
-    return true;
-}
-Return<bool> AGnssRil::updateNetworkState_2_0(const V2_0::IAGnssRil::NetworkAttributes& attributes) {
-    ENTRY_LOG_CALLFLOW();
-    std::string apn = attributes.apn;
-    if (nullptr != mGnss && (nullptr != mGnss->getGnssInterface())) {
-        int8_t typeout = loc_core::TYPE_UNKNOWN;
-        bool roaming = false;
-        if (attributes.capabilities & IAGnssRil::NetworkCapability::NOT_METERED) {
-            typeout = loc_core::TYPE_WIFI;
-        } else {
-            typeout = loc_core::TYPE_MOBILE;
-        }
-        if (attributes.capabilities & IAGnssRil::NetworkCapability::NOT_ROAMING) {
-            roaming = false;
-        }
-        LOC_LOGd("apn string received is: %s", apn.c_str());
-        mGnss->getGnssInterface()->updateConnectionStatus(attributes.isConnected,
-                typeout, roaming, (NetworkHandle) attributes.networkHandle, apn);
-    }
-    return true;
-}
-
-}  // namespace implementation
-}  // namespace V2_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
diff --git a/gps/android/2.0/AGnssRil.h b/gps/android/2.0/AGnssRil.h
deleted file mode 100644
index a04d8aa..0000000
--- a/gps/android/2.0/AGnssRil.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-#ifndef ANDROID_HARDWARE_GNSS_V2_0_AGNSSRIL_H_
-#define ANDROID_HARDWARE_GNSS_V2_0_AGNSSRIL_H_
-
-#include <android/hardware/gnss/2.0/IAGnssRil.h>
-#include <hidl/Status.h>
-#include <location_interface.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V2_0 {
-namespace implementation {
-
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::sp;
-
-struct Gnss;
-/*
- * Extended interface for AGNSS RIL support. An Assisted GNSS Radio Interface Layer interface
- * allows the GNSS chipset to request radio interface layer information from Android platform.
- * Examples of such information are reference location, unique subscriber ID, phone number string
- * and network availability changes. Also contains wrapper methods to allow methods from
- * IAGnssiRilCallback interface to be passed into the conventional implementation of the GNSS HAL.
- */
-struct AGnssRil : public V2_0::IAGnssRil {
-    AGnssRil(Gnss* gnss);
-    ~AGnssRil();
-
-    /*
-     * Methods from ::android::hardware::gnss::V1_0::IAGnssRil follow.
-     * These declarations were generated from IAGnssRil.hal.
-     */
-    Return<void> setCallback(const sp<V1_0::IAGnssRilCallback>& /*callback*/) override {
-        return Void();
-    }
-    Return<void> setRefLocation(const V1_0::IAGnssRil::AGnssRefLocation& /*agnssReflocation*/) override {
-        return Void();
-    }
-    Return<bool> setSetId(V1_0::IAGnssRil::SetIDType /*type*/, const hidl_string& /*setid*/) override {
-        return false;
-    }
-    Return<bool> updateNetworkAvailability(bool /*available*/,
-                                    const hidl_string& /*apn*/) override {
-        return false;
-    }
-    Return<bool> updateNetworkState(bool connected, V1_0::IAGnssRil::NetworkType type, bool roaming) override;
-
-    // Methods from ::android::hardware::gnss::V2_0::IAGnssRil follow
-    Return<bool> updateNetworkState_2_0(const V2_0::IAGnssRil::NetworkAttributes& attributes) override;
-
- private:
-    Gnss* mGnss = nullptr;
-};
-
-}  // namespace implementation
-}  // namespace V2_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
-
-#endif  // ANDROID_HARDWARE_GNSS_V2_0_AGNSSRIL_H_
diff --git a/gps/android/2.0/Android.mk b/gps/android/2.0/Android.mk
deleted file mode 100644
index 1de5590..0000000
--- a/gps/android/2.0/Android.mk
+++ /dev/null
@@ -1,108 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.gnss@2.0-impl-qti
-
-LOCAL_VENDOR_MODULE := true
-LOCAL_MODULE_RELATIVE_PATH := hw
-LOCAL_SRC_FILES := \
-    AGnss.cpp \
-    Gnss.cpp \
-    AGnssRil.cpp \
-    GnssMeasurement.cpp \
-    GnssConfiguration.cpp \
-    GnssBatching.cpp \
-    GnssGeofencing.cpp \
-    GnssNi.cpp \
-    GnssDebug.cpp \
-    MeasurementCorrections.cpp \
-    GnssVisibilityControl.cpp
-
-LOCAL_SRC_FILES += \
-    location_api/GnssAPIClient.cpp \
-    location_api/MeasurementAPIClient.cpp \
-    location_api/GeofenceAPIClient.cpp \
-    location_api/BatchingAPIClient.cpp \
-    location_api/LocationUtil.cpp \
-
-ifeq ($(GNSS_HIDL_LEGACY_MEASURMENTS),true)
-LOCAL_CFLAGS += \
-     -DGNSS_HIDL_LEGACY_MEASURMENTS
-endif
-
-LOCAL_C_INCLUDES:= \
-    $(LOCAL_PATH)/location_api
-
-LOCAL_HEADER_LIBRARIES := \
-    libgps.utils_headers \
-    libloc_core_headers \
-    libloc_pla_headers \
-    liblocation_api_headers \
-    liblocbatterylistener_headers
-
-LOCAL_SHARED_LIBRARIES := \
-    liblog \
-    libhidlbase \
-    libcutils \
-    libutils \
-    android.hardware.gnss@1.0 \
-    android.hardware.gnss@1.1 \
-    android.hardware.gnss@2.0 \
-    android.hardware.gnss.measurement_corrections@1.0 \
-    android.hardware.gnss.visibility_control@1.0 \
-    android.hardware.health@1.0 \
-    android.hardware.health@2.0 \
-    android.hardware.health@2.1 \
-    android.hardware.power@1.2 \
-    libbase
-
-LOCAL_SHARED_LIBRARIES += \
-    libloc_core \
-    libgps.utils \
-    libdl \
-    liblocation_api \
-
-LOCAL_CFLAGS += $(GNSS_CFLAGS)
-LOCAL_STATIC_LIBRARIES := liblocbatterylistener
-LOCAL_STATIC_LIBRARIES += libhealthhalutils
-include $(BUILD_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := android.hardware.gnss@2.0-service-qti
-
-LOCAL_VINTF_FRAGMENTS := android.hardware.gnss@2.0-service-qti.xml
-LOCAL_VENDOR_MODULE := true
-LOCAL_MODULE_RELATIVE_PATH := hw
-LOCAL_INIT_RC := android.hardware.gnss@2.0-service-qti.rc
-LOCAL_SRC_FILES := \
-    service.cpp \
-
-LOCAL_HEADER_LIBRARIES := \
-    libgps.utils_headers \
-    libloc_core_headers \
-    libloc_pla_headers \
-    liblocation_api_headers
-
-
-LOCAL_SHARED_LIBRARIES := \
-    liblog \
-    libcutils \
-    libdl \
-    libbase \
-    libutils \
-    libgps.utils \
-    libqti_vndfwk_detect \
-
-LOCAL_SHARED_LIBRARIES += \
-    libhidlbase \
-    android.hardware.gnss@1.0 \
-    android.hardware.gnss@1.1 \
-    android.hardware.gnss@2.0 \
-
-LOCAL_CFLAGS += $(GNSS_CFLAGS)
-
-ifneq ($(LOC_HIDL_VERSION),)
-LOCAL_CFLAGS += -DLOC_HIDL_VERSION='"$(LOC_HIDL_VERSION)"'
-endif
-
-include $(BUILD_EXECUTABLE)
diff --git a/gps/android/2.0/Gnss.cpp b/gps/android/2.0/Gnss.cpp
deleted file mode 100644
index 8fad5d6..0000000
--- a/gps/android/2.0/Gnss.cpp
+++ /dev/null
@@ -1,679 +0,0 @@
-/*
- * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-#define LOG_TAG "LocSvc_GnssInterface"
-#define LOG_NDEBUG 0
-
-#include <fstream>
-#include <log_util.h>
-#include <dlfcn.h>
-#include <cutils/properties.h>
-#include "Gnss.h"
-#include "LocationUtil.h"
-#include "battery_listener.h"
-#include "loc_misc_utils.h"
-
-typedef const GnssInterface* (getLocationInterface)();
-
-#define IMAGES_INFO_FILE "/sys/devices/soc0/images"
-#define DELIMITER ";"
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V2_0 {
-namespace implementation {
-
-using ::android::hardware::gnss::visibility_control::V1_0::implementation::GnssVisibilityControl;
-static sp<Gnss> sGnss;
-static std::string getVersionString() {
-    static std::string version;
-    if (!version.empty())
-        return version;
-
-    char value[PROPERTY_VALUE_MAX] = {0};
-    property_get("ro.hardware", value, "unknown");
-    version.append(value).append(DELIMITER);
-
-    std::ifstream in(IMAGES_INFO_FILE);
-    std::string s;
-    while(getline(in, s)) {
-        std::size_t found = s.find("CRM:");
-        if (std::string::npos == found) {
-            continue;
-        }
-
-        // skip over space characters after "CRM:"
-        const char* substr = s.c_str();
-        found += 4;
-        while (0 != substr[found] && isspace(substr[found])) {
-            found++;
-        }
-        if (s.find("11:") != found) {
-            continue;
-        }
-        s.erase(0, found + 3);
-
-        found = s.find_first_of("\r\n");
-        if (std::string::npos != found) {
-            s.erase(s.begin() + found, s.end());
-        }
-        version.append(s).append(DELIMITER);
-    }
-    return version;
-}
-
-void Gnss::GnssDeathRecipient::serviceDied(uint64_t cookie, const wp<IBase>& who) {
-    LOC_LOGE("%s] service died. cookie: %llu, who: %p",
-            __FUNCTION__, static_cast<unsigned long long>(cookie), &who);
-    if (mGnss != nullptr) {
-        mGnss->getGnssInterface()->resetNetworkInfo();
-        mGnss->cleanup();
-    }
-}
-
-void location_on_battery_status_changed(bool charging) {
-    LOC_LOGd("battery status changed to %s charging", charging ? "" : "not");
-    if (sGnss != nullptr) {
-        sGnss->getGnssInterface()->updateBatteryStatus(charging);
-    }
-}
-Gnss::Gnss() {
-    ENTRY_LOG_CALLFLOW();
-    sGnss = this;
-    // initilize gnss interface at first in case needing notify battery status
-    sGnss->getGnssInterface()->initialize();
-    // register health client to listen on battery change
-    loc_extn_battery_properties_listener_init(location_on_battery_status_changed);
-    // clear pending GnssConfig
-    memset(&mPendingConfig, 0, sizeof(GnssConfig));
-    mGnssDeathRecipient = new GnssDeathRecipient(this);
-}
-
-Gnss::~Gnss() {
-    ENTRY_LOG_CALLFLOW();
-    if (mApi != nullptr) {
-        mApi->destroy();
-        mApi = nullptr;
-    }
-    sGnss = nullptr;
-}
-
-GnssAPIClient* Gnss::getApi() {
-    if (mApi != nullptr) {
-        return mApi;
-    }
-
-    if (mGnssCbIface_2_0 != nullptr) {
-        mApi = new GnssAPIClient(mGnssCbIface_2_0);
-    } else if (mGnssCbIface_1_1 != nullptr) {
-        mApi = new GnssAPIClient(mGnssCbIface_1_1, mGnssNiCbIface);
-    } else if (mGnssCbIface != nullptr) {
-        mApi = new GnssAPIClient(mGnssCbIface, mGnssNiCbIface);
-    } else {
-        LOC_LOGW("%s] GnssAPIClient is not ready", __FUNCTION__);
-        return mApi;
-    }
-
-    if (mPendingConfig.size == sizeof(GnssConfig)) {
-        // we have pending GnssConfig
-        mApi->gnssConfigurationUpdate(mPendingConfig);
-        // clear size to invalid mPendingConfig
-        mPendingConfig.size = 0;
-        if (mPendingConfig.assistanceServer.hostName != nullptr) {
-            free((void*)mPendingConfig.assistanceServer.hostName);
-        }
-    }
-
-    return mApi;
-}
-
-const GnssInterface* Gnss::getGnssInterface() {
-    static bool getGnssInterfaceFailed = false;
-
-    if (nullptr == mGnssInterface && !getGnssInterfaceFailed) {
-        void * libHandle = nullptr;
-        getLocationInterface* getter = (getLocationInterface*)
-                dlGetSymFromLib(libHandle, "libgnss.so", "getGnssInterface");
-
-        if (nullptr == getter) {
-            getGnssInterfaceFailed = true;
-        } else {
-            mGnssInterface = (GnssInterface*)(*getter)();
-        }
-    }
-    return mGnssInterface;
-}
-
-Return<bool> Gnss::setCallback(const sp<V1_0::IGnssCallback>& callback)  {
-    ENTRY_LOG_CALLFLOW();
-
-    // In case where previous call to setCallback_1_1 or setCallback_2_0, then
-    // we need to cleanup these interfaces/callbacks here since we no longer
-    // do so in cleanup() function to keep callbacks around after cleanup()
-    if (mApi != nullptr) {
-        mApi->gnssUpdateCallbacks_2_0(nullptr);
-    }
-    if (mGnssCbIface_1_1 != nullptr) {
-        mGnssCbIface_1_1->unlinkToDeath(mGnssDeathRecipient);
-        mGnssCbIface_1_1 = nullptr;
-    }
-    if (mGnssCbIface_2_0 != nullptr) {
-        mGnssCbIface_2_0->unlinkToDeath(mGnssDeathRecipient);
-        mGnssCbIface_2_0 = nullptr;
-    }
-
-
-    if (mGnssCbIface != nullptr) {
-        mGnssCbIface->unlinkToDeath(mGnssDeathRecipient);
-    }
-    mGnssCbIface = callback;
-    if (mGnssCbIface != nullptr) {
-        mGnssCbIface->linkToDeath(mGnssDeathRecipient, 0 /*cookie*/);
-    }
-
-    GnssAPIClient* api = getApi();
-    if (api != nullptr) {
-        api->gnssUpdateCallbacks(mGnssCbIface, mGnssNiCbIface);
-        api->gnssEnable(LOCATION_TECHNOLOGY_TYPE_GNSS);
-        api->requestCapabilities();
-    }
-    return true;
-}
-
-Return<bool> Gnss::setGnssNiCb(const sp<IGnssNiCallback>& callback) {
-    ENTRY_LOG_CALLFLOW();
-    mGnssNiCbIface = callback;
-    GnssAPIClient* api = getApi();
-    if (api != nullptr) {
-        api->gnssUpdateCallbacks(mGnssCbIface, mGnssNiCbIface);
-    }
-    return true;
-}
-
-Return<bool> Gnss::updateConfiguration(GnssConfig& gnssConfig) {
-    ENTRY_LOG_CALLFLOW();
-    GnssAPIClient* api = getApi();
-    if (api) {
-        api->gnssConfigurationUpdate(gnssConfig);
-    } else if (gnssConfig.flags != 0) {
-        // api is not ready yet, update mPendingConfig with gnssConfig
-        mPendingConfig.size = sizeof(GnssConfig);
-
-        if (gnssConfig.flags & GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT) {
-            mPendingConfig.flags |= GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT;
-            mPendingConfig.gpsLock = gnssConfig.gpsLock;
-        }
-        if (gnssConfig.flags & GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT) {
-            mPendingConfig.flags |= GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT;
-            mPendingConfig.suplVersion = gnssConfig.suplVersion;
-        }
-        if (gnssConfig.flags & GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT) {
-            mPendingConfig.flags |= GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT;
-            mPendingConfig.assistanceServer.size = sizeof(GnssConfigSetAssistanceServer);
-            mPendingConfig.assistanceServer.type = gnssConfig.assistanceServer.type;
-            if (mPendingConfig.assistanceServer.hostName != nullptr) {
-                free((void*)mPendingConfig.assistanceServer.hostName);
-                mPendingConfig.assistanceServer.hostName =
-                    strdup(gnssConfig.assistanceServer.hostName);
-            }
-            mPendingConfig.assistanceServer.port = gnssConfig.assistanceServer.port;
-        }
-        if (gnssConfig.flags & GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT) {
-            mPendingConfig.flags |= GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT;
-            mPendingConfig.lppProfileMask = gnssConfig.lppProfileMask;
-        }
-        if (gnssConfig.flags & GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT) {
-            mPendingConfig.flags |= GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT;
-            mPendingConfig.lppeControlPlaneMask = gnssConfig.lppeControlPlaneMask;
-        }
-        if (gnssConfig.flags & GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT) {
-            mPendingConfig.flags |= GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT;
-            mPendingConfig.lppeUserPlaneMask = gnssConfig.lppeUserPlaneMask;
-        }
-        if (gnssConfig.flags & GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT) {
-            mPendingConfig.flags |= GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT;
-            mPendingConfig.aGlonassPositionProtocolMask = gnssConfig.aGlonassPositionProtocolMask;
-        }
-        if (gnssConfig.flags & GNSS_CONFIG_FLAGS_EM_PDN_FOR_EM_SUPL_VALID_BIT) {
-            mPendingConfig.flags |= GNSS_CONFIG_FLAGS_EM_PDN_FOR_EM_SUPL_VALID_BIT;
-            mPendingConfig.emergencyPdnForEmergencySupl = gnssConfig.emergencyPdnForEmergencySupl;
-        }
-        if (gnssConfig.flags & GNSS_CONFIG_FLAGS_SUPL_EM_SERVICES_BIT) {
-            mPendingConfig.flags |= GNSS_CONFIG_FLAGS_SUPL_EM_SERVICES_BIT;
-            mPendingConfig.suplEmergencyServices = gnssConfig.suplEmergencyServices;
-        }
-        if (gnssConfig.flags & GNSS_CONFIG_FLAGS_SUPL_MODE_BIT) {
-            mPendingConfig.flags |= GNSS_CONFIG_FLAGS_SUPL_MODE_BIT;
-            mPendingConfig.suplModeMask = gnssConfig.suplModeMask;
-        }
-        if (gnssConfig.flags & GNSS_CONFIG_FLAGS_BLACKLISTED_SV_IDS_BIT) {
-            mPendingConfig.flags |= GNSS_CONFIG_FLAGS_BLACKLISTED_SV_IDS_BIT;
-            mPendingConfig.blacklistedSvIds = gnssConfig.blacklistedSvIds;
-        }
-        if (gnssConfig.flags & GNSS_CONFIG_FLAGS_EMERGENCY_EXTENSION_SECONDS_BIT) {
-            mPendingConfig.flags |= GNSS_CONFIG_FLAGS_EMERGENCY_EXTENSION_SECONDS_BIT;
-            mPendingConfig.emergencyExtensionSeconds = gnssConfig.emergencyExtensionSeconds;
-        }
-    }
-    return true;
-}
-
-Return<bool> Gnss::start()  {
-    ENTRY_LOG_CALLFLOW();
-    bool retVal = false;
-    GnssAPIClient* api = getApi();
-    if (api) {
-        retVal = api->gnssStart();
-    }
-    return retVal;
-}
-
-Return<bool> Gnss::stop()  {
-    ENTRY_LOG_CALLFLOW();
-    bool retVal = false;
-    GnssAPIClient* api = getApi();
-    if (api) {
-        retVal = api->gnssStop();
-    }
-    return retVal;
-}
-
-Return<void> Gnss::cleanup()  {
-    ENTRY_LOG_CALLFLOW();
-
-    if (mApi != nullptr) {
-        mApi->gnssStop();
-        mApi->gnssDisable();
-    }
-
-    return Void();
-}
-
-Return<bool> Gnss::injectLocation(double latitudeDegrees,
-                                  double longitudeDegrees,
-                                  float accuracyMeters)  {
-    ENTRY_LOG_CALLFLOW();
-    const GnssInterface* gnssInterface = getGnssInterface();
-    if (nullptr != gnssInterface) {
-        gnssInterface->injectLocation(latitudeDegrees, longitudeDegrees, accuracyMeters);
-        return true;
-    } else {
-        return false;
-    }
-}
-
-Return<bool> Gnss::injectTime(int64_t timeMs, int64_t timeReferenceMs,
-                              int32_t uncertaintyMs) {
-    return true;
-}
-
-Return<void> Gnss::deleteAidingData(V1_0::IGnss::GnssAidingData aidingDataFlags)  {
-    ENTRY_LOG_CALLFLOW();
-    GnssAPIClient* api = getApi();
-    if (api) {
-        api->gnssDeleteAidingData(aidingDataFlags);
-    }
-    return Void();
-}
-
-Return<bool> Gnss::setPositionMode(V1_0::IGnss::GnssPositionMode mode,
-                                   V1_0::IGnss::GnssPositionRecurrence recurrence,
-                                   uint32_t minIntervalMs,
-                                   uint32_t preferredAccuracyMeters,
-                                   uint32_t preferredTimeMs)  {
-    ENTRY_LOG_CALLFLOW();
-    bool retVal = false;
-    GnssAPIClient* api = getApi();
-    if (api) {
-        retVal = api->gnssSetPositionMode(mode, recurrence, minIntervalMs,
-                preferredAccuracyMeters, preferredTimeMs);
-    }
-    return retVal;
-}
-
-Return<sp<V1_0::IAGnss>> Gnss::getExtensionAGnss()  {
-    ENTRY_LOG_CALLFLOW();
-    // deprecated function. Must return nullptr to pass VTS
-    return nullptr;
-}
-
-Return<sp<V1_0::IGnssNi>> Gnss::getExtensionGnssNi()  {
-    ENTRY_LOG_CALLFLOW();
-    // deprecated function. Must return nullptr to pass VTS
-    return nullptr;
-}
-
-Return<sp<V1_0::IGnssMeasurement>> Gnss::getExtensionGnssMeasurement() {
-    ENTRY_LOG_CALLFLOW();
-    if (mGnssMeasurement == nullptr)
-        mGnssMeasurement = new GnssMeasurement();
-    return mGnssMeasurement;
-}
-
-Return<sp<V1_0::IGnssConfiguration>> Gnss::getExtensionGnssConfiguration()  {
-    ENTRY_LOG_CALLFLOW();
-    if (mGnssConfig == nullptr) {
-        mGnssConfig = new GnssConfiguration(this);
-    }
-    return mGnssConfig;
-}
-
-Return<sp<V1_0::IGnssGeofencing>> Gnss::getExtensionGnssGeofencing()  {
-    ENTRY_LOG_CALLFLOW();
-    if (mGnssGeofencingIface == nullptr) {
-        mGnssGeofencingIface = new GnssGeofencing();
-    }
-    return mGnssGeofencingIface;
-}
-
-Return<sp<V1_0::IGnssBatching>> Gnss::getExtensionGnssBatching()  {
-    ENTRY_LOG_CALLFLOW();
-    if (mGnssBatching == nullptr) {
-        mGnssBatching = new GnssBatching();
-    }
-    return mGnssBatching;
-}
-
-Return<sp<V1_0::IGnssDebug>> Gnss::getExtensionGnssDebug() {
-    ENTRY_LOG_CALLFLOW();
-    if (mGnssDebug == nullptr) {
-        mGnssDebug = new GnssDebug(this);
-    }
-    return mGnssDebug;
-}
-
-Return<sp<V1_0::IAGnssRil>> Gnss::getExtensionAGnssRil() {
-    ENTRY_LOG_CALLFLOW();
-    if (mGnssRil == nullptr) {
-        mGnssRil = new AGnssRil(this);
-    }
-    return mGnssRil;
-}
-
-// Methods from ::android::hardware::gnss::V1_1::IGnss follow.
-Return<bool> Gnss::setCallback_1_1(const sp<V1_1::IGnssCallback>& callback) {
-    ENTRY_LOG_CALLFLOW();
-    auto r = callback->gnssNameCb(getVersionString());
-    if (!r.isOk()) {
-        LOC_LOGE("%s] Error from gnssNameCb description=%s",
-                __func__, r.description().c_str());
-    }
-
-    // In case where previous call to setCallback or setCallback_2_1, then
-    // we need to cleanup these interfaces/callbacks here since we no longer
-    // do so in cleanup() function to keep callbacks around after cleanup()
-    if (mApi != nullptr) {
-        mApi->gnssUpdateCallbacks_2_0(nullptr);
-    }
-    if (mGnssCbIface != nullptr) {
-        mGnssCbIface->unlinkToDeath(mGnssDeathRecipient);
-        mGnssCbIface = nullptr;
-    }
-    if (mGnssCbIface_2_0 != nullptr) {
-        mGnssCbIface_2_0->unlinkToDeath(mGnssDeathRecipient);
-        mGnssCbIface_2_0 = nullptr;
-    }
-
-
-    if (mGnssCbIface_1_1 != nullptr) {
-        mGnssCbIface_1_1->unlinkToDeath(mGnssDeathRecipient);
-    }
-    mGnssCbIface_1_1 = callback;
-    if (mGnssCbIface_1_1 != nullptr) {
-        mGnssCbIface_1_1->linkToDeath(mGnssDeathRecipient, 0 /*cookie*/);
-    }
-
-    const GnssInterface* gnssInterface = getGnssInterface();
-    if (nullptr != gnssInterface) {
-        OdcpiRequestCallback cb = [this](const OdcpiRequestInfo& odcpiRequest) {
-            odcpiRequestCb(odcpiRequest);
-        };
-        gnssInterface->odcpiInit(cb, OdcpiPrioritytype::ODCPI_HANDLER_PRIORITY_LOW,
-                (EMERGENCY_ODCPI | NON_EMERGENCY_ODCPI));
-    }
-
-    GnssAPIClient* api = getApi();
-    if (api != nullptr) {
-        api->gnssUpdateCallbacks(mGnssCbIface_1_1, mGnssNiCbIface);
-        api->gnssEnable(LOCATION_TECHNOLOGY_TYPE_GNSS);
-        api->requestCapabilities();
-    }
-
-    return true;
-}
-
-Return<bool> Gnss::setPositionMode_1_1(V1_0::IGnss::GnssPositionMode mode,
-        V1_0::IGnss::GnssPositionRecurrence recurrence,
-        uint32_t minIntervalMs,
-        uint32_t preferredAccuracyMeters,
-        uint32_t preferredTimeMs,
-        bool lowPowerMode) {
-    ENTRY_LOG_CALLFLOW();
-    bool retVal = false;
-    GnssAPIClient* api = getApi();
-    if (api) {
-        GnssPowerMode powerMode = lowPowerMode?
-                GNSS_POWER_MODE_M4 : GNSS_POWER_MODE_M2;
-        retVal = api->gnssSetPositionMode(mode, recurrence, minIntervalMs,
-                preferredAccuracyMeters, preferredTimeMs, powerMode, minIntervalMs);
-    }
-    return retVal;
-}
-
-Return<sp<V1_1::IGnssMeasurement>> Gnss::getExtensionGnssMeasurement_1_1() {
-    ENTRY_LOG_CALLFLOW();
-#ifdef GNSS_HIDL_LEGACY_MEASURMENTS
-    return nullptr;
-#else
-    if (mGnssMeasurement == nullptr)
-        mGnssMeasurement = new GnssMeasurement();
-    return mGnssMeasurement;
-#endif
-}
-
-Return<sp<V1_1::IGnssConfiguration>> Gnss::getExtensionGnssConfiguration_1_1() {
-    ENTRY_LOG_CALLFLOW();
-    if (mGnssConfig == nullptr)
-        mGnssConfig = new GnssConfiguration(this);
-    return mGnssConfig;
-}
-
-Return<bool> Gnss::injectBestLocation(const GnssLocation& gnssLocation) {
-    ENTRY_LOG_CALLFLOW();
-    const GnssInterface* gnssInterface = getGnssInterface();
-    if (nullptr != gnssInterface) {
-        Location location = {};
-        convertGnssLocation(gnssLocation, location);
-        gnssInterface->odcpiInject(location);
-    }
-    return true;
-}
-
-void Gnss::odcpiRequestCb(const OdcpiRequestInfo& request) {
-    ENTRY_LOG_CALLFLOW();
-
-    if (ODCPI_REQUEST_TYPE_STOP == request.type) {
-        return;
-    }
-    if (mGnssCbIface_2_0 != nullptr) {
-        // For emergency mode, request DBH (Device based hybrid) location
-        // Mark Independent from GNSS flag to false.
-        if (ODCPI_REQUEST_TYPE_START == request.type) {
-            LOC_LOGd("gnssRequestLocationCb_2_0 isUserEmergency = %d", request.isEmergencyMode);
-            auto r = mGnssCbIface_2_0->gnssRequestLocationCb_2_0(!request.isEmergencyMode,
-                                                                 request.isEmergencyMode);
-            if (!r.isOk()) {
-                LOC_LOGe("Error invoking gnssRequestLocationCb_2_0 %s", r.description().c_str());
-            }
-        } else {
-            LOC_LOGv("Unsupported ODCPI request type: %d", request.type);
-        }
-    } else if (mGnssCbIface_1_1 != nullptr) {
-        // For emergency mode, request DBH (Device based hybrid) location
-        // Mark Independent from GNSS flag to false.
-        if (ODCPI_REQUEST_TYPE_START == request.type) {
-            auto r = mGnssCbIface_1_1->gnssRequestLocationCb(!request.isEmergencyMode);
-            if (!r.isOk()) {
-                LOC_LOGe("Error invoking gnssRequestLocationCb %s", r.description().c_str());
-            }
-        } else {
-            LOC_LOGv("Unsupported ODCPI request type: %d", request.type);
-        }
-    } else {
-        LOC_LOGe("ODCPI request not supported.");
-    }
-}
-
-// Methods from ::android::hardware::gnss::V2_0::IGnss follow.
-Return<bool> Gnss::setCallback_2_0(const sp<V2_0::IGnssCallback>& callback) {
-    ENTRY_LOG_CALLFLOW();
-    auto r = callback->gnssNameCb(getVersionString());
-    if (!r.isOk()) {
-        LOC_LOGE("%s] Error from gnssNameCb description=%s",
-                __func__, r.description().c_str());
-    }
-
-    // In case where previous call to setCallback or setCallback_1_1, then
-    // we need to cleanup these interfaces/callbacks here since we no longer
-    // do so in cleanup() function to keep callbacks around after cleanup()
-    if (mApi != nullptr) {
-        mApi->gnssUpdateCallbacks(nullptr, nullptr);
-    }
-    mGnssNiCbIface = nullptr;
-    if (mGnssCbIface != nullptr) {
-        mGnssCbIface->unlinkToDeath(mGnssDeathRecipient);
-        mGnssCbIface = nullptr;
-    }
-    if (mGnssCbIface_1_1 != nullptr) {
-        mGnssCbIface_1_1->unlinkToDeath(mGnssDeathRecipient);
-        mGnssCbIface_1_1 = nullptr;
-    }
-
-    if (mGnssCbIface_2_0 != nullptr) {
-        mGnssCbIface_2_0->unlinkToDeath(mGnssDeathRecipient);
-    }
-    mGnssCbIface_2_0 = callback;
-    if (mGnssCbIface_2_0 != nullptr) {
-        mGnssCbIface_2_0->linkToDeath(mGnssDeathRecipient, 0 /*cookie*/);
-    }
-
-    const GnssInterface* gnssInterface = getGnssInterface();
-    if (nullptr != gnssInterface) {
-        OdcpiRequestCallback cb = [this](const OdcpiRequestInfo& odcpiRequest) {
-            odcpiRequestCb(odcpiRequest);
-        };
-        gnssInterface->odcpiInit(cb, OdcpiPrioritytype::ODCPI_HANDLER_PRIORITY_LOW,
-                (EMERGENCY_ODCPI | NON_EMERGENCY_ODCPI));
-    }
-
-    GnssAPIClient* api = getApi();
-    if (api != nullptr) {
-        api->gnssUpdateCallbacks_2_0(mGnssCbIface_2_0);
-        api->gnssEnable(LOCATION_TECHNOLOGY_TYPE_GNSS);
-        api->requestCapabilities();
-    }
-
-    return true;
-}
-
-Return<sp<V2_0::IAGnss>> Gnss::getExtensionAGnss_2_0() {
-    ENTRY_LOG_CALLFLOW();
-    if (mAGnssIface_2_0 == nullptr) {
-        mAGnssIface_2_0 = new AGnss(this);
-    }
-    return mAGnssIface_2_0;
-}
-Return<sp<V2_0::IAGnssRil>> Gnss::getExtensionAGnssRil_2_0() {
-    if (mGnssRil == nullptr) {
-        mGnssRil = new AGnssRil(this);
-    }
-    return mGnssRil;
-}
-
-Return<sp<V2_0::IGnssConfiguration>> Gnss::getExtensionGnssConfiguration_2_0() {
-    ENTRY_LOG_CALLFLOW();
-    if (mGnssConfig == nullptr) {
-        mGnssConfig = new GnssConfiguration(this);
-    }
-    return mGnssConfig;
-}
-Return<sp<V2_0::IGnssMeasurement>> Gnss::getExtensionGnssMeasurement_2_0() {
-    ENTRY_LOG_CALLFLOW();
-#ifdef GNSS_HIDL_LEGACY_MEASURMENTS
-    return nullptr;
-#else
-    if (mGnssMeasurement == nullptr)
-        mGnssMeasurement = new GnssMeasurement();
-    return mGnssMeasurement;
-#endif
-}
-Return<sp<::android::hardware::gnss::measurement_corrections::V1_0::IMeasurementCorrections>>
-        Gnss::getExtensionMeasurementCorrections() {
-    // We do not support, so return nullptr to pass VTS
-    return nullptr;
-}
-Return<sp<::android::hardware::gnss::visibility_control::V1_0::IGnssVisibilityControl>>
-        Gnss::getExtensionVisibilityControl() {
-    ENTRY_LOG_CALLFLOW();
-    if (mVisibCtrl == nullptr) {
-        mVisibCtrl = new GnssVisibilityControl(this);
-    }
-    return mVisibCtrl;
-}
-
-Return<bool> Gnss::injectBestLocation_2_0(const V2_0::GnssLocation& gnssLocation) {
-    ENTRY_LOG_CALLFLOW();
-    const GnssInterface* gnssInterface = getGnssInterface();
-    if (nullptr != gnssInterface) {
-        Location location = {};
-        convertGnssLocation(gnssLocation, location);
-        gnssInterface->odcpiInject(location);
-    }
-    return true;
-}
-
-Return<sp<V2_0::IGnssDebug>> Gnss::getExtensionGnssDebug_2_0() {
-    ENTRY_LOG_CALLFLOW();
-    if (mGnssDebug == nullptr) {
-        mGnssDebug = new GnssDebug(this);
-    }
-    return mGnssDebug;
-}
-
-Return<sp<V2_0::IGnssBatching>> Gnss::getExtensionGnssBatching_2_0() {
-    return nullptr;
-}
-
-V1_0::IGnss* HIDL_FETCH_IGnss(const char* hal) {
-    ENTRY_LOG_CALLFLOW();
-    V1_0::IGnss* iface = nullptr;
-    iface = new Gnss();
-    if (iface == nullptr) {
-        LOC_LOGE("%s]: failed to get %s", __FUNCTION__, hal);
-    }
-    return iface;
-}
-
-}  // namespace implementation
-}  // namespace V2_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
diff --git a/gps/android/2.0/Gnss.h b/gps/android/2.0/Gnss.h
deleted file mode 100644
index a403d61..0000000
--- a/gps/android/2.0/Gnss.h
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-#ifndef ANDROID_HARDWARE_GNSS_V2_0_GNSS_H
-#define ANDROID_HARDWARE_GNSS_V2_0_GNSS_H
-
-#include <AGnss.h>
-#include <AGnssRil.h>
-#include <GnssConfiguration.h>
-#include <GnssMeasurement.h>
-#include <GnssBatching.h>
-#include <GnssGeofencing.h>
-#include <GnssNi.h>
-#include <GnssDebug.h>
-
-#include <android/hardware/gnss/2.0/IGnss.h>
-#include <MeasurementCorrections.h>
-#include <GnssVisibilityControl.h>
-#include <hidl/MQDescriptor.h>
-#include <hidl/Status.h>
-
-#include "GnssAPIClient.h"
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V2_0 {
-namespace implementation {
-
-using ::android::hardware::hidl_array;
-using ::android::hardware::hidl_memory;
-using ::android::hardware::hidl_string;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::sp;
-using ::android::hardware::gnss::V1_0::GnssLocation;
-using ::android::hardware::gnss::measurement_corrections::V1_0::IMeasurementCorrections;
-using ::android::hardware::gnss::measurement_corrections::V1_0::implementation::MeasurementCorrections;
-using ::android::hardware::gnss::visibility_control::V1_0::IGnssVisibilityControl;
-
-struct Gnss : public IGnss {
-    Gnss();
-    ~Gnss();
-
-    /*
-     * Methods from ::android::hardware::gnss::V1_0::IGnss follow.
-     * These declarations were generated from Gnss.hal.
-     */
-    Return<bool> setCallback(const sp<V1_0::IGnssCallback>& callback)  override;
-    Return<bool> start()  override;
-    Return<bool> stop()  override;
-    Return<void> cleanup()  override;
-    Return<bool> injectLocation(double latitudeDegrees,
-                                double longitudeDegrees,
-                                float accuracyMeters)  override;
-    Return<bool> injectTime(int64_t timeMs,
-                            int64_t timeReferenceMs,
-                            int32_t uncertaintyMs) override;
-    Return<void> deleteAidingData(V1_0::IGnss::GnssAidingData aidingDataFlags)  override;
-    Return<bool> setPositionMode(V1_0::IGnss::GnssPositionMode mode,
-                                 V1_0::IGnss::GnssPositionRecurrence recurrence,
-                                 uint32_t minIntervalMs,
-                                 uint32_t preferredAccuracyMeters,
-                                 uint32_t preferredTimeMs)  override;
-    Return<sp<V1_0::IAGnss>> getExtensionAGnss() override;
-    Return<sp<V1_0::IGnssNi>> getExtensionGnssNi() override;
-    Return<sp<V1_0::IGnssMeasurement>> getExtensionGnssMeasurement() override;
-    Return<sp<V1_0::IGnssConfiguration>> getExtensionGnssConfiguration() override;
-    Return<sp<V1_0::IGnssGeofencing>> getExtensionGnssGeofencing() override;
-    Return<sp<V1_0::IGnssBatching>> getExtensionGnssBatching() override;
-
-    Return<sp<V1_0::IAGnssRil>> getExtensionAGnssRil() override;
-
-    inline Return<sp<V1_0::IGnssNavigationMessage>> getExtensionGnssNavigationMessage() override {
-        return nullptr;
-    }
-
-    inline Return<sp<V1_0::IGnssXtra>> getExtensionXtra() override {
-        return nullptr;
-    }
-
-    Return<sp<V1_0::IGnssDebug>> getExtensionGnssDebug() override;
-
-    // Methods from ::android::hardware::gnss::V1_1::IGnss follow.
-    Return<bool> setCallback_1_1(const sp<V1_1::IGnssCallback>& callback) override;
-    Return<bool> setPositionMode_1_1(V1_0::IGnss::GnssPositionMode mode,
-            V1_0::IGnss::GnssPositionRecurrence recurrence,
-            uint32_t minIntervalMs, uint32_t preferredAccuracyMeters,
-            uint32_t preferredTimeMs, bool lowPowerMode) override;
-    Return<sp<V1_1::IGnssMeasurement>> getExtensionGnssMeasurement_1_1() override;
-    Return<sp<V1_1::IGnssConfiguration>> getExtensionGnssConfiguration_1_1() override;
-    Return<bool> injectBestLocation(const GnssLocation& location) override;
-
-    // Methods from ::android::hardware::gnss::V2_0::IGnss follow.
-    Return<bool> setCallback_2_0(const sp<V2_0::IGnssCallback>& callback) override;
-    Return<sp<V2_0::IAGnss>> getExtensionAGnss_2_0() override;
-    Return<sp<V2_0::IAGnssRil>> getExtensionAGnssRil_2_0() override;
-
-    Return<sp<V2_0::IGnssConfiguration>> getExtensionGnssConfiguration_2_0() override;
-    Return<sp<::android::hardware::gnss::measurement_corrections::V1_0::IMeasurementCorrections>>
-            getExtensionMeasurementCorrections() override;
-    Return<sp<V2_0::IGnssMeasurement>> getExtensionGnssMeasurement_2_0() override;
-
-    Return<bool> injectBestLocation_2_0(const ::android::hardware::gnss::V2_0::GnssLocation& location) override;
-
-    Return<sp<V2_0::IGnssBatching>> getExtensionGnssBatching_2_0() override;
-    Return<sp<V2_0::IGnssDebug>> getExtensionGnssDebug_2_0() override;
-
-
-    /**
-     * This method returns the IGnssVisibilityControl interface.
-     *
-     * @return visibilityControlIface Handle to the IGnssVisibilityControl interface.
-     */
-    Return<sp<::android::hardware::gnss::visibility_control::V1_0::IGnssVisibilityControl>>
-            getExtensionVisibilityControl() override;
-
-
-    // These methods are not part of the IGnss base class.
-    GnssAPIClient* getApi();
-    Return<bool> setGnssNiCb(const sp<IGnssNiCallback>& niCb);
-    Return<bool> updateConfiguration(GnssConfig& gnssConfig);
-    const GnssInterface* getGnssInterface();
-
-    // Callback for ODCPI request
-    void odcpiRequestCb(const OdcpiRequestInfo& request);
-
- private:
-    struct GnssDeathRecipient : hidl_death_recipient {
-        GnssDeathRecipient(sp<Gnss> gnss) : mGnss(gnss) {
-        }
-        ~GnssDeathRecipient() = default;
-        virtual void serviceDied(uint64_t cookie, const wp<IBase>& who) override;
-        sp<Gnss> mGnss;
-    };
-
- private:
-    sp<GnssDeathRecipient> mGnssDeathRecipient = nullptr;
-
-    sp<V1_0::IGnssNi> mGnssNi = nullptr;
-    sp<V1_0::IGnssGeofencing> mGnssGeofencingIface = nullptr;
-    sp<V1_0::IAGnss> mAGnssIface = nullptr;
-    sp<V1_0::IGnssCallback> mGnssCbIface = nullptr;
-    sp<V1_0::IGnssNiCallback> mGnssNiCbIface = nullptr;
-    sp<V1_1::IGnssCallback> mGnssCbIface_1_1 = nullptr;
-    sp<V2_0::IAGnss> mAGnssIface_2_0 = nullptr;
-    sp<V2_0::IAGnssRil> mGnssRil = nullptr;
-    sp<V2_0::IGnssMeasurement> mGnssMeasurement = nullptr;
-    sp<V2_0::IGnssConfiguration> mGnssConfig = nullptr;
-    sp<V2_0::IGnssBatching> mGnssBatching = nullptr;
-    sp<V2_0::IGnssDebug> mGnssDebug = nullptr;
-    sp<V2_0::IGnssCallback> mGnssCbIface_2_0 = nullptr;
-    sp<IMeasurementCorrections> mGnssMeasCorr = nullptr;
-    sp<IGnssVisibilityControl> mVisibCtrl = nullptr;
-
-    GnssAPIClient* mApi = nullptr;
-    GnssConfig mPendingConfig;
-    const GnssInterface* mGnssInterface = nullptr;
-};
-
-extern "C" V1_0::IGnss* HIDL_FETCH_IGnss(const char* name);
-
-}  // namespace implementation
-}  // namespace V2_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
-
-#endif  // ANDROID_HARDWARE_GNSS_V2_0_GNSS_H
diff --git a/gps/android/2.0/GnssBatching.cpp b/gps/android/2.0/GnssBatching.cpp
deleted file mode 100644
index 6a2a09e..0000000
--- a/gps/android/2.0/GnssBatching.cpp
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-#define LOG_TAG "LocSvc_GnssBatchingInterface"
-
-#include <log_util.h>
-#include <BatchingAPIClient.h>
-#include "GnssBatching.h"
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V2_0 {
-namespace implementation {
-
-void GnssBatching::GnssBatchingDeathRecipient::serviceDied(
-        uint64_t cookie, const wp<IBase>& who) {
-    LOC_LOGE("%s] service died. cookie: %llu, who: %p",
-            __FUNCTION__, static_cast<unsigned long long>(cookie), &who);
-    if (mGnssBatching != nullptr) {
-        mGnssBatching->stop();
-        mGnssBatching->cleanup();
-    }
-}
-
-GnssBatching::GnssBatching() : mApi(nullptr) {
-    mGnssBatchingDeathRecipient = new GnssBatchingDeathRecipient(this);
-}
-
-GnssBatching::~GnssBatching() {
-    if (mApi != nullptr) {
-        mApi->destroy();
-        mApi = nullptr;
-    }
-}
-
-
-// Methods from ::android::hardware::gnss::V1_0::IGnssBatching follow.
-Return<bool> GnssBatching::init(const sp<V1_0::IGnssBatchingCallback>& callback) {
-    if (mApi != nullptr) {
-        LOC_LOGD("%s]: mApi is NOT nullptr, delete it first", __FUNCTION__);
-        mApi->destroy();
-        mApi = nullptr;
-    }
-
-    mApi = new BatchingAPIClient(callback);
-    if (mApi == nullptr) {
-        LOC_LOGE("%s]: failed to create mApi", __FUNCTION__);
-        return false;
-    }
-
-    if (mGnssBatchingCbIface != nullptr) {
-        mGnssBatchingCbIface->unlinkToDeath(mGnssBatchingDeathRecipient);
-    }
-    mGnssBatchingCbIface = callback;
-    if (mGnssBatchingCbIface != nullptr) {
-        mGnssBatchingCbIface->linkToDeath(mGnssBatchingDeathRecipient, 0 /*cookie*/);
-    }
-
-    return true;
-}
-
-Return<uint16_t> GnssBatching::getBatchSize() {
-    uint16_t ret = 0;
-    if (mApi == nullptr) {
-        LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
-    } else {
-        ret = mApi->getBatchSize();
-    }
-    return ret;
-}
-
-Return<bool> GnssBatching::start(const IGnssBatching::Options& options) {
-    bool ret = false;
-    if (mApi == nullptr) {
-        LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
-    } else {
-        ret = mApi->startSession(options);
-    }
-    return ret;
-}
-
-Return<void> GnssBatching::flush() {
-    if (mApi == nullptr) {
-        LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
-    } else {
-        mApi->flushBatchedLocations();
-    }
-    return Void();
-}
-
-Return<bool> GnssBatching::stop() {
-    bool ret = false;
-    if (mApi == nullptr) {
-        LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
-    } else {
-        ret = mApi->stopSession();
-    }
-    return ret;
-}
-
-Return<void> GnssBatching::cleanup() {
-    if (mApi != nullptr) {
-        mApi->stopSession();
-    }
-    if (mGnssBatchingCbIface != nullptr) {
-        mGnssBatchingCbIface->unlinkToDeath(mGnssBatchingDeathRecipient);
-        mGnssBatchingCbIface = nullptr;
-    }
-    if (mGnssBatchingCbIface_2_0 != nullptr) {
-        mGnssBatchingCbIface_2_0->unlinkToDeath(mGnssBatchingDeathRecipient);
-        mGnssBatchingCbIface_2_0 = nullptr;
-    }
-    return Void();
-}
-
-// Methods from ::android::hardware::gnss::V2_0::IGnssBatching follow.
-Return<bool> GnssBatching::init_2_0(const sp<V2_0::IGnssBatchingCallback>& callback) {
-    if (mApi != nullptr) {
-        LOC_LOGD("%s]: mApi is NOT nullptr, delete it first", __FUNCTION__);
-        mApi->destroy();
-        mApi = nullptr;
-    }
-
-    mApi = new BatchingAPIClient(callback);
-    if (mApi == nullptr) {
-        LOC_LOGE("%s]: failed to create mApi", __FUNCTION__);
-        return false;
-    }
-
-    if (mGnssBatchingCbIface_2_0 != nullptr) {
-        mGnssBatchingCbIface_2_0->unlinkToDeath(mGnssBatchingDeathRecipient);
-    }
-    mGnssBatchingCbIface_2_0 = callback;
-    if (mGnssBatchingCbIface_2_0 != nullptr) {
-        mGnssBatchingCbIface_2_0->linkToDeath(mGnssBatchingDeathRecipient, 0 /*cookie*/);
-    }
-
-    return true;
-}
-
-}  // namespace implementation
-}  // namespace V2_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
diff --git a/gps/android/2.0/GnssBatching.h b/gps/android/2.0/GnssBatching.h
deleted file mode 100644
index 4c8d1db..0000000
--- a/gps/android/2.0/GnssBatching.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-#ifndef ANDROID_HARDWARE_GNSS_V2_0_GNSSBATCHING_H
-#define ANDROID_HARDWARE_GNSS_V2_0_GNSSBATCHING_H
-
-#include <android/hardware/gnss/2.0/IGnssBatching.h>
-#include <hidl/Status.h>
-
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V2_0 {
-namespace implementation {
-
-using ::android::hardware::gnss::V2_0::IGnssBatching;
-using ::android::hardware::gnss::V2_0::IGnssBatchingCallback;
-using ::android::hidl::base::V1_0::IBase;
-using ::android::hardware::hidl_array;
-using ::android::hardware::hidl_memory;
-using ::android::hardware::hidl_string;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::sp;
-
-class BatchingAPIClient;
-struct GnssBatching : public IGnssBatching {
-    GnssBatching();
-    ~GnssBatching();
-
-    // Methods from ::android::hardware::gnss::V1_0::IGnssBatching follow.
-    Return<bool> init(const sp<V1_0::IGnssBatchingCallback>& callback) override;
-    Return<uint16_t> getBatchSize() override;
-    Return<bool> start(const IGnssBatching::Options& options ) override;
-    Return<void> flush() override;
-    Return<bool> stop() override;
-    Return<void> cleanup() override;
-
-    // Methods from ::android::hardware::gnss::V2_0::IGnssBatching follow.
-    Return<bool> init_2_0(const sp<V2_0::IGnssBatchingCallback>& callback) override;
-
- private:
-    struct GnssBatchingDeathRecipient : hidl_death_recipient {
-        GnssBatchingDeathRecipient(sp<GnssBatching> gnssBatching) :
-            mGnssBatching(gnssBatching) {
-        }
-        ~GnssBatchingDeathRecipient() = default;
-        virtual void serviceDied(uint64_t cookie, const wp<IBase>& who) override;
-        sp<GnssBatching> mGnssBatching;
-    };
-
- private:
-    sp<GnssBatchingDeathRecipient> mGnssBatchingDeathRecipient = nullptr;
-    sp<V1_0::IGnssBatchingCallback> mGnssBatchingCbIface = nullptr;
-    BatchingAPIClient* mApi = nullptr;
-    sp<V2_0::IGnssBatchingCallback> mGnssBatchingCbIface_2_0 = nullptr;
-};
-
-}  // namespace implementation
-}  // namespace V2_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
-
-#endif  // ANDROID_HARDWARE_GNSS_V2_0_GNSSBATCHING_H
diff --git a/gps/android/2.0/GnssConfiguration.cpp b/gps/android/2.0/GnssConfiguration.cpp
deleted file mode 100644
index 55a70dc..0000000
--- a/gps/android/2.0/GnssConfiguration.cpp
+++ /dev/null
@@ -1,317 +0,0 @@
-/*
- * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-#define LOG_TAG "LocSvc_GnssConfigurationInterface"
-
-#include <log_util.h>
-#include "Gnss.h"
-#include "GnssConfiguration.h"
-#include "ContextBase.h"
-#include <android/hardware/gnss/1.0/types.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V2_0 {
-namespace implementation {
-
-using ::android::hardware::gnss::V1_0::GnssConstellationType;
-using namespace loc_core;
-
-GnssConfiguration::GnssConfiguration(Gnss* gnss) : mGnss(gnss) {
-}
-
-// Methods from ::android::hardware::gps::V1_0::IGnssConfiguration follow.
-Return<bool> GnssConfiguration::setSuplEs(bool enabled)  {
-    // deprecated function. Must return false to pass VTS
-    return false;
-}
-
-Return<bool> GnssConfiguration::setSuplVersion(uint32_t version)  {
-    if (mGnss == nullptr) {
-        LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__);
-        return false;
-    }
-
-    GnssConfig config;
-    memset(&config, 0, sizeof(GnssConfig));
-    config.size = sizeof(GnssConfig);
-    config.flags = GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT;
-    switch (version) {
-        case 0x00020004:
-            config.suplVersion = GNSS_CONFIG_SUPL_VERSION_2_0_4;
-            break;
-        case 0x00020002:
-            config.suplVersion = GNSS_CONFIG_SUPL_VERSION_2_0_2;
-            break;
-        case 0x00020000:
-            config.suplVersion = GNSS_CONFIG_SUPL_VERSION_2_0_0;
-            break;
-        case 0x00010000:
-            config.suplVersion = GNSS_CONFIG_SUPL_VERSION_1_0_0;
-            break;
-        default:
-            LOC_LOGE("%s]: invalid version: 0x%x.", __FUNCTION__, version);
-            return false;
-    }
-
-    return mGnss->updateConfiguration(config);
-}
-
-Return<bool> GnssConfiguration::setSuplMode(uint8_t mode)  {
-    if (mGnss == nullptr) {
-        LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__);
-        return false;
-    }
-
-    GnssConfig config;
-    memset(&config, 0, sizeof(GnssConfig));
-    config.size = sizeof(GnssConfig);
-    config.flags = GNSS_CONFIG_FLAGS_SUPL_MODE_BIT;
-    switch (mode) {
-        case 0:
-            config.suplModeMask = 0; // STANDALONE ONLY
-            break;
-        case 1:
-            config.suplModeMask = GNSS_CONFIG_SUPL_MODE_MSB_BIT;
-            break;
-        case 2:
-            config.suplModeMask = GNSS_CONFIG_SUPL_MODE_MSA_BIT;
-            break;
-        case 3:
-            config.suplModeMask = GNSS_CONFIG_SUPL_MODE_MSB_BIT | GNSS_CONFIG_SUPL_MODE_MSA_BIT;
-            break;
-        default:
-            LOC_LOGE("%s]: invalid mode: %d.", __FUNCTION__, mode);
-            return false;
-    }
-
-    return mGnss->updateConfiguration(config);
-}
-
-Return<bool> GnssConfiguration::setLppProfile(uint8_t lppProfileMask) {
-    if (mGnss == nullptr) {
-        LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__);
-        return false;
-    }
-
-    GnssConfig config = {};
-    config.size = sizeof(GnssConfig);
-    config.flags = GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT;
-    config.lppProfileMask = GNSS_CONFIG_LPP_PROFILE_RRLP_ON_LTE; //default
-
-    if (lppProfileMask & (1<<0)) {
-        config.lppProfileMask |= GNSS_CONFIG_LPP_PROFILE_USER_PLANE_BIT;
-    }
-    if (lppProfileMask & (1<<1)) {
-        config.lppProfileMask |= GNSS_CONFIG_LPP_PROFILE_CONTROL_PLANE_BIT;
-    }
-    if (lppProfileMask & (1<<2)) {
-        config.lppProfileMask |= GNSS_CONFIG_LPP_PROFILE_USER_PLANE_OVER_NR5G_SA_BIT;
-    }
-    if (lppProfileMask & (1<<3)) {
-        config.lppProfileMask |= GNSS_CONFIG_LPP_PROFILE_CONTROL_PLANE_OVER_NR5G_SA_BIT;
-    }
-
-    return mGnss->updateConfiguration(config);
-}
-
-Return<bool> GnssConfiguration::setGlonassPositioningProtocol(uint8_t protocol) {
-    if (mGnss == nullptr) {
-        LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__);
-        return false;
-    }
-
-    GnssConfig config;
-    memset(&config, 0, sizeof(GnssConfig));
-    config.size = sizeof(GnssConfig);
-
-    config.flags = GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT;
-    if (protocol & (1<<0)) {
-        config.aGlonassPositionProtocolMask |= GNSS_CONFIG_RRC_CONTROL_PLANE_BIT;
-    }
-    if (protocol & (1<<1)) {
-        config.aGlonassPositionProtocolMask |= GNSS_CONFIG_RRLP_USER_PLANE_BIT;
-    }
-    if (protocol & (1<<2)) {
-        config.aGlonassPositionProtocolMask |= GNSS_CONFIG_LLP_USER_PLANE_BIT;
-    }
-    if (protocol & (1<<3)) {
-        config.aGlonassPositionProtocolMask |= GNSS_CONFIG_LLP_CONTROL_PLANE_BIT;
-    }
-
-    return mGnss->updateConfiguration(config);
-}
-
-Return<bool> GnssConfiguration::setGpsLock(uint8_t lock) {
-
-    if (mGnss == nullptr) {
-        LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__);
-        return false;
-    }
-
-    GnssConfig config = {};
-    config.size = sizeof(GnssConfig);
-    config.flags = GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT;
-    switch (lock) {
-    case 0:
-        config.gpsLock = GNSS_CONFIG_GPS_LOCK_NONE;
-        break;
-    case 1:
-        config.gpsLock = GNSS_CONFIG_GPS_LOCK_MO;
-        break;
-    case 2:
-        config.gpsLock = GNSS_CONFIG_GPS_LOCK_NI;
-        break;
-    case 3:
-        config.gpsLock = GNSS_CONFIG_GPS_LOCK_MO_AND_NI;
-        break;
-    default:
-        LOC_LOGE("%s]: invalid lock: %d.", __FUNCTION__, lock);
-        return false;
-    }
-
-    mGnss->updateConfiguration(config);
-    // Must return false to pass VTS
-    return false;
-}
-
-Return<bool> GnssConfiguration::setEmergencySuplPdn(bool enabled) {
-    if (mGnss == nullptr) {
-        LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__);
-        return false;
-    }
-
-    GnssConfig config;
-    memset(&config, 0, sizeof(GnssConfig));
-    config.size = sizeof(GnssConfig);
-    config.flags = GNSS_CONFIG_FLAGS_EM_PDN_FOR_EM_SUPL_VALID_BIT;
-    config.emergencyPdnForEmergencySupl = (enabled ?
-            GNSS_CONFIG_EMERGENCY_PDN_FOR_EMERGENCY_SUPL_YES :
-            GNSS_CONFIG_EMERGENCY_PDN_FOR_EMERGENCY_SUPL_NO);
-
-    return mGnss->updateConfiguration(config);
-}
-
-// Methods from ::android::hardware::gnss::V1_1::IGnssConfiguration follow.
-Return<bool> GnssConfiguration::setBlacklist(
-            const hidl_vec<GnssConfiguration::BlacklistedSource>& blacklist) {
-
-    ENTRY_LOG_CALLFLOW();
-    if (nullptr == mGnss) {
-        LOC_LOGe("mGnss is null");
-        return false;
-    }
-
-    // blValid is true if blacklist is empty, i.e. clearing the BL;
-    // if blacklist is not empty, blValid is initialied to false, and later
-    // updated in the for loop to become true only if there is at least
-    // one {constellation, svid} in the list that is valid.
-    bool blValid = (0 == blacklist.size());
-    GnssConfig config;
-    memset(&config, 0, sizeof(GnssConfig));
-    config.size = sizeof(GnssConfig);
-    config.flags = GNSS_CONFIG_FLAGS_BLACKLISTED_SV_IDS_BIT;
-    config.blacklistedSvIds.clear();
-
-    GnssSvIdSource source = {};
-    for (int idx = 0; idx < (int)blacklist.size(); idx++) {
-        // Set blValid true if any one source is valid
-        blValid = setBlacklistedSource(source, blacklist[idx]) || blValid;
-        config.blacklistedSvIds.push_back(source);
-    }
-
-    // Update configuration only if blValid is true
-    // i.e. only if atleast one source is valid for blacklisting
-    return (blValid && mGnss->updateConfiguration(config));
-}
-
-bool GnssConfiguration::setBlacklistedSource(
-        GnssSvIdSource& copyToSource,
-        const GnssConfiguration::BlacklistedSource& copyFromSource) {
-
-    bool retVal = true;
-    uint16_t svIdOffset = 0;
-    copyToSource.size = sizeof(GnssSvIdSource);
-    copyToSource.svId = copyFromSource.svid;
-
-    switch(copyFromSource.constellation) {
-    case GnssConstellationType::GPS:
-        copyToSource.constellation = GNSS_SV_TYPE_GPS;
-        LOC_LOGe("GPS SVs can't be blacklisted.");
-        retVal = false;
-        break;
-    case GnssConstellationType::SBAS:
-        copyToSource.constellation = GNSS_SV_TYPE_SBAS;
-        LOC_LOGe("SBAS SVs can't be blacklisted.");
-        retVal = false;
-        break;
-    case GnssConstellationType::GLONASS:
-        copyToSource.constellation = GNSS_SV_TYPE_GLONASS;
-        svIdOffset = GNSS_SV_CONFIG_GLO_INITIAL_SV_ID - 1;
-        break;
-    case GnssConstellationType::QZSS:
-        copyToSource.constellation = GNSS_SV_TYPE_QZSS;
-        svIdOffset = 0;
-        break;
-    case GnssConstellationType::BEIDOU:
-        copyToSource.constellation = GNSS_SV_TYPE_BEIDOU;
-        svIdOffset = GNSS_SV_CONFIG_BDS_INITIAL_SV_ID - 1;
-        break;
-    case GnssConstellationType::GALILEO:
-        copyToSource.constellation = GNSS_SV_TYPE_GALILEO;
-        svIdOffset = GNSS_SV_CONFIG_GAL_INITIAL_SV_ID - 1;
-        break;
-    default:
-        copyToSource.constellation = GNSS_SV_TYPE_UNKNOWN;
-        LOC_LOGe("Invalid constellation %hhu", copyFromSource.constellation);
-        retVal = false;
-        break;
-    }
-
-    if (copyToSource.svId > 0 && svIdOffset > 0) {
-        copyToSource.svId += svIdOffset;
-    }
-
-    return retVal;
-}
-
-// Methods from ::android::hardware::gnss::V2_0::IGnssConfiguration follow.
-Return<bool> GnssConfiguration::setEsExtensionSec(uint32_t emergencyExtensionSeconds) {
-    ENTRY_LOG_CALLFLOW();
-    if (mGnss == nullptr) {
-        LOC_LOGe("mGnss is nullptr");
-        return false;
-    }
-
-    GnssConfig config;
-    memset(&config, 0, sizeof(GnssConfig));
-    config.size = sizeof(GnssConfig);
-    config.flags = GNSS_CONFIG_FLAGS_EMERGENCY_EXTENSION_SECONDS_BIT;
-    config.emergencyExtensionSeconds = emergencyExtensionSeconds;
-
-    return mGnss->updateConfiguration(config);
-}
-
-}  // namespace implementation
-}  // namespace V2_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
diff --git a/gps/android/2.0/GnssConfiguration.h b/gps/android/2.0/GnssConfiguration.h
deleted file mode 100644
index c3de2c9..0000000
--- a/gps/android/2.0/GnssConfiguration.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-
- /* 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.
- */
-
-
-#ifndef ANDROID_HARDWARE_GNSS_V2_0_GNSSCONFIGURATION_H
-#define ANDROID_HARDWARE_GNSS_V2_0_GNSSCONFIGURATION_H
-
-#include <android/hardware/gnss/2.0/IGnssConfiguration.h>
-#include <hidl/Status.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V2_0 {
-namespace implementation {
-
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::sp;
-
-/*
- * Interface for passing GNSS configuration info from platform to HAL.
- */
-struct Gnss;
-struct GnssConfiguration : public V2_0::IGnssConfiguration {
-    GnssConfiguration(Gnss* gnss);
-    ~GnssConfiguration() = default;
-
-    /*
-     * Methods from ::android::hardware::gnss::V1_0::IGnssConfiguration follow.
-     * These declarations were generated from IGnssConfiguration.hal.
-     */
-    Return<bool> setSuplVersion(uint32_t version) override;
-    Return<bool> setSuplMode(uint8_t mode) override;
-    Return<bool> setSuplEs(bool enabled) override;
-    Return<bool> setLppProfile(uint8_t lppProfileMask) override;
-    Return<bool> setGlonassPositioningProtocol(uint8_t protocol) override;
-    Return<bool> setEmergencySuplPdn(bool enable) override;
-    Return<bool> setGpsLock(uint8_t lock) override;
-
-    // Methods from ::android::hardware::gnss::V1_1::IGnssConfiguration follow.
-    Return<bool> setBlacklist(
-            const hidl_vec<GnssConfiguration::BlacklistedSource>& blacklist) override;
-
-    // Methods from ::android::hardware::gnss::V2_0::IGnssConfiguration follow.
-    Return<bool> setEsExtensionSec(uint32_t emergencyExtensionSeconds) override;
-
- private:
-    Gnss* mGnss = nullptr;
-    bool setBlacklistedSource(
-            GnssSvIdSource& copyToSource,
-            const GnssConfiguration::BlacklistedSource& copyFromSource);
-};
-
-}  // namespace implementation
-}  // namespace V2_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
-
-#endif  // ANDROID_HARDWARE_GNSS_V2_0_GNSSCONFIGURATION_H
diff --git a/gps/android/2.0/GnssDebug.cpp b/gps/android/2.0/GnssDebug.cpp
deleted file mode 100644
index dc0d9f4..0000000
--- a/gps/android/2.0/GnssDebug.cpp
+++ /dev/null
@@ -1,299 +0,0 @@
-/*
- * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-#define LOG_TAG "LocSvc_GnssDebugInterface"
-
-#include <log/log.h>
-#include <log_util.h>
-#include "Gnss.h"
-#include "GnssDebug.h"
-#include "LocationUtil.h"
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V2_0 {
-namespace implementation {
-
-using ::android::hardware::hidl_vec;
-using ::android::hardware::gnss::V2_0::IGnssDebug;
-
-#define GNSS_DEBUG_UNKNOWN_HORIZONTAL_ACCURACY_METERS (20000000)
-#define GNSS_DEBUG_UNKNOWN_VERTICAL_ACCURACY_METERS   (20000)
-#define GNSS_DEBUG_UNKNOWN_SPEED_ACCURACY_PER_SEC     (500)
-#define GNSS_DEBUG_UNKNOWN_BEARING_ACCURACY_DEG       (180)
-
-#define GNSS_DEBUG_UNKNOWN_UTC_TIME            (1483228800000LL) // 1/1/2017 00:00 GMT
-#define GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC_MIN    (999) // 999 ns
-#define GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC_MAX    (1.57783680E17) // 5 years in ns
-#define GNSS_DEBUG_UNKNOWN_FREQ_UNC_NS_PER_SEC (2.0e5)  // ppm
-
-GnssDebug::GnssDebug(Gnss* gnss) : mGnss(gnss)
-{
-}
-
-/*
- * This methods requests position, time and satellite ephemeris debug information
- * from the HAL.
- *
- * @return void
-*/
-Return<void> GnssDebug::getDebugData(getDebugData_cb _hidl_cb)
-{
-    LOC_LOGD("%s]: ", __func__);
-
-    V1_0::IGnssDebug::DebugData data = { };
-
-    if((nullptr == mGnss) || (nullptr == mGnss->getGnssInterface())){
-        LOC_LOGE("GnssDebug - Null GNSS interface");
-        _hidl_cb(data);
-        return Void();
-    }
-
-    // get debug report snapshot via hal interface
-    GnssDebugReport reports = { };
-    mGnss->getGnssInterface()->getDebugReport(reports);
-
-    // location block
-    if (reports.mLocation.mValid) {
-        data.position.valid = true;
-        data.position.latitudeDegrees = reports.mLocation.mLocation.latitude;
-        data.position.longitudeDegrees = reports.mLocation.mLocation.longitude;
-        data.position.altitudeMeters = reports.mLocation.mLocation.altitude;
-
-        data.position.speedMetersPerSec =
-            (double)(reports.mLocation.mLocation.speed);
-        data.position.bearingDegrees =
-            (double)(reports.mLocation.mLocation.bearing);
-        data.position.horizontalAccuracyMeters =
-            (double)(reports.mLocation.mLocation.accuracy);
-        data.position.verticalAccuracyMeters =
-            reports.mLocation.verticalAccuracyMeters;
-        data.position.speedAccuracyMetersPerSecond =
-            reports.mLocation.speedAccuracyMetersPerSecond;
-        data.position.bearingAccuracyDegrees =
-            reports.mLocation.bearingAccuracyDegrees;
-
-        timeval tv_now, tv_report;
-        tv_report.tv_sec  = reports.mLocation.mUtcReported.tv_sec;
-        tv_report.tv_usec = reports.mLocation.mUtcReported.tv_nsec / 1000ULL;
-        gettimeofday(&tv_now, NULL);
-        data.position.ageSeconds =
-            (tv_now.tv_sec - tv_report.tv_sec) +
-            (float)((tv_now.tv_usec - tv_report.tv_usec)) / 1000000;
-    }
-    else {
-        data.position.valid = false;
-    }
-
-    if (data.position.horizontalAccuracyMeters <= 0 ||
-        data.position.horizontalAccuracyMeters > GNSS_DEBUG_UNKNOWN_HORIZONTAL_ACCURACY_METERS) {
-        data.position.horizontalAccuracyMeters = GNSS_DEBUG_UNKNOWN_HORIZONTAL_ACCURACY_METERS;
-    }
-    if (data.position.verticalAccuracyMeters <= 0 ||
-        data.position.verticalAccuracyMeters > GNSS_DEBUG_UNKNOWN_VERTICAL_ACCURACY_METERS) {
-        data.position.verticalAccuracyMeters = GNSS_DEBUG_UNKNOWN_VERTICAL_ACCURACY_METERS;
-    }
-    if (data.position.speedAccuracyMetersPerSecond <= 0 ||
-        data.position.speedAccuracyMetersPerSecond > GNSS_DEBUG_UNKNOWN_SPEED_ACCURACY_PER_SEC) {
-        data.position.speedAccuracyMetersPerSecond = GNSS_DEBUG_UNKNOWN_SPEED_ACCURACY_PER_SEC;
-    }
-    if (data.position.bearingAccuracyDegrees <= 0 ||
-        data.position.bearingAccuracyDegrees > GNSS_DEBUG_UNKNOWN_BEARING_ACCURACY_DEG) {
-        data.position.bearingAccuracyDegrees = GNSS_DEBUG_UNKNOWN_BEARING_ACCURACY_DEG;
-    }
-
-    // time block
-    if (reports.mTime.mValid) {
-        data.time.timeEstimate = reports.mTime.timeEstimate;
-        data.time.timeUncertaintyNs = reports.mTime.timeUncertaintyNs;
-        data.time.frequencyUncertaintyNsPerSec =
-            reports.mTime.frequencyUncertaintyNsPerSec;
-    }
-
-    if (data.time.timeEstimate < GNSS_DEBUG_UNKNOWN_UTC_TIME) {
-        data.time.timeEstimate = GNSS_DEBUG_UNKNOWN_UTC_TIME;
-    }
-    if (data.time.timeUncertaintyNs <= 0) {
-        data.time.timeUncertaintyNs = (float)GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC_MIN;
-    } else if (data.time.timeUncertaintyNs > GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC_MAX) {
-        data.time.timeUncertaintyNs = (float)GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC_MAX;
-    }
-    if (data.time.frequencyUncertaintyNsPerSec <= 0 ||
-        data.time.frequencyUncertaintyNsPerSec > (float)GNSS_DEBUG_UNKNOWN_FREQ_UNC_NS_PER_SEC) {
-        data.time.frequencyUncertaintyNsPerSec = (float)GNSS_DEBUG_UNKNOWN_FREQ_UNC_NS_PER_SEC;
-    }
-
-    // satellite data block
-    V1_0::IGnssDebug::SatelliteData s = { };
-    std::vector<V1_0::IGnssDebug::SatelliteData> s_array;
-
-    for (uint32_t i=0; i<reports.mSatelliteInfo.size(); i++) {
-        memset(&s, 0, sizeof(s));
-        s.svid = reports.mSatelliteInfo[i].svid;
-        convertGnssConstellationType(
-            reports.mSatelliteInfo[i].constellation, s.constellation);
-        convertGnssEphemerisType(
-            reports.mSatelliteInfo[i].mEphemerisType, s.ephemerisType);
-        convertGnssEphemerisSource(
-            reports.mSatelliteInfo[i].mEphemerisSource, s.ephemerisSource);
-        convertGnssEphemerisHealth(
-            reports.mSatelliteInfo[i].mEphemerisHealth, s.ephemerisHealth);
-
-        s.ephemerisAgeSeconds =
-            reports.mSatelliteInfo[i].ephemerisAgeSeconds;
-        s.serverPredictionIsAvailable =
-            reports.mSatelliteInfo[i].serverPredictionIsAvailable;
-        s.serverPredictionAgeSeconds =
-            reports.mSatelliteInfo[i].serverPredictionAgeSeconds;
-
-        s_array.push_back(s);
-    }
-    data.satelliteDataArray = s_array;
-
-    // callback HIDL with collected debug data
-    _hidl_cb(data);
-    return Void();
-}
-
-Return<void> GnssDebug::getDebugData_2_0(getDebugData_2_0_cb _hidl_cb)
-{
-    LOC_LOGD("%s]: ", __func__);
-
-    V2_0::IGnssDebug::DebugData data = { };
-
-    if((nullptr == mGnss) || (nullptr == mGnss->getGnssInterface())){
-        LOC_LOGE("GnssDebug - Null GNSS interface");
-        _hidl_cb(data);
-        return Void();
-    }
-
-    // get debug report snapshot via hal interface
-    GnssDebugReport reports = { };
-    mGnss->getGnssInterface()->getDebugReport(reports);
-
-    // location block
-    if (reports.mLocation.mValid) {
-        data.position.valid = true;
-        data.position.latitudeDegrees = reports.mLocation.mLocation.latitude;
-        data.position.longitudeDegrees = reports.mLocation.mLocation.longitude;
-        data.position.altitudeMeters = reports.mLocation.mLocation.altitude;
-
-        data.position.speedMetersPerSec =
-            (double)(reports.mLocation.mLocation.speed);
-        data.position.bearingDegrees =
-            (double)(reports.mLocation.mLocation.bearing);
-        data.position.horizontalAccuracyMeters =
-            (double)(reports.mLocation.mLocation.accuracy);
-        data.position.verticalAccuracyMeters =
-            reports.mLocation.verticalAccuracyMeters;
-        data.position.speedAccuracyMetersPerSecond =
-            reports.mLocation.speedAccuracyMetersPerSecond;
-        data.position.bearingAccuracyDegrees =
-            reports.mLocation.bearingAccuracyDegrees;
-
-        timeval tv_now, tv_report;
-        tv_report.tv_sec  = reports.mLocation.mUtcReported.tv_sec;
-        tv_report.tv_usec = reports.mLocation.mUtcReported.tv_nsec / 1000ULL;
-        gettimeofday(&tv_now, NULL);
-        data.position.ageSeconds =
-            (tv_now.tv_sec - tv_report.tv_sec) +
-            (float)((tv_now.tv_usec - tv_report.tv_usec)) / 1000000;
-    }
-    else {
-        data.position.valid = false;
-    }
-
-    if (data.position.horizontalAccuracyMeters <= 0 ||
-        data.position.horizontalAccuracyMeters > GNSS_DEBUG_UNKNOWN_HORIZONTAL_ACCURACY_METERS) {
-        data.position.horizontalAccuracyMeters = GNSS_DEBUG_UNKNOWN_HORIZONTAL_ACCURACY_METERS;
-    }
-    if (data.position.verticalAccuracyMeters <= 0 ||
-        data.position.verticalAccuracyMeters > GNSS_DEBUG_UNKNOWN_VERTICAL_ACCURACY_METERS) {
-        data.position.verticalAccuracyMeters = GNSS_DEBUG_UNKNOWN_VERTICAL_ACCURACY_METERS;
-    }
-    if (data.position.speedAccuracyMetersPerSecond <= 0 ||
-        data.position.speedAccuracyMetersPerSecond > GNSS_DEBUG_UNKNOWN_SPEED_ACCURACY_PER_SEC) {
-        data.position.speedAccuracyMetersPerSecond = GNSS_DEBUG_UNKNOWN_SPEED_ACCURACY_PER_SEC;
-    }
-    if (data.position.bearingAccuracyDegrees <= 0 ||
-        data.position.bearingAccuracyDegrees > GNSS_DEBUG_UNKNOWN_BEARING_ACCURACY_DEG) {
-        data.position.bearingAccuracyDegrees = GNSS_DEBUG_UNKNOWN_BEARING_ACCURACY_DEG;
-    }
-
-    // time block
-    if (reports.mTime.mValid) {
-        data.time.timeEstimate = reports.mTime.timeEstimate;
-        data.time.timeUncertaintyNs = reports.mTime.timeUncertaintyNs;
-        data.time.frequencyUncertaintyNsPerSec =
-            reports.mTime.frequencyUncertaintyNsPerSec;
-    }
-
-    if (data.time.timeEstimate < GNSS_DEBUG_UNKNOWN_UTC_TIME) {
-        data.time.timeEstimate = GNSS_DEBUG_UNKNOWN_UTC_TIME;
-    }
-    if (data.time.timeUncertaintyNs <= 0) {
-        data.time.timeUncertaintyNs = (float)GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC_MIN;
-    }
-    else if (data.time.timeUncertaintyNs > GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC_MAX) {
-        data.time.timeUncertaintyNs = (float)GNSS_DEBUG_UNKNOWN_UTC_TIME_UNC_MAX;
-    }
-    if (data.time.frequencyUncertaintyNsPerSec <= 0 ||
-        data.time.frequencyUncertaintyNsPerSec > (float)GNSS_DEBUG_UNKNOWN_FREQ_UNC_NS_PER_SEC) {
-        data.time.frequencyUncertaintyNsPerSec = (float)GNSS_DEBUG_UNKNOWN_FREQ_UNC_NS_PER_SEC;
-    }
-
-    // satellite data block
-    V2_0::IGnssDebug::SatelliteData s = { };
-    std::vector<V2_0::IGnssDebug::SatelliteData> s_array;
-
-    for (uint32_t i=0; i<reports.mSatelliteInfo.size(); i++) {
-        memset(&s, 0, sizeof(s));
-        s.v1_0.svid = reports.mSatelliteInfo[i].svid;
-        convertGnssConstellationType(
-            reports.mSatelliteInfo[i].constellation, s.constellation);
-        convertGnssEphemerisType(
-            reports.mSatelliteInfo[i].mEphemerisType, s.v1_0.ephemerisType);
-        convertGnssEphemerisSource(
-            reports.mSatelliteInfo[i].mEphemerisSource, s.v1_0.ephemerisSource);
-        convertGnssEphemerisHealth(
-            reports.mSatelliteInfo[i].mEphemerisHealth, s.v1_0.ephemerisHealth);
-
-        s.v1_0.ephemerisAgeSeconds =
-            reports.mSatelliteInfo[i].ephemerisAgeSeconds;
-        s.v1_0.serverPredictionIsAvailable =
-            reports.mSatelliteInfo[i].serverPredictionIsAvailable;
-        s.v1_0.serverPredictionAgeSeconds =
-            reports.mSatelliteInfo[i].serverPredictionAgeSeconds;
-
-        s_array.push_back(s);
-    }
-    data.satelliteDataArray = s_array;
-
-    // callback HIDL with collected debug data
-    _hidl_cb(data);
-    return Void();
-}
-
-}  // namespace implementation
-}  // namespace V2_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
diff --git a/gps/android/2.0/GnssDebug.h b/gps/android/2.0/GnssDebug.h
deleted file mode 100644
index 8d75bea..0000000
--- a/gps/android/2.0/GnssDebug.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-#ifndef ANDROID_HARDWARE_GNSS_V2_0_GNSSDEBUG_H
-#define ANDROID_HARDWARE_GNSS_V2_0_GNSSDEBUG_H
-
-
-#include <android/hardware/gnss/2.0/IGnssDebug.h>
-#include <hidl/Status.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V2_0 {
-namespace implementation {
-
-using ::android::hardware::gnss::V2_0::IGnssDebug;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::sp;
-
-/* Interface for GNSS Debug support. */
-struct Gnss;
-struct GnssDebug : public IGnssDebug {
-    GnssDebug(Gnss* gnss);
-    ~GnssDebug() {};
-
-    //  Methods from ::android::hardware::gnss::V1_0::IGnssDebug follow
-    Return<void> getDebugData(getDebugData_cb _hidl_cb) override;
-    //  Methods from ::android::hardware::gnss::V2_0::IGnssDebug follow.
-    Return<void> getDebugData_2_0(getDebugData_2_0_cb _hidl_cb) override;
-
-private:
-    Gnss* mGnss = nullptr;
-};
-
-}  // namespace implementation
-}  // namespace V2_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
-
-#endif  // ANDROID_HARDWARE_GNSS_V2_0_GNSSDEBUG_H
diff --git a/gps/android/2.0/GnssGeofencing.cpp b/gps/android/2.0/GnssGeofencing.cpp
deleted file mode 100644
index b6fc94b..0000000
--- a/gps/android/2.0/GnssGeofencing.cpp
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-#define LOG_TAG "GnssHal_GnssGeofencing"
-
-#include <log_util.h>
-#include <GeofenceAPIClient.h>
-#include "GnssGeofencing.h"
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V2_0 {
-namespace implementation {
-
-void GnssGeofencing::GnssGeofencingDeathRecipient::serviceDied(
-        uint64_t cookie, const wp<IBase>& who) {
-    LOC_LOGE("%s] service died. cookie: %llu, who: %p",
-            __FUNCTION__, static_cast<unsigned long long>(cookie), &who);
-    if (mGnssGeofencing != nullptr) {
-        mGnssGeofencing->removeAllGeofences();
-    }
-}
-
-GnssGeofencing::GnssGeofencing() : mApi(nullptr) {
-    mGnssGeofencingDeathRecipient = new GnssGeofencingDeathRecipient(this);
-}
-
-GnssGeofencing::~GnssGeofencing() {
-    if (mApi != nullptr) {
-        mApi->destroy();
-        mApi = nullptr;
-    }
-}
-
-// Methods from ::android::hardware::gnss::V1_0::IGnssGeofencing follow.
-Return<void> GnssGeofencing::setCallback(const sp<IGnssGeofenceCallback>& callback)  {
-    if (mApi != nullptr) {
-        LOC_LOGd("mApi is NOT nullptr");
-        return Void();
-    }
-
-    mApi = new GeofenceAPIClient(callback);
-    if (mApi == nullptr) {
-        LOC_LOGE("%s]: failed to create mApi", __FUNCTION__);
-    }
-
-    if (mGnssGeofencingCbIface != nullptr) {
-        mGnssGeofencingCbIface->unlinkToDeath(mGnssGeofencingDeathRecipient);
-    }
-    mGnssGeofencingCbIface = callback;
-    if (mGnssGeofencingCbIface != nullptr) {
-        mGnssGeofencingCbIface->linkToDeath(mGnssGeofencingDeathRecipient, 0 /*cookie*/);
-    }
-
-    return Void();
-}
-
-Return<void> GnssGeofencing::addGeofence(
-        int32_t geofenceId,
-        double latitudeDegrees,
-        double longitudeDegrees,
-        double radiusMeters,
-        IGnssGeofenceCallback::GeofenceTransition lastTransition,
-        int32_t monitorTransitions,
-        uint32_t notificationResponsivenessMs,
-        uint32_t unknownTimerMs)  {
-    if (mApi == nullptr) {
-        LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
-    } else {
-        mApi->geofenceAdd(
-                geofenceId,
-                latitudeDegrees,
-                longitudeDegrees,
-                radiusMeters,
-                static_cast<int32_t>(lastTransition),
-                monitorTransitions,
-                notificationResponsivenessMs,
-                unknownTimerMs);
-    }
-    return Void();
-}
-
-Return<void> GnssGeofencing::pauseGeofence(int32_t geofenceId)  {
-    if (mApi == nullptr) {
-        LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
-    } else {
-        mApi->geofencePause(geofenceId);
-    }
-    return Void();
-}
-
-Return<void> GnssGeofencing::resumeGeofence(int32_t geofenceId, int32_t monitorTransitions)  {
-    if (mApi == nullptr) {
-        LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
-    } else {
-        mApi->geofenceResume(geofenceId, monitorTransitions);
-    }
-    return Void();
-}
-
-Return<void> GnssGeofencing::removeGeofence(int32_t geofenceId)  {
-    if (mApi == nullptr) {
-        LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
-    } else {
-        mApi->geofenceRemove(geofenceId);
-    }
-    return Void();
-}
-
-Return<void> GnssGeofencing::removeAllGeofences()  {
-    if (mApi == nullptr) {
-        LOC_LOGD("%s]: mApi is nullptr, do nothing", __FUNCTION__);
-    } else {
-        mApi->geofenceRemoveAll();
-    }
-    return Void();
-}
-
-}  // namespace implementation
-}  // namespace V2_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
diff --git a/gps/android/2.0/GnssGeofencing.h b/gps/android/2.0/GnssGeofencing.h
deleted file mode 100644
index caa56d0..0000000
--- a/gps/android/2.0/GnssGeofencing.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-#ifndef ANDROID_HARDWARE_GNSS_V2_0_GNSSGEOFENCING_H
-#define ANDROID_HARDWARE_GNSS_V2_0_GNSSGEOFENCING_H
-
-#include <android/hardware/gnss/1.0/IGnssGeofencing.h>
-#include <hidl/Status.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V2_0 {
-namespace implementation {
-
-using ::android::hardware::gnss::V1_0::IGnssGeofenceCallback;
-using ::android::hardware::gnss::V1_0::IGnssGeofencing;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::sp;
-
-class GeofenceAPIClient;
-struct GnssGeofencing : public IGnssGeofencing {
-    GnssGeofencing();
-    ~GnssGeofencing();
-
-    /*
-     * Methods from ::android::hardware::gnss::V1_0::IGnssGeofencing follow.
-     * These declarations were generated from IGnssGeofencing.hal.
-     */
-    Return<void> setCallback(const sp<IGnssGeofenceCallback>& callback)  override;
-    Return<void> addGeofence(int32_t geofenceId,
-                             double latitudeDegrees,
-                             double longitudeDegrees,
-                             double radiusMeters,
-                             IGnssGeofenceCallback::GeofenceTransition lastTransition,
-                             int32_t monitorTransitions,
-                             uint32_t notificationResponsivenessMs,
-                             uint32_t unknownTimerMs)  override;
-
-    Return<void> pauseGeofence(int32_t geofenceId)  override;
-    Return<void> resumeGeofence(int32_t geofenceId, int32_t monitorTransitions)  override;
-    Return<void> removeGeofence(int32_t geofenceId)  override;
-
- private:
-    // This method is not part of the IGnss base class.
-    // It is called by GnssGeofencingDeathRecipient to remove all geofences added so far.
-    Return<void> removeAllGeofences();
-
- private:
-    struct GnssGeofencingDeathRecipient : hidl_death_recipient {
-        GnssGeofencingDeathRecipient(sp<GnssGeofencing> gnssGeofencing) :
-            mGnssGeofencing(gnssGeofencing) {
-        }
-        ~GnssGeofencingDeathRecipient() = default;
-        virtual void serviceDied(uint64_t cookie, const wp<IBase>& who) override;
-        sp<GnssGeofencing> mGnssGeofencing;
-    };
-
- private:
-    sp<GnssGeofencingDeathRecipient> mGnssGeofencingDeathRecipient = nullptr;
-    sp<IGnssGeofenceCallback> mGnssGeofencingCbIface = nullptr;
-    GeofenceAPIClient* mApi = nullptr;
-};
-
-}  // namespace implementation
-}  // namespace V2_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
-
-#endif  // ANDROID_HARDWARE_GNSS_V2_0_GNSSGEOFENCING_H
diff --git a/gps/android/2.0/GnssMeasurement.cpp b/gps/android/2.0/GnssMeasurement.cpp
deleted file mode 100644
index 3a93a3c..0000000
--- a/gps/android/2.0/GnssMeasurement.cpp
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-/* ​​​​​Changes from Qualcomm Innovation Center are provided under the following license:
- * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
- * SPDX-License-Identifier: BSD-3-Clause-Clear
- */
-
-#define LOG_TAG "LocSvc_GnssMeasurementInterface"
-
-#include <log_util.h>
-#include "GnssMeasurement.h"
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V2_0 {
-namespace implementation {
-
-void GnssMeasurement::GnssMeasurementDeathRecipient::serviceDied(
-        uint64_t cookie, const wp<IBase>& who) {
-    LOC_LOGE("%s] service died. cookie: %llu, who: %p",
-            __FUNCTION__, static_cast<unsigned long long>(cookie), &who);
-    if (mGnssMeasurement != nullptr) {
-        mGnssMeasurement->close();
-    }
-}
-
-GnssMeasurement::GnssMeasurement() {
-    mGnssMeasurementDeathRecipient = new GnssMeasurementDeathRecipient(this);
-    mApi = new MeasurementAPIClient();
-}
-
-GnssMeasurement::~GnssMeasurement() {
-    if (mApi) {
-        mApi->destroy();
-        mApi = nullptr;
-    }
-}
-
-// Methods from ::android::hardware::gnss::V1_0::IGnssMeasurement follow.
-Return<GnssMeasurement::GnssMeasurementStatus> GnssMeasurement::setCallback(
-        const sp<V1_0::IGnssMeasurementCallback>& callback)  {
-    return setCallback(callback, mGnssMeasurementCbIface, GNSS_POWER_MODE_INVALID);
-}
-
-template <typename T>
-Return<IGnssMeasurement::GnssMeasurementStatus> GnssMeasurement::setCallback(
-        const sp<T>& callback, sp<T>& myCallback, GnssPowerMode powerMode) {
-    Return<GnssMeasurement::GnssMeasurementStatus> ret =
-            IGnssMeasurement::GnssMeasurementStatus::ERROR_GENERIC;
-    if (mApi == nullptr) {
-        LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
-        return ret;
-    }
-    if (myCallback != callback) {
-        if (nullptr == callback) {
-            LOC_LOGE("%s]: callback is nullptr", __FUNCTION__);
-            mApi->measurementSetCallback(callback);
-            close();
-        } else {
-            if (nullptr != myCallback) {
-                myCallback->unlinkToDeath(mGnssMeasurementDeathRecipient);
-            }
-            myCallback = callback;
-            myCallback->linkToDeath(mGnssMeasurementDeathRecipient, 0);
-            ret = mApi->measurementSetCallback(callback, powerMode);
-        }
-    }
-
-    return ret;
-}
-
-void GnssMeasurement::clearInterfaces() {
-    if (mApi != nullptr) {
-        mApi->measurementSetCallback<V1_0::IGnssMeasurementCallback>(nullptr);
-        mApi->measurementSetCallback<V1_1::IGnssMeasurementCallback>(nullptr);
-        mApi->measurementSetCallback<V2_0::IGnssMeasurementCallback>(nullptr);
-    if (mGnssMeasurementCbIface != nullptr) {
-        mGnssMeasurementCbIface->unlinkToDeath(mGnssMeasurementDeathRecipient);
-        mGnssMeasurementCbIface = nullptr;
-    }
-    if (mGnssMeasurementCbIface_1_1 != nullptr) {
-        mGnssMeasurementCbIface_1_1->unlinkToDeath(mGnssMeasurementDeathRecipient);
-        mGnssMeasurementCbIface_1_1 = nullptr;
-    }
-    if (mGnssMeasurementCbIface_2_0 != nullptr) {
-        mGnssMeasurementCbIface_2_0->unlinkToDeath(mGnssMeasurementDeathRecipient);
-        mGnssMeasurementCbIface_2_0 = nullptr;
-    }
-}
-
-Return<void> GnssMeasurement::close()  {
-    if (mApi == nullptr) {
-        LOC_LOGE("%s]: mApi is nullptr", __FUNCTION__);
-        return Void();
-    }
-
-    clearInterfaces();
-    mApi->measurementClose();
-
-    return Void();
-}
-
-// Methods from ::android::hardware::gnss::V1_1::IGnssMeasurement follow.
-Return<GnssMeasurement::GnssMeasurementStatus> GnssMeasurement::setCallback_1_1(
-        const sp<V1_1::IGnssMeasurementCallback>& callback, bool enableFullTracking) {
-    return setCallback(callback, mGnssMeasurementCbIface_1_1,
-                       enableFullTracking ? GNSS_POWER_MODE_M1 : GNSS_POWER_MODE_M2);
-}
-// Methods from ::android::hardware::gnss::V2_0::IGnssMeasurement follow.
-Return<V1_0::IGnssMeasurement::GnssMeasurementStatus> GnssMeasurement::setCallback_2_0(
-        const sp<V2_0::IGnssMeasurementCallback>& callback,
-        bool enableFullTracking) {
-    return setCallback(callback, mGnssMeasurementCbIface_2_0,
-                       enableFullTracking ? GNSS_POWER_MODE_M1 : GNSS_POWER_MODE_M2);
-}
-
-}  // namespace implementation
-}  // namespace V2_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
diff --git a/gps/android/2.0/GnssMeasurement.h b/gps/android/2.0/GnssMeasurement.h
deleted file mode 100644
index 35c20d9..0000000
--- a/gps/android/2.0/GnssMeasurement.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-/* ​​​​​Changes from Qualcomm Innovation Center are provided under the following license:
- * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
- * SPDX-License-Identifier: BSD-3-Clause-Clear
- */
-
-#ifndef ANDROID_HARDWARE_GNSS_V2_0_GNSSMEASUREMENT_H
-#define ANDROID_HARDWARE_GNSS_V2_0_GNSSMEASUREMENT_H
-
-#include <android/hardware/gnss/2.0/IGnssMeasurement.h>
-#include <hidl/MQDescriptor.h>
-#include <hidl/Status.h>
-#include "MeasurementAPIClient.h"
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V2_0 {
-namespace implementation {
-
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::sp;
-
-class MeasurementAPIClient;
-struct GnssMeasurement : public V2_0::IGnssMeasurement {
-    GnssMeasurement();
-    ~GnssMeasurement();
-
-    /*
-     * Methods from ::android::hardware::gnss::V1_0::IGnssMeasurement follow.
-     * These declarations were generated from IGnssMeasurement.hal.
-     */
-    Return<GnssMeasurement::GnssMeasurementStatus> setCallback(
-        const sp<V1_0::IGnssMeasurementCallback>& callback) override;
-    Return<void> close() override;
-
-    // Methods from ::android::hardware::gnss::V1_1::IGnssMeasurement follow.
-    Return<GnssMeasurement::GnssMeasurementStatus> setCallback_1_1(
-            const sp<V1_1::IGnssMeasurementCallback>& callback,
-            bool enableFullTracking) override;
-
-    // Methods from ::android::hardware::gnss::V2_0::IGnssMeasurement follow.
-    Return<GnssMeasurement::GnssMeasurementStatus> setCallback_2_0(
-            const sp<V2_0::IGnssMeasurementCallback>& callback,
-            bool enableFullTracking) override;
- private:
-    struct GnssMeasurementDeathRecipient : hidl_death_recipient {
-        GnssMeasurementDeathRecipient(sp<GnssMeasurement> gnssMeasurement) :
-            mGnssMeasurement(gnssMeasurement) {
-        }
-        ~GnssMeasurementDeathRecipient() = default;
-        virtual void serviceDied(uint64_t cookie, const wp<IBase>& who) override;
-        sp<GnssMeasurement> mGnssMeasurement;
-    };
-
-    template <typename T>
-    Return<IGnssMeasurement::GnssMeasurementStatus> setCallback(
-            const sp<T>& callback, sp<T>& myCallback, GnssPowerMode powerMode);
-    sp<GnssMeasurementDeathRecipient> mGnssMeasurementDeathRecipient = nullptr;
-    sp<V1_0::IGnssMeasurementCallback> mGnssMeasurementCbIface = nullptr;
-    sp<V1_1::IGnssMeasurementCallback> mGnssMeasurementCbIface_1_1 = nullptr;
-    sp<V2_0::IGnssMeasurementCallback> mGnssMeasurementCbIface_2_0 = nullptr;
-    MeasurementAPIClient* mApi;
-    void clearInterfaces();
-};
-
-}  // namespace implementation
-}  // namespace V2_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
-
-#endif  // ANDROID_HARDWARE_GNSS_V2_0_GNSSMEASUREMENT_H
diff --git a/gps/android/2.0/GnssNi.cpp b/gps/android/2.0/GnssNi.cpp
deleted file mode 100644
index d65a488..0000000
--- a/gps/android/2.0/GnssNi.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-#define LOG_TAG "LocSvc_GnssNiInterface"
-
-#include <log_util.h>
-#include "Gnss.h"
-#include "GnssNi.h"
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V2_0 {
-namespace implementation {
-
-void GnssNi::GnssNiDeathRecipient::serviceDied(uint64_t cookie, const wp<IBase>& who) {
-    LOC_LOGE("%s] service died. cookie: %llu, who: %p",
-            __FUNCTION__, static_cast<unsigned long long>(cookie), &who);
-    // we do nothing here
-    // Gnss::GnssDeathRecipient will stop the session
-}
-
-GnssNi::GnssNi(Gnss* gnss) : mGnss(gnss) {
-    mGnssNiDeathRecipient = new GnssNiDeathRecipient(this);
-}
-
-// Methods from ::android::hardware::gnss::V1_0::IGnssNi follow.
-Return<void> GnssNi::setCallback(const sp<IGnssNiCallback>& callback)  {
-    if (mGnss == nullptr) {
-        LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__);
-        return Void();
-    }
-
-    mGnss->setGnssNiCb(callback);
-
-    if (mGnssNiCbIface != nullptr) {
-        mGnssNiCbIface->unlinkToDeath(mGnssNiDeathRecipient);
-    }
-    mGnssNiCbIface = callback;
-    if (mGnssNiCbIface != nullptr) {
-        mGnssNiCbIface->linkToDeath(mGnssNiDeathRecipient, 0 /*cookie*/);
-    }
-
-    return Void();
-}
-
-Return<void> GnssNi::respond(int32_t notifId, IGnssNiCallback::GnssUserResponseType userResponse)  {
-    if (mGnss == nullptr) {
-        LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__);
-        return Void();
-    }
-
-    GnssAPIClient* api = mGnss->getApi();
-    if (api == nullptr) {
-        LOC_LOGE("%s]: api is nullptr", __FUNCTION__);
-        return Void();
-    }
-
-    api->gnssNiRespond(notifId, userResponse);
-
-    return Void();
-}
-
-}  // namespace implementation
-}  // namespace V2_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
diff --git a/gps/android/2.0/GnssNi.h b/gps/android/2.0/GnssNi.h
deleted file mode 100644
index 26e281f..0000000
--- a/gps/android/2.0/GnssNi.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-#ifndef ANDROID_HARDWARE_GNSS_V2_0_GNSSNI_H
-#define ANDROID_HARDWARE_GNSS_V2_0_GNSSNI_H
-
-#include <android/hardware/gnss/1.0/IGnssNi.h>
-#include <hidl/Status.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V2_0 {
-namespace implementation {
-
-using ::android::hardware::gnss::V1_0::IGnssNi;
-using ::android::hardware::gnss::V1_0::IGnssNiCallback;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::hidl_string;
-using ::android::sp;
-
-struct Gnss;
-struct GnssNi : public IGnssNi {
-    GnssNi(Gnss* gnss);
-    ~GnssNi() = default;
-
-    /*
-     * Methods from ::android::hardware::gnss::V1_0::IGnssNi follow.
-     * These declarations were generated from IGnssNi.hal.
-     */
-    Return<void> setCallback(const sp<IGnssNiCallback>& callback) override;
-    Return<void> respond(int32_t notifId,
-                         IGnssNiCallback::GnssUserResponseType userResponse) override;
-
- private:
-    struct GnssNiDeathRecipient : hidl_death_recipient {
-        GnssNiDeathRecipient(sp<GnssNi> gnssNi) : mGnssNi(gnssNi) {
-        }
-        ~GnssNiDeathRecipient() = default;
-        virtual void serviceDied(uint64_t cookie, const wp<IBase>& who) override;
-        sp<GnssNi> mGnssNi;
-    };
-
- private:
-    sp<GnssNiDeathRecipient> mGnssNiDeathRecipient = nullptr;
-    sp<IGnssNiCallback> mGnssNiCbIface = nullptr;
-    Gnss* mGnss = nullptr;
-};
-
-}  // namespace implementation
-}  // namespace V2_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
-
-#endif  // ANDROID_HARDWARE_GNSS_V2_0_GNSSNI_H
diff --git a/gps/android/2.0/GnssVisibilityControl.cpp b/gps/android/2.0/GnssVisibilityControl.cpp
deleted file mode 100644
index 5a8c697..0000000
--- a/gps/android/2.0/GnssVisibilityControl.cpp
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright (c) 2019, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- *       copyright notice, this list of conditions and the following
- *       disclaimer in the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of The Linux Foundation nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <android/hardware/gnss/visibility_control/1.0/IGnssVisibilityControl.h>
-#include <hidl/MQDescriptor.h>
-#include <hidl/Status.h>
-#include "GnssVisibilityControl.h"
-#include <location_interface.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace visibility_control {
-namespace V1_0 {
-namespace implementation {
-
-using ::android::hardware::hidl_array;
-using ::android::hardware::hidl_memory;
-using ::android::hardware::hidl_string;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::sp;
-
-static GnssVisibilityControl* spGnssVisibilityControl = nullptr;
-
-static void convertGnssNfwNotification(GnssNfwNotification& in,
-    IGnssVisibilityControlCallback::NfwNotification& out);
-
-GnssVisibilityControl::GnssVisibilityControl(Gnss* gnss) : mGnss(gnss) {
-    spGnssVisibilityControl = this;
-}
-GnssVisibilityControl::~GnssVisibilityControl() {
-    spGnssVisibilityControl = nullptr;
-}
-
-void GnssVisibilityControl::nfwStatusCb(GnssNfwNotification notification) {
-    if (nullptr != spGnssVisibilityControl) {
-        spGnssVisibilityControl->statusCb(notification);
-    }
-}
-
-bool GnssVisibilityControl::isInEmergencySession() {
-    if (nullptr != spGnssVisibilityControl) {
-        return spGnssVisibilityControl->isE911Session();
-    }
-    return false;
-}
-
-static void convertGnssNfwNotification(GnssNfwNotification& in,
-    IGnssVisibilityControlCallback::NfwNotification& out)
-{
-    memset(&out, 0, sizeof(IGnssVisibilityControlCallback::NfwNotification));
-    out.proxyAppPackageName = in.proxyAppPackageName;
-    out.protocolStack = (IGnssVisibilityControlCallback::NfwProtocolStack)in.protocolStack;
-    out.otherProtocolStackName = in.otherProtocolStackName;
-    out.requestor = (IGnssVisibilityControlCallback::NfwRequestor)in.requestor;
-    out.requestorId = in.requestorId;
-    out.responseType = (IGnssVisibilityControlCallback::NfwResponseType)in.responseType;
-    out.inEmergencyMode = in.inEmergencyMode;
-    out.isCachedLocation = in.isCachedLocation;
-}
-
-void GnssVisibilityControl::statusCb(GnssNfwNotification notification) {
-
-    if (mGnssVisibilityControlCbIface != nullptr) {
-        IGnssVisibilityControlCallback::NfwNotification nfwNotification;
-
-        // Convert from one structure to another
-        convertGnssNfwNotification(notification, nfwNotification);
-
-        auto r = mGnssVisibilityControlCbIface->nfwNotifyCb(nfwNotification);
-        if (!r.isOk()) {
-            LOC_LOGw("Error invoking NFW status cb %s", r.description().c_str());
-        }
-    } else {
-        LOC_LOGw("setCallback has not been called yet");
-    }
-}
-
-bool GnssVisibilityControl::isE911Session() {
-
-    if (mGnssVisibilityControlCbIface != nullptr) {
-        auto r = mGnssVisibilityControlCbIface->isInEmergencySession();
-        if (!r.isOk()) {
-            LOC_LOGw("Error invoking NFW status cb %s", r.description().c_str());
-            return false;
-        } else {
-            return (r);
-        }
-    } else {
-        LOC_LOGw("setCallback has not been called yet");
-        return false;
-    }
-}
-
-// Methods from ::android::hardware::gnss::visibility_control::V1_0::IGnssVisibilityControl follow.
-Return<bool> GnssVisibilityControl::enableNfwLocationAccess(const hidl_vec<::android::hardware::hidl_string>& proxyApps) {
-
-    if (nullptr == mGnss || nullptr == mGnss->getGnssInterface()) {
-        LOC_LOGe("Null GNSS interface");
-        return false;
-    }
-
-    /* If the vector is empty we need to disable all NFW clients
-       If there is at least one app in the vector we need to enable
-       all NFW clients */
-    if (0 == proxyApps.size()) {
-        mGnss->getGnssInterface()->enableNfwLocationAccess(false);
-    } else {
-        mGnss->getGnssInterface()->enableNfwLocationAccess(true);
-    }
-
-    return true;
-}
-/**
- * Registers the callback for HAL implementation to use.
- *
- * @param callback Handle to IGnssVisibilityControlCallback interface.
- */
-Return<bool> GnssVisibilityControl::setCallback(const ::android::sp<::android::hardware::gnss::visibility_control::V1_0::IGnssVisibilityControlCallback>& callback) {
-
-    if (nullptr == mGnss || nullptr == mGnss->getGnssInterface()) {
-        LOC_LOGe("Null GNSS interface");
-        return false;
-    }
-    mGnssVisibilityControlCbIface = callback;
-
-    NfwCbInfo cbInfo = {};
-    cbInfo.visibilityControlCb = (void*)nfwStatusCb;
-    cbInfo.isInEmergencySession = (void*)isInEmergencySession;
-
-    mGnss->getGnssInterface()->nfwInit(cbInfo);
-
-    return true;
-}
-
-}  // namespace implementation
-}  // namespace V1_0
-}  // namespace visibility_control
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
diff --git a/gps/android/2.0/GnssVisibilityControl.h b/gps/android/2.0/GnssVisibilityControl.h
deleted file mode 100644
index 9c26e38..0000000
--- a/gps/android/2.0/GnssVisibilityControl.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (c) 2019, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- *       copyright notice, this list of conditions and the following
- *       disclaimer in the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of The Linux Foundation nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ANDROID_HARDWARE_GNSS_V1_0_GnssVisibilityControl_H
-#define ANDROID_HARDWARE_GNSS_V1_0_GnssVisibilityControl_H
-
-#include <android/hardware/gnss/visibility_control/1.0/IGnssVisibilityControl.h>
-#include <hidl/MQDescriptor.h>
-#include <hidl/Status.h>
-
-#include <gps_extended_c.h>
-#include <location_interface.h>
-#include "Gnss.h"
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace visibility_control {
-namespace V1_0 {
-namespace implementation {
-
-using ::android::hardware::hidl_array;
-using ::android::hardware::hidl_memory;
-using ::android::hardware::hidl_string;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::sp;
-using ::android::hardware::gnss::V2_0::implementation::Gnss;
-
-struct GnssVisibilityControl : public IGnssVisibilityControl {
-    GnssVisibilityControl(Gnss* gnss);
-    ~GnssVisibilityControl();
-
-    // Methods from ::android::hardware::gnss::visibility_control::V1_0::IGnssVisibilityControl follow.
-    Return<bool> enableNfwLocationAccess(const hidl_vec<::android::hardware::hidl_string>& proxyApps) override;
-    /**
-     * Registers the callback for HAL implementation to use.
-     *
-     * @param callback Handle to IGnssVisibilityControlCallback interface.
-     */
-    Return<bool> setCallback(const ::android::sp<::android::hardware::gnss::visibility_control::V1_0::IGnssVisibilityControlCallback>& callback) override;
-
-    void statusCb(GnssNfwNotification notification);
-    bool isE911Session();
-
-    /* Data call setup callback passed down to GNSS HAL implementation */
-    static void nfwStatusCb(GnssNfwNotification notification);
-    static bool isInEmergencySession();
-
-private:
-    Gnss* mGnss = nullptr;
-    sp<IGnssVisibilityControlCallback> mGnssVisibilityControlCbIface = nullptr;
-};
-
-
-}  // namespace implementation
-}  // namespace V1_0
-}  // namespace visibility_control
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
-
-#endif  // ANDROID_HARDWARE_GNSS_V1_0_GnssVisibilityControl_H
diff --git a/gps/android/2.0/MeasurementCorrections.cpp b/gps/android/2.0/MeasurementCorrections.cpp
deleted file mode 100644
index bb75073..0000000
--- a/gps/android/2.0/MeasurementCorrections.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2019-2020, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- *       copyright notice, this list of conditions and the following
- *       disclaimer in the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of The Linux Foundation nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#define LOG_TAG "LocSvc_MeasurementCorrectionsInterface"
-
-#include <log_util.h>
-#include "MeasurementCorrections.h"
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace measurement_corrections {
-namespace V1_0 {
-namespace implementation {
-
-using ::android::hardware::hidl_array;
-using ::android::hardware::hidl_memory;
-using ::android::hardware::hidl_string;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::sp;
-using ::android::hardware::gnss::V1_0::GnssLocation;
-
-MeasurementCorrections::MeasurementCorrections() {
-}
-
-MeasurementCorrections::~MeasurementCorrections() {
-}
-
-Return<bool> MeasurementCorrections::setCorrections(
-        const ::android::hardware::gnss::measurement_corrections::
-                V1_0::MeasurementCorrections& /*corrections*/) {
-    return true;
-}
-
-Return<bool> MeasurementCorrections::setCallback(
-        const sp<V1_0::IMeasurementCorrectionsCallback>& /*callback*/) {
-    return true;
-}
-
-}  // namespace implementation
-}  // namespace V1_0
-}  // namespace measurement_corrections
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
diff --git a/gps/android/2.0/MeasurementCorrections.h b/gps/android/2.0/MeasurementCorrections.h
deleted file mode 100644
index 96b1120..0000000
--- a/gps/android/2.0/MeasurementCorrections.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2019-2020, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- *       copyright notice, this list of conditions and the following
- *       disclaimer in the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of The Linux Foundation nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef ANDROID_HARDWARE_GNSS_V1_0_MeasurementCorrections_H
-#define ANDROID_HARDWARE_GNSS_V1_0_MeasurementCorrections_H
-
-#include <android/hardware/gnss/measurement_corrections/1.0/IMeasurementCorrections.h>
-#include <android/hardware/gnss/measurement_corrections/1.0/IMeasurementCorrectionsCallback.h>
-#include <hidl/MQDescriptor.h>
-#include <hidl/Status.h>
-
-#include <location_interface.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace measurement_corrections {
-namespace V1_0 {
-namespace implementation {
-
-using ::android::hardware::hidl_array;
-using ::android::hardware::hidl_memory;
-using ::android::hardware::hidl_string;
-using ::android::hardware::hidl_vec;
-using ::android::hardware::Return;
-using ::android::hardware::Void;
-using ::android::sp;
-using ::android::hardware::gnss::V1_0::GnssLocation;
-using ::android::hardware::gnss::measurement_corrections::V1_0::IMeasurementCorrectionsCallback;
-
-struct MeasurementCorrections : public IMeasurementCorrections {
-    MeasurementCorrections();
-    ~MeasurementCorrections();
-
-// Methods from ::android::hardware::gnss::measurement_corrections::V1_0::IMeasurementCorrections follow.
-Return<bool> setCorrections(
-        const ::android::hardware::gnss::measurement_corrections::
-                V1_0::MeasurementCorrections& corrections) override;
-
-Return<bool> setCallback(const sp<IMeasurementCorrectionsCallback>& callback) override;
-};
-
-
-}  // namespace implementation
-}  // namespace V1_0
-}  // namespace measurement_corrections
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
-
-#endif  // ANDROID_HARDWARE_GNSS_V1_0_MeasurementCorrections_H
diff --git a/gps/android/2.0/android.hardware.gnss@2.0-service-qti.rc b/gps/android/2.0/android.hardware.gnss@2.0-service-qti.rc
deleted file mode 100644
index ad46d5d..0000000
--- a/gps/android/2.0/android.hardware.gnss@2.0-service-qti.rc
+++ /dev/null
@@ -1,4 +0,0 @@
-service gnss_service /vendor/bin/hw/android.hardware.gnss@2.0-service-qti
-    class hal
-    user gps
-    group system gps radio vendor_qti_diag
diff --git a/gps/android/2.0/android.hardware.gnss@2.0-service-qti.xml b/gps/android/2.0/android.hardware.gnss@2.0-service-qti.xml
deleted file mode 100644
index ff9fb2c..0000000
--- a/gps/android/2.0/android.hardware.gnss@2.0-service-qti.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<!-- Copyright (c) 2019, The Linux Foundation. All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-    * Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-    * Redistributions in binary form must reproduce the above
-      copyright notice, this list of conditions and the following
-      disclaimer in the documentation and/or other materials provided
-      with the distribution.
-    * Neither the name of The Linux Foundation nor the names of its
-      contributors may be used to endorse or promote products derived
-      from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
-WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
-ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
-BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
-BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
-IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--->
-<manifest version="1.0" type="device">
-    <hal format="hidl">
-        <name>android.hardware.gnss</name>
-        <transport>hwbinder</transport>
-        <fqname>@1.1::IGnss/default</fqname>
-        <fqname>@2.0::IGnss/default</fqname>
-    </hal>
-</manifest>
-
diff --git a/gps/android/2.0/location_api/BatchingAPIClient.cpp b/gps/android/2.0/location_api/BatchingAPIClient.cpp
deleted file mode 100644
index 766c37a..0000000
--- a/gps/android/2.0/location_api/BatchingAPIClient.cpp
+++ /dev/null
@@ -1,251 +0,0 @@
-/* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- *       copyright notice, this list of conditions and the following
- *       disclaimer in the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of The Linux Foundation, nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#define LOG_NDEBUG 0
-#define LOG_TAG "LocSvc_BatchingAPIClient"
-
-#include <inttypes.h>
-#include <log_util.h>
-#include <loc_cfg.h>
-
-#include "LocationUtil.h"
-#include "BatchingAPIClient.h"
-
-#include "limits.h"
-
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V2_0 {
-namespace implementation {
-
-using ::android::hardware::gnss::V2_0::IGnssBatching;
-using ::android::hardware::gnss::V2_0::IGnssBatchingCallback;
-using ::android::hardware::gnss::V2_0::GnssLocation;
-
-static void convertBatchOption(const IGnssBatching::Options& in, LocationOptions& out,
-        LocationCapabilitiesMask mask);
-
-BatchingAPIClient::BatchingAPIClient(const sp<V1_0::IGnssBatchingCallback>& callback) :
-    LocationAPIClientBase(),
-    mGnssBatchingCbIface(nullptr),
-    mDefaultId(UINT_MAX),
-    mLocationCapabilitiesMask(0),
-    mGnssBatchingCbIface_2_0(nullptr)
-{
-    LOC_LOGD("%s]: (%p)", __FUNCTION__, &callback);
-
-    gnssUpdateCallbacks(callback);
-}
-
-BatchingAPIClient::BatchingAPIClient(const sp<V2_0::IGnssBatchingCallback>& callback) :
-    LocationAPIClientBase(),
-    mGnssBatchingCbIface(nullptr),
-    mDefaultId(UINT_MAX),
-    mLocationCapabilitiesMask(0),
-    mGnssBatchingCbIface_2_0(nullptr)
-{
-    LOC_LOGD("%s]: (%p)", __FUNCTION__, &callback);
-
-    gnssUpdateCallbacks_2_0(callback);
-}
-
-BatchingAPIClient::~BatchingAPIClient()
-{
-    LOC_LOGD("%s]: ()", __FUNCTION__);
-}
-
-int BatchingAPIClient::getBatchSize()
-{
-    LOC_LOGD("%s]: ()", __FUNCTION__);
-    return locAPIGetBatchSize();
-}
-
-void BatchingAPIClient::setCallbacks()
-{
-    LocationCallbacks locationCallbacks;
-    memset(&locationCallbacks, 0, sizeof(LocationCallbacks));
-    locationCallbacks.size = sizeof(LocationCallbacks);
-
-    locationCallbacks.trackingCb = nullptr;
-    locationCallbacks.batchingCb = nullptr;
-    locationCallbacks.batchingCb = [this](size_t count, Location* location,
-        BatchingOptions batchOptions) {
-        onBatchingCb(count, location, batchOptions);
-    };
-    locationCallbacks.geofenceBreachCb = nullptr;
-    locationCallbacks.geofenceStatusCb = nullptr;
-    locationCallbacks.gnssLocationInfoCb = nullptr;
-    locationCallbacks.gnssNiCb = nullptr;
-    locationCallbacks.gnssSvCb = nullptr;
-    locationCallbacks.gnssNmeaCb = nullptr;
-    locationCallbacks.gnssMeasurementsCb = nullptr;
-
-    locAPISetCallbacks(locationCallbacks);
-}
-
-void BatchingAPIClient::gnssUpdateCallbacks(const sp<V1_0::IGnssBatchingCallback>& callback)
-{
-    mMutex.lock();
-    mGnssBatchingCbIface = callback;
-    mMutex.unlock();
-
-    if (mGnssBatchingCbIface != nullptr) {
-        setCallbacks();
-    }
-}
-
-void BatchingAPIClient::gnssUpdateCallbacks_2_0(const sp<V2_0::IGnssBatchingCallback>& callback)
-{
-    mMutex.lock();
-    mGnssBatchingCbIface_2_0 = callback;
-    mMutex.unlock();
-
-    if (mGnssBatchingCbIface_2_0 != nullptr) {
-        setCallbacks();
-    }
-}
-
-int BatchingAPIClient::startSession(const IGnssBatching::Options& opts)
-{
-    LOC_LOGD("%s]: (%lld %d)", __FUNCTION__,
-            static_cast<long long>(opts.periodNanos), static_cast<uint8_t>(opts.flags));
-    int retVal = -1;
-    LocationOptions options;
-    convertBatchOption(opts, options, mLocationCapabilitiesMask);
-    uint32_t mode = 0;
-    if (opts.flags == static_cast<uint8_t>(IGnssBatching::Flag::WAKEUP_ON_FIFO_FULL)) {
-        mode = SESSION_MODE_ON_FULL;
-    }
-    if (locAPIStartSession(mDefaultId, mode, options) == LOCATION_ERROR_SUCCESS) {
-        retVal = 1;
-    }
-    return retVal;
-}
-
-int BatchingAPIClient::updateSessionOptions(const IGnssBatching::Options& opts)
-{
-    LOC_LOGD("%s]: (%lld %d)", __FUNCTION__,
-            static_cast<long long>(opts.periodNanos), static_cast<uint8_t>(opts.flags));
-    int retVal = -1;
-    LocationOptions options;
-    convertBatchOption(opts, options, mLocationCapabilitiesMask);
-
-    uint32_t mode = 0;
-    if (opts.flags == static_cast<uint8_t>(IGnssBatching::Flag::WAKEUP_ON_FIFO_FULL)) {
-        mode = SESSION_MODE_ON_FULL;
-    }
-    if (locAPIUpdateSessionOptions(mDefaultId, mode, options) == LOCATION_ERROR_SUCCESS) {
-        retVal = 1;
-    }
-    return retVal;
-}
-
-int BatchingAPIClient::stopSession()
-{
-    LOC_LOGD("%s]: ", __FUNCTION__);
-    int retVal = -1;
-    if (locAPIStopSession(mDefaultId) == LOCATION_ERROR_SUCCESS) {
-        retVal = 1;
-    }
-    return retVal;
-}
-
-void BatchingAPIClient::getBatchedLocation(int last_n_locations)
-{
-    LOC_LOGD("%s]: (%d)", __FUNCTION__, last_n_locations);
-    locAPIGetBatchedLocations(mDefaultId, last_n_locations);
-}
-
-void BatchingAPIClient::flushBatchedLocations()
-{
-    LOC_LOGD("%s]: ()", __FUNCTION__);
-    locAPIGetBatchedLocations(mDefaultId, SIZE_MAX);
-}
-
-void BatchingAPIClient::onCapabilitiesCb(LocationCapabilitiesMask capabilitiesMask)
-{
-    LOC_LOGD("%s]: (%" PRIu64 ")", __FUNCTION__, capabilitiesMask);
-    mLocationCapabilitiesMask = capabilitiesMask;
-}
-
-void BatchingAPIClient::onBatchingCb(size_t count, Location* location,
-        BatchingOptions /*batchOptions*/)
-{
-    mMutex.lock();
-    auto gnssBatchingCbIface(mGnssBatchingCbIface);
-    auto gnssBatchingCbIface_2_0(mGnssBatchingCbIface_2_0);
-    mMutex.unlock();
-
-    LOC_LOGD("%s]: (count: %zu)", __FUNCTION__, count);
-    if (gnssBatchingCbIface_2_0 != nullptr && count > 0) {
-        hidl_vec<V2_0::GnssLocation> locationVec;
-        locationVec.resize(count);
-        for (size_t i = 0; i < count; i++) {
-            convertGnssLocation(location[i], locationVec[i]);
-        }
-        auto r = gnssBatchingCbIface_2_0->gnssLocationBatchCb(locationVec);
-        if (!r.isOk()) {
-            LOC_LOGE("%s] Error from gnssLocationBatchCb 2.0 description=%s",
-                __func__, r.description().c_str());
-        }
-    } else if (gnssBatchingCbIface != nullptr && count > 0) {
-        hidl_vec<V1_0::GnssLocation> locationVec;
-        locationVec.resize(count);
-        for (size_t i = 0; i < count; i++) {
-            convertGnssLocation(location[i], locationVec[i]);
-        }
-        auto r = gnssBatchingCbIface->gnssLocationBatchCb(locationVec);
-        if (!r.isOk()) {
-            LOC_LOGE("%s] Error from gnssLocationBatchCb 1.0 description=%s",
-                __func__, r.description().c_str());
-        }
-    }
-}
-
-static void convertBatchOption(const IGnssBatching::Options& in, LocationOptions& out,
-        LocationCapabilitiesMask mask)
-{
-    memset(&out, 0, sizeof(LocationOptions));
-    out.size = sizeof(LocationOptions);
-    out.minInterval = (uint32_t)(in.periodNanos / 1000000L);
-    out.minDistance = 0;
-    out.mode = GNSS_SUPL_MODE_STANDALONE;
-    if (mask & LOCATION_CAPABILITIES_GNSS_MSA_BIT)
-        out.mode = GNSS_SUPL_MODE_MSA;
-    if (mask & LOCATION_CAPABILITIES_GNSS_MSB_BIT)
-        out.mode = GNSS_SUPL_MODE_MSB;
-}
-
-}  // namespace implementation
-}  // namespace V2_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
diff --git a/gps/android/2.0/location_api/BatchingAPIClient.h b/gps/android/2.0/location_api/BatchingAPIClient.h
deleted file mode 100644
index d2d9b4a..0000000
--- a/gps/android/2.0/location_api/BatchingAPIClient.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- *       copyright notice, this list of conditions and the following
- *       disclaimer in the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of The Linux Foundation, nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#ifndef BATCHING_API_CLINET_H
-#define BATCHING_API_CLINET_H
-
-#include <mutex>
-#include <android/hardware/gnss/2.0/IGnssBatching.h>
-#include <android/hardware/gnss/2.0/IGnssBatchingCallback.h>
-#include <pthread.h>
-
-#include <LocationAPIClientBase.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V2_0 {
-namespace implementation {
-
-class BatchingAPIClient : public LocationAPIClientBase
-{
-public:
-    BatchingAPIClient(const sp<V1_0::IGnssBatchingCallback>& callback);
-    BatchingAPIClient(const sp<V2_0::IGnssBatchingCallback>& callback);
-    void gnssUpdateCallbacks(const sp<V1_0::IGnssBatchingCallback>& callback);
-    void gnssUpdateCallbacks_2_0(const sp<V2_0::IGnssBatchingCallback>& callback);
-    int getBatchSize();
-    int startSession(const V1_0::IGnssBatching::Options& options);
-    int updateSessionOptions(const V1_0::IGnssBatching::Options& options);
-    int stopSession();
-    void getBatchedLocation(int last_n_locations);
-    void flushBatchedLocations();
-
-    inline LocationCapabilitiesMask getCapabilities() { return mLocationCapabilitiesMask; }
-
-    // callbacks
-    void onCapabilitiesCb(LocationCapabilitiesMask capabilitiesMask) final;
-    void onBatchingCb(size_t count, Location* location, BatchingOptions batchOptions) final;
-
-private:
-    void setCallbacks();
-    ~BatchingAPIClient();
-
-    std::mutex mMutex;
-    sp<V1_0::IGnssBatchingCallback> mGnssBatchingCbIface;
-    uint32_t mDefaultId;
-    LocationCapabilitiesMask mLocationCapabilitiesMask;
-    sp<V2_0::IGnssBatchingCallback> mGnssBatchingCbIface_2_0;
-};
-
-}  // namespace implementation
-}  // namespace V2_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
-#endif // BATCHING_API_CLINET_H
diff --git a/gps/android/2.0/location_api/GeofenceAPIClient.cpp b/gps/android/2.0/location_api/GeofenceAPIClient.cpp
deleted file mode 100644
index a93c988..0000000
--- a/gps/android/2.0/location_api/GeofenceAPIClient.cpp
+++ /dev/null
@@ -1,275 +0,0 @@
-/* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- *       copyright notice, this list of conditions and the following
- *       disclaimer in the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of The Linux Foundation, nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#define LOG_NDEBUG 0
-#define LOG_TAG "LocSvc_GeofenceApiClient"
-
-#include <log_util.h>
-#include <loc_cfg.h>
-
-#include "LocationUtil.h"
-#include "GeofenceAPIClient.h"
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V2_0 {
-namespace implementation {
-
-using ::android::hardware::gnss::V1_0::IGnssGeofenceCallback;
-using ::android::hardware::gnss::V1_0::GnssLocation;
-
-GeofenceAPIClient::GeofenceAPIClient(const sp<IGnssGeofenceCallback>& callback) :
-    LocationAPIClientBase(),
-    mGnssGeofencingCbIface(callback)
-{
-    LOC_LOGD("%s]: (%p)", __FUNCTION__, &callback);
-
-    LocationCallbacks locationCallbacks;
-    memset(&locationCallbacks, 0, sizeof(LocationCallbacks));
-    locationCallbacks.size = sizeof(LocationCallbacks);
-
-    locationCallbacks.trackingCb = nullptr;
-    locationCallbacks.batchingCb = nullptr;
-
-    locationCallbacks.geofenceBreachCb = nullptr;
-    if (mGnssGeofencingCbIface != nullptr) {
-        locationCallbacks.geofenceBreachCb =
-            [this](GeofenceBreachNotification geofenceBreachNotification) {
-                onGeofenceBreachCb(geofenceBreachNotification);
-            };
-
-        locationCallbacks.geofenceStatusCb =
-            [this](GeofenceStatusNotification geofenceStatusNotification) {
-                onGeofenceStatusCb(geofenceStatusNotification);
-            };
-    }
-
-    locationCallbacks.gnssLocationInfoCb = nullptr;
-    locationCallbacks.gnssNiCb = nullptr;
-    locationCallbacks.gnssSvCb = nullptr;
-    locationCallbacks.gnssNmeaCb = nullptr;
-    locationCallbacks.gnssMeasurementsCb = nullptr;
-
-    locAPISetCallbacks(locationCallbacks);
-}
-
-void GeofenceAPIClient::geofenceAdd(uint32_t geofence_id, double latitude, double longitude,
-        double radius_meters, int32_t last_transition, int32_t monitor_transitions,
-        uint32_t notification_responsiveness_ms, uint32_t unknown_timer_ms)
-{
-    LOC_LOGD("%s]: (%d %f %f %f %d %d %d %d)", __FUNCTION__,
-            geofence_id, latitude, longitude, radius_meters,
-            last_transition, monitor_transitions, notification_responsiveness_ms, unknown_timer_ms);
-
-    GeofenceOption options;
-    memset(&options, 0, sizeof(GeofenceOption));
-    options.size = sizeof(GeofenceOption);
-    if (monitor_transitions & IGnssGeofenceCallback::GeofenceTransition::ENTERED)
-        options.breachTypeMask |= GEOFENCE_BREACH_ENTER_BIT;
-    if (monitor_transitions & IGnssGeofenceCallback::GeofenceTransition::EXITED)
-        options.breachTypeMask |=  GEOFENCE_BREACH_EXIT_BIT;
-    options.responsiveness = notification_responsiveness_ms;
-
-    GeofenceInfo data;
-    data.size = sizeof(GeofenceInfo);
-    data.latitude = latitude;
-    data.longitude = longitude;
-    data.radius = radius_meters;
-
-    LocationError err = (LocationError)locAPIAddGeofences(1, &geofence_id, &options, &data);
-    if (LOCATION_ERROR_SUCCESS != err) {
-        onAddGeofencesCb(1, &err, &geofence_id);
-    }
-}
-
-void GeofenceAPIClient::geofencePause(uint32_t geofence_id)
-{
-    LOC_LOGD("%s]: (%d)", __FUNCTION__, geofence_id);
-    locAPIPauseGeofences(1, &geofence_id);
-}
-
-void GeofenceAPIClient::geofenceResume(uint32_t geofence_id, int32_t monitor_transitions)
-{
-    LOC_LOGD("%s]: (%d %d)", __FUNCTION__, geofence_id, monitor_transitions);
-    GeofenceBreachTypeMask mask = 0;
-    if (monitor_transitions & IGnssGeofenceCallback::GeofenceTransition::ENTERED)
-        mask |= GEOFENCE_BREACH_ENTER_BIT;
-    if (monitor_transitions & IGnssGeofenceCallback::GeofenceTransition::EXITED)
-        mask |=  GEOFENCE_BREACH_EXIT_BIT;
-    locAPIResumeGeofences(1, &geofence_id, &mask);
-}
-
-void GeofenceAPIClient::geofenceRemove(uint32_t geofence_id)
-{
-    LOC_LOGD("%s]: (%d)", __FUNCTION__, geofence_id);
-    locAPIRemoveGeofences(1, &geofence_id);
-}
-
-void GeofenceAPIClient::geofenceRemoveAll()
-{
-    LOC_LOGD("%s]", __FUNCTION__);
-    // TODO locAPIRemoveAllGeofences();
-}
-
-// callbacks
-void GeofenceAPIClient::onGeofenceBreachCb(GeofenceBreachNotification geofenceBreachNotification)
-{
-    LOC_LOGD("%s]: (%d)", __FUNCTION__, geofenceBreachNotification.count);
-    if (mGnssGeofencingCbIface != nullptr) {
-        for (size_t i = 0; i < geofenceBreachNotification.count; i++) {
-            GnssLocation gnssLocation;
-            convertGnssLocation(geofenceBreachNotification.location, gnssLocation);
-
-            IGnssGeofenceCallback::GeofenceTransition transition;
-            if (geofenceBreachNotification.type == GEOFENCE_BREACH_ENTER)
-                transition = IGnssGeofenceCallback::GeofenceTransition::ENTERED;
-            else if (geofenceBreachNotification.type == GEOFENCE_BREACH_EXIT)
-                transition = IGnssGeofenceCallback::GeofenceTransition::EXITED;
-            else {
-                // continue with other breach if transition is
-                // nether GPS_GEOFENCE_ENTERED nor GPS_GEOFENCE_EXITED
-                continue;
-            }
-
-            auto r = mGnssGeofencingCbIface->gnssGeofenceTransitionCb(
-                    geofenceBreachNotification.ids[i], gnssLocation, transition,
-                    static_cast<V1_0::GnssUtcTime>(geofenceBreachNotification.timestamp));
-            if (!r.isOk()) {
-                LOC_LOGE("%s] Error from gnssGeofenceTransitionCb description=%s",
-                    __func__, r.description().c_str());
-            }
-        }
-    }
-}
-
-void GeofenceAPIClient::onGeofenceStatusCb(GeofenceStatusNotification geofenceStatusNotification)
-{
-    LOC_LOGD("%s]: (%d)", __FUNCTION__, geofenceStatusNotification.available);
-    if (mGnssGeofencingCbIface != nullptr) {
-        IGnssGeofenceCallback::GeofenceAvailability status =
-            IGnssGeofenceCallback::GeofenceAvailability::UNAVAILABLE;
-        if (geofenceStatusNotification.available == GEOFENCE_STATUS_AVAILABILE_YES) {
-            status = IGnssGeofenceCallback::GeofenceAvailability::AVAILABLE;
-        }
-        GnssLocation gnssLocation;
-        memset(&gnssLocation, 0, sizeof(GnssLocation));
-        auto r = mGnssGeofencingCbIface->gnssGeofenceStatusCb(status, gnssLocation);
-        if (!r.isOk()) {
-            LOC_LOGE("%s] Error from gnssGeofenceStatusCb description=%s",
-                __func__, r.description().c_str());
-        }
-    }
-}
-
-void GeofenceAPIClient::onAddGeofencesCb(size_t count, LocationError* errors, uint32_t* ids)
-{
-    LOC_LOGD("%s]: (%zu)", __FUNCTION__, count);
-    if (mGnssGeofencingCbIface != nullptr) {
-        for (size_t i = 0; i < count; i++) {
-            IGnssGeofenceCallback::GeofenceStatus status =
-                IGnssGeofenceCallback::GeofenceStatus::ERROR_GENERIC;
-            if (errors[i] == LOCATION_ERROR_SUCCESS)
-                status = IGnssGeofenceCallback::GeofenceStatus::OPERATION_SUCCESS;
-            else if (errors[i] == LOCATION_ERROR_ID_EXISTS)
-                status = IGnssGeofenceCallback::GeofenceStatus::ERROR_ID_EXISTS;
-            auto r = mGnssGeofencingCbIface->gnssGeofenceAddCb(ids[i], status);
-            if (!r.isOk()) {
-                LOC_LOGE("%s] Error from gnssGeofenceAddCb description=%s",
-                    __func__, r.description().c_str());
-            }
-        }
-    }
-}
-
-void GeofenceAPIClient::onRemoveGeofencesCb(size_t count, LocationError* errors, uint32_t* ids)
-{
-    LOC_LOGD("%s]: (%zu)", __FUNCTION__, count);
-    if (mGnssGeofencingCbIface != nullptr) {
-        for (size_t i = 0; i < count; i++) {
-            IGnssGeofenceCallback::GeofenceStatus status =
-                IGnssGeofenceCallback::GeofenceStatus::ERROR_GENERIC;
-            if (errors[i] == LOCATION_ERROR_SUCCESS)
-                status = IGnssGeofenceCallback::GeofenceStatus::OPERATION_SUCCESS;
-            else if (errors[i] == LOCATION_ERROR_ID_UNKNOWN)
-                status = IGnssGeofenceCallback::GeofenceStatus::ERROR_ID_UNKNOWN;
-            auto r = mGnssGeofencingCbIface->gnssGeofenceRemoveCb(ids[i], status);
-            if (!r.isOk()) {
-                LOC_LOGE("%s] Error from gnssGeofenceRemoveCb description=%s",
-                    __func__, r.description().c_str());
-            }
-        }
-    }
-}
-
-void GeofenceAPIClient::onPauseGeofencesCb(size_t count, LocationError* errors, uint32_t* ids)
-{
-    LOC_LOGD("%s]: (%zu)", __FUNCTION__, count);
-    if (mGnssGeofencingCbIface != nullptr) {
-        for (size_t i = 0; i < count; i++) {
-            IGnssGeofenceCallback::GeofenceStatus status =
-                IGnssGeofenceCallback::GeofenceStatus::ERROR_GENERIC;
-            if (errors[i] == LOCATION_ERROR_SUCCESS)
-                status = IGnssGeofenceCallback::GeofenceStatus::OPERATION_SUCCESS;
-            else if (errors[i] == LOCATION_ERROR_ID_UNKNOWN)
-                status = IGnssGeofenceCallback::GeofenceStatus::ERROR_ID_UNKNOWN;
-            auto r = mGnssGeofencingCbIface->gnssGeofencePauseCb(ids[i], status);
-            if (!r.isOk()) {
-                LOC_LOGE("%s] Error from gnssGeofencePauseCb description=%s",
-                    __func__, r.description().c_str());
-            }
-        }
-    }
-}
-
-void GeofenceAPIClient::onResumeGeofencesCb(size_t count, LocationError* errors, uint32_t* ids)
-{
-    LOC_LOGD("%s]: (%zu)", __FUNCTION__, count);
-    if (mGnssGeofencingCbIface != nullptr) {
-        for (size_t i = 0; i < count; i++) {
-            IGnssGeofenceCallback::GeofenceStatus status =
-                IGnssGeofenceCallback::GeofenceStatus::ERROR_GENERIC;
-            if (errors[i] == LOCATION_ERROR_SUCCESS)
-                status = IGnssGeofenceCallback::GeofenceStatus::OPERATION_SUCCESS;
-            else if (errors[i] == LOCATION_ERROR_ID_UNKNOWN)
-                status = IGnssGeofenceCallback::GeofenceStatus::ERROR_ID_UNKNOWN;
-            auto r = mGnssGeofencingCbIface->gnssGeofenceResumeCb(ids[i], status);
-            if (!r.isOk()) {
-                LOC_LOGE("%s] Error from gnssGeofenceResumeCb description=%s",
-                    __func__, r.description().c_str());
-            }
-        }
-    }
-}
-
-}  // namespace implementation
-}  // namespace V2_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
diff --git a/gps/android/2.0/location_api/GeofenceAPIClient.h b/gps/android/2.0/location_api/GeofenceAPIClient.h
deleted file mode 100644
index 5bce476..0000000
--- a/gps/android/2.0/location_api/GeofenceAPIClient.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- *       copyright notice, this list of conditions and the following
- *       disclaimer in the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of The Linux Foundation, nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#ifndef GEOFENCE_API_CLINET_H
-#define GEOFENCE_API_CLINET_H
-
-
-#include <android/hardware/gnss/1.0/IGnssGeofenceCallback.h>
-#include <LocationAPIClientBase.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V2_0 {
-namespace implementation {
-
-using ::android::sp;
-
-class GeofenceAPIClient : public LocationAPIClientBase
-{
-public:
-    GeofenceAPIClient(const sp<V1_0::IGnssGeofenceCallback>& callback);
-
-    void geofenceAdd(uint32_t geofence_id, double latitude, double longitude,
-            double radius_meters, int32_t last_transition, int32_t monitor_transitions,
-            uint32_t notification_responsiveness_ms, uint32_t unknown_timer_ms);
-    void geofencePause(uint32_t geofence_id);
-    void geofenceResume(uint32_t geofence_id, int32_t monitor_transitions);
-    void geofenceRemove(uint32_t geofence_id);
-    void geofenceRemoveAll();
-
-    // callbacks
-    void onGeofenceBreachCb(GeofenceBreachNotification geofenceBreachNotification) final;
-    void onGeofenceStatusCb(GeofenceStatusNotification geofenceStatusNotification) final;
-    void onAddGeofencesCb(size_t count, LocationError* errors, uint32_t* ids) final;
-    void onRemoveGeofencesCb(size_t count, LocationError* errors, uint32_t* ids) final;
-    void onPauseGeofencesCb(size_t count, LocationError* errors, uint32_t* ids) final;
-    void onResumeGeofencesCb(size_t count, LocationError* errors, uint32_t* ids) final;
-
-private:
-    virtual ~GeofenceAPIClient() = default;
-
-    sp<V1_0::IGnssGeofenceCallback> mGnssGeofencingCbIface;
-};
-
-}  // namespace implementation
-}  // namespace V2_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
-#endif // GEOFENCE_API_CLINET_H
diff --git a/gps/android/2.0/location_api/GnssAPIClient.cpp b/gps/android/2.0/location_api/GnssAPIClient.cpp
deleted file mode 100644
index 44007d9..0000000
--- a/gps/android/2.0/location_api/GnssAPIClient.cpp
+++ /dev/null
@@ -1,728 +0,0 @@
-/* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- *       copyright notice, this list of conditions and the following
- *       disclaimer in the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of The Linux Foundation, nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#define LOG_NDEBUG 0
-#define LOG_TAG "LocSvc_GnssAPIClient"
-#define SINGLE_SHOT_MIN_TRACKING_INTERVAL_MSEC (590 * 60 * 60 * 1000) // 590 hours
-
-#include <inttypes.h>
-#include <log_util.h>
-#include <loc_cfg.h>
-
-#include "LocationUtil.h"
-#include "GnssAPIClient.h"
-#include <LocContext.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V2_0 {
-namespace implementation {
-
-using ::android::hardware::gnss::V2_0::IGnss;
-using ::android::hardware::gnss::V2_0::IGnssCallback;
-using ::android::hardware::gnss::V1_0::IGnssNiCallback;
-using ::android::hardware::gnss::V2_0::GnssLocation;
-
-static void convertGnssSvStatus(GnssSvNotification& in, V1_0::IGnssCallback::GnssSvStatus& out);
-static void convertGnssSvStatus(GnssSvNotification& in,
-        hidl_vec<V2_0::IGnssCallback::GnssSvInfo>& out);
-
-GnssAPIClient::GnssAPIClient(const sp<V1_0::IGnssCallback>& gpsCb,
-        const sp<V1_0::IGnssNiCallback>& niCb) :
-    LocationAPIClientBase(),
-    mGnssCbIface(nullptr),
-    mGnssNiCbIface(nullptr),
-    mControlClient(new LocationAPIControlClient()),
-    mLocationCapabilitiesMask(0),
-    mLocationCapabilitiesCached(false),
-    mTracking(false),
-    mGnssCbIface_2_0(nullptr)
-{
-    LOC_LOGD("%s]: (%p %p)", __FUNCTION__, &gpsCb, &niCb);
-
-    initLocationOptions();
-    gnssUpdateCallbacks(gpsCb, niCb);
-}
-
-GnssAPIClient::GnssAPIClient(const sp<V2_0::IGnssCallback>& gpsCb) :
-    LocationAPIClientBase(),
-    mGnssCbIface(nullptr),
-    mGnssNiCbIface(nullptr),
-    mControlClient(new LocationAPIControlClient()),
-    mLocationCapabilitiesMask(0),
-    mLocationCapabilitiesCached(false),
-    mTracking(false),
-    mGnssCbIface_2_0(nullptr)
-{
-    LOC_LOGD("%s]: (%p)", __FUNCTION__, &gpsCb);
-
-    initLocationOptions();
-    gnssUpdateCallbacks_2_0(gpsCb);
-}
-
-GnssAPIClient::~GnssAPIClient()
-{
-    LOC_LOGD("%s]: ()", __FUNCTION__);
-    if (mControlClient) {
-        delete mControlClient;
-        mControlClient = nullptr;
-    }
-}
-
-void GnssAPIClient::initLocationOptions()
-{
-    // set default LocationOptions.
-    memset(&mTrackingOptions, 0, sizeof(TrackingOptions));
-    mTrackingOptions.size = sizeof(TrackingOptions);
-    mTrackingOptions.minInterval = 1000;
-    mTrackingOptions.minDistance = 0;
-    mTrackingOptions.mode = GNSS_SUPL_MODE_STANDALONE;
-}
-
-void GnssAPIClient::setCallbacks()
-{
-    LocationCallbacks locationCallbacks;
-    memset(&locationCallbacks, 0, sizeof(LocationCallbacks));
-    locationCallbacks.size = sizeof(LocationCallbacks);
-
-    locationCallbacks.trackingCb = nullptr;
-    locationCallbacks.trackingCb = [this](Location location) {
-        onTrackingCb(location);
-    };
-
-    locationCallbacks.batchingCb = nullptr;
-    locationCallbacks.geofenceBreachCb = nullptr;
-    locationCallbacks.geofenceStatusCb = nullptr;
-    locationCallbacks.gnssLocationInfoCb = nullptr;
-    locationCallbacks.gnssNiCb = nullptr;
-    if (mGnssNiCbIface != nullptr) {
-        loc_core::ContextBase* context =
-                loc_core::LocContext::getLocContext(loc_core::LocContext::mLocationHalName);
-        if (!context->hasAgpsExtendedCapabilities()) {
-            LOC_LOGD("Registering NI CB");
-            locationCallbacks.gnssNiCb = [this](uint32_t id, GnssNiNotification gnssNiNotify) {
-                onGnssNiCb(id, gnssNiNotify);
-            };
-        }
-    }
-
-    locationCallbacks.gnssSvCb = nullptr;
-    locationCallbacks.gnssSvCb = [this](GnssSvNotification gnssSvNotification) {
-        onGnssSvCb(gnssSvNotification);
-    };
-
-    locationCallbacks.gnssNmeaCb = nullptr;
-    locationCallbacks.gnssNmeaCb = [this](GnssNmeaNotification gnssNmeaNotification) {
-        onGnssNmeaCb(gnssNmeaNotification);
-    };
-
-    locationCallbacks.gnssMeasurementsCb = nullptr;
-
-    locAPISetCallbacks(locationCallbacks);
-}
-
-// for GpsInterface
-void GnssAPIClient::gnssUpdateCallbacks(const sp<V1_0::IGnssCallback>& gpsCb,
-    const sp<IGnssNiCallback>& niCb)
-{
-    LOC_LOGD("%s]: (%p %p)", __FUNCTION__, &gpsCb, &niCb);
-
-    mMutex.lock();
-    mGnssCbIface = gpsCb;
-    mGnssNiCbIface = niCb;
-    mMutex.unlock();
-
-    if (mGnssCbIface != nullptr || mGnssNiCbIface != nullptr) {
-        setCallbacks();
-    }
-}
-
-void GnssAPIClient::gnssUpdateCallbacks_2_0(const sp<V2_0::IGnssCallback>& gpsCb)
-{
-    LOC_LOGD("%s]: (%p)", __FUNCTION__, &gpsCb);
-
-    mMutex.lock();
-    mGnssCbIface_2_0 = gpsCb;
-    mMutex.unlock();
-
-    if (mGnssCbIface_2_0 != nullptr) {
-        setCallbacks();
-    }
-}
-
-bool GnssAPIClient::gnssStart()
-{
-    LOC_LOGD("%s]: ()", __FUNCTION__);
-
-    mMutex.lock();
-    mTracking = true;
-    mMutex.unlock();
-
-    bool retVal = true;
-    locAPIStartTracking(mTrackingOptions);
-    return retVal;
-}
-
-bool GnssAPIClient::gnssStop()
-{
-    LOC_LOGD("%s]: ()", __FUNCTION__);
-
-    mMutex.lock();
-    mTracking = false;
-    mMutex.unlock();
-
-    bool retVal = true;
-    locAPIStopTracking();
-    return retVal;
-}
-
-bool GnssAPIClient::gnssSetPositionMode(IGnss::GnssPositionMode mode,
-        IGnss::GnssPositionRecurrence recurrence, uint32_t minIntervalMs,
-        uint32_t preferredAccuracyMeters, uint32_t preferredTimeMs,
-        GnssPowerMode powerMode, uint32_t timeBetweenMeasurement)
-{
-    LOC_LOGD("%s]: (%d %d %d %d %d %d %d)", __FUNCTION__,
-            (int)mode, recurrence, minIntervalMs, preferredAccuracyMeters,
-            preferredTimeMs, (int)powerMode, timeBetweenMeasurement);
-    bool retVal = true;
-    memset(&mTrackingOptions, 0, sizeof(TrackingOptions));
-    mTrackingOptions.size = sizeof(TrackingOptions);
-    mTrackingOptions.minInterval = minIntervalMs;
-    if (IGnss::GnssPositionMode::MS_ASSISTED == mode ||
-            IGnss::GnssPositionRecurrence::RECURRENCE_SINGLE == recurrence) {
-        // We set a very large interval to simulate SINGLE mode. Once we report a fix,
-        // the caller should take the responsibility to stop the session.
-        // For MSA, we always treat it as SINGLE mode.
-        mTrackingOptions.minInterval = SINGLE_SHOT_MIN_TRACKING_INTERVAL_MSEC;
-    }
-    if (mode == IGnss::GnssPositionMode::STANDALONE)
-        mTrackingOptions.mode = GNSS_SUPL_MODE_STANDALONE;
-    else if (mode == IGnss::GnssPositionMode::MS_BASED)
-        mTrackingOptions.mode = GNSS_SUPL_MODE_MSB;
-    else if (mode ==  IGnss::GnssPositionMode::MS_ASSISTED)
-        mTrackingOptions.mode = GNSS_SUPL_MODE_MSA;
-    else {
-        LOC_LOGD("%s]: invalid GnssPositionMode: %d", __FUNCTION__, (int)mode);
-        retVal = false;
-    }
-    if (GNSS_POWER_MODE_INVALID != powerMode) {
-        mTrackingOptions.powerMode = powerMode;
-        mTrackingOptions.tbm = timeBetweenMeasurement;
-    }
-    locAPIUpdateTrackingOptions(mTrackingOptions);
-    return retVal;
-}
-
-// for GpsNiInterface
-void GnssAPIClient::gnssNiRespond(int32_t notifId,
-        IGnssNiCallback::GnssUserResponseType userResponse)
-{
-    LOC_LOGD("%s]: (%d %d)", __FUNCTION__, notifId, static_cast<int>(userResponse));
-    GnssNiResponse data;
-    switch (userResponse) {
-    case IGnssNiCallback::GnssUserResponseType::RESPONSE_ACCEPT:
-        data = GNSS_NI_RESPONSE_ACCEPT;
-        break;
-    case IGnssNiCallback::GnssUserResponseType::RESPONSE_DENY:
-        data = GNSS_NI_RESPONSE_DENY;
-        break;
-    case IGnssNiCallback::GnssUserResponseType::RESPONSE_NORESP:
-        data = GNSS_NI_RESPONSE_NO_RESPONSE;
-        break;
-    default:
-        data = GNSS_NI_RESPONSE_IGNORE;
-        break;
-    }
-
-    locAPIGnssNiResponse(notifId, data);
-}
-
-// these apis using LocationAPIControlClient
-void GnssAPIClient::gnssDeleteAidingData(IGnss::GnssAidingData aidingDataFlags)
-{
-    LOC_LOGD("%s]: (%02hx)", __FUNCTION__, aidingDataFlags);
-    if (mControlClient == nullptr) {
-        return;
-    }
-    GnssAidingData data;
-    memset(&data, 0, sizeof (GnssAidingData));
-    data.sv.svTypeMask = GNSS_AIDING_DATA_SV_TYPE_GPS_BIT |
-        GNSS_AIDING_DATA_SV_TYPE_GLONASS_BIT |
-        GNSS_AIDING_DATA_SV_TYPE_QZSS_BIT |
-        GNSS_AIDING_DATA_SV_TYPE_BEIDOU_BIT |
-        GNSS_AIDING_DATA_SV_TYPE_GALILEO_BIT |
-        GNSS_AIDING_DATA_SV_TYPE_NAVIC_BIT;
-    data.posEngineMask = STANDARD_POSITIONING_ENGINE;
-
-    if (aidingDataFlags == IGnss::GnssAidingData::DELETE_ALL)
-        data.deleteAll = true;
-    else {
-        if (aidingDataFlags & IGnss::GnssAidingData::DELETE_EPHEMERIS)
-            data.sv.svMask |= GNSS_AIDING_DATA_SV_EPHEMERIS_BIT;
-        if (aidingDataFlags & IGnss::GnssAidingData::DELETE_ALMANAC)
-            data.sv.svMask |= GNSS_AIDING_DATA_SV_ALMANAC_BIT;
-        if (aidingDataFlags & IGnss::GnssAidingData::DELETE_POSITION)
-            data.common.mask |= GNSS_AIDING_DATA_COMMON_POSITION_BIT;
-        if (aidingDataFlags & IGnss::GnssAidingData::DELETE_TIME)
-            data.common.mask |= GNSS_AIDING_DATA_COMMON_TIME_BIT;
-        if (aidingDataFlags & IGnss::GnssAidingData::DELETE_IONO)
-            data.sv.svMask |= GNSS_AIDING_DATA_SV_IONOSPHERE_BIT;
-        if (aidingDataFlags & IGnss::GnssAidingData::DELETE_UTC)
-            data.common.mask |= GNSS_AIDING_DATA_COMMON_UTC_BIT;
-        if (aidingDataFlags & IGnss::GnssAidingData::DELETE_HEALTH)
-            data.sv.svMask |= GNSS_AIDING_DATA_SV_HEALTH_BIT;
-        if (aidingDataFlags & IGnss::GnssAidingData::DELETE_SVDIR)
-            data.sv.svMask |= GNSS_AIDING_DATA_SV_DIRECTION_BIT;
-        if (aidingDataFlags & IGnss::GnssAidingData::DELETE_SVSTEER)
-            data.sv.svMask |= GNSS_AIDING_DATA_SV_STEER_BIT;
-        if (aidingDataFlags & IGnss::GnssAidingData::DELETE_SADATA)
-            data.sv.svMask |= GNSS_AIDING_DATA_SV_SA_DATA_BIT;
-        if (aidingDataFlags & IGnss::GnssAidingData::DELETE_RTI)
-            data.common.mask |= GNSS_AIDING_DATA_COMMON_RTI_BIT;
-        if (aidingDataFlags & IGnss::GnssAidingData::DELETE_CELLDB_INFO)
-            data.common.mask |= GNSS_AIDING_DATA_COMMON_CELLDB_BIT;
-    }
-    mControlClient->locAPIGnssDeleteAidingData(data);
-}
-
-void GnssAPIClient::gnssEnable(LocationTechnologyType techType)
-{
-    LOC_LOGD("%s]: (%0d)", __FUNCTION__, techType);
-    if (mControlClient == nullptr) {
-        return;
-    }
-    mControlClient->locAPIEnable(techType);
-}
-
-void GnssAPIClient::gnssDisable()
-{
-    LOC_LOGD("%s]: ()", __FUNCTION__);
-    if (mControlClient == nullptr) {
-        return;
-    }
-    mControlClient->locAPIDisable();
-}
-
-void GnssAPIClient::gnssConfigurationUpdate(const GnssConfig& gnssConfig)
-{
-    LOC_LOGD("%s]: (%02x)", __FUNCTION__, gnssConfig.flags);
-    if (mControlClient == nullptr) {
-        return;
-    }
-    mControlClient->locAPIGnssUpdateConfig(gnssConfig);
-}
-
-void GnssAPIClient::requestCapabilities() {
-    // only send capablities if it's already cached, otherwise the first time LocationAPI
-    // is initialized, capabilities will be sent by LocationAPI
-    if (mLocationCapabilitiesCached) {
-        onCapabilitiesCb(mLocationCapabilitiesMask);
-    }
-}
-
-// callbacks
-void GnssAPIClient::onCapabilitiesCb(LocationCapabilitiesMask capabilitiesMask)
-{
-    LOC_LOGD("%s]: (%" PRIu64 ")", __FUNCTION__, capabilitiesMask);
-    mLocationCapabilitiesMask = capabilitiesMask;
-    mLocationCapabilitiesCached = true;
-
-    mMutex.lock();
-    auto gnssCbIface(mGnssCbIface);
-    auto gnssCbIface_2_0(mGnssCbIface_2_0);
-    mMutex.unlock();
-
-    if (gnssCbIface_2_0 != nullptr || gnssCbIface != nullptr) {
-        uint32_t data = 0;
-        if ((capabilitiesMask & LOCATION_CAPABILITIES_TIME_BASED_TRACKING_BIT) ||
-                (capabilitiesMask & LOCATION_CAPABILITIES_TIME_BASED_BATCHING_BIT) ||
-                (capabilitiesMask & LOCATION_CAPABILITIES_DISTANCE_BASED_TRACKING_BIT) ||
-                (capabilitiesMask & LOCATION_CAPABILITIES_DISTANCE_BASED_BATCHING_BIT))
-            data |= IGnssCallback::Capabilities::SCHEDULING;
-        if (capabilitiesMask & LOCATION_CAPABILITIES_GEOFENCE_BIT)
-            data |= V1_0::IGnssCallback::Capabilities::GEOFENCING;
-        if (capabilitiesMask & LOCATION_CAPABILITIES_GNSS_MEASUREMENTS_BIT)
-            data |= V1_0::IGnssCallback::Capabilities::MEASUREMENTS;
-        if (capabilitiesMask & LOCATION_CAPABILITIES_GNSS_MSB_BIT)
-            data |= IGnssCallback::Capabilities::MSB;
-        if (capabilitiesMask & LOCATION_CAPABILITIES_GNSS_MSA_BIT)
-            data |= IGnssCallback::Capabilities::MSA;
-        if (capabilitiesMask & LOCATION_CAPABILITIES_AGPM_BIT)
-            data |= IGnssCallback::Capabilities::LOW_POWER_MODE;
-        if (capabilitiesMask & LOCATION_CAPABILITIES_CONSTELLATION_ENABLEMENT_BIT)
-            data |= IGnssCallback::Capabilities::SATELLITE_BLACKLIST;
-
-        IGnssCallback::GnssSystemInfo gnssInfo = { .yearOfHw = 2015 };
-
-        if (capabilitiesMask & LOCATION_CAPABILITIES_GNSS_MEASUREMENTS_BIT) {
-            gnssInfo.yearOfHw++; // 2016
-            if (capabilitiesMask & LOCATION_CAPABILITIES_DEBUG_NMEA_BIT) {
-                gnssInfo.yearOfHw++; // 2017
-                if (capabilitiesMask & LOCATION_CAPABILITIES_CONSTELLATION_ENABLEMENT_BIT ||
-                    capabilitiesMask & LOCATION_CAPABILITIES_AGPM_BIT) {
-                    gnssInfo.yearOfHw++; // 2018
-                    if (capabilitiesMask & LOCATION_CAPABILITIES_PRIVACY_BIT) {
-                        gnssInfo.yearOfHw++; // 2019
-                    }
-                }
-            }
-        }
-        LOC_LOGV("%s:%d] set_system_info_cb (%d)", __FUNCTION__, __LINE__, gnssInfo.yearOfHw);
-
-        if (gnssCbIface_2_0 != nullptr) {
-            auto r = gnssCbIface_2_0->gnssSetCapabilitiesCb_2_0(data);
-            if (!r.isOk()) {
-                LOC_LOGE("%s] Error from gnssSetCapabilitiesCb_2_0 description=%s",
-                    __func__, r.description().c_str());
-            }
-            r = gnssCbIface_2_0->gnssSetSystemInfoCb(gnssInfo);
-            if (!r.isOk()) {
-                LOC_LOGE("%s] Error from gnssSetSystemInfoCb description=%s",
-                    __func__, r.description().c_str());
-            }
-        } else if (gnssCbIface != nullptr) {
-            auto r = gnssCbIface->gnssSetCapabilitesCb(data);
-            if (!r.isOk()) {
-                LOC_LOGE("%s] Error from gnssSetCapabilitesCb description=%s",
-                    __func__, r.description().c_str());
-            }
-            r = gnssCbIface->gnssSetSystemInfoCb(gnssInfo);
-            if (!r.isOk()) {
-                LOC_LOGE("%s] Error from gnssSetSystemInfoCb description=%s",
-                    __func__, r.description().c_str());
-            }
-        }
-
-    }
-
-}
-
-void GnssAPIClient::onTrackingCb(Location location)
-{
-    mMutex.lock();
-    auto gnssCbIface(mGnssCbIface);
-    auto gnssCbIface_2_0(mGnssCbIface_2_0);
-    bool isTracking = mTracking;
-    mMutex.unlock();
-
-    LOC_LOGD("%s]: (flags: %02x isTracking: %d)", __FUNCTION__, location.flags, isTracking);
-
-    if (!isTracking) {
-        return;
-    }
-
-    if (gnssCbIface_2_0 != nullptr) {
-        V2_0::GnssLocation gnssLocation;
-        convertGnssLocation(location, gnssLocation);
-        auto r = gnssCbIface_2_0->gnssLocationCb_2_0(gnssLocation);
-        if (!r.isOk()) {
-            LOC_LOGE("%s] Error from gnssLocationCb_2_0 description=%s",
-                __func__, r.description().c_str());
-        }
-    } else if (gnssCbIface != nullptr) {
-        V1_0::GnssLocation gnssLocation;
-        convertGnssLocation(location, gnssLocation);
-        auto r = gnssCbIface->gnssLocationCb(gnssLocation);
-        if (!r.isOk()) {
-            LOC_LOGE("%s] Error from gnssLocationCb description=%s",
-                __func__, r.description().c_str());
-        }
-    } else {
-        LOC_LOGW("%s] No GNSS Interface ready for gnssLocationCb ", __FUNCTION__);
-    }
-
-}
-
-void GnssAPIClient::onGnssNiCb(uint32_t id, GnssNiNotification gnssNiNotification)
-{
-    LOC_LOGD("%s]: (id: %d)", __FUNCTION__, id);
-    mMutex.lock();
-    auto gnssNiCbIface(mGnssNiCbIface);
-    mMutex.unlock();
-
-    if (gnssNiCbIface == nullptr) {
-        LOC_LOGE("%s]: mGnssNiCbIface is nullptr", __FUNCTION__);
-        return;
-    }
-
-    IGnssNiCallback::GnssNiNotification notificationGnss = {};
-
-    notificationGnss.notificationId = id;
-
-    if (gnssNiNotification.type == GNSS_NI_TYPE_VOICE)
-        notificationGnss.niType = IGnssNiCallback::GnssNiType::VOICE;
-    else if (gnssNiNotification.type == GNSS_NI_TYPE_SUPL)
-        notificationGnss.niType = IGnssNiCallback::GnssNiType::UMTS_SUPL;
-    else if (gnssNiNotification.type == GNSS_NI_TYPE_CONTROL_PLANE)
-        notificationGnss.niType = IGnssNiCallback::GnssNiType::UMTS_CTRL_PLANE;
-    else if (gnssNiNotification.type == GNSS_NI_TYPE_EMERGENCY_SUPL)
-        notificationGnss.niType = IGnssNiCallback::GnssNiType::EMERGENCY_SUPL;
-
-    if (gnssNiNotification.options & GNSS_NI_OPTIONS_NOTIFICATION_BIT)
-        notificationGnss.notifyFlags |= IGnssNiCallback::GnssNiNotifyFlags::NEED_NOTIFY;
-    if (gnssNiNotification.options & GNSS_NI_OPTIONS_VERIFICATION_BIT)
-        notificationGnss.notifyFlags |= IGnssNiCallback::GnssNiNotifyFlags::NEED_VERIFY;
-    if (gnssNiNotification.options & GNSS_NI_OPTIONS_PRIVACY_OVERRIDE_BIT)
-        notificationGnss.notifyFlags |= IGnssNiCallback::GnssNiNotifyFlags::PRIVACY_OVERRIDE;
-
-    notificationGnss.timeoutSec = gnssNiNotification.timeout;
-
-    if (gnssNiNotification.timeoutResponse == GNSS_NI_RESPONSE_ACCEPT)
-        notificationGnss.defaultResponse = IGnssNiCallback::GnssUserResponseType::RESPONSE_ACCEPT;
-    else if (gnssNiNotification.timeoutResponse == GNSS_NI_RESPONSE_DENY)
-        notificationGnss.defaultResponse = IGnssNiCallback::GnssUserResponseType::RESPONSE_DENY;
-    else if (gnssNiNotification.timeoutResponse == GNSS_NI_RESPONSE_NO_RESPONSE ||
-            gnssNiNotification.timeoutResponse == GNSS_NI_RESPONSE_IGNORE)
-        notificationGnss.defaultResponse = IGnssNiCallback::GnssUserResponseType::RESPONSE_NORESP;
-
-    notificationGnss.requestorId = gnssNiNotification.requestor;
-
-    notificationGnss.notificationMessage = gnssNiNotification.message;
-
-    if (gnssNiNotification.requestorEncoding == GNSS_NI_ENCODING_TYPE_NONE)
-        notificationGnss.requestorIdEncoding =
-            IGnssNiCallback::GnssNiEncodingType::ENC_NONE;
-    else if (gnssNiNotification.requestorEncoding == GNSS_NI_ENCODING_TYPE_GSM_DEFAULT)
-        notificationGnss.requestorIdEncoding =
-            IGnssNiCallback::GnssNiEncodingType::ENC_SUPL_GSM_DEFAULT;
-    else if (gnssNiNotification.requestorEncoding == GNSS_NI_ENCODING_TYPE_UTF8)
-        notificationGnss.requestorIdEncoding =
-            IGnssNiCallback::GnssNiEncodingType::ENC_SUPL_UTF8;
-    else if (gnssNiNotification.requestorEncoding == GNSS_NI_ENCODING_TYPE_UCS2)
-        notificationGnss.requestorIdEncoding =
-            IGnssNiCallback::GnssNiEncodingType::ENC_SUPL_UCS2;
-
-    if (gnssNiNotification.messageEncoding == GNSS_NI_ENCODING_TYPE_NONE)
-        notificationGnss.notificationIdEncoding =
-            IGnssNiCallback::GnssNiEncodingType::ENC_NONE;
-    else if (gnssNiNotification.messageEncoding == GNSS_NI_ENCODING_TYPE_GSM_DEFAULT)
-        notificationGnss.notificationIdEncoding =
-            IGnssNiCallback::GnssNiEncodingType::ENC_SUPL_GSM_DEFAULT;
-    else if (gnssNiNotification.messageEncoding == GNSS_NI_ENCODING_TYPE_UTF8)
-        notificationGnss.notificationIdEncoding =
-            IGnssNiCallback::GnssNiEncodingType::ENC_SUPL_UTF8;
-    else if (gnssNiNotification.messageEncoding == GNSS_NI_ENCODING_TYPE_UCS2)
-        notificationGnss.notificationIdEncoding =
-            IGnssNiCallback::GnssNiEncodingType::ENC_SUPL_UCS2;
-
-    gnssNiCbIface->niNotifyCb(notificationGnss);
-}
-
-void GnssAPIClient::onGnssSvCb(GnssSvNotification gnssSvNotification)
-{
-    LOC_LOGD("%s]: (count: %u)", __FUNCTION__, gnssSvNotification.count);
-    mMutex.lock();
-    auto gnssCbIface(mGnssCbIface);
-    auto gnssCbIface_2_0(mGnssCbIface_2_0);
-    mMutex.unlock();
-
-    if (gnssCbIface_2_0 != nullptr) {
-        hidl_vec<V2_0::IGnssCallback::GnssSvInfo> svInfoList;
-        convertGnssSvStatus(gnssSvNotification, svInfoList);
-        auto r = gnssCbIface_2_0->gnssSvStatusCb_2_0(svInfoList);
-        if (!r.isOk()) {
-            LOC_LOGE("%s] Error from gnssSvStatusCb_2_0 description=%s",
-                __func__, r.description().c_str());
-        }
-    } else if (gnssCbIface != nullptr) {
-        V1_0::IGnssCallback::GnssSvStatus svStatus;
-        convertGnssSvStatus(gnssSvNotification, svStatus);
-        auto r = gnssCbIface->gnssSvStatusCb(svStatus);
-        if (!r.isOk()) {
-            LOC_LOGE("%s] Error from gnssSvStatusCb description=%s",
-                __func__, r.description().c_str());
-        }
-    }
-}
-
-void GnssAPIClient::onGnssNmeaCb(GnssNmeaNotification gnssNmeaNotification)
-{
-    mMutex.lock();
-    auto gnssCbIface(mGnssCbIface);
-    auto gnssCbIface_2_0(mGnssCbIface_2_0);
-    mMutex.unlock();
-
-    if (gnssCbIface != nullptr || gnssCbIface_2_0 != nullptr) {
-        const std::string s(gnssNmeaNotification.nmea);
-        std::stringstream ss(s);
-        std::string each;
-        while(std::getline(ss, each, '\n')) {
-            each += '\n';
-            android::hardware::hidl_string nmeaString;
-            nmeaString.setToExternal(each.c_str(), each.length());
-            if (gnssCbIface_2_0 != nullptr) {
-                auto r = gnssCbIface_2_0->gnssNmeaCb(
-                        static_cast<V1_0::GnssUtcTime>(gnssNmeaNotification.timestamp), nmeaString);
-                if (!r.isOk()) {
-                    LOC_LOGE("%s] Error from gnssCbIface_2_0 nmea=%s length=%u description=%s",
-                             __func__, gnssNmeaNotification.nmea, gnssNmeaNotification.length,
-                             r.description().c_str());
-                }
-            } else if (gnssCbIface != nullptr) {
-                auto r = gnssCbIface->gnssNmeaCb(
-                        static_cast<V1_0::GnssUtcTime>(gnssNmeaNotification.timestamp), nmeaString);
-                if (!r.isOk()) {
-                    LOC_LOGE("%s] Error from gnssNmeaCb nmea=%s length=%u description=%s",
-                             __func__, gnssNmeaNotification.nmea, gnssNmeaNotification.length,
-                             r.description().c_str());
-                }
-            }
-        }
-    }
-}
-
-void GnssAPIClient::onStartTrackingCb(LocationError error)
-{
-    LOC_LOGD("%s]: (%d)", __FUNCTION__, error);
-    mMutex.lock();
-    auto gnssCbIface(mGnssCbIface);
-    auto gnssCbIface_2_0(mGnssCbIface_2_0);
-    mMutex.unlock();
-
-    if (error == LOCATION_ERROR_SUCCESS) {
-        if (gnssCbIface_2_0 != nullptr) {
-            auto r = gnssCbIface_2_0->gnssStatusCb(IGnssCallback::GnssStatusValue::ENGINE_ON);
-            if (!r.isOk()) {
-                LOC_LOGE("%s] Error from gnssStatusCb 2.0 ENGINE_ON description=%s",
-                    __func__, r.description().c_str());
-            }
-            r = gnssCbIface_2_0->gnssStatusCb(IGnssCallback::GnssStatusValue::SESSION_BEGIN);
-            if (!r.isOk()) {
-                LOC_LOGE("%s] Error from gnssStatusCb 2.0 SESSION_BEGIN description=%s",
-                    __func__, r.description().c_str());
-            }
-        } else if (gnssCbIface != nullptr) {
-            auto r = gnssCbIface->gnssStatusCb(IGnssCallback::GnssStatusValue::ENGINE_ON);
-            if (!r.isOk()) {
-                LOC_LOGE("%s] Error from gnssStatusCb ENGINE_ON description=%s",
-                    __func__, r.description().c_str());
-            }
-            r = gnssCbIface->gnssStatusCb(IGnssCallback::GnssStatusValue::SESSION_BEGIN);
-            if (!r.isOk()) {
-                LOC_LOGE("%s] Error from gnssStatusCb SESSION_BEGIN description=%s",
-                    __func__, r.description().c_str());
-            }
-        }
-    }
-}
-
-void GnssAPIClient::onStopTrackingCb(LocationError error)
-{
-    LOC_LOGD("%s]: (%d)", __FUNCTION__, error);
-    mMutex.lock();
-    auto gnssCbIface(mGnssCbIface);
-    auto gnssCbIface_2_0(mGnssCbIface_2_0);
-    mMutex.unlock();
-
-    if (error == LOCATION_ERROR_SUCCESS) {
-        if (gnssCbIface_2_0 != nullptr) {
-            auto r = gnssCbIface_2_0->gnssStatusCb(IGnssCallback::GnssStatusValue::SESSION_END);
-            if (!r.isOk()) {
-                LOC_LOGE("%s] Error from gnssStatusCb 2.0 SESSION_END description=%s",
-                    __func__, r.description().c_str());
-            }
-            r = gnssCbIface_2_0->gnssStatusCb(IGnssCallback::GnssStatusValue::ENGINE_OFF);
-            if (!r.isOk()) {
-                LOC_LOGE("%s] Error from gnssStatusCb 2.0 ENGINE_OFF description=%s",
-                    __func__, r.description().c_str());
-            }
-
-        } else if (gnssCbIface != nullptr) {
-            auto r = gnssCbIface->gnssStatusCb(IGnssCallback::GnssStatusValue::SESSION_END);
-            if (!r.isOk()) {
-                LOC_LOGE("%s] Error from gnssStatusCb SESSION_END description=%s",
-                    __func__, r.description().c_str());
-            }
-            r = gnssCbIface->gnssStatusCb(IGnssCallback::GnssStatusValue::ENGINE_OFF);
-            if (!r.isOk()) {
-                LOC_LOGE("%s] Error from gnssStatusCb ENGINE_OFF description=%s",
-                    __func__, r.description().c_str());
-            }
-        }
-    }
-}
-
-static void convertGnssSvStatus(GnssSvNotification& in, V1_0::IGnssCallback::GnssSvStatus& out)
-{
-    memset(&out, 0, sizeof(IGnssCallback::GnssSvStatus));
-    out.numSvs = in.count;
-    if (out.numSvs > static_cast<uint32_t>(V1_0::GnssMax::SVS_COUNT)) {
-        LOC_LOGW("%s]: Too many satellites %u. Clamps to %d.",
-                __FUNCTION__,  out.numSvs, V1_0::GnssMax::SVS_COUNT);
-        out.numSvs = static_cast<uint32_t>(V1_0::GnssMax::SVS_COUNT);
-    }
-    for (size_t i = 0; i < out.numSvs; i++) {
-        convertGnssSvid(in.gnssSvs[i], out.gnssSvList[i].svid);
-        convertGnssConstellationType(in.gnssSvs[i].type, out.gnssSvList[i].constellation);
-        out.gnssSvList[i].cN0Dbhz = in.gnssSvs[i].cN0Dbhz;
-        out.gnssSvList[i].elevationDegrees = in.gnssSvs[i].elevation;
-        out.gnssSvList[i].azimuthDegrees = in.gnssSvs[i].azimuth;
-        out.gnssSvList[i].carrierFrequencyHz = in.gnssSvs[i].carrierFrequencyHz;
-        out.gnssSvList[i].svFlag = static_cast<uint8_t>(IGnssCallback::GnssSvFlags::NONE);
-        if (in.gnssSvs[i].gnssSvOptionsMask & GNSS_SV_OPTIONS_HAS_EPHEMER_BIT)
-            out.gnssSvList[i].svFlag |= IGnssCallback::GnssSvFlags::HAS_EPHEMERIS_DATA;
-        if (in.gnssSvs[i].gnssSvOptionsMask & GNSS_SV_OPTIONS_HAS_ALMANAC_BIT)
-            out.gnssSvList[i].svFlag |= IGnssCallback::GnssSvFlags::HAS_ALMANAC_DATA;
-        if (in.gnssSvs[i].gnssSvOptionsMask & GNSS_SV_OPTIONS_USED_IN_FIX_BIT)
-            out.gnssSvList[i].svFlag |= IGnssCallback::GnssSvFlags::USED_IN_FIX;
-        if (in.gnssSvs[i].gnssSvOptionsMask & GNSS_SV_OPTIONS_HAS_CARRIER_FREQUENCY_BIT)
-            out.gnssSvList[i].svFlag |= IGnssCallback::GnssSvFlags::HAS_CARRIER_FREQUENCY;
-    }
-}
-
-static void convertGnssSvStatus(GnssSvNotification& in,
-        hidl_vec<V2_0::IGnssCallback::GnssSvInfo>& out)
-{
-    out.resize(in.count);
-    for (size_t i = 0; i < in.count; i++) {
-        convertGnssSvid(in.gnssSvs[i], out[i].v1_0.svid);
-        out[i].v1_0.cN0Dbhz = in.gnssSvs[i].cN0Dbhz;
-        out[i].v1_0.elevationDegrees = in.gnssSvs[i].elevation;
-        out[i].v1_0.azimuthDegrees = in.gnssSvs[i].azimuth;
-        out[i].v1_0.carrierFrequencyHz = in.gnssSvs[i].carrierFrequencyHz;
-        out[i].v1_0.svFlag = static_cast<uint8_t>(IGnssCallback::GnssSvFlags::NONE);
-        if (in.gnssSvs[i].gnssSvOptionsMask & GNSS_SV_OPTIONS_HAS_EPHEMER_BIT)
-            out[i].v1_0.svFlag |= IGnssCallback::GnssSvFlags::HAS_EPHEMERIS_DATA;
-        if (in.gnssSvs[i].gnssSvOptionsMask & GNSS_SV_OPTIONS_HAS_ALMANAC_BIT)
-            out[i].v1_0.svFlag |= IGnssCallback::GnssSvFlags::HAS_ALMANAC_DATA;
-        if (in.gnssSvs[i].gnssSvOptionsMask & GNSS_SV_OPTIONS_USED_IN_FIX_BIT)
-            out[i].v1_0.svFlag |= IGnssCallback::GnssSvFlags::USED_IN_FIX;
-        if (in.gnssSvs[i].gnssSvOptionsMask & GNSS_SV_OPTIONS_HAS_CARRIER_FREQUENCY_BIT)
-            out[i].v1_0.svFlag |= IGnssCallback::GnssSvFlags::HAS_CARRIER_FREQUENCY;
-
-        convertGnssConstellationType(in.gnssSvs[i].type, out[i].constellation);
-    }
-}
-
-}  // namespace implementation
-}  // namespace V2_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
diff --git a/gps/android/2.0/location_api/GnssAPIClient.h b/gps/android/2.0/location_api/GnssAPIClient.h
deleted file mode 100644
index cfa78c7..0000000
--- a/gps/android/2.0/location_api/GnssAPIClient.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- *       copyright notice, this list of conditions and the following
- *       disclaimer in the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of The Linux Foundation, nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#ifndef GNSS_API_CLINET_H
-#define GNSS_API_CLINET_H
-
-
-#include <mutex>
-#include <android/hardware/gnss/2.0/IGnss.h>
-#include <android/hardware/gnss/2.0/IGnssCallback.h>
-#include <LocationAPIClientBase.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V2_0 {
-namespace implementation {
-
-using ::android::sp;
-
-class GnssAPIClient : public LocationAPIClientBase
-{
-public:
-    GnssAPIClient(const sp<V1_0::IGnssCallback>& gpsCb,
-            const sp<V1_0::IGnssNiCallback>& niCb);
-    GnssAPIClient(const sp<V2_0::IGnssCallback>& gpsCb);
-    GnssAPIClient(const GnssAPIClient&) = delete;
-    GnssAPIClient& operator=(const GnssAPIClient&) = delete;
-
-    // for GpsInterface
-    void gnssUpdateCallbacks(const sp<V1_0::IGnssCallback>& gpsCb,
-            const sp<V1_0::IGnssNiCallback>& niCb);
-    void gnssUpdateCallbacks_2_0(const sp<V2_0::IGnssCallback>& gpsCb);
-    bool gnssStart();
-    bool gnssStop();
-    bool gnssSetPositionMode(V1_0::IGnss::GnssPositionMode mode,
-            V1_0::IGnss::GnssPositionRecurrence recurrence,
-            uint32_t minIntervalMs,
-            uint32_t preferredAccuracyMeters,
-            uint32_t preferredTimeMs,
-            GnssPowerMode powerMode = GNSS_POWER_MODE_INVALID,
-            uint32_t timeBetweenMeasurement = 0);
-
-    // for GpsNiInterface
-    void gnssNiRespond(int32_t notifId, V1_0::IGnssNiCallback::GnssUserResponseType userResponse);
-
-    // these apis using LocationAPIControlClient
-    void gnssDeleteAidingData(V1_0::IGnss::GnssAidingData aidingDataFlags);
-    void gnssEnable(LocationTechnologyType techType);
-    void gnssDisable();
-    void gnssConfigurationUpdate(const GnssConfig& gnssConfig);
-
-    inline LocationCapabilitiesMask gnssGetCapabilities() const {
-        return mLocationCapabilitiesMask;
-    }
-    void requestCapabilities();
-
-    // callbacks we are interested in
-    void onCapabilitiesCb(LocationCapabilitiesMask capabilitiesMask) final;
-    void onTrackingCb(Location location) final;
-    void onGnssNiCb(uint32_t id, GnssNiNotification gnssNiNotification) final;
-    void onGnssSvCb(GnssSvNotification gnssSvNotification) final;
-    void onGnssNmeaCb(GnssNmeaNotification gnssNmeaNotification) final;
-
-    void onStartTrackingCb(LocationError error) final;
-    void onStopTrackingCb(LocationError error) final;
-
-private:
-    virtual ~GnssAPIClient();
-
-    void setCallbacks();
-    void initLocationOptions();
-    sp<V1_0::IGnssCallback> mGnssCbIface;
-    sp<V1_0::IGnssNiCallback> mGnssNiCbIface;
-    std::mutex mMutex;
-    LocationAPIControlClient* mControlClient;
-    LocationCapabilitiesMask mLocationCapabilitiesMask;
-    bool mLocationCapabilitiesCached;
-    TrackingOptions mTrackingOptions;
-    bool mTracking;
-    sp<V2_0::IGnssCallback> mGnssCbIface_2_0;
-};
-
-}  // namespace implementation
-}  // namespace V2_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
-#endif // GNSS_API_CLINET_H
diff --git a/gps/android/2.0/location_api/LocationUtil.cpp b/gps/android/2.0/location_api/LocationUtil.cpp
deleted file mode 100644
index 961b7b1..0000000
--- a/gps/android/2.0/location_api/LocationUtil.cpp
+++ /dev/null
@@ -1,334 +0,0 @@
-/* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- *       copyright notice, this list of conditions and the following
- *       disclaimer in the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of The Linux Foundation, nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#include <LocationUtil.h>
-#include <log_util.h>
-#include <inttypes.h>
-#include <gps_extended_c.h>
-#include <loc_misc_utils.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V2_0 {
-namespace implementation {
-
-using ::android::hardware::gnss::V2_0::GnssLocation;
-using ::android::hardware::gnss::V2_0::ElapsedRealtimeFlags;
-using ::android::hardware::gnss::V2_0::GnssConstellationType;
-using ::android::hardware::gnss::V1_0::GnssLocationFlags;
-
-void convertGnssLocation(Location& in, V1_0::GnssLocation& out)
-{
-    memset(&out, 0, sizeof(V1_0::GnssLocation));
-    if (in.flags & LOCATION_HAS_LAT_LONG_BIT) {
-        out.gnssLocationFlags |= GnssLocationFlags::HAS_LAT_LONG;
-        out.latitudeDegrees = in.latitude;
-        out.longitudeDegrees = in.longitude;
-    }
-    if (in.flags & LOCATION_HAS_ALTITUDE_BIT) {
-        out.gnssLocationFlags |= GnssLocationFlags::HAS_ALTITUDE;
-        out.altitudeMeters = in.altitude;
-    }
-    if (in.flags & LOCATION_HAS_SPEED_BIT) {
-        out.gnssLocationFlags |= GnssLocationFlags::HAS_SPEED;
-        out.speedMetersPerSec = in.speed;
-    }
-    if (in.flags & LOCATION_HAS_BEARING_BIT) {
-        out.gnssLocationFlags |= GnssLocationFlags::HAS_BEARING;
-        out.bearingDegrees = in.bearing;
-    }
-    if (in.flags & LOCATION_HAS_ACCURACY_BIT) {
-        out.gnssLocationFlags |= GnssLocationFlags::HAS_HORIZONTAL_ACCURACY;
-        out.horizontalAccuracyMeters = in.accuracy;
-    }
-    if (in.flags & LOCATION_HAS_VERTICAL_ACCURACY_BIT) {
-        out.gnssLocationFlags |= GnssLocationFlags::HAS_VERTICAL_ACCURACY;
-        out.verticalAccuracyMeters = in.verticalAccuracy;
-    }
-    if (in.flags & LOCATION_HAS_SPEED_ACCURACY_BIT) {
-        out.gnssLocationFlags |= GnssLocationFlags::HAS_SPEED_ACCURACY;
-        out.speedAccuracyMetersPerSecond = in.speedAccuracy;
-    }
-    if (in.flags & LOCATION_HAS_BEARING_ACCURACY_BIT) {
-        out.gnssLocationFlags |= GnssLocationFlags::HAS_BEARING_ACCURACY;
-        out.bearingAccuracyDegrees = in.bearingAccuracy;
-    }
-
-    out.timestamp = static_cast<V1_0::GnssUtcTime>(in.timestamp);
-}
-
-void convertGnssLocation(Location& in, V2_0::GnssLocation& out)
-{
-    memset(&out, 0, sizeof(V2_0::GnssLocation));
-    convertGnssLocation(in, out.v1_0);
-
-    if (in.flags & LOCATION_HAS_ELAPSED_REAL_TIME) {
-        out.elapsedRealtime.flags |= ElapsedRealtimeFlags::HAS_TIMESTAMP_NS;
-        out.elapsedRealtime.timestampNs = in.elapsedRealTime;
-        out.elapsedRealtime.flags |= ElapsedRealtimeFlags::HAS_TIME_UNCERTAINTY_NS;
-        out.elapsedRealtime.timeUncertaintyNs = in.elapsedRealTimeUnc;
-        LOC_LOGd("out.elapsedRealtime.timestampNs=%" PRIi64 ""
-                 " out.elapsedRealtime.timeUncertaintyNs=%" PRIi64 ""
-                 " out.elapsedRealtime.flags=0x%X",
-                 out.elapsedRealtime.timestampNs,
-                 out.elapsedRealtime.timeUncertaintyNs, out.elapsedRealtime.flags);
-    }
-}
-
-void convertGnssLocation(const V1_0::GnssLocation& in, Location& out)
-{
-    memset(&out, 0, sizeof(out));
-    if (in.gnssLocationFlags & GnssLocationFlags::HAS_LAT_LONG) {
-        out.flags |= LOCATION_HAS_LAT_LONG_BIT;
-        out.latitude = in.latitudeDegrees;
-        out.longitude = in.longitudeDegrees;
-    }
-    if (in.gnssLocationFlags & GnssLocationFlags::HAS_ALTITUDE) {
-        out.flags |= LOCATION_HAS_ALTITUDE_BIT;
-        out.altitude = in.altitudeMeters;
-    }
-    if (in.gnssLocationFlags & GnssLocationFlags::HAS_SPEED) {
-        out.flags |= LOCATION_HAS_SPEED_BIT;
-        out.speed = in.speedMetersPerSec;
-    }
-    if (in.gnssLocationFlags & GnssLocationFlags::HAS_BEARING) {
-        out.flags |= LOCATION_HAS_BEARING_BIT;
-        out.bearing = in.bearingDegrees;
-    }
-    if (in.gnssLocationFlags & GnssLocationFlags::HAS_HORIZONTAL_ACCURACY) {
-        out.flags |= LOCATION_HAS_ACCURACY_BIT;
-        out.accuracy = in.horizontalAccuracyMeters;
-    }
-    if (in.gnssLocationFlags & GnssLocationFlags::HAS_VERTICAL_ACCURACY) {
-        out.flags |= LOCATION_HAS_VERTICAL_ACCURACY_BIT;
-        out.verticalAccuracy = in.verticalAccuracyMeters;
-    }
-    if (in.gnssLocationFlags & GnssLocationFlags::HAS_SPEED_ACCURACY) {
-        out.flags |= LOCATION_HAS_SPEED_ACCURACY_BIT;
-        out.speedAccuracy = in.speedAccuracyMetersPerSecond;
-    }
-    if (in.gnssLocationFlags & GnssLocationFlags::HAS_BEARING_ACCURACY) {
-        out.flags |= LOCATION_HAS_BEARING_ACCURACY_BIT;
-        out.bearingAccuracy = in.bearingAccuracyDegrees;
-    }
-
-    out.timestamp = static_cast<uint64_t>(in.timestamp);
-}
-
-void convertGnssLocation(const V2_0::GnssLocation& in, Location& out)
-{
-    memset(&out, 0, sizeof(out));
-    convertGnssLocation(in.v1_0, out);
-}
-
-void convertGnssConstellationType(GnssSvType& in, V1_0::GnssConstellationType& out)
-{
-    switch(in) {
-        case GNSS_SV_TYPE_GPS:
-            out = V1_0::GnssConstellationType::GPS;
-            break;
-        case GNSS_SV_TYPE_SBAS:
-            out = V1_0::GnssConstellationType::SBAS;
-            break;
-        case GNSS_SV_TYPE_GLONASS:
-            out = V1_0::GnssConstellationType::GLONASS;
-            break;
-        case GNSS_SV_TYPE_QZSS:
-            out = V1_0::GnssConstellationType::QZSS;
-            break;
-        case GNSS_SV_TYPE_BEIDOU:
-            out = V1_0::GnssConstellationType::BEIDOU;
-            break;
-        case GNSS_SV_TYPE_GALILEO:
-            out = V1_0::GnssConstellationType::GALILEO;
-            break;
-        case GNSS_SV_TYPE_UNKNOWN:
-        default:
-            out = V1_0::GnssConstellationType::UNKNOWN;
-            break;
-    }
-}
-
-void convertGnssConstellationType(GnssSvType& in, V2_0::GnssConstellationType& out)
-{
-    switch(in) {
-        case GNSS_SV_TYPE_GPS:
-            out = V2_0::GnssConstellationType::GPS;
-            break;
-        case GNSS_SV_TYPE_SBAS:
-            out = V2_0::GnssConstellationType::SBAS;
-            break;
-        case GNSS_SV_TYPE_GLONASS:
-            out = V2_0::GnssConstellationType::GLONASS;
-            break;
-        case GNSS_SV_TYPE_QZSS:
-            out = V2_0::GnssConstellationType::QZSS;
-            break;
-        case GNSS_SV_TYPE_BEIDOU:
-            out = V2_0::GnssConstellationType::BEIDOU;
-            break;
-        case GNSS_SV_TYPE_GALILEO:
-            out = V2_0::GnssConstellationType::GALILEO;
-            break;
-        case GNSS_SV_TYPE_NAVIC:
-            out = V2_0::GnssConstellationType::IRNSS;
-            break;
-        case GNSS_SV_TYPE_UNKNOWN:
-        default:
-            out = V2_0::GnssConstellationType::UNKNOWN;
-            break;
-    }
-}
-
-void convertGnssSvid(GnssSv& in, int16_t& out)
-{
-    switch (in.type) {
-        case GNSS_SV_TYPE_GPS:
-            out = in.svId;
-            break;
-        case GNSS_SV_TYPE_SBAS:
-            out = in.svId;
-            break;
-        case GNSS_SV_TYPE_GLONASS:
-            if (!isGloSlotUnknown(in.svId)) { // OSN is known
-                out = in.svId - GLO_SV_PRN_MIN + 1;
-            } else { // OSN is not known, report FCN
-                out = in.gloFrequency + 92;
-            }
-            break;
-        case GNSS_SV_TYPE_QZSS:
-            out = in.svId;
-            break;
-        case GNSS_SV_TYPE_BEIDOU:
-            out = in.svId - BDS_SV_PRN_MIN + 1;
-            break;
-        case GNSS_SV_TYPE_GALILEO:
-            out = in.svId - GAL_SV_PRN_MIN + 1;
-            break;
-        case GNSS_SV_TYPE_NAVIC:
-            out = in.svId - NAVIC_SV_PRN_MIN + 1;
-            break;
-        default:
-            out = in.svId;
-            break;
-    }
-}
-
-void convertGnssSvid(GnssMeasurementsData& in, int16_t& out)
-{
-    switch (in.svType) {
-        case GNSS_SV_TYPE_GPS:
-            out = in.svId;
-            break;
-        case GNSS_SV_TYPE_SBAS:
-            out = in.svId;
-            break;
-        case GNSS_SV_TYPE_GLONASS:
-            if (!isGloSlotUnknown(in.svId)) { // OSN is known
-                out = in.svId - GLO_SV_PRN_MIN + 1;
-            } else { // OSN is not known, report FCN
-                out = in.gloFrequency + 92;
-            }
-            break;
-        case GNSS_SV_TYPE_QZSS:
-            out = in.svId;
-            break;
-        case GNSS_SV_TYPE_BEIDOU:
-            out = in.svId - BDS_SV_PRN_MIN + 1;
-            break;
-        case GNSS_SV_TYPE_GALILEO:
-            out = in.svId - GAL_SV_PRN_MIN + 1;
-            break;
-        case GNSS_SV_TYPE_NAVIC:
-            out = in.svId - NAVIC_SV_PRN_MIN + 1;
-            break;
-        default:
-            out = in.svId;
-            break;
-    }
-}
-
-void convertGnssEphemerisType(GnssEphemerisType& in, GnssDebug::SatelliteEphemerisType& out)
-{
-    switch(in) {
-        case GNSS_EPH_TYPE_EPHEMERIS:
-            out = GnssDebug::SatelliteEphemerisType::EPHEMERIS;
-            break;
-        case GNSS_EPH_TYPE_ALMANAC:
-            out = GnssDebug::SatelliteEphemerisType::ALMANAC_ONLY;
-            break;
-        case GNSS_EPH_TYPE_UNKNOWN:
-        default:
-            out = GnssDebug::SatelliteEphemerisType::NOT_AVAILABLE;
-            break;
-    }
-}
-
-void convertGnssEphemerisSource(GnssEphemerisSource& in, GnssDebug::SatelliteEphemerisSource& out)
-{
-    switch(in) {
-        case GNSS_EPH_SOURCE_DEMODULATED:
-            out = GnssDebug::SatelliteEphemerisSource::DEMODULATED;
-            break;
-        case GNSS_EPH_SOURCE_SUPL_PROVIDED:
-            out = GnssDebug::SatelliteEphemerisSource::SUPL_PROVIDED;
-            break;
-        case GNSS_EPH_SOURCE_OTHER_SERVER_PROVIDED:
-            out = GnssDebug::SatelliteEphemerisSource::OTHER_SERVER_PROVIDED;
-            break;
-        case GNSS_EPH_SOURCE_LOCAL:
-        case GNSS_EPH_SOURCE_UNKNOWN:
-        default:
-            out = GnssDebug::SatelliteEphemerisSource::OTHER;
-            break;
-    }
-}
-
-void convertGnssEphemerisHealth(GnssEphemerisHealth& in, GnssDebug::SatelliteEphemerisHealth& out)
-{
-    switch(in) {
-        case GNSS_EPH_HEALTH_GOOD:
-            out = GnssDebug::SatelliteEphemerisHealth::GOOD;
-            break;
-        case GNSS_EPH_HEALTH_BAD:
-            out = GnssDebug::SatelliteEphemerisHealth::BAD;
-            break;
-        case GNSS_EPH_HEALTH_UNKNOWN:
-        default:
-            out = GnssDebug::SatelliteEphemerisHealth::UNKNOWN;
-            break;
-    }
-}
-
-}  // namespace implementation
-}  // namespace V2_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
diff --git a/gps/android/2.0/location_api/LocationUtil.h b/gps/android/2.0/location_api/LocationUtil.h
deleted file mode 100644
index 70729e4..0000000
--- a/gps/android/2.0/location_api/LocationUtil.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- *       copyright notice, this list of conditions and the following
- *       disclaimer in the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of The Linux Foundation, nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#ifndef LOCATION_UTIL_H
-#define LOCATION_UTIL_H
-
-#include <android/hardware/gnss/2.0/types.h>
-#include <LocationAPI.h>
-#include <GnssDebug.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V2_0 {
-namespace implementation {
-
-void convertGnssLocation(Location& in, V1_0::GnssLocation& out);
-void convertGnssLocation(Location& in, V2_0::GnssLocation& out);
-void convertGnssLocation(const V1_0::GnssLocation& in, Location& out);
-void convertGnssLocation(const V2_0::GnssLocation& in, Location& out);
-void convertGnssConstellationType(GnssSvType& in, V1_0::GnssConstellationType& out);
-void convertGnssConstellationType(GnssSvType& in, V2_0::GnssConstellationType& out);
-void convertGnssSvid(GnssSv& in, int16_t& out);
-void convertGnssSvid(GnssMeasurementsData& in, int16_t& out);
-void convertGnssEphemerisType(GnssEphemerisType& in, GnssDebug::SatelliteEphemerisType& out);
-void convertGnssEphemerisSource(GnssEphemerisSource& in, GnssDebug::SatelliteEphemerisSource& out);
-void convertGnssEphemerisHealth(GnssEphemerisHealth& in, GnssDebug::SatelliteEphemerisHealth& out);
-
-}  // namespace implementation
-}  // namespace V2_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
-#endif // LOCATION_UTIL_H
diff --git a/gps/android/2.0/location_api/MeasurementAPIClient.cpp b/gps/android/2.0/location_api/MeasurementAPIClient.cpp
deleted file mode 100644
index e1cb3f8..0000000
--- a/gps/android/2.0/location_api/MeasurementAPIClient.cpp
+++ /dev/null
@@ -1,452 +0,0 @@
-/* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- *       copyright notice, this list of conditions and the following
- *       disclaimer in the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of The Linux Foundation, nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#define LOG_NDEBUG 0
-#define LOG_TAG "LocSvc_MeasurementAPIClient"
-
-#include <log_util.h>
-#include <loc_cfg.h>
-#include <inttypes.h>
-
-#include "LocationUtil.h"
-#include "MeasurementAPIClient.h"
-#include <loc_misc_utils.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V2_0 {
-namespace implementation {
-
-using ::android::hardware::gnss::V1_0::IGnssMeasurement;
-using ::android::hardware::gnss::V2_0::IGnssMeasurementCallback;
-
-static void convertGnssData(GnssMeasurementsNotification& in,
-        V1_0::IGnssMeasurementCallback::GnssData& out);
-static void convertGnssData_1_1(GnssMeasurementsNotification& in,
-        V1_1::IGnssMeasurementCallback::GnssData& out);
-static void convertGnssData_2_0(GnssMeasurementsNotification& in,
-        V2_0::IGnssMeasurementCallback::GnssData& out);
-static void convertGnssMeasurement(GnssMeasurementsData& in,
-        V1_0::IGnssMeasurementCallback::GnssMeasurement& out);
-static void convertGnssClock(GnssMeasurementsClock& in, IGnssMeasurementCallback::GnssClock& out);
-static void convertGnssMeasurementsCodeType(GnssMeasurementsCodeType& in,
-        ::android::hardware::hidl_string& out);
-static void convertElapsedRealtimeNanos(GnssMeasurementsNotification& in,
-        ::android::hardware::gnss::V2_0::ElapsedRealtime& elapsedRealtimeNanos);
-
-MeasurementAPIClient::MeasurementAPIClient() :
-    mGnssMeasurementCbIface(nullptr),
-    mGnssMeasurementCbIface_1_1(nullptr),
-    mGnssMeasurementCbIface_2_0(nullptr),
-    mTracking(false)
-{
-    LOC_LOGD("%s]: ()", __FUNCTION__);
-}
-
-MeasurementAPIClient::~MeasurementAPIClient()
-{
-    LOC_LOGD("%s]: ()", __FUNCTION__);
-}
-
-void MeasurementAPIClient::clearInterfaces()
-{
-    mGnssMeasurementCbIface = nullptr;
-    mGnssMeasurementCbIface_1_1 = nullptr;
-    mGnssMeasurementCbIface_2_0 = nullptr;
-}
-
-Return<IGnssMeasurement::GnssMeasurementStatus>
-MeasurementAPIClient::startTracking(
-        GnssPowerMode powerMode, uint32_t timeBetweenMeasurement)
-{
-    LocationCallbacks locationCallbacks;
-    memset(&locationCallbacks, 0, sizeof(LocationCallbacks));
-    locationCallbacks.size = sizeof(LocationCallbacks);
-
-    if (mGnssMeasurementCbIface_2_0 != nullptr ||
-        mGnssMeasurementCbIface_1_1 != nullptr ||
-        mGnssMeasurementCbIface != nullptr) {
-        locationCallbacks.gnssMeasurementsCb =
-            [this](GnssMeasurementsNotification gnssMeasurementsNotification) {
-                onGnssMeasurementsCb(gnssMeasurementsNotification);
-            };
-    }
-
-    locAPISetCallbacks(locationCallbacks);
-
-    TrackingOptions options = {};
-    memset(&options, 0, sizeof(TrackingOptions));
-    options.size = sizeof(TrackingOptions);
-    options.minInterval = 1000;
-    options.mode = GNSS_SUPL_MODE_STANDALONE;
-    if (GNSS_POWER_MODE_INVALID != powerMode) {
-        options.powerMode = powerMode;
-        options.tbm = timeBetweenMeasurement;
-    }
-
-    mTracking = true;
-    LOC_LOGd("(powermode: %d) (tbm %d)", (int)powerMode, timeBetweenMeasurement);
-    locAPIStartTracking(options);
-    return IGnssMeasurement::GnssMeasurementStatus::SUCCESS;
-}
-
-// for GpsMeasurementInterface
-void MeasurementAPIClient::measurementClose() {
-    LOC_LOGD("%s]: ()", __FUNCTION__);
-    mTracking = false;
-    clearInterfaces();
-    locAPIStopTracking();
-}
-
-// callbacks
-void MeasurementAPIClient::onGnssMeasurementsCb(
-        GnssMeasurementsNotification gnssMeasurementsNotification)
-{
-    LOC_LOGD("%s]: (count: %u active: %d)",
-            __FUNCTION__, gnssMeasurementsNotification.count, mTracking);
-    if (mTracking) {
-        mMutex.lock();
-        sp<V1_0::IGnssMeasurementCallback> gnssMeasurementCbIface = nullptr;
-        sp<V1_1::IGnssMeasurementCallback> gnssMeasurementCbIface_1_1 = nullptr;
-        sp<V2_0::IGnssMeasurementCallback> gnssMeasurementCbIface_2_0 = nullptr;
-        if (mGnssMeasurementCbIface_2_0 != nullptr) {
-            gnssMeasurementCbIface_2_0 = mGnssMeasurementCbIface_2_0;
-        } else if (mGnssMeasurementCbIface_1_1 != nullptr) {
-            gnssMeasurementCbIface_1_1 = mGnssMeasurementCbIface_1_1;
-        } else if (mGnssMeasurementCbIface != nullptr) {
-            gnssMeasurementCbIface = mGnssMeasurementCbIface;
-        }
-        mMutex.unlock();
-
-        if (gnssMeasurementCbIface_2_0 != nullptr) {
-            V2_0::IGnssMeasurementCallback::GnssData gnssData;
-            convertGnssData_2_0(gnssMeasurementsNotification, gnssData);
-            auto r = gnssMeasurementCbIface_2_0->gnssMeasurementCb_2_0(gnssData);
-            if (!r.isOk()) {
-                LOC_LOGE("%s] Error from gnssMeasurementCb description=%s",
-                    __func__, r.description().c_str());
-            }
-        } else if (gnssMeasurementCbIface_1_1 != nullptr) {
-            V1_1::IGnssMeasurementCallback::GnssData gnssData;
-            convertGnssData_1_1(gnssMeasurementsNotification, gnssData);
-            auto r = gnssMeasurementCbIface_1_1->gnssMeasurementCb(gnssData);
-            if (!r.isOk()) {
-                LOC_LOGE("%s] Error from gnssMeasurementCb description=%s",
-                    __func__, r.description().c_str());
-            }
-        } else if (gnssMeasurementCbIface != nullptr) {
-            V1_0::IGnssMeasurementCallback::GnssData gnssData;
-            convertGnssData(gnssMeasurementsNotification, gnssData);
-            auto r = gnssMeasurementCbIface->GnssMeasurementCb(gnssData);
-            if (!r.isOk()) {
-                LOC_LOGE("%s] Error from GnssMeasurementCb description=%s",
-                    __func__, r.description().c_str());
-            }
-        }
-    }
-}
-
-static void convertGnssMeasurement(GnssMeasurementsData& in,
-        V1_0::IGnssMeasurementCallback::GnssMeasurement& out)
-{
-    memset(&out, 0, sizeof(out));
-    if (in.flags & GNSS_MEASUREMENTS_DATA_SIGNAL_TO_NOISE_RATIO_BIT)
-        out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_SNR;
-    if (in.flags & GNSS_MEASUREMENTS_DATA_CARRIER_FREQUENCY_BIT)
-        out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_CARRIER_FREQUENCY;
-    if (in.flags & GNSS_MEASUREMENTS_DATA_CARRIER_CYCLES_BIT)
-        out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_CARRIER_CYCLES;
-    if (in.flags & GNSS_MEASUREMENTS_DATA_CARRIER_PHASE_BIT)
-        out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_CARRIER_PHASE;
-    if (in.flags & GNSS_MEASUREMENTS_DATA_CARRIER_PHASE_UNCERTAINTY_BIT)
-        out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_CARRIER_PHASE_UNCERTAINTY;
-    if (in.flags & GNSS_MEASUREMENTS_DATA_AUTOMATIC_GAIN_CONTROL_BIT)
-        out.flags |= IGnssMeasurementCallback::GnssMeasurementFlags::HAS_AUTOMATIC_GAIN_CONTROL;
-    convertGnssSvid(in, out.svid);
-    convertGnssConstellationType(in.svType, out.constellation);
-    out.timeOffsetNs = in.timeOffsetNs;
-    if (in.stateMask & GNSS_MEASUREMENTS_STATE_CODE_LOCK_BIT)
-        out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_CODE_LOCK;
-    if (in.stateMask & GNSS_MEASUREMENTS_STATE_BIT_SYNC_BIT)
-        out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_BIT_SYNC;
-    if (in.stateMask & GNSS_MEASUREMENTS_STATE_SUBFRAME_SYNC_BIT)
-        out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_SUBFRAME_SYNC;
-    if (in.stateMask & GNSS_MEASUREMENTS_STATE_TOW_DECODED_BIT)
-        out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_TOW_DECODED;
-    if (in.stateMask & GNSS_MEASUREMENTS_STATE_MSEC_AMBIGUOUS_BIT)
-        out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_MSEC_AMBIGUOUS;
-    if (in.stateMask & GNSS_MEASUREMENTS_STATE_SYMBOL_SYNC_BIT)
-        out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_SYMBOL_SYNC;
-    if (in.stateMask & GNSS_MEASUREMENTS_STATE_GLO_STRING_SYNC_BIT)
-        out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GLO_STRING_SYNC;
-    if (in.stateMask & GNSS_MEASUREMENTS_STATE_GLO_TOD_DECODED_BIT)
-        out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GLO_TOD_DECODED;
-    if (in.stateMask & GNSS_MEASUREMENTS_STATE_BDS_D2_BIT_SYNC_BIT)
-        out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_BDS_D2_BIT_SYNC;
-    if (in.stateMask & GNSS_MEASUREMENTS_STATE_BDS_D2_SUBFRAME_SYNC_BIT)
-        out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_BDS_D2_SUBFRAME_SYNC;
-    if (in.stateMask & GNSS_MEASUREMENTS_STATE_GAL_E1BC_CODE_LOCK_BIT)
-        out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GAL_E1BC_CODE_LOCK;
-    if (in.stateMask & GNSS_MEASUREMENTS_STATE_GAL_E1C_2ND_CODE_LOCK_BIT)
-        out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GAL_E1C_2ND_CODE_LOCK;
-    if (in.stateMask & GNSS_MEASUREMENTS_STATE_GAL_E1B_PAGE_SYNC_BIT)
-        out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GAL_E1B_PAGE_SYNC;
-    if (in.stateMask &  GNSS_MEASUREMENTS_STATE_SBAS_SYNC_BIT)
-        out.state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_SBAS_SYNC;
-    out.receivedSvTimeInNs = in.receivedSvTimeNs;
-    out.receivedSvTimeUncertaintyInNs = in.receivedSvTimeUncertaintyNs;
-    out.cN0DbHz = in.carrierToNoiseDbHz;
-    out.pseudorangeRateMps = in.pseudorangeRateMps;
-    out.pseudorangeRateUncertaintyMps = in.pseudorangeRateUncertaintyMps;
-    if (in.adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_VALID_BIT)
-        out.accumulatedDeltaRangeState |=
-            IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_VALID;
-    if (in.adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_RESET_BIT)
-        out.accumulatedDeltaRangeState |=
-            IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_RESET;
-    if (in.adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_CYCLE_SLIP_BIT)
-        out.accumulatedDeltaRangeState |=
-            IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_CYCLE_SLIP;
-    out.accumulatedDeltaRangeM = in.adrMeters;
-    out.accumulatedDeltaRangeUncertaintyM = in.adrUncertaintyMeters;
-    out.carrierFrequencyHz = in.carrierFrequencyHz;
-    out.carrierCycles = in.carrierCycles;
-    out.carrierPhase = in.carrierPhase;
-    out.carrierPhaseUncertainty = in.carrierPhaseUncertainty;
-    uint8_t indicator =
-        static_cast<uint8_t>(IGnssMeasurementCallback::GnssMultipathIndicator::INDICATOR_UNKNOWN);
-    if (in.multipathIndicator & GNSS_MEASUREMENTS_MULTIPATH_INDICATOR_PRESENT)
-        indicator |= IGnssMeasurementCallback::GnssMultipathIndicator::INDICATOR_PRESENT;
-    if (in.multipathIndicator & GNSS_MEASUREMENTS_MULTIPATH_INDICATOR_NOT_PRESENT)
-        indicator |= IGnssMeasurementCallback::GnssMultipathIndicator::INDICATIOR_NOT_PRESENT;
-    out.multipathIndicator =
-        static_cast<IGnssMeasurementCallback::GnssMultipathIndicator>(indicator);
-    out.snrDb = in.signalToNoiseRatioDb;
-    out.agcLevelDb = in.agcLevelDb;
-}
-
-static void convertGnssClock(GnssMeasurementsClock& in, IGnssMeasurementCallback::GnssClock& out)
-{
-    memset(&out, 0, sizeof(out));
-    if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_LEAP_SECOND_BIT)
-        out.gnssClockFlags |= IGnssMeasurementCallback::GnssClockFlags::HAS_LEAP_SECOND;
-    if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_TIME_UNCERTAINTY_BIT)
-        out.gnssClockFlags |= IGnssMeasurementCallback::GnssClockFlags::HAS_TIME_UNCERTAINTY;
-    if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_FULL_BIAS_BIT)
-        out.gnssClockFlags |= IGnssMeasurementCallback::GnssClockFlags::HAS_FULL_BIAS;
-    if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_BIAS_BIT)
-        out.gnssClockFlags |= IGnssMeasurementCallback::GnssClockFlags::HAS_BIAS;
-    if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_BIAS_UNCERTAINTY_BIT)
-        out.gnssClockFlags |= IGnssMeasurementCallback::GnssClockFlags::HAS_BIAS_UNCERTAINTY;
-    if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_DRIFT_BIT)
-        out.gnssClockFlags |= IGnssMeasurementCallback::GnssClockFlags::HAS_DRIFT;
-    if (in.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_DRIFT_UNCERTAINTY_BIT)
-        out.gnssClockFlags |= IGnssMeasurementCallback::GnssClockFlags::HAS_DRIFT_UNCERTAINTY;
-    out.leapSecond = in.leapSecond;
-    out.timeNs = in.timeNs;
-    out.timeUncertaintyNs = in.timeUncertaintyNs;
-    out.fullBiasNs = in.fullBiasNs;
-    out.biasNs = in.biasNs;
-    out.biasUncertaintyNs = in.biasUncertaintyNs;
-    out.driftNsps = in.driftNsps;
-    out.driftUncertaintyNsps = in.driftUncertaintyNsps;
-    out.hwClockDiscontinuityCount = in.hwClockDiscontinuityCount;
-}
-
-static void convertGnssData(GnssMeasurementsNotification& in,
-        V1_0::IGnssMeasurementCallback::GnssData& out)
-{
-    memset(&out, 0, sizeof(out));
-    out.measurementCount = in.count;
-    if (out.measurementCount > static_cast<uint32_t>(V1_0::GnssMax::SVS_COUNT)) {
-        LOC_LOGW("%s]: Too many measurement %u. Clamps to %d.",
-                __FUNCTION__,  out.measurementCount, V1_0::GnssMax::SVS_COUNT);
-        out.measurementCount = static_cast<uint32_t>(V1_0::GnssMax::SVS_COUNT);
-    }
-    for (size_t i = 0; i < out.measurementCount; i++) {
-        convertGnssMeasurement(in.measurements[i], out.measurements[i]);
-    }
-    convertGnssClock(in.clock, out.clock);
-}
-
-static void convertGnssData_1_1(GnssMeasurementsNotification& in,
-        V1_1::IGnssMeasurementCallback::GnssData& out)
-{
-    memset(&out, 0, sizeof(out));
-    out.measurements.resize(in.count);
-    for (size_t i = 0; i < in.count; i++) {
-        convertGnssMeasurement(in.measurements[i], out.measurements[i].v1_0);
-        if (in.measurements[i].adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_VALID_BIT)
-            out.measurements[i].accumulatedDeltaRangeState |=
-            IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_VALID;
-        if (in.measurements[i].adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_RESET_BIT)
-            out.measurements[i].accumulatedDeltaRangeState |=
-            IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_RESET;
-        if (in.measurements[i].adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_CYCLE_SLIP_BIT)
-            out.measurements[i].accumulatedDeltaRangeState |=
-            IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_CYCLE_SLIP;
-        if (in.measurements[i].adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_HALF_CYCLE_RESOLVED_BIT)
-            out.measurements[i].accumulatedDeltaRangeState |=
-            IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_HALF_CYCLE_RESOLVED;
-    }
-    convertGnssClock(in.clock, out.clock);
-}
-
-static void convertGnssData_2_0(GnssMeasurementsNotification& in,
-        V2_0::IGnssMeasurementCallback::GnssData& out)
-{
-    memset(&out, 0, sizeof(out));
-    out.measurements.resize(in.count);
-    for (size_t i = 0; i < in.count; i++) {
-        convertGnssMeasurement(in.measurements[i], out.measurements[i].v1_1.v1_0);
-        convertGnssConstellationType(in.measurements[i].svType, out.measurements[i].constellation);
-        convertGnssMeasurementsCodeType(in.measurements[i].codeType, out.measurements[i].codeType);
-        if (in.measurements[i].adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_VALID_BIT)
-            out.measurements[i].v1_1.accumulatedDeltaRangeState |=
-            IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_VALID;
-        if (in.measurements[i].adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_RESET_BIT)
-            out.measurements[i].v1_1.accumulatedDeltaRangeState |=
-            IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_RESET;
-        if (in.measurements[i].adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_CYCLE_SLIP_BIT)
-            out.measurements[i].v1_1.accumulatedDeltaRangeState |=
-            IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_CYCLE_SLIP;
-        if (in.measurements[i].adrStateMask & GNSS_MEASUREMENTS_ACCUMULATED_DELTA_RANGE_STATE_HALF_CYCLE_RESOLVED_BIT)
-            out.measurements[i].v1_1.accumulatedDeltaRangeState |=
-            IGnssMeasurementCallback::GnssAccumulatedDeltaRangeState::ADR_STATE_HALF_CYCLE_RESOLVED;
-        if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_CODE_LOCK_BIT)
-            out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_CODE_LOCK;
-        if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_BIT_SYNC_BIT)
-            out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_BIT_SYNC;
-        if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_SUBFRAME_SYNC_BIT)
-            out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_SUBFRAME_SYNC;
-        if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_TOW_DECODED_BIT)
-            out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_TOW_DECODED;
-        if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_MSEC_AMBIGUOUS_BIT)
-            out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_MSEC_AMBIGUOUS;
-        if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_SYMBOL_SYNC_BIT)
-            out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_SYMBOL_SYNC;
-        if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_GLO_STRING_SYNC_BIT)
-            out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GLO_STRING_SYNC;
-        if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_GLO_TOD_DECODED_BIT)
-            out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GLO_TOD_DECODED;
-        if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_BDS_D2_BIT_SYNC_BIT)
-            out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_BDS_D2_BIT_SYNC;
-        if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_BDS_D2_SUBFRAME_SYNC_BIT)
-            out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_BDS_D2_SUBFRAME_SYNC;
-        if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_GAL_E1BC_CODE_LOCK_BIT)
-            out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GAL_E1BC_CODE_LOCK;
-        if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_GAL_E1C_2ND_CODE_LOCK_BIT)
-            out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GAL_E1C_2ND_CODE_LOCK;
-        if (in.measurements[i].stateMask & GNSS_MEASUREMENTS_STATE_GAL_E1B_PAGE_SYNC_BIT)
-            out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GAL_E1B_PAGE_SYNC;
-        if (in.measurements[i].stateMask &  GNSS_MEASUREMENTS_STATE_SBAS_SYNC_BIT)
-            out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_SBAS_SYNC;
-        if (in.measurements[i].stateMask &  GNSS_MEASUREMENTS_STATE_TOW_KNOWN_BIT)
-            out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_TOW_KNOWN;
-        if (in.measurements[i].stateMask &  GNSS_MEASUREMENTS_STATE_GLO_TOD_KNOWN_BIT)
-            out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_GLO_TOD_KNOWN;
-        if (in.measurements[i].stateMask &  GNSS_MEASUREMENTS_STATE_2ND_CODE_LOCK_BIT)
-            out.measurements[i].state |= IGnssMeasurementCallback::GnssMeasurementState::STATE_2ND_CODE_LOCK;
-    }
-    convertGnssClock(in.clock, out.clock);
-    convertElapsedRealtimeNanos(in, out.elapsedRealtime);
-}
-
-static void convertElapsedRealtimeNanos(GnssMeasurementsNotification& in,
-        ::android::hardware::gnss::V2_0::ElapsedRealtime& elapsedRealtime)
-{
-    if (in.clock.flags & GNSS_MEASUREMENTS_CLOCK_FLAGS_ELAPSED_REAL_TIME_BIT) {
-        elapsedRealtime.flags |= V2_0::ElapsedRealtimeFlags::HAS_TIMESTAMP_NS;
-        elapsedRealtime.timestampNs = in.clock.elapsedRealTime;
-        elapsedRealtime.flags |= V2_0::ElapsedRealtimeFlags::HAS_TIME_UNCERTAINTY_NS;
-        elapsedRealtime.timeUncertaintyNs = in.clock.elapsedRealTimeUnc;
-        LOC_LOGd("elapsedRealtime.timestampNs=%" PRIi64 ""
-                 " elapsedRealtime.timeUncertaintyNs=%" PRIi64 " elapsedRealtime.flags=0x%X",
-                 elapsedRealtime.timestampNs,
-                 elapsedRealtime.timeUncertaintyNs, elapsedRealtime.flags);
-    }
-}
-
-static void convertGnssMeasurementsCodeType(GnssMeasurementsCodeType& in,
-        ::android::hardware::hidl_string& out)
-{
-    switch(in) {
-        case GNSS_MEASUREMENTS_CODE_TYPE_A:
-            out = "A";
-            break;
-        case GNSS_MEASUREMENTS_CODE_TYPE_B:
-            out = "B";
-            break;
-        case GNSS_MEASUREMENTS_CODE_TYPE_C:
-            out = "C";
-            break;
-        case GNSS_MEASUREMENTS_CODE_TYPE_I:
-            out = "I";
-            break;
-        case GNSS_MEASUREMENTS_CODE_TYPE_L:
-            out = "L";
-            break;
-        case GNSS_MEASUREMENTS_CODE_TYPE_M:
-            out = "M";
-            break;
-        case GNSS_MEASUREMENTS_CODE_TYPE_P:
-            out = "P";
-            break;
-        case GNSS_MEASUREMENTS_CODE_TYPE_Q:
-            out = "Q";
-            break;
-        case GNSS_MEASUREMENTS_CODE_TYPE_S:
-            out = "S";
-            break;
-        case GNSS_MEASUREMENTS_CODE_TYPE_W:
-            out = "W";
-            break;
-        case GNSS_MEASUREMENTS_CODE_TYPE_X:
-            out = "X";
-            break;
-        case GNSS_MEASUREMENTS_CODE_TYPE_Y:
-            out = "Y";
-            break;
-        case GNSS_MEASUREMENTS_CODE_TYPE_Z:
-            out = "Z";
-            break;
-        case GNSS_MEASUREMENTS_CODE_TYPE_N:
-            out = "N";
-            break;
-        default:
-            out = "UNKNOWN";
-    }
-}
-
-}  // namespace implementation
-}  // namespace V2_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
diff --git a/gps/android/2.0/location_api/MeasurementAPIClient.h b/gps/android/2.0/location_api/MeasurementAPIClient.h
deleted file mode 100644
index cd47c08..0000000
--- a/gps/android/2.0/location_api/MeasurementAPIClient.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- *       copyright notice, this list of conditions and the following
- *       disclaimer in the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of The Linux Foundation, nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#ifndef MEASUREMENT_API_CLINET_H
-#define MEASUREMENT_API_CLINET_H
-
-#include <mutex>
-#include <android/hardware/gnss/2.0/IGnssMeasurement.h>
-#include <LocationAPIClientBase.h>
-#include <hidl/Status.h>
-#include <gps_extended_c.h>
-
-namespace android {
-namespace hardware {
-namespace gnss {
-namespace V2_0 {
-namespace implementation {
-
-using ::android::sp;
-
-class MeasurementAPIClient : public LocationAPIClientBase
-{
-public:
-    MeasurementAPIClient();
-    MeasurementAPIClient(const MeasurementAPIClient&) = delete;
-    MeasurementAPIClient& operator=(const MeasurementAPIClient&) = delete;
-
-    // for GpsMeasurementInterface
-    template <typename T>
-    Return<IGnssMeasurement::GnssMeasurementStatus> measurementSetCallback(
-            const sp<T>& callback, GnssPowerMode powerMode = GNSS_POWER_MODE_INVALID) {
-        mMutex.lock();
-        setCallbackLocked(callback);
-        mMutex.unlock();
-
-        return startTracking(powerMode);
-    }
-    void measurementClose();
-    Return<IGnssMeasurement::GnssMeasurementStatus> startTracking(
-            GnssPowerMode powerMode = GNSS_POWER_MODE_INVALID,
-            uint32_t timeBetweenMeasurement = GPS_DEFAULT_FIX_INTERVAL_MS);
-
-    // callbacks we are interested in
-    void onGnssMeasurementsCb(GnssMeasurementsNotification gnssMeasurementsNotification) final;
-
-private:
-    inline void setCallbackLocked(const sp<V1_0::IGnssMeasurementCallback>& callback) {
-        mGnssMeasurementCbIface = callback;
-    }
-    inline void setCallbackLocked(const sp<V1_1::IGnssMeasurementCallback>& callback) {
-        mGnssMeasurementCbIface_1_1 = callback;
-    }
-    inline void setCallbackLocked(const sp<V2_0::IGnssMeasurementCallback>& callback) {
-        mGnssMeasurementCbIface_2_0 = callback;
-    }
-    virtual ~MeasurementAPIClient();
-
-    std::mutex mMutex;
-    sp<V1_0::IGnssMeasurementCallback> mGnssMeasurementCbIface;
-    sp<V1_1::IGnssMeasurementCallback> mGnssMeasurementCbIface_1_1;
-    sp<V2_0::IGnssMeasurementCallback> mGnssMeasurementCbIface_2_0;
-    bool mTracking;
-    void clearInterfaces();
-};
-
-}  // namespace implementation
-}  // namespace V2_0
-}  // namespace gnss
-}  // namespace hardware
-}  // namespace android
-#endif // MEASUREMENT_API_CLINET_H
diff --git a/gps/android/2.0/service.cpp b/gps/android/2.0/service.cpp
deleted file mode 100644
index f7efb18..0000000
--- a/gps/android/2.0/service.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
- * Not a Contribution
- */
-/*
- * 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.
- */
-
-#define LOG_TAG "android.hardware.gnss@2.0-service-qti"
-
-#include <android/hardware/gnss/2.0/IGnss.h>
-#include <hidl/LegacySupport.h>
-#include "loc_cfg.h"
-#include "loc_misc_utils.h"
-
-extern "C" {
-#include "vndfwk-detect.h"
-}
-
-#ifdef ARCH_ARM_32
-#define DEFAULT_HW_BINDER_MEM_SIZE 65536
-#endif
-
-using android::hardware::gnss::V2_0::IGnss;
-
-using android::hardware::configureRpcThreadpool;
-using android::hardware::registerPassthroughServiceImplementation;
-using android::hardware::joinRpcThreadpool;
-
-using android::status_t;
-using android::OK;
-
-typedef int vendorEnhancedServiceMain(int /* argc */, char* /* argv */ []);
-
-int main() {
-
-    ALOGI("%s", __FUNCTION__);
-
-    int vendorInfo = getVendorEnhancedInfo();
-    bool vendorEnhanced = ( 1 == vendorInfo || 3 == vendorInfo );
-    setVendorEnhanced(vendorEnhanced);
-
-#ifdef ARCH_ARM_32
-    android::hardware::ProcessState::initWithMmapSize((size_t)(DEFAULT_HW_BINDER_MEM_SIZE));
-#endif
-    configureRpcThreadpool(1, true);
-    status_t status;
-
-    status = registerPassthroughServiceImplementation<IGnss>();
-    if (status == OK) {
-    #ifdef LOC_HIDL_VERSION
-        #define VENDOR_ENHANCED_LIB "vendor.qti.gnss@" LOC_HIDL_VERSION "-service.so"
-
-        void* libHandle = NULL;
-        vendorEnhancedServiceMain* vendorEnhancedMainMethod = (vendorEnhancedServiceMain*)
-                dlGetSymFromLib(libHandle, VENDOR_ENHANCED_LIB, "main");
-        if (NULL != vendorEnhancedMainMethod) {
-            (*vendorEnhancedMainMethod)(0, NULL);
-        }
-    #else
-        ALOGI("LOC_HIDL_VERSION not defined.");
-    #endif
-        joinRpcThreadpool();
-    } else {
-        ALOGE("Error while registering IGnss 2.0 service: %d", status);
-    }
-
-    return 0;
-}
