Modifications to support soong builds
diff --git a/Android.bp b/Android.bp
deleted file mode 100644
index aaca436..0000000
--- a/Android.bp
+++ /dev/null
@@ -1,4 +0,0 @@
-optional_subdirs = [
-    "interfaces",
-    "example-server",
-]
diff --git a/example-server/Android.bp b/example-server/Android.bp
deleted file mode 100644
index 7dc1614..0000000
--- a/example-server/Android.bp
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * The example server is a standalone daemon, however
- * vendor implementations may combine with other hal server daemons.
- */
-cc_binary {
-    name: "com.dsi.ant@1.0-example",
-    relative_install_path: "hw",
-    proprietary: true,
-    srcs: [
-        "src/Ant.cpp",
-        "src/Server.cpp"
-    ],
-    shared_libs: [
-        "libhidlbase",
-        "libhidltransport",
-        "libutils",
-        "liblog",
-        "com.dsi.ant@1.0",
-    ],
-    init_rc: [
-        "com.dsi.ant@1.0-example.rc",
-    ],
-}
diff --git a/example-server/README.txt b/example-server/README.txt
deleted file mode 100644
index 246b9f9..0000000
--- a/example-server/README.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-This folder contains an example implementation of a HAL client for ant.
-
-This example expects to be able to use a unix domain socket located at
-/dev/socket/ant. The sepolicy directory shows example policy to use
-as a starting point for the vendor policy, and vintf contains a fragment
-that should be added to the vendor manifest.xml in order to advertise
-that the service is provided.
-
-Note that the example policy does not currently contain the pieces that
-are needed to actually open and use the socket.
-
diff --git a/example-server/com.dsi.ant@1.0-example.rc b/example-server/com.dsi.ant@1.0-example.rc
deleted file mode 100644
index 8595b8c..0000000
--- a/example-server/com.dsi.ant@1.0-example.rc
+++ /dev/null
@@ -1,4 +0,0 @@
-service ant_hal_service /vendor/bin/hw/com.dsi.ant@1.0-example
-    class hal
-    user system
-    group system
diff --git a/example-server/sepolicy/ant_example_server.te b/example-server/sepolicy/ant_example_server.te
deleted file mode 100644
index 31fa595..0000000
--- a/example-server/sepolicy/ant_example_server.te
+++ /dev/null
@@ -1,10 +0,0 @@
-type ant_hidl_example, domain;
-type ant_hidl_example_exec, exec_type, vendor_file_type, file_type;
-
-init_daemon_domain(ant_hidl_example);
-hal_server_domain(ant_hidl_example, hal_dsi_ant);
-
-# Any other permissions needed by the server go here.
-# For example, to allow opening the proper socket/char devices
-# needed to communicate with the hardware
-
diff --git a/example-server/sepolicy/file_contexts b/example-server/sepolicy/file_contexts
deleted file mode 100644
index 0547ba0..0000000
--- a/example-server/sepolicy/file_contexts
+++ /dev/null
@@ -1,2 +0,0 @@
-/vendor/bin/hw/com\.dsi\.ant\@1\.0-example          u:object_r:ant_hidl_example_exec:s0
-
diff --git a/example-server/src/Ant.cpp b/example-server/src/Ant.cpp
deleted file mode 100644
index 2c25e97..0000000
--- a/example-server/src/Ant.cpp
+++ /dev/null
@@ -1,465 +0,0 @@
-/*
- * ANT Android Host Stack
- *
- * Copyright 2018 Dynastream Innovations
- *
- * 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 "Ant Hidl Example"
-
-#include <cassert>
-#include <cstring>
-
-#include <limits>
-#include <sstream>
-#include <stdexcept>
-
-#include <sys/eventfd.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-
-#include <poll.h>
-
-#include "log/log.h"
-
-#include "Ant.h"
-
-// NOTE: Code here holds mutex locks while making callbacks. This is fine in this case since
-// all of the callback methods are marked as oneway in the hal and therefore are non-blocking.
-
-namespace com {
-namespace dsi {
-namespace ant {
-namespace V1_0 {
-namespace example {
-
-// Convenience typedef, since we only use one type of mutex.
-typedef std::lock_guard<std::mutex> lock;
-
-// Header for framing ANT messages to go to the chip.
-struct MsgHeader {
-    uint8_t channel_id;
-    uint8_t payload_len;
-
-    static const size_t max_payload = std::numeric_limits<uint8_t>::max();
-};
-
-// Error classes. This implementation uses the upper 16 bits of a status code
-// to indicate a class, and the lower 16 bits as an associated errno value.
-// It assumes that all errno values fit, which is currently the case in the
-// errno.h header used by android.
-// see translateStatus to understand exactly what each error code means.
-enum errors : uint16_t {
-    GENERIC_ERR,
-    SOCKET_ERR,
-    CONNECT_ERR,
-    EFD_ERR,
-    NOFD_ERR,
-    LARGEMSG_ERR,
-};
-
-// Convenience to not need the fully scoped name every time.
-static const Status STATUS_OK = (Status)CommonStatusCodes::OK;
-
-// Example implementation uses an UNIX domain socket, which allows for
-// adb reverse-forwarding to be used.
-static const sockaddr_un socket_addr = {
-    AF_UNIX,
-    "/dev/socket/ant",
-    };
-
-static const int poll_timeout_ms = 1000 * 5;
-
-// Implementation properties are constant.
-static const ImplProps props = {
-    "ant.hidl.example.1.0",
-    OptionFlags::USE_KEEPALIVE | OptionFlags::USE_ANT_FLOW_CONTROL,
-};
-
-// Bit manipulation for status codes.
-
-static Status makeStatus(uint32_t cls, uint32_t err_code)
-{ return ((cls << 16)|(err_code & 0xffff)); }
-
-static uint16_t getErrClass(Status status)
-{ return (uint16_t)((status >> 16) & 0xffff); }
-
-static uint16_t getErrCode(Status status)
-{ return (uint16_t)(status & 0xffff); }
-
-// Convenience stuff for file descriptors.
-static bool isValidFd(int fd) { return fd >= 0; }
-
-static int invalid_fd = -1;
-
-class MessageReader {
-public:
-    MessageReader(int fd) : fd(fd), read_idx(0) {}
-    int checkForMessages(const sp<IAntCallbacks> &callbacks);
-
-private:
-    int fd;
-    uint8_t read_buf[sizeof(MsgHeader) + MsgHeader::max_payload];
-    size_t read_idx;
-};
-
-int MessageReader::checkForMessages(const sp<IAntCallbacks> &callbacks) {
-
-    // First consume any new data that is available.
-    ssize_t read_result = read(
-        fd,
-        &read_buf[read_idx],
-        sizeof(read_buf) - read_idx);
-
-    if (read_result < 0) {
-        switch(errno) {
-        case EAGAIN:
-        case EINTR:
-            // These errors are okay, act like no data read.
-            read_result = 0;
-            break;
-        default:
-            return errno;
-        };
-    }
-
-    read_idx += read_result;
-
-    // Now dispatch all read messages.
-
-    // Alias the front of the buffer as a message header.
-    MsgHeader *header = (MsgHeader*)read_buf;
-
-    size_t full_size = header->payload_len + sizeof(MsgHeader);
-    while (read_idx >= sizeof(MsgHeader) && read_idx >= full_size) {
-
-        assert((header->channel_id == Ant::command_channel_id) ||
-            (header->channel_id == Ant::data_channel_id));
-
-        if (callbacks != NULL) {
-            hidl_vec<uint8_t> msg;
-            msg.setToExternal(read_buf + sizeof(MsgHeader), header->payload_len);
-            callbacks->onMessageReceived(msg);
-        }
-
-        if (read_idx > full_size) {
-            // There's (part of) another message, move it to the front of the buffer.
-            std::memmove(read_buf, read_buf + full_size, read_idx - full_size);
-        }
-        read_idx -= full_size;
-        full_size = header->payload_len + sizeof(MsgHeader);
-    }
-
-    return STATUS_OK;
-}
-
-Ant::Ant():
-   transport_fd(invalid_fd),
-   shutdown_fd(invalid_fd),
-   stop_polling(true)
-   {}
-
-// Methods from IAnt follow.
-Return<void> Ant::getProperties(getProperties_cb _hidl_cb) {
-    _hidl_cb(props);
-    return Void();
-}
-
-Return<void> Ant::setCallbacks(const sp<IAntCallbacks>& callbacks) {
-    // Keep a reference to the old value around until we are outside of the
-    // locked scope. See RefBase.h for why this is needed.
-    sp<IAntCallbacks> old;
-    {
-        lock l(state_mtx);
-        old = this->callbacks;
-        this->callbacks = callbacks;
-    }
-
-    return Void();
-}
-
-Return<void> Ant::translateStatus(Status status, translateStatus_cb _hidl_cb) {
-    std::ostringstream err;
-    uint16_t err_class = getErrClass(status);
-    uint16_t err_code = getErrCode(status);
-
-    switch(err_class) {
-    case GENERIC_ERR:
-        break;
-    case SOCKET_ERR:
-        err << "Socket creation failed.";
-        break;
-    case CONNECT_ERR:
-        err << "Socket connect failed.";
-        break;
-    case EFD_ERR:
-        err << "Event fd not created.";
-        break;
-    case NOFD_ERR:
-        err << "Transport not open.";
-        break;
-    case LARGEMSG_ERR:
-        err << "Provided message too big.";
-        break;
-    default:
-        err << "Unknown Error Class (" << err_class << ").";
-        break;
-    };
-
-    if (err_code) {
-        // Add a space between class and error string, only if a class string was
-        // added (ie. length > 0)
-        if (err.tellp() > 0) {
-            err << " ";
-        }
-        err << strerror(err_code);
-    }
-
-    _hidl_cb(err.str());
-    return Void();
-}
-
-Return<Status> Ant::enable() {
-    // Early returns are used to bail out here, this is okay in this case though
-    // since disable will always be used to recover, and we deal with any inconsistent state there.
-
-    ALOGV("Enabling");
-
-    lock l(state_mtx);
-
-    stop_polling = false;
-
-    // Open the local socket that is adb-forwarded somewhere. Actual implementations
-    // would maybe open a character device here.
-    // The socket is non-blocking since the poll loop waits for data anyways.
-    transport_fd = socket(AF_UNIX, SOCK_STREAM|SOCK_NONBLOCK, 0);
-    if (!isValidFd(transport_fd)) {
-        return makeStatus(SOCKET_ERR, errno);
-    }
-
-    if (connect(transport_fd, (const sockaddr*)&socket_addr, sizeof(socket_addr)) < 0) {
-        return makeStatus(CONNECT_ERR, errno);
-    }
-
-    // Setup the shutdown handle, which is an event-fd that can be used to interrupt
-    // the poll thread when it is stuck in a poll().
-    shutdown_fd = eventfd(0, EFD_NONBLOCK);
-    if (!isValidFd(shutdown_fd)) {
-        return makeStatus(EFD_ERR, errno);
-    }
-
-    // If all state was setup succesfully then the poll thread can be started.
-    poll_thread = std::thread(&Ant::pollThreadEntry, this);
-
-    return STATUS_OK;
-}
-
-Return<Status> Ant::disable() {
-    ALOGV("Disabling");
-
-    // Used to capture the value of the poll thread.
-    std::thread old_poll;
-
-    {
-        // Use a scope block, since we need to be unlocked while joining the thread.
-        lock l(state_mtx);
-
-        std::swap(old_poll, poll_thread);
-        if (isValidFd(shutdown_fd)) {
-            uint64_t shutdown_evt = 1;
-            if (write(shutdown_fd, &shutdown_evt, sizeof(shutdown_evt)) < 0) {
-                ALOGW("Shutdown sending signal failed. %s", strerror(errno));
-            }
-        }
-
-        stop_polling = true;
-    }
-
-    if (old_poll.get_id() != std::thread::id()) {
-        // NOTE: if it's possible for the poll thread to get stuck it might
-        // be better to do a timed wait on a future<void> set by the threads exit.
-        // If a timeout occurs the thread should be detached instead of joined.
-        old_poll.join();
-    }
-
-    // At this point the poll thread should be stopped, meaning it's safe to start
-    // cleaning up files. The state lock is still held to make sure we don't close
-    // the handles on any message writes in progress.
-
-    lock l2(state_mtx);
-
-    if (isValidFd(shutdown_fd)) {
-        if (close(shutdown_fd) < 0) {
-            ALOGW("Could not cleanly close event_fd. %s", strerror(errno));
-        }
-    }
-    shutdown_fd = invalid_fd;
-
-    if (isValidFd(transport_fd)) {
-        if (close(transport_fd) < 0) {
-            ALOGW("Could not cleanly close transport_fd. %s", strerror(errno));
-        }
-    }
-    transport_fd = invalid_fd;
-
-    return STATUS_OK;
-}
-
-void Ant::pollThreadEntry() {
-    bool should_quit = false;
-    MessageReader reader(transport_fd);
-    // This remains empty as long as no error occured.
-    std::string err_msg;
-
-    struct poll_fds_t {
-       pollfd transport;
-       pollfd shutdown;
-    } poll_fds;
-
-    // Static setup for poll loop.
-    // The only non-error event that matters is the data ready event.
-    poll_fds.transport.fd = transport_fd;
-    poll_fds.transport.events = POLLIN;
-    poll_fds.shutdown.fd = shutdown_fd;
-    poll_fds.shutdown.events = POLLIN;
-
-    class poll_err : public std::runtime_error {};
-
-    // Error cases just bail straight out of the thread
-    while(!should_quit) {
-        // Clear out previous events.
-        poll_fds.transport.revents = 0;
-        poll_fds.shutdown.revents = 0;
-
-        int poll_result = poll((pollfd*)&poll_fds, sizeof(poll_fds)/sizeof(pollfd), poll_timeout_ms);
-
-        // Now that poll is done grab the state lock, the rest should be quick, since all
-        // operations are non-blocking.
-        lock l(state_mtx);
-
-        should_quit = stop_polling;
-
-        // Only care to differentiate error case, and ignore EINTR errors.
-        if (poll_result < 0 && errno != EINTR) {
-            err_msg = std::string("Poll call failed. ") + strerror(errno);
-            break;
-        }
-
-        if (poll_fds.transport.revents) {
-            if (poll_fds.transport.revents != POLLIN) {
-                std::ostringstream err_bld("Poll error flags on transport file: ");
-                err_bld << (int)poll_fds.transport.revents;
-                err_msg = err_bld.str();
-                break;
-            }
-
-            int read_result = reader.checkForMessages(callbacks);
-            if (read_result != STATUS_OK) {
-                err_msg =  std::string("Could not read available data") + strerror(read_result);
-                break;
-            }
-        }
-
-        if (poll_fds.shutdown.revents) {
-            if (poll_fds.shutdown.revents != POLLIN) {
-                std::ostringstream err_bld("Poll error flags on shutdown file: ");
-                err_bld << (int)poll_fds.shutdown.revents;
-                err_msg = err_bld.str();
-                break;
-            }
-
-            // No need to read, the eventfd is only signaled when shutting down.
-            should_quit = true;
-        }
-    }
-
-    if (!err_msg.empty()) {
-        lock l(state_mtx);
-        if (callbacks != NULL) {
-            callbacks->onTransportDown(err_msg);
-        }
-    }
-
-    return;
-}
-
-Status Ant::writeMsg(const hidl_vec<uint8_t> &msg, uint8_t channel_id) {
-    if (msg.size() > MsgHeader::max_payload) {
-        return makeStatus(LARGEMSG_ERR, 0);
-    }
-
-    // Lock is held for full function to make sure the fd isn't changed on us.
-    // This should never take long, higher level flow control should ensure
-    // we never block waiting for space in write buffers.
-    lock l(state_mtx);
-    if (!isValidFd(transport_fd)) {
-        return makeStatus(NOFD_ERR, 0);
-    }
-
-    Status retval = STATUS_OK;
-
-    MsgHeader header = {
-        channel_id,
-        (uint8_t)msg.size(),
-    };
-
-    iovec vecs[] = {
-        { (uint8_t*)&header, sizeof(header) },
-        // Cast away the constness of the data.
-        // This is okay because we are only sourcing the data for a write,
-        // but is required because the struct in the writev api is non-const
-        // in order to be shared with readv calls.
-        { const_cast<uint8_t*>(msg.data()), msg.size() },
-    };
-    size_t num_vecs = sizeof(vecs)/sizeof(vecs[0]);
-
-    // Continue until the last chunk has been fully written.
-    while(vecs[num_vecs - 1].iov_len > 0) {
-        ssize_t written = writev(transport_fd, vecs, num_vecs);
-
-        if (written < 0) {
-            if (errno == EINTR) {
-                // EINTR is okay, it means no data was written though.
-                written = 0;
-            } else {
-                retval = makeStatus(GENERIC_ERR, errno);
-                // Abort writing the remainder.
-                break;
-            }
-        }
-
-        // Adjust write to resume with unwritten portion.
-        for (size_t i = 0; i < num_vecs; i++) {
-            if ((size_t)written <= vecs[i].iov_len) {
-                // Chunk was partially written, pointer adjustment needed.
-                vecs[i].iov_len -= written;
-                vecs[i].iov_base = ((uint8_t*)vecs[i].iov_base) + written;
-                // Remaining chunks are unchanged.
-                break;
-            }
-
-            // Chunk fully written, move onto next.
-            vecs[i].iov_len = 0;
-            written -= vecs[i].iov_len;
-        }
-    }
-
-    return retval;
-}
-
-}  // namespace example
-}  // namespace V1_0
-}  // namespace ant
-}  // namespace dsi
-}  // namespace com
diff --git a/example-server/src/Ant.h b/example-server/src/Ant.h
deleted file mode 100644
index 5a36c12..0000000
--- a/example-server/src/Ant.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * ANT Android Host Stack
- *
- * Copyright 2018 Dynastream Innovations
- *
- * 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 COM_DSI_ANT_V1_0_ANT_H
-#define COM_DSI_ANT_V1_0_ANT_H
-
-#include <mutex>
-#include <thread>
-
-#include <com/dsi/ant/1.0/IAnt.h>
-#include <hidl/Status.h>
-
-namespace com {
-namespace dsi {
-namespace ant {
-namespace V1_0 {
-namespace example {
-
-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;
-
-struct Ant : public IAnt {
-
-public:
-
-    // These need to be declared here because they are used in the inline versions
-    // of sendData/CommandMessage.
-    static const uint8_t command_channel_id = 0x0C;
-    static const uint8_t data_channel_id = 0x0E;
-
-    // Methods from IAnt follow.
-    Return<void> getProperties(getProperties_cb _hidl_cb) override;
-    Return<void> setCallbacks(const sp<IAntCallbacks>& callbacks) override;
-    Return<void> translateStatus(Status status, translateStatus_cb _hidl_cb) override;
-    Return<Status> enable() override;
-    Return<Status> disable() override;
-
-    Return<Status> sendDataMessage(const hidl_vec<uint8_t>& msg) override
-    { return writeMsg(msg, data_channel_id); }
-    Return<Status> sendCommandMessage(const hidl_vec<uint8_t>& msg) override
-    { return writeMsg(msg, command_channel_id); }
-
-    Ant();
-
-private:
-
-    sp<IAntCallbacks> callbacks;
-    // File handle used for communicating with the ant chip.
-    int transport_fd;
-    // File handle used to signal the poll thread when shutting down.
-    int shutdown_fd;
-    std::thread poll_thread;
-    // This is set to indicate that the poll thread should exit.
-    bool stop_polling;
-    // Coarse mutex for all internal state.
-    std::mutex state_mtx;
-
-    void pollThreadEntry();
-    Status writeMsg(const hidl_vec<uint8_t> &msg, uint8_t channel_id);
-};
-
-
-}  // namespace example
-}  // namespace V1_0
-}  // namespace ant
-}  // namespace dsi
-}  // namespace com
-
-#endif  // COM_DSI_ANT_V1_0_ANT_H
diff --git a/example-server/src/Server.cpp b/example-server/src/Server.cpp
deleted file mode 100644
index 9ea376b..0000000
--- a/example-server/src/Server.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * ANT Android Host Stack
- *
- * Copyright 2018 Dynastream Innovations
- *
- * 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 "Ant Hidl Example"
-
-#include "Ant.h"
-
-#include "log/log.h"
-#include <hidl/HidlTransportSupport.h>
-
-using com::dsi::ant::V1_0::example::Ant;
-using namespace android;
-using namespace android::hardware;
-
-/* Handle 1 data + 1 command + power control. */
-static const uint32_t THREAD_POOL_SIZE = 3;
-
-int main(void) {
-    /*
-     * This is fairly standard daemon code based on
-     * defaultPassthroughServiceImplementation()
-     */
-    ALOGI("Starting example ANT HIDL daemon");
-    configureRpcThreadpool(THREAD_POOL_SIZE, true);
-
-    Ant ant;
-    status_t status = ant.registerAsService();
-    if (status != OK) {
-        ALOGE("Unable to register service: %d", status);
-        return -1;
-    }
-
-    joinRpcThreadpool();
-}
-
diff --git a/example-server/vintf/manifest.xml b/example-server/vintf/manifest.xml
deleted file mode 100644
index 12e07cf..0000000
--- a/example-server/vintf/manifest.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<hal format="hidl">
-    <name>com.dsi.ant</name>
-    <transport>hwbinder</transport>
-    <version>1.0</version>
-    <interface>
-        <name>IAnt</name>
-        <instance>default</instance>
-    </interface>
-</hal>
-
diff --git a/interfaces/Android.bp b/interfaces/Android.bp
deleted file mode 100644
index 7aef46b..0000000
--- a/interfaces/Android.bp
+++ /dev/null
@@ -1,3 +0,0 @@
-subdirs = [
-    "*"
-]
diff --git a/interfaces/ant/1.0/.hidl-autogen b/interfaces/ant/1.0/.hidl-autogen
new file mode 100644
index 0000000..2b11d6f
--- /dev/null
+++ b/interfaces/ant/1.0/.hidl-autogen
@@ -0,0 +1,17 @@
+// This file is autogenerated by hidl-gen -Landroidbp.
+
+hidl_interface {
+    name: "com.dsi.ant@1.0",
+    root: "com.dsi.ant",
+    product_specific: true,
+    srcs: [
+        "types.hal",
+        "IAnt.hal",
+        "IAntCallbacks.hal",
+    ],
+    interfaces: [
+        "android.hidl.base@1.0",
+    ],
+    gen_java: true,
+}
+
diff --git a/interfaces/ant/1.0/Android.bp b/interfaces/ant/1.0/Android.bp
index e5ea3d5..18f1cac 100644
--- a/interfaces/ant/1.0/Android.bp
+++ b/interfaces/ant/1.0/Android.bp
@@ -1,96 +1,16 @@
-// This file is autogenerated by hidl-gen. Do not edit manually.
+// This file is autogenerated by hidl-gen -Landroidbp.
 
-filegroup {
-    name: "com.dsi.ant@1.0_hal",
+hidl_interface {
+    name: "com.dsi.ant@1.0",
+    root: "com.dsi.ant",
+    system_ext_specific: true,
     srcs: [
         "types.hal",
         "IAnt.hal",
         "IAntCallbacks.hal",
     ],
-}
-
-genrule {
-    name: "com.dsi.ant@1.0_genc++",
-    tools: ["hidl-gen"],
-    cmd: "$(location hidl-gen) -o $(genDir) -Lc++-sources -randroid.hidl:system/libhidl/transport -rcom.dsi:external/ant-wireless/hidl/interfaces com.dsi.ant@1.0",
-    srcs: [
-        ":com.dsi.ant@1.0_hal",
+    interfaces: [
+        "android.hidl.base@1.0",
     ],
-    out: [
-        "com/dsi/ant/1.0/types.cpp",
-        "com/dsi/ant/1.0/AntAll.cpp",
-        "com/dsi/ant/1.0/AntCallbacksAll.cpp",
-    ],
-}
-
-genrule {
-    name: "com.dsi.ant@1.0_genc++_headers",
-    tools: ["hidl-gen"],
-    cmd: "$(location hidl-gen) -o $(genDir) -Lc++-headers -randroid.hidl:system/libhidl/transport -rcom.dsi:external/ant-wireless/hidl/interfaces com.dsi.ant@1.0",
-    srcs: [
-        ":com.dsi.ant@1.0_hal",
-    ],
-    out: [
-        "com/dsi/ant/1.0/types.h",
-        "com/dsi/ant/1.0/hwtypes.h",
-        "com/dsi/ant/1.0/IAnt.h",
-        "com/dsi/ant/1.0/IHwAnt.h",
-        "com/dsi/ant/1.0/BnHwAnt.h",
-        "com/dsi/ant/1.0/BpHwAnt.h",
-        "com/dsi/ant/1.0/BsAnt.h",
-        "com/dsi/ant/1.0/IAntCallbacks.h",
-        "com/dsi/ant/1.0/IHwAntCallbacks.h",
-        "com/dsi/ant/1.0/BnHwAntCallbacks.h",
-        "com/dsi/ant/1.0/BpHwAntCallbacks.h",
-        "com/dsi/ant/1.0/BsAntCallbacks.h",
-    ],
-}
-
-cc_library {
-    name: "com.dsi.ant@1.0",
-    defaults: ["hidl-module-defaults"],
-    generated_sources: ["com.dsi.ant@1.0_genc++"],
-    generated_headers: ["com.dsi.ant@1.0_genc++_headers"],
-    export_generated_headers: ["com.dsi.ant@1.0_genc++_headers"],
-    vendor_available: true,
-    vndk: {
-        enabled: true,
-    },
-    shared_libs: [
-        "libhidlbase",
-        "libhidltransport",
-        "libhwbinder",
-        "liblog",
-        "libutils",
-        "libcutils",
-    ],
-    export_shared_lib_headers: [
-        "libhidlbase",
-        "libhidltransport",
-        "libhwbinder",
-        "libutils",
-    ],
-}
-
-cc_library {
-    name: "com.dsi.ant@1.0_vendor",
-    defaults: ["hidl-module-defaults"],
-    generated_sources: ["com.dsi.ant@1.0_genc++"],
-    generated_headers: ["com.dsi.ant@1.0_genc++_headers"],
-    export_generated_headers: ["com.dsi.ant@1.0_genc++_headers"],
-    vendor: true,
-    shared_libs: [
-        "libhidlbase",
-        "libhidltransport",
-        "libhwbinder",
-        "liblog",
-        "libutils",
-        "libcutils",
-    ],
-    export_shared_lib_headers: [
-        "libhidlbase",
-        "libhidltransport",
-        "libhwbinder",
-        "libutils",
-    ],
+    gen_java: true,
 }
diff --git a/interfaces/ant/1.0/Android.mk b/interfaces/ant/1.0/Android.mk
deleted file mode 100644
index bf21f0e..0000000
--- a/interfaces/ant/1.0/Android.mk
+++ /dev/null
@@ -1,198 +0,0 @@
-# This file is autogenerated by hidl-gen. Do not edit manually.
-
-LOCAL_PATH := $(call my-dir)
-
-################################################################################
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := com.dsi.ant-V1.0-java
-LOCAL_MODULE_CLASS := JAVA_LIBRARIES
-
-intermediates := $(call local-generated-sources-dir, COMMON)
-
-HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
-
-LOCAL_JAVA_LIBRARIES := \
-    android.hidl.base-V1.0-java \
-
-
-#
-# Build types.hal (ImplProps)
-#
-GEN := $(intermediates)/com/dsi/ant/V1_0/ImplProps.java
-$(GEN): $(HIDL)
-$(GEN): PRIVATE_HIDL := $(HIDL)
-$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
-$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
-$(GEN): PRIVATE_CUSTOM_TOOL = \
-        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
-        -Ljava \
-        -randroid.hidl:system/libhidl/transport \
-        -rcom.dsi:external/ant-wireless/hidl/interfaces \
-        com.dsi.ant@1.0::types.ImplProps
-
-$(GEN): $(LOCAL_PATH)/types.hal
-	$(transform-generated-source)
-LOCAL_GENERATED_SOURCES += $(GEN)
-
-#
-# Build types.hal (OptionFlags)
-#
-GEN := $(intermediates)/com/dsi/ant/V1_0/OptionFlags.java
-$(GEN): $(HIDL)
-$(GEN): PRIVATE_HIDL := $(HIDL)
-$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
-$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
-$(GEN): PRIVATE_CUSTOM_TOOL = \
-        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
-        -Ljava \
-        -randroid.hidl:system/libhidl/transport \
-        -rcom.dsi:external/ant-wireless/hidl/interfaces \
-        com.dsi.ant@1.0::types.OptionFlags
-
-$(GEN): $(LOCAL_PATH)/types.hal
-	$(transform-generated-source)
-LOCAL_GENERATED_SOURCES += $(GEN)
-
-#
-# Build IAnt.hal
-#
-GEN := $(intermediates)/com/dsi/ant/V1_0/IAnt.java
-$(GEN): $(HIDL)
-$(GEN): PRIVATE_HIDL := $(HIDL)
-$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IAnt.hal
-$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IAntCallbacks.hal
-$(GEN): $(LOCAL_PATH)/IAntCallbacks.hal
-$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
-$(GEN): $(LOCAL_PATH)/types.hal
-$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
-$(GEN): PRIVATE_CUSTOM_TOOL = \
-        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
-        -Ljava \
-        -randroid.hidl:system/libhidl/transport \
-        -rcom.dsi:external/ant-wireless/hidl/interfaces \
-        com.dsi.ant@1.0::IAnt
-
-$(GEN): $(LOCAL_PATH)/IAnt.hal
-	$(transform-generated-source)
-LOCAL_GENERATED_SOURCES += $(GEN)
-
-#
-# Build IAntCallbacks.hal
-#
-GEN := $(intermediates)/com/dsi/ant/V1_0/IAntCallbacks.java
-$(GEN): $(HIDL)
-$(GEN): PRIVATE_HIDL := $(HIDL)
-$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IAntCallbacks.hal
-$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
-$(GEN): PRIVATE_CUSTOM_TOOL = \
-        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
-        -Ljava \
-        -randroid.hidl:system/libhidl/transport \
-        -rcom.dsi:external/ant-wireless/hidl/interfaces \
-        com.dsi.ant@1.0::IAntCallbacks
-
-$(GEN): $(LOCAL_PATH)/IAntCallbacks.hal
-	$(transform-generated-source)
-LOCAL_GENERATED_SOURCES += $(GEN)
-include $(BUILD_JAVA_LIBRARY)
-
-
-################################################################################
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := com.dsi.ant-V1.0-java-static
-LOCAL_MODULE_CLASS := JAVA_LIBRARIES
-
-intermediates := $(call local-generated-sources-dir, COMMON)
-
-HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
-
-LOCAL_STATIC_JAVA_LIBRARIES := \
-    android.hidl.base-V1.0-java-static \
-
-
-#
-# Build types.hal (ImplProps)
-#
-GEN := $(intermediates)/com/dsi/ant/V1_0/ImplProps.java
-$(GEN): $(HIDL)
-$(GEN): PRIVATE_HIDL := $(HIDL)
-$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
-$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
-$(GEN): PRIVATE_CUSTOM_TOOL = \
-        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
-        -Ljava \
-        -randroid.hidl:system/libhidl/transport \
-        -rcom.dsi:external/ant-wireless/hidl/interfaces \
-        com.dsi.ant@1.0::types.ImplProps
-
-$(GEN): $(LOCAL_PATH)/types.hal
-	$(transform-generated-source)
-LOCAL_GENERATED_SOURCES += $(GEN)
-
-#
-# Build types.hal (OptionFlags)
-#
-GEN := $(intermediates)/com/dsi/ant/V1_0/OptionFlags.java
-$(GEN): $(HIDL)
-$(GEN): PRIVATE_HIDL := $(HIDL)
-$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
-$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
-$(GEN): PRIVATE_CUSTOM_TOOL = \
-        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
-        -Ljava \
-        -randroid.hidl:system/libhidl/transport \
-        -rcom.dsi:external/ant-wireless/hidl/interfaces \
-        com.dsi.ant@1.0::types.OptionFlags
-
-$(GEN): $(LOCAL_PATH)/types.hal
-	$(transform-generated-source)
-LOCAL_GENERATED_SOURCES += $(GEN)
-
-#
-# Build IAnt.hal
-#
-GEN := $(intermediates)/com/dsi/ant/V1_0/IAnt.java
-$(GEN): $(HIDL)
-$(GEN): PRIVATE_HIDL := $(HIDL)
-$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IAnt.hal
-$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/IAntCallbacks.hal
-$(GEN): $(LOCAL_PATH)/IAntCallbacks.hal
-$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
-$(GEN): $(LOCAL_PATH)/types.hal
-$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
-$(GEN): PRIVATE_CUSTOM_TOOL = \
-        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
-        -Ljava \
-        -randroid.hidl:system/libhidl/transport \
-        -rcom.dsi:external/ant-wireless/hidl/interfaces \
-        com.dsi.ant@1.0::IAnt
-
-$(GEN): $(LOCAL_PATH)/IAnt.hal
-	$(transform-generated-source)
-LOCAL_GENERATED_SOURCES += $(GEN)
-
-#
-# Build IAntCallbacks.hal
-#
-GEN := $(intermediates)/com/dsi/ant/V1_0/IAntCallbacks.java
-$(GEN): $(HIDL)
-$(GEN): PRIVATE_HIDL := $(HIDL)
-$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IAntCallbacks.hal
-$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
-$(GEN): PRIVATE_CUSTOM_TOOL = \
-        $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
-        -Ljava \
-        -randroid.hidl:system/libhidl/transport \
-        -rcom.dsi:external/ant-wireless/hidl/interfaces \
-        com.dsi.ant@1.0::IAntCallbacks
-
-$(GEN): $(LOCAL_PATH)/IAntCallbacks.hal
-	$(transform-generated-source)
-LOCAL_GENERATED_SOURCES += $(GEN)
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/interfaces/ant/Android.bp b/interfaces/ant/Android.bp
index bbb3e4b..53f0962 100644
--- a/interfaces/ant/Android.bp
+++ b/interfaces/ant/Android.bp
@@ -1,4 +1,9 @@
-// This is an autogenerated file, do not edit.
 subdirs = [
-    "1.0",
+    "*"
 ]
+
+hidl_package_root {
+    name: "com.dsi.ant",
+    path: "external/ant-wireless/hidl/interfaces/ant",
+}
+
diff --git a/interfaces/update-makefiles.sh b/interfaces/update-makefiles.sh
deleted file mode 100644
index 06eff1e..0000000
--- a/interfaces/update-makefiles.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/bash
-
-source $ANDROID_BUILD_TOP/system/tools/hidl/update-makefiles-helper.sh
-
-do_makefiles_update \
-  "com.dsi:external/ant-wireless/hidl/interfaces" \
-  "android.hidl:system/libhidl/transport"
-
diff --git a/sepolicy/README.txt b/sepolicy/README.txt
deleted file mode 100644
index 838de0a..0000000
--- a/sepolicy/README.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-The policy files in this directory must be merged with the platform policy files.
-
-for the public policy this is either system/sepolicy/public or BOARD_PLAT_PUBLIC_SEPOLICY
-for the private policy this is either system/sepolicy/private or BOARD_PLAT_PRIVATE_SEPOLICY
diff --git a/sepolicy/private/hwservice_contexts b/sepolicy/private/hwservice_contexts
deleted file mode 100644
index 5d915dd..0000000
--- a/sepolicy/private/hwservice_contexts
+++ /dev/null
@@ -1 +0,0 @@
-com.dsi.ant::IAnt                   u:object_r:hal_dsi_ant_hwservice:s0
diff --git a/sepolicy/public/attributes b/sepolicy/public/attributes
deleted file mode 100644
index be962bc..0000000
--- a/sepolicy/public/attributes
+++ /dev/null
@@ -1,6 +0,0 @@
-attribute hal_dsi_ant;
-expandattribute hal_dsi_ant true;
-attribute hal_dsi_ant_client;
-expandattribute hal_dsi_ant_client true;
-attribute hald_dsi_ant_server;
-expandattribute hal_dsi_ant_server false;
diff --git a/sepolicy/public/hal_dsi_ant.te b/sepolicy/public/hal_dsi_ant.te
deleted file mode 100644
index c5f93b0..0000000
--- a/sepolicy/public/hal_dsi_ant.te
+++ /dev/null
@@ -1,9 +0,0 @@
-type hal_dsi_ant_hwservice, hwservice_manager_type;
-
-# Allow interaction with the hwservice manager for the initial bind.
-add_hwservice(hal_dsi_ant_server, hal_dsi_ant_hwservice);
-allow hal_dsi_ant_client hal_dsi_ant_hwservice:hwservice_manager find;
-
-# Binder calls are made in both directions.
-binder_call(hal_dsi_ant_client, hal_dsi_ant_server);
-binder_call(hal_dsi_ant_server, hal_dsi_ant_client);