vibrator: Sync up the delta from leading project

1. Add motion awareness
2. Switch from HIDL to AIDL

Bug: 148249136
Bug: 150916170
Bug: 150737103
Test: VTS, Unit Test
Signed-off-by: chasewu <chasewu@google.com>
Change-Id: I50e317d880ca9d01bf3eff16b754c9dc91617b49
diff --git a/CleanSpec.mk b/CleanSpec.mk
new file mode 100644
index 0000000..2f8d947
--- /dev/null
+++ b/CleanSpec.mk
@@ -0,0 +1,50 @@
+# Copyright 2020 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.
+#
+
+# If you don't need to do a full clean build but would like to touch
+# a file or delete some intermediate files, add a clean step to the end
+# of the list.  These steps will only be run once, if they haven't been
+# run before.
+#
+# E.g.:
+#     $(call add-clean-step, touch -c external/sqlite/sqlite3.h)
+#     $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates)
+#
+# Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with
+# files that are missing or have been moved.
+#
+# Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory.
+# Use $(OUT_DIR) to refer to the "out" directory.
+#
+# If you need to re-do something that's already mentioned, just copy
+# the command and add it to the bottom of the list.  E.g., if a change
+# that you made last week required touching a file and a change you
+# made today requires touching the same file, just copy the old
+# touch step and add it to the end of the list.
+#
+# ************************************************
+# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
+# ************************************************
+
+# For example:
+#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates)
+#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates)
+#$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f)
+#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*)
+
+# Vibrator HAL switch to AIDL
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/etc/init/android.hardware.vibrator@1.3-service.redfin.rc)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/bin/hw/android.hardware.vibrator@1.3-service.redfin)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/etc/vintf/manifest/android.hardware.vibrator@1.3-service.redfin.xml)
diff --git a/device-redfin.mk b/device-redfin.mk
index 5a9a765..9362f99 100644
--- a/device-redfin.mk
+++ b/device-redfin.mk
@@ -117,7 +117,7 @@
 
 # Vibrator HAL
 PRODUCT_PACKAGES += \
-    android.hardware.vibrator@1.3-service.redfin
+    android.hardware.vibrator-service.redfin
 
 # DRV2624 Haptics Waveform
 PRODUCT_COPY_FILES += \
diff --git a/vibrator/common/Android.bp b/vibrator/common/Android.bp
deleted file mode 100644
index 477aa05..0000000
--- a/vibrator/common/Android.bp
+++ /dev/null
@@ -1,33 +0,0 @@
-//
-// Copyright (C) 2019 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-cc_library {
-    name: "PixelVibratorCommonRedfin",
-    srcs: [
-        "HardwareBase.cpp",
-    ],
-    shared_libs: [
-        "libbase",
-        "libcutils",
-        "liblog",
-        "libutils",
-    ],
-    cflags: [
-        "-DATRACE_TAG=(ATRACE_TAG_VIBRATOR | ATRACE_TAG_HAL)",
-        "-DLOG_TAG=\"android.hardware.vibrator@1.x-common\"",
-    ],
-    export_include_dirs: ["."],
-    vendor_available: true,
-}
diff --git a/vibrator/common/HardwareBase.cpp b/vibrator/common/HardwareBase.cpp
deleted file mode 100644
index f868b6a..0000000
--- a/vibrator/common/HardwareBase.cpp
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright (C) 2019 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.
- */
-
-#include "HardwareBase.h"
-
-#include <cutils/properties.h>
-#include <log/log.h>
-
-#include <fstream>
-#include <sstream>
-
-#include "utils.h"
-
-namespace android {
-namespace hardware {
-namespace vibrator {
-namespace common {
-namespace implementation {
-
-HwApiBase::HwApiBase() {
-    mPathPrefix = std::getenv("HWAPI_PATH_PREFIX") ?: "";
-    if (mPathPrefix.empty()) {
-        ALOGE("Failed get HWAPI path prefix!");
-    }
-}
-
-bool HwApiBase::has(const std::ios &stream) {
-    return !!stream;
-}
-
-void HwApiBase::debug(int fd) {
-    dprintf(fd, "Kernel:\n");
-
-    for (auto &entry : utils::pathsFromEnv("HWAPI_DEBUG_PATHS", mPathPrefix)) {
-        auto &path = entry.first;
-        auto &stream = entry.second;
-        std::string line;
-
-        dprintf(fd, "  %s:\n", path.c_str());
-        while (std::getline(stream, line)) {
-            dprintf(fd, "    %s\n", line.c_str());
-        }
-    }
-
-    mRecordsMutex.lock();
-    dprintf(fd, "  Records:\n");
-    for (auto &r : mRecords) {
-        if (r == nullptr) {
-            continue;
-        }
-        dprintf(fd, "    %s\n", r->toString(mNames).c_str());
-    }
-    mRecordsMutex.unlock();
-}
-
-HwCalBase::HwCalBase() {
-    std::ifstream calfile;
-    auto propertyPrefix = std::getenv("PROPERTY_PREFIX");
-
-    if (propertyPrefix != NULL) {
-        mPropertyPrefix = std::string(propertyPrefix);
-    } else {
-        ALOGE("Failed get property prefix!");
-    }
-
-    utils::fileFromEnv("CALIBRATION_FILEPATH", &calfile);
-
-    for (std::string line; std::getline(calfile, line);) {
-        if (line.empty() || line[0] == '#') {
-            continue;
-        }
-        std::istringstream is_line(line);
-        std::string key, value;
-        if (std::getline(is_line, key, ':') && std::getline(is_line, value)) {
-            mCalData[utils::trim(key)] = utils::trim(value);
-        }
-    }
-}
-
-void HwCalBase::debug(int fd) {
-    std::ifstream stream;
-    std::string path;
-    std::string line;
-    struct context {
-        HwCalBase *obj;
-        int fd;
-    } context{this, fd};
-
-    dprintf(fd, "Properties:\n");
-
-    property_list(
-        [](const char *key, const char *value, void *cookie) {
-            struct context *context = static_cast<struct context *>(cookie);
-            HwCalBase *obj = context->obj;
-            int fd = context->fd;
-            const std::string expect{obj->mPropertyPrefix};
-            const std::string actual{key, std::min(strlen(key), expect.size())};
-            if (actual == expect) {
-                dprintf(fd, "  %s:\n", key);
-                dprintf(fd, "    %s\n", value);
-            }
-        },
-        &context);
-
-    dprintf(fd, "\n");
-
-    dprintf(fd, "Persist:\n");
-
-    utils::fileFromEnv("CALIBRATION_FILEPATH", &stream, &path);
-
-    dprintf(fd, "  %s:\n", path.c_str());
-    while (std::getline(stream, line)) {
-        dprintf(fd, "    %s\n", line.c_str());
-    }
-}
-
-}  // namespace implementation
-}  // namespace common
-}  // namespace vibrator
-}  // namespace hardware
-}  // namespace android
diff --git a/vibrator/common/HardwareBase.h b/vibrator/common/HardwareBase.h
deleted file mode 100644
index 8bd1577..0000000
--- a/vibrator/common/HardwareBase.h
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- * Copyright (C) 2019 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_VIBRATOR_HARDWARE_BASE_H
-#define ANDROID_HARDWARE_VIBRATOR_HARDWARE_BASE_H
-
-#include <android-base/unique_fd.h>
-#include <log/log.h>
-#include <sys/epoll.h>
-#include <utils/Trace.h>
-
-#include <list>
-#include <map>
-#include <sstream>
-#include <string>
-
-#include "utils.h"
-
-namespace android {
-namespace hardware {
-namespace vibrator {
-namespace common {
-namespace implementation {
-
-using base::unique_fd;
-
-class HwApiBase {
-  private:
-    using NamesMap = std::map<const std::ios *, std::string>;
-
-    class RecordInterface {
-      public:
-        virtual std::string toString(const NamesMap &names) = 0;
-        virtual ~RecordInterface() {}
-    };
-    template <typename T>
-    class Record : public RecordInterface {
-      public:
-        Record(const char *func, const T &value, const std::ios *stream)
-            : mFunc(func), mValue(value), mStream(stream) {}
-        std::string toString(const NamesMap &names) override;
-
-      private:
-        const char *mFunc;
-        const T mValue;
-        const std::ios *mStream;
-    };
-    using Records = std::list<std::unique_ptr<RecordInterface>>;
-
-    static constexpr uint32_t RECORDS_SIZE = 32;
-
-  public:
-    HwApiBase();
-    void debug(int fd);
-
-  protected:
-    template <typename T>
-    void open(const std::string &name, T *stream);
-    template <typename T>
-    void openFull(const std::string &name, T *stream);
-    bool has(const std::ios &stream);
-    template <typename T>
-    bool get(T *value, std::istream *stream);
-    template <typename T>
-    bool set(const T &value, std::ostream *stream);
-    template <typename T>
-    bool poll(const T &value, std::istream *stream);
-    template <typename T>
-    void record(const char *func, const T &value, const std::ios *stream);
-
-  private:
-    std::string mPathPrefix;
-    NamesMap mNames;
-    Records mRecords{RECORDS_SIZE};
-    std::mutex mRecordsMutex;
-};
-
-#define HWAPI_RECORD(args...) HwApiBase::record(__FUNCTION__, ##args)
-
-template <typename T>
-void HwApiBase::open(const std::string &name, T *stream) {
-    mNames[stream] = name;
-    utils::openNoCreate(mPathPrefix + name, stream);
-}
-
-template <typename T>
-void HwApiBase::openFull(const std::string &name, T *stream) {
-    mNames[stream] = name;
-    utils::openNoCreate(name, stream);
-}
-
-template <typename T>
-bool HwApiBase::get(T *value, std::istream *stream) {
-    ATRACE_NAME("HwApi::get");
-    bool ret;
-    stream->seekg(0);
-    *stream >> *value;
-    if (!(ret = !!*stream)) {
-        ALOGE("Failed to read %s (%d): %s", mNames[stream].c_str(), errno, strerror(errno));
-    }
-    stream->clear();
-    HWAPI_RECORD(*value, stream);
-    return ret;
-}
-
-template <typename T>
-bool HwApiBase::set(const T &value, std::ostream *stream) {
-    ATRACE_NAME("HwApi::set");
-    using utils::operator<<;
-    bool ret;
-    *stream << value << std::endl;
-    if (!(ret = !!*stream)) {
-        ALOGE("Failed to write %s (%d): %s", mNames[stream].c_str(), errno, strerror(errno));
-        stream->clear();
-    }
-    HWAPI_RECORD(value, stream);
-    return ret;
-}
-
-template <typename T>
-bool HwApiBase::poll(const T &value, std::istream *stream) {
-    ATRACE_NAME("HwApi::poll");
-    auto path = mPathPrefix + mNames[stream];
-    unique_fd fileFd{::open(path.c_str(), O_RDONLY)};
-    unique_fd epollFd{epoll_create(1)};
-    epoll_event event = {
-        .events = EPOLLPRI | EPOLLET,
-    };
-    T actual;
-    bool ret;
-
-    if (epoll_ctl(epollFd, EPOLL_CTL_ADD, fileFd, &event)) {
-        ALOGE("Failed to poll %s (%d): %s", mNames[stream].c_str(), errno, strerror(errno));
-        return false;
-    }
-
-    while ((ret = get(&actual, stream)) && (actual != value)) {
-        epoll_wait(epollFd, &event, 1, -1);
-    }
-
-    HWAPI_RECORD(value, stream);
-    return ret;
-}
-
-template <typename T>
-void HwApiBase::record(const char *func, const T &value, const std::ios *stream) {
-    std::lock_guard<std::mutex> lock(mRecordsMutex);
-    mRecords.emplace_back(std::make_unique<Record<T>>(func, value, stream));
-    mRecords.pop_front();
-}
-
-template <typename T>
-std::string HwApiBase::Record<T>::toString(const NamesMap &names) {
-    using utils::operator<<;
-    std::stringstream ret;
-
-    ret << mFunc << " '" << names.at(mStream) << "' = '" << mValue << "'";
-
-    return ret.str();
-}
-
-class HwCalBase {
-  public:
-    HwCalBase();
-    void debug(int fd);
-
-  protected:
-    template <typename T>
-    bool getProperty(const char *key, T *value, const T defval);
-    template <typename T>
-    bool getPersist(const char *key, T *value);
-
-  private:
-    std::string mPropertyPrefix;
-    std::map<std::string, std::string> mCalData;
-};
-
-template <typename T>
-bool HwCalBase::getProperty(const char *key, T *outval, const T defval) {
-    ATRACE_NAME("HwCal::getProperty");
-    *outval = utils::getProperty(mPropertyPrefix + key, defval);
-    return true;
-}
-
-template <typename T>
-bool HwCalBase::getPersist(const char *key, T *value) {
-    ATRACE_NAME("HwCal::getPersist");
-    auto it = mCalData.find(key);
-    if (it == mCalData.end()) {
-        ALOGE("Missing %s config!", key);
-        return false;
-    }
-    std::stringstream stream{it->second};
-    utils::unpack(stream, value);
-    if (!stream || !stream.eof()) {
-        ALOGE("Invalid %s config!", key);
-        return false;
-    }
-    return true;
-}
-
-}  // namespace implementation
-}  // namespace common
-}  // namespace vibrator
-}  // namespace hardware
-}  // namespace android
-
-#endif  // ANDROID_HARDWARE_VIBRATOR_HARDWARE_BASE_H
diff --git a/vibrator/common/TEST_MAPPING b/vibrator/common/TEST_MAPPING
deleted file mode 100644
index c0e8e98..0000000
--- a/vibrator/common/TEST_MAPPING
+++ /dev/null
@@ -1,13 +0,0 @@
-{
-  "postsubmit": [
-    {
-      "name": "VibratorHalIntegrationBenchmark"
-    },
-    {
-      "name": "VibratorHalIntegrationBenchmark",
-      "keywords": [
-        "primary-device"
-      ]
-    }
-  ]
-}
diff --git a/vibrator/common/bench/Android.bp b/vibrator/common/bench/Android.bp
deleted file mode 100644
index 8df1d8d..0000000
--- a/vibrator/common/bench/Android.bp
+++ /dev/null
@@ -1,32 +0,0 @@
-//
-// Copyright (C) 2019 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-cc_benchmark {
-    name: "VibratorHalIntegrationBenchmarkRedfin",
-    defaults: ["hidl_defaults"],
-    srcs: [
-        "benchmark.cpp",
-    ],
-    shared_libs: [
-        "android.hardware.vibrator@1.0",
-        "android.hardware.vibrator@1.1",
-        "android.hardware.vibrator@1.2",
-        "android.hardware.vibrator@1.3",
-        "libhardware",
-        "libhidlbase",
-        "libutils",
-    ],
-    test_suites: ["device-tests"],
-}
diff --git a/vibrator/common/bench/benchmark.cpp b/vibrator/common/bench/benchmark.cpp
deleted file mode 100644
index 06013f9..0000000
--- a/vibrator/common/bench/benchmark.cpp
+++ /dev/null
@@ -1,274 +0,0 @@
-/*
- * Copyright (C) 2019 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.
- */
-
-#include "benchmark/benchmark.h"
-
-#include <android/hardware/vibrator/1.3/IVibrator.h>
-
-using ::android::sp;
-using ::android::hardware::hidl_enum_range;
-using ::android::hardware::Return;
-using ::android::hardware::details::hidl_enum_values;
-using ::benchmark::Counter;
-using ::benchmark::Fixture;
-using ::benchmark::kMicrosecond;
-using ::benchmark::State;
-using ::benchmark::internal::Benchmark;
-using ::std::chrono::duration;
-using ::std::chrono::duration_cast;
-using ::std::chrono::high_resolution_clock;
-
-namespace V1_0 = ::android::hardware::vibrator::V1_0;
-namespace V1_1 = ::android::hardware::vibrator::V1_1;
-namespace V1_2 = ::android::hardware::vibrator::V1_2;
-namespace V1_3 = ::android::hardware::vibrator::V1_3;
-
-template <typename I>
-class VibratorBench : public Fixture {
-  public:
-    void SetUp(State & /*state*/) override { mVibrator = I::getService(); }
-
-    void TearDown(State & /*state*/) override {
-        if (!mVibrator) {
-            return;
-        }
-        mVibrator->off();
-    }
-
-    static void DefaultConfig(Benchmark *b) { b->Unit(kMicrosecond); }
-
-    static void DefaultArgs(Benchmark * /*b*/) {
-        // none
-    }
-
-  protected:
-    auto getOtherArg(const State &state, std::size_t index) const {
-        return state.range(index + 0);
-    }
-
-  protected:
-    sp<I> mVibrator;
-};
-
-enum class EmptyEnum : uint32_t;
-template <>
-inline constexpr std::array<EmptyEnum, 0> hidl_enum_values<EmptyEnum> = {};
-
-template <typename T, typename U>
-std::set<T> difference(const hidl_enum_range<T> &t, const hidl_enum_range<U> &u) {
-    class Compare {
-      public:
-        bool operator()(const T &a, const U &b) { return a < static_cast<T>(b); }
-        bool operator()(const U &a, const T &b) { return static_cast<T>(a) < b; }
-    };
-    std::set<T> ret;
-
-    std::set_difference(t.begin(), t.end(), u.begin(), u.end(),
-                        std::insert_iterator<decltype(ret)>(ret, ret.begin()), Compare());
-
-    return ret;
-}
-
-template <typename I, typename E1, typename E2 = EmptyEnum>
-class VibratorEffectsBench : public VibratorBench<I> {
-  public:
-    using Effect = E1;
-    using EffectStrength = V1_0::EffectStrength;
-    using Status = V1_0::Status;
-
-  public:
-    static void DefaultArgs(Benchmark *b) {
-        b->ArgNames({"Effect", "Strength"});
-        for (const auto &effect : difference(hidl_enum_range<E1>(), hidl_enum_range<E2>())) {
-            for (const auto &strength : hidl_enum_range<EffectStrength>()) {
-                b->Args({static_cast<long>(effect), static_cast<long>(strength)});
-            }
-        }
-    }
-
-    void performBench(State *state, Return<void> (I::*performApi)(Effect, EffectStrength,
-                                                                  typename I::perform_cb)) {
-        auto effect = getEffect(*state);
-        auto strength = getStrength(*state);
-        bool supported = true;
-
-        (*this->mVibrator.*performApi)(effect, strength, [&](Status status, uint32_t /*lengthMs*/) {
-            if (status == Status::UNSUPPORTED_OPERATION) {
-                supported = false;
-            }
-        });
-
-        if (!supported) {
-            return;
-        }
-
-        for (auto _ : *state) {
-            state->ResumeTiming();
-            (*this->mVibrator.*performApi)(effect, strength,
-                                           [](Status /*status*/, uint32_t /*lengthMs*/) {});
-            state->PauseTiming();
-            this->mVibrator->off();
-        }
-    }
-
-  protected:
-    auto getEffect(const State &state) const {
-        return static_cast<Effect>(this->getOtherArg(state, 0));
-    }
-
-    auto getStrength(const State &state) const {
-        return static_cast<EffectStrength>(this->getOtherArg(state, 1));
-    }
-};
-
-#define BENCHMARK_WRAPPER(fixt, test, code) \
-    BENCHMARK_DEFINE_F(fixt, test)          \
-    /* NOLINTNEXTLINE */                    \
-    (State & state) {                       \
-        if (!mVibrator) {                   \
-            return;                         \
-        }                                   \
-                                            \
-        code                                \
-    }                                       \
-    BENCHMARK_REGISTER_F(fixt, test)->Apply(fixt::DefaultConfig)->Apply(fixt::DefaultArgs)
-
-using VibratorBench_V1_0 = VibratorBench<V1_0::IVibrator>;
-
-BENCHMARK_WRAPPER(VibratorBench_V1_0, on, {
-    uint32_t ms = UINT32_MAX;
-
-    for (auto _ : state) {
-        state.ResumeTiming();
-        mVibrator->on(ms);
-        state.PauseTiming();
-        mVibrator->off();
-    }
-});
-
-BENCHMARK_WRAPPER(VibratorBench_V1_0, off, {
-    uint32_t ms = UINT32_MAX;
-
-    for (auto _ : state) {
-        state.PauseTiming();
-        mVibrator->on(ms);
-        state.ResumeTiming();
-        mVibrator->off();
-    }
-});
-
-BENCHMARK_WRAPPER(VibratorBench_V1_0, supportsAmplitudeControl, {
-    for (auto _ : state) {
-        mVibrator->supportsAmplitudeControl();
-    }
-});
-
-BENCHMARK_WRAPPER(VibratorBench_V1_0, setAmplitude, {
-    uint8_t amplitude = UINT8_MAX;
-
-    if (!mVibrator->supportsAmplitudeControl()) {
-        return;
-    }
-
-    mVibrator->on(UINT32_MAX);
-
-    for (auto _ : state) {
-        mVibrator->setAmplitude(amplitude);
-    }
-
-    mVibrator->off();
-});
-
-using VibratorEffectsBench_V1_0 = VibratorEffectsBench<V1_0::IVibrator, V1_0::Effect>;
-
-BENCHMARK_WRAPPER(VibratorEffectsBench_V1_0, perform,
-                  { performBench(&state, &V1_0::IVibrator::perform); });
-
-using VibratorEffectsBench_V1_1 =
-    VibratorEffectsBench<V1_1::IVibrator, V1_1::Effect_1_1, V1_0::Effect>;
-
-BENCHMARK_WRAPPER(VibratorEffectsBench_V1_1, perform_1_1,
-                  { performBench(&state, &V1_1::IVibrator::perform_1_1); });
-
-using VibratorEffectsBench_V1_2 =
-    VibratorEffectsBench<V1_2::IVibrator, V1_2::Effect, V1_1::Effect_1_1>;
-
-BENCHMARK_WRAPPER(VibratorEffectsBench_V1_2, perform_1_2,
-                  { performBench(&state, &V1_2::IVibrator::perform_1_2); });
-
-using VibratorBench_V1_3 = VibratorBench<V1_3::IVibrator>;
-
-BENCHMARK_WRAPPER(VibratorBench_V1_3, supportsExternalControl, {
-    for (auto _ : state) {
-        mVibrator->supportsExternalControl();
-    }
-});
-
-BENCHMARK_WRAPPER(VibratorBench_V1_3, setExternalControl, {
-    bool enable = true;
-
-    if (!mVibrator->supportsExternalControl()) {
-        return;
-    }
-
-    for (auto _ : state) {
-        state.ResumeTiming();
-        mVibrator->setExternalControl(enable);
-        state.PauseTiming();
-        mVibrator->setExternalControl(false);
-    }
-});
-
-BENCHMARK_WRAPPER(VibratorBench_V1_3, supportsExternalAmplitudeControl, {
-    if (!mVibrator->supportsExternalControl()) {
-        return;
-    }
-
-    mVibrator->setExternalControl(true);
-
-    for (auto _ : state) {
-        mVibrator->supportsAmplitudeControl();
-    }
-
-    mVibrator->setExternalControl(false);
-});
-
-BENCHMARK_WRAPPER(VibratorBench_V1_3, setExternalAmplitude, {
-    uint8_t amplitude = UINT8_MAX;
-
-    if (!mVibrator->supportsExternalControl()) {
-        return;
-    }
-
-    mVibrator->setExternalControl(true);
-
-    if (!mVibrator->supportsAmplitudeControl()) {
-        return;
-    }
-
-    for (auto _ : state) {
-        mVibrator->setAmplitude(amplitude);
-    }
-
-    mVibrator->setExternalControl(false);
-});
-
-using VibratorEffectsBench_V1_3 = VibratorEffectsBench<V1_3::IVibrator, V1_3::Effect, V1_2::Effect>;
-
-BENCHMARK_WRAPPER(VibratorEffectsBench_V1_3, perform_1_3,
-                  { performBench(&state, &V1_3::IVibrator::perform_1_3); });
-
-BENCHMARK_MAIN();
diff --git a/vibrator/common/utils.h b/vibrator/common/utils.h
deleted file mode 100644
index 2079256..0000000
--- a/vibrator/common/utils.h
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Copyright (C) 2019 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_VIBRATOR_UTILS_H
-#define ANDROID_HARDWARE_VIBRATOR_UTILS_H
-
-#include <android-base/macros.h>
-#include <android-base/properties.h>
-#include <log/log.h>
-
-#include <fstream>
-
-namespace android {
-namespace hardware {
-namespace vibrator {
-namespace utils {
-
-template <typename T>
-class Is_Iterable {
-  private:
-    template <typename U>
-    static std::true_type test(typename U::iterator *u);
-
-    template <typename U>
-    static std::false_type test(U *u);
-
-  public:
-    static const bool value = decltype(test<T>(0))::value;
-};
-
-template <typename T, bool B>
-using Enable_If_Iterable = std::enable_if_t<Is_Iterable<T>::value == B>;
-
-template <typename T, typename U = void>
-using Enable_If_Signed = std::enable_if_t<std::is_signed_v<T>, U>;
-
-template <typename T, typename U = void>
-using Enable_If_Unsigned = std::enable_if_t<std::is_unsigned_v<T>, U>;
-
-// override for default behavior of printing as a character
-inline std::ostream &operator<<(std::ostream &stream, const int8_t value) {
-    return stream << +value;
-}
-// override for default behavior of printing as a character
-inline std::ostream &operator<<(std::ostream &stream, const uint8_t value) {
-    return stream << +value;
-}
-
-template <typename T>
-inline auto toUnderlying(const T value) {
-    return static_cast<std::underlying_type_t<T>>(value);
-}
-
-template <typename T>
-inline Enable_If_Iterable<T, true> unpack(std::istream &stream, T *value) {
-    for (auto &entry : *value) {
-        stream >> entry;
-    }
-}
-
-template <typename T>
-inline Enable_If_Iterable<T, false> unpack(std::istream &stream, T *value) {
-    stream >> *value;
-}
-
-template <>
-inline void unpack<std::string>(std::istream &stream, std::string *value) {
-    *value = std::string(std::istreambuf_iterator(stream), {});
-    stream.setstate(std::istream::eofbit);
-}
-
-template <typename T>
-inline Enable_If_Signed<T, T> getProperty(const std::string &key, const T def) {
-    return base::GetIntProperty(key, def);
-}
-
-template <typename T>
-inline Enable_If_Unsigned<T, T> getProperty(const std::string &key, const T def) {
-    return base::GetUintProperty(key, def);
-}
-
-template <>
-inline bool getProperty<bool>(const std::string &key, const bool def) {
-    return base::GetBoolProperty(key, def);
-}
-
-template <typename T>
-static void openNoCreate(const std::string &file, T *outStream) {
-    auto mode = std::is_base_of_v<std::ostream, T> ? std::ios_base::out : std::ios_base::in;
-
-    // Force 'in' mode to prevent file creation
-    outStream->open(file, mode | std::ios_base::in);
-    if (!*outStream) {
-        ALOGE("Failed to open %s (%d): %s", file.c_str(), errno, strerror(errno));
-    }
-}
-
-template <typename T>
-static void fileFromEnv(const char *env, T *outStream, std::string *outName = nullptr) {
-    auto file = std::getenv(env);
-
-    if (file == nullptr) {
-        ALOGE("Failed get env %s", env);
-        return;
-    }
-
-    if (outName != nullptr) {
-        *outName = std::string(file);
-    }
-
-    openNoCreate(file, outStream);
-}
-
-static ATTRIBUTE_UNUSED auto pathsFromEnv(const char *env, const std::string &prefix = "") {
-    std::map<std::string, std::ifstream> ret;
-    auto value = std::getenv(env);
-
-    if (value == nullptr) {
-        return ret;
-    }
-
-    std::istringstream paths{value};
-    std::string path;
-
-    while (paths >> path) {
-        ret[path].open(prefix + path);
-    }
-
-    return ret;
-}
-
-static ATTRIBUTE_UNUSED std::string trim(const std::string &str,
-                                         const std::string &whitespace = " \t") {
-    const auto str_begin = str.find_first_not_of(whitespace);
-    if (str_begin == std::string::npos) {
-        return "";
-    }
-
-    const auto str_end = str.find_last_not_of(whitespace);
-    const auto str_range = str_end - str_begin + 1;
-
-    return str.substr(str_begin, str_range);
-}
-
-}  // namespace utils
-}  // namespace vibrator
-}  // namespace hardware
-}  // namespace android
-
-#endif  // ANDROID_HARDWARE_VIBRATOR_UTILS_H
diff --git a/vibrator/drv2624/Android.bp b/vibrator/drv2624/Android.bp
index 420c228..c3184c2 100644
--- a/vibrator/drv2624/Android.bp
+++ b/vibrator/drv2624/Android.bp
@@ -1,5 +1,5 @@
 //
-// Copyright (C) 2019 The Android Open Source Project
+// Copyright (C) 2020 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.
@@ -14,42 +14,46 @@
 // limitations under the License.
 
 cc_defaults {
-    name: "android.hardware.vibrator@1.3-defaults.redfin",
-    defaults: ["PixelVibratorDefaultsRedfin"],
-    shared_libs: [
-        "android.hardware.vibrator@1.0",
-        "android.hardware.vibrator@1.1",
-        "android.hardware.vibrator@1.2",
-        "android.hardware.vibrator@1.3",
-    ],
+    name: "android.hardware.vibrator-defaults.redfin",
     cflags: [
         "-DATRACE_TAG=(ATRACE_TAG_VIBRATOR | ATRACE_TAG_HAL)",
-        "-DLOG_TAG=\"android.hardware.vibrator@1.3-redfin\"",
+        "-DLOG_TAG=\"android.hardware.vibrator-redfin\"",
     ],
 }
 
 cc_defaults {
-    name: "VibratorHalDrv2624TestDefaultsRedfin",
-    defaults: ["android.hardware.vibrator@1.3-defaults.redfin"],
-    static_libs: ["android.hardware.vibrator@1.3-impl.redfin"],
-    test_suites: ["device-tests"],
-    require_root: true,
+    name: "VibratorHalDrv2624BinaryDefaultsRedfin",
+    defaults: [
+        "PixelVibratorBinaryDefaults",
+        "android.hardware.vibrator-defaults.redfin",
+    ],
+    target: {
+        android: {
+            // TODO: Add sensor stub for tests.
+        },
+        vendor: {
+            shared_libs: [
+                "libsensorndkbridge",
+            ],
+        }
+    },
 }
 
 cc_library {
-    name: "android.hardware.vibrator@1.3-impl.redfin",
-    defaults: ["android.hardware.vibrator@1.3-defaults.redfin"],
+    name: "android.hardware.vibrator-impl.redfin",
+    defaults: ["VibratorHalDrv2624BinaryDefaultsRedfin"],
     srcs: ["Vibrator.cpp"],
     export_include_dirs: ["."],
-    vendor_available: true,
+    proprietary: true,
+    visibility: [":__subpackages__"],
 }
 
 cc_binary {
-    name: "android.hardware.vibrator@1.3-service.redfin",
-    defaults: ["android.hardware.vibrator@1.3-defaults.redfin"],
-    init_rc: ["android.hardware.vibrator@1.3-service.redfin.rc"],
-    vintf_fragments: ["android.hardware.vibrator@1.3-service.redfin.xml"],
+    name: "android.hardware.vibrator-service.redfin",
+    defaults: ["VibratorHalDrv2624BinaryDefaultsRedfin"],
+    init_rc: ["android.hardware.vibrator-service.redfin.rc"],
+    vintf_fragments: ["android.hardware.vibrator-service.redfin.xml"],
     srcs: ["service.cpp"],
-    static_libs: ["android.hardware.vibrator@1.3-impl.redfin"],
+    static_libs: ["android.hardware.vibrator-impl.redfin"],
     proprietary: true,
 }
diff --git a/vibrator/drv2624/Hardware.h b/vibrator/drv2624/Hardware.h
index 96fd62f..2609247 100644
--- a/vibrator/drv2624/Hardware.h
+++ b/vibrator/drv2624/Hardware.h
@@ -13,20 +13,15 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#ifndef ANDROID_HARDWARE_VIBRATOR_HARDWARE_H
-#define ANDROID_HARDWARE_VIBRATOR_HARDWARE_H
+#pragma once
 
 #include "../common/HardwareBase.h"
 #include "Vibrator.h"
 
+namespace aidl {
 namespace android {
 namespace hardware {
 namespace vibrator {
-namespace V1_3 {
-namespace implementation {
-
-using common::implementation::HwApiBase;
-using common::implementation::HwCalBase;
 
 class HwApi : public Vibrator::HwApi, private HwApiBase {
   public:
@@ -73,7 +68,14 @@
         open("device/lra_wave_shape", &mLraWaveShape);
         open("device/od_clamp", &mOdClamp);
         // TODO: for future new architecture: b/149610125
-        openFull("/sys/devices/virtual/thermal/tz-by-name/pa-therm1/temp", &mPATemp);
+        openFull("/sys/devices/virtual/thermal/tz-by-name/pa-therm1/temp",
+                 &mPATemp);
+    }
+
+    template <typename T>
+    void openFull(const std::string &name, T *stream) {
+        saveName(name, stream);
+        utils::openNoCreate(name, stream);
     }
 
   private:
@@ -103,7 +105,7 @@
 
     static constexpr uint32_t WAVEFORM_CLICK_EFFECT_MS = 6;
     static constexpr uint32_t WAVEFORM_TICK_EFFECT_MS = 2;
-    static constexpr uint32_t WAVEFORM_DOUBLE_CLICK_EFFECT_MS = 144;
+    static constexpr uint32_t WAVEFORM_DOUBLE_CLICK_EFFECT_MS = 160;
     static constexpr uint32_t WAVEFORM_HEAVY_CLICK_EFFECT_MS = 8;
 
     static constexpr uint32_t DEFAULT_LRA_PERIOD = 262;
@@ -181,10 +183,7 @@
     void debug(int fd) override { HwCalBase::debug(fd); }
 };
 
-}  // namespace implementation
-}  // namespace V1_3
 }  // namespace vibrator
 }  // namespace hardware
 }  // namespace android
-
-#endif  // ANDROID_HARDWARE_VIBRATOR_HARDWARE_H
+}  // namespace aidl
diff --git a/vibrator/drv2624/TEST_MAPPING b/vibrator/drv2624/TEST_MAPPING
index ec34f66..3c18a65 100644
--- a/vibrator/drv2624/TEST_MAPPING
+++ b/vibrator/drv2624/TEST_MAPPING
@@ -1,12 +1,12 @@
 {
   "presubmit": [
     {
-      "name": "VibratorHalDrv2624TestSuite"
+      "name": "VibratorHalDrv2624TestSuiteRedfin"
     }
   ],
   "postsubmit": [
     {
-      "name": "VibratorHalDrv2624Benchmark",
+      "name": "VibratorHalDrv2624BenchmarkRedfin",
       "keywords": [
         "primary-device"
       ]
diff --git a/vibrator/drv2624/Vibrator.cpp b/vibrator/drv2624/Vibrator.cpp
index 793b2b1..8b193e1 100644
--- a/vibrator/drv2624/Vibrator.cpp
+++ b/vibrator/drv2624/Vibrator.cpp
@@ -15,25 +15,30 @@
  */
 
 #include "Vibrator.h"
+#include "utils.h"
 
+#include <android/looper.h>
+#include <android/sensor.h>
 #include <cutils/properties.h>
 #include <hardware/hardware.h>
 #include <hardware/vibrator.h>
 #include <log/log.h>
+#include <utils/Errors.h>
 #include <utils/Trace.h>
 
 #include <cinttypes>
 #include <cmath>
 #include <fstream>
 #include <iostream>
+#include <numeric>
 
-#include "utils.h"
-
+namespace aidl {
 namespace android {
 namespace hardware {
 namespace vibrator {
-namespace V1_3 {
-namespace implementation {
+
+using ::android::NO_ERROR;
+using ::android::UNEXPECTED_NULL;
 
 static constexpr int8_t MAX_RTP_INPUT = 127;
 static constexpr int8_t MIN_RTP_INPUT = 0;
@@ -54,10 +59,80 @@
 static constexpr char WAVEFORM_HEAVY_CLICK_EFFECT_SEQ[] = "4 0";
 
 // UT team design those target G values
-static constexpr std::array<float, 5> EFFECT_TARGET_G = {0.175, 0.325, 0.37, 0.475, 0.6};
-static constexpr std::array<float, 3> STEADY_TARGET_G = {1.38, 1.145, 0.905};
+static constexpr std::array<float, 5> EFFECT_TARGET_G = {0.22, 0.35, 0.42, 0.57, 0.67};
+static constexpr std::array<float, 3> STEADY_TARGET_G = {1.2, 1.145, 0.4};
+
+struct SensorContext {
+    ASensorEventQueue *queue;
+};
+static std::vector<float> sXAxleData;
+static std::vector<float> sYAxleData;
+static uint64_t sEndTime = 0;
+static struct timespec sGetTime;
 
 #define FLOAT_EPS 1e-7
+#define SENSOR_DATA_NUM 20
+// Set sensing period to 2s
+#define SENSING_PERIOD 2000000000
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
+
+int GSensorCallback(__attribute__((unused)) int fd, __attribute__((unused)) int events,
+                    void *data) {
+    ASensorEvent event;
+    int event_count = 0;
+    SensorContext *context = reinterpret_cast<SensorContext *>(data);
+    event_count = ASensorEventQueue_getEvents(context->queue, &event, 1);
+    ALOGI("%s: event data: %f %f\n", __func__, event.data[0], event.data[1]);
+    sXAxleData.push_back(event.data[0]);
+    sYAxleData.push_back(event.data[1]);
+    return 1;
+}
+// TODO: b/152305970
+int32_t PollGSensor() {
+    int err = NO_ERROR, counter = 0;
+    ASensorManager *sensorManager = nullptr;
+    ASensorRef GSensor;
+    ALooper *looper;
+    struct SensorContext context = {nullptr};
+
+    // Get proximity sensor events from the NDK
+    sensorManager = ASensorManager_getInstanceForPackage("");
+    if (!sensorManager) {
+        ALOGI("Chase %s: Sensor manager is NULL.\n", __FUNCTION__);
+        err = UNEXPECTED_NULL;
+        return 0;
+    }
+    GSensor = ASensorManager_getDefaultSensor(sensorManager, ASENSOR_TYPE_GRAVITY);
+    if (GSensor == nullptr) {
+        ALOGE("%s:Chase Unable to get g sensor\n", __func__);
+    } else {
+        looper = ALooper_forThread();
+        if (looper == nullptr) {
+            looper = ALooper_prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS);
+        }
+        context.queue =
+            ASensorManager_createEventQueue(sensorManager, looper, 0, GSensorCallback, &context);
+
+        err = ASensorEventQueue_registerSensor(context.queue, GSensor, 0, 0);
+        if (err != NO_ERROR) {
+            ALOGE("Chase %s: Error %d registering G sensor with event queue.\n", __FUNCTION__, err);
+            return 0;
+        }
+        if (err < 0) {
+            ALOGE("%s:Chase Unable to register for G sensor events\n", __func__);
+        } else {
+            for (counter = 0; counter < SENSOR_DATA_NUM; counter++) {
+                ALooper_pollOnce(5, nullptr, nullptr, nullptr);
+            }
+        }
+    }
+    if (sensorManager != nullptr && context.queue != nullptr) {
+        ASensorEventQueue_disableSensor(context.queue, GSensor);
+        ASensorManager_destroyEventQueue(sensorManager, context.queue);
+    }
+
+    return 0;
+}
 
 // Temperature protection upper bound 10°C and lower bound 5°C
 static constexpr int32_t TEMP_UPPER_BOUND = 10000;
@@ -173,10 +248,31 @@
     }
 }
 
-using utils::toUnderlying;
+static bool motionAwareness() {
+    float avgX = 0.0, avgY = 0.0;
+    uint64_t current_time = 0;
+    clock_gettime(CLOCK_MONOTONIC, &sGetTime);
+    current_time = ((uint64_t)sGetTime.tv_sec * 1000 * 1000 * 1000) + sGetTime.tv_nsec;
 
-using Status = ::android::hardware::vibrator::V1_0::Status;
-using EffectStrength = ::android::hardware::vibrator::V1_0::EffectStrength;
+    if ((current_time - sEndTime) > SENSING_PERIOD) {
+        sXAxleData.clear();
+        sYAxleData.clear();
+        PollGSensor();
+        avgX = std::accumulate(sXAxleData.begin(), sXAxleData.end(), 0.0) / sXAxleData.size();
+        avgY = std::accumulate(sYAxleData.begin(), sYAxleData.end(), 0.0) / sYAxleData.size();
+        clock_gettime(CLOCK_MONOTONIC, &sGetTime);
+
+        sEndTime = ((uint64_t)sGetTime.tv_sec * 1000 * 1000 * 1000) + sGetTime.tv_nsec;
+    }
+
+    if ((avgX > -1.3) && (avgX < 1.3) && (avgY > -0.8) && (avgY < 0.8)) {
+        return false;
+    } else {
+        return true;
+    }
+}
+
+using utils::toUnderlying;
 
 Vibrator::Vibrator(std::unique_ptr<HwApi> hwapi, std::unique_ptr<HwCal> hwcal)
     : mHwApi(std::move(hwapi)), mHwCal(std::move(hwcal)) {
@@ -288,9 +384,19 @@
     }
 }
 
-Return<Status> Vibrator::on(uint32_t timeoutMs, const char mode[],
-                            const std::unique_ptr<VibrationConfig> &config,
-                            const int8_t volOffset) {
+ndk::ScopedAStatus Vibrator::getCapabilities(int32_t *_aidl_return) {
+    ATRACE_NAME("Vibrator::getCapabilities");
+    int32_t ret = 0;
+    if (mHwApi->hasRtpInput()) {
+        ret |= IVibrator::CAP_AMPLITUDE_CONTROL;
+    }
+    *_aidl_return = ret;
+    return ndk::ScopedAStatus::ok();
+}
+
+ndk::ScopedAStatus Vibrator::on(uint32_t timeoutMs, const char mode[],
+                                const std::unique_ptr<VibrationConfig> &config,
+                                const int8_t volOffset) {
     LoopControl loopMode = LoopControl::OPEN;
 
     // Open-loop mode is used for short click for over-drive
@@ -302,7 +408,7 @@
     mHwApi->setCtrlLoop(toUnderlying(loopMode));
     if (!mHwApi->setDuration(timeoutMs)) {
         ALOGE("Failed to set duration (%d): %s", errno, strerror(errno));
-        return Status::UNKNOWN_ERROR;
+        return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
     }
 
     mHwApi->setMode(mode);
@@ -314,21 +420,29 @@
 
     if (!mHwApi->setActivate(1)) {
         ALOGE("Failed to activate (%d): %s", errno, strerror(errno));
-        return Status::UNKNOWN_ERROR;
+        return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
     }
 
-    return Status::OK;
+    return ndk::ScopedAStatus::ok();
 }
 
-// Methods from ::android::hardware::vibrator::V1_2::IVibrator follow.
-Return<Status> Vibrator::on(uint32_t timeoutMs) {
+ndk::ScopedAStatus Vibrator::on(int32_t timeoutMs,
+                                const std::shared_ptr<IVibratorCallback> &callback) {
     ATRACE_NAME("Vibrator::on");
+
+    if (callback) {
+        return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
+    }
+
     if (mDynamicConfig) {
         int temperature = 0;
         mHwApi->getPATemp(&temperature);
         if (temperature > TEMP_UPPER_BOUND) {
             mSteadyConfig->odClamp = &mSteadyTargetOdClamp[0];
             mSteadyConfig->olLraPeriod = mSteadyOlLraPeriod;
+            if (!motionAwareness()) {
+                return on(timeoutMs, RTP_MODE, mSteadyConfig, 2);
+            }
         } else if (temperature < TEMP_LOWER_BOUND) {
             mSteadyConfig->odClamp = &STEADY_VOLTAGE_LOWER_BOUND;
             mSteadyConfig->olLraPeriod = mSteadyOlLraPeriodShift;
@@ -338,62 +452,47 @@
     return on(timeoutMs, RTP_MODE, mSteadyConfig, 0);
 }
 
-Return<Status> Vibrator::off() {
+ndk::ScopedAStatus Vibrator::off() {
     ATRACE_NAME("Vibrator::off");
     if (!mHwApi->setActivate(0)) {
         ALOGE("Failed to turn vibrator off (%d): %s", errno, strerror(errno));
-        return Status::UNKNOWN_ERROR;
+        return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
     }
-    return Status::OK;
+    return ndk::ScopedAStatus::ok();
 }
 
-Return<bool> Vibrator::supportsAmplitudeControl() {
-    ATRACE_NAME("Vibrator::supportsAmplitudeControl");
-    return (mHwApi->hasRtpInput() ? true : false);
-}
-
-Return<Status> Vibrator::setAmplitude(uint8_t amplitude) {
+ndk::ScopedAStatus Vibrator::setAmplitude(float amplitude) {
     ATRACE_NAME("Vibrator::setAmplitude");
-    if (amplitude == 0) {
-        return Status::BAD_VALUE;
+    if (amplitude <= 0.0f || amplitude > 1.0f) {
+        return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
     }
 
-    int32_t rtp_input =
-        std::round((amplitude - 1) / 254.0 * (MAX_RTP_INPUT - MIN_RTP_INPUT) + MIN_RTP_INPUT);
+    int32_t rtp_input = std::round(amplitude * (MAX_RTP_INPUT - MIN_RTP_INPUT) + MIN_RTP_INPUT);
 
     if (!mHwApi->setRtpInput(rtp_input)) {
         ALOGE("Failed to set amplitude (%d): %s", errno, strerror(errno));
-        return Status::UNKNOWN_ERROR;
+        return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
     }
 
-    return Status::OK;
+    return ndk::ScopedAStatus::ok();
 }
 
-// Methods from ::android::hardware::vibrator::V1_3::IVibrator follow.
-
-Return<bool> Vibrator::supportsExternalControl() {
-    ATRACE_NAME("Vibrator::supportsExternalControl");
-    return false;
-}
-
-Return<Status> Vibrator::setExternalControl(bool enabled) {
+ndk::ScopedAStatus Vibrator::setExternalControl(bool enabled) {
     ATRACE_NAME("Vibrator::setExternalControl");
     ALOGE("Not support in DRV2624 solution, %d", enabled);
-    return Status::UNSUPPORTED_OPERATION;
+    return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
 }
 
-// Methods from ::android.hidl.base::V1_0::IBase follow.
-
-Return<void> Vibrator::debug(const hidl_handle &handle,
-                             const hidl_vec<hidl_string> & /* options */) {
-    if (handle == nullptr || handle->numFds < 1 || handle->data[0] < 0) {
+binder_status_t Vibrator::dump(int fd, const char **args, uint32_t numArgs) {
+    if (fd < 0) {
         ALOGE("Called debug() with invalid fd.");
-        return Void();
+        return STATUS_OK;
     }
 
-    int fd = handle->data[0];
+    (void)args;
+    (void)numArgs;
 
-    dprintf(fd, "HIDL:\n");
+    dprintf(fd, "AIDL:\n");
 
     dprintf(fd, "  Close Loop Thresh: %" PRIu32 "\n", mCloseLoopThreshold);
     if (mSteadyConfig) {
@@ -424,45 +523,33 @@
     mHwCal->debug(fd);
 
     fsync(fd);
-    return Void();
+    return STATUS_OK;
 }
 
-Return<void> Vibrator::perform(V1_0::Effect effect, EffectStrength strength, perform_cb _hidl_cb) {
-    return performWrapper(effect, strength, _hidl_cb);
+ndk::ScopedAStatus Vibrator::getSupportedEffects(std::vector<Effect> *_aidl_return) {
+    *_aidl_return = {Effect::TEXTURE_TICK, Effect::TICK, Effect::CLICK, Effect::HEAVY_CLICK,
+                     Effect::DOUBLE_CLICK};
+    return ndk::ScopedAStatus::ok();
 }
 
-Return<void> Vibrator::perform_1_1(V1_1::Effect_1_1 effect, EffectStrength strength,
-                                   perform_cb _hidl_cb) {
-    return performWrapper(effect, strength, _hidl_cb);
-}
+ndk::ScopedAStatus Vibrator::perform(Effect effect, EffectStrength strength,
+                                     const std::shared_ptr<IVibratorCallback> &callback,
+                                     int32_t *_aidl_return) {
+    ATRACE_NAME("Vibrator::perform");
+    ndk::ScopedAStatus status;
 
-Return<void> Vibrator::perform_1_2(V1_2::Effect effect, EffectStrength strength,
-                                   perform_cb _hidl_cb) {
-    return performWrapper(effect, strength, _hidl_cb);
-}
-
-Return<void> Vibrator::perform_1_3(Effect effect, EffectStrength strength, perform_cb _hidl_cb) {
-    return performWrapper(effect, strength, _hidl_cb);
-}
-
-template <typename T>
-Return<void> Vibrator::performWrapper(T effect, EffectStrength strength, perform_cb _hidl_cb) {
-    ATRACE_NAME("Vibrator::performWrapper");
-    auto validEffectRange = hidl_enum_range<T>();
-    if (effect < *validEffectRange.begin() || effect > *std::prev(validEffectRange.end())) {
-        _hidl_cb(Status::UNSUPPORTED_OPERATION, 0);
-        return Void();
+    if (callback) {
+        status = ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
+    } else {
+        status = performEffect(effect, strength, _aidl_return);
     }
-    auto validStrengthRange = hidl_enum_range<EffectStrength>();
-    if (strength < *validStrengthRange.begin() || strength > *std::prev(validStrengthRange.end())) {
-        _hidl_cb(Status::UNSUPPORTED_OPERATION, 0);
-        return Void();
-    }
-    return performEffect(static_cast<Effect>(effect), strength, _hidl_cb);
+
+    return status;
 }
 
-Return<void> Vibrator::performEffect(Effect effect, EffectStrength strength, perform_cb _hidl_cb) {
-    Status status = Status::OK;
+ndk::ScopedAStatus Vibrator::performEffect(Effect effect, EffectStrength strength,
+                                           int32_t *outTimeMs) {
+    ndk::ScopedAStatus status;
     uint32_t timeMS;
     int8_t volOffset;
 
@@ -477,7 +564,7 @@
             volOffset = 1;
             break;
         default:
-            status = Status::UNSUPPORTED_OPERATION;
+            return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
             break;
     }
 
@@ -508,16 +595,53 @@
             volOffset += HEAVY_CLICK;
             break;
         default:
-            _hidl_cb(Status::UNSUPPORTED_OPERATION, 0);
-            return Void();
+            return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
     }
-    on(timeMS, WAVEFORM_MODE, mEffectConfig, volOffset);
-    _hidl_cb(status, timeMS);
-    return Void();
+    status = on(timeMS, WAVEFORM_MODE, mEffectConfig, volOffset);
+    if (!status.isOk()) {
+        return status;
+    }
+
+    *outTimeMs = timeMS;
+
+    return ndk::ScopedAStatus::ok();
 }
 
-}  // namespace implementation
-}  // namespace V1_3
+ndk::ScopedAStatus Vibrator::getSupportedAlwaysOnEffects(std::vector<Effect> * /*_aidl_return*/) {
+    return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
+}
+
+ndk::ScopedAStatus Vibrator::alwaysOnEnable(int32_t /*id*/, Effect /*effect*/,
+                                            EffectStrength /*strength*/) {
+    return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
+}
+ndk::ScopedAStatus Vibrator::alwaysOnDisable(int32_t /*id*/) {
+    return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
+}
+
+ndk::ScopedAStatus Vibrator::getCompositionDelayMax(int32_t * /*maxDelayMs*/) {
+    return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
+}
+
+ndk::ScopedAStatus Vibrator::getCompositionSizeMax(int32_t * /*maxSize*/) {
+    return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
+}
+
+ndk::ScopedAStatus Vibrator::getSupportedPrimitives(std::vector<CompositePrimitive> * /*supported*/) {
+    return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
+}
+
+ndk::ScopedAStatus Vibrator::getPrimitiveDuration(CompositePrimitive /*primitive*/,
+                                                  int32_t * /*durationMs*/) {
+    return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
+}
+
+ndk::ScopedAStatus Vibrator::compose(const std::vector<CompositeEffect> & /*composite*/,
+                                     const std::shared_ptr<IVibratorCallback> & /*callback*/) {
+    return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
+}
+
 }  // namespace vibrator
 }  // namespace hardware
 }  // namespace android
+}  // namespace aidl
diff --git a/vibrator/drv2624/Vibrator.h b/vibrator/drv2624/Vibrator.h
index 234b35d..969269d 100644
--- a/vibrator/drv2624/Vibrator.h
+++ b/vibrator/drv2624/Vibrator.h
@@ -13,21 +13,18 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#ifndef ANDROID_HARDWARE_VIBRATOR_V1_3_VIBRATOR_H
-#define ANDROID_HARDWARE_VIBRATOR_V1_3_VIBRATOR_H
+#pragma once
 
-#include <android/hardware/vibrator/1.3/IVibrator.h>
-#include <hidl/Status.h>
+#include <aidl/android/hardware/vibrator/BnVibrator.h>
 
 #include <fstream>
 
+namespace aidl {
 namespace android {
 namespace hardware {
 namespace vibrator {
-namespace V1_3 {
-namespace implementation {
 
-class Vibrator : public IVibrator {
+class Vibrator : public BnVibrator {
   public:
     // APIs for interfacing with the kernel driver.
     class HwApi {
@@ -156,35 +153,34 @@
   public:
     Vibrator(std::unique_ptr<HwApi> hwapi, std::unique_ptr<HwCal> hwcal);
 
-    // Methods from ::android::hardware::vibrator::V1_0::IVibrator follow.
-    using Status = ::android::hardware::vibrator::V1_0::Status;
-    Return<Status> on(uint32_t timeoutMs) override;
-    Return<Status> off() override;
-    Return<bool> supportsAmplitudeControl() override;
-    Return<Status> setAmplitude(uint8_t amplitude) override;
+    ndk::ScopedAStatus getCapabilities(int32_t *_aidl_return) override;
+    ndk::ScopedAStatus off() override;
+    ndk::ScopedAStatus on(int32_t timeoutMs,
+                          const std::shared_ptr<IVibratorCallback> &callback) override;
+    ndk::ScopedAStatus perform(Effect effect, EffectStrength strength,
+                               const std::shared_ptr<IVibratorCallback> &callback,
+                               int32_t *_aidl_return) override;
+    ndk::ScopedAStatus getSupportedEffects(std::vector<Effect> *_aidl_return) override;
+    ndk::ScopedAStatus setAmplitude(float amplitude) override;
+    ndk::ScopedAStatus setExternalControl(bool enabled) override;
+    ndk::ScopedAStatus getCompositionDelayMax(int32_t *maxDelayMs);
+    ndk::ScopedAStatus getCompositionSizeMax(int32_t *maxSize);
+    ndk::ScopedAStatus getSupportedPrimitives(std::vector<CompositePrimitive> *supported) override;
+    ndk::ScopedAStatus getPrimitiveDuration(CompositePrimitive primitive,
+                                            int32_t *durationMs) override;
+    ndk::ScopedAStatus compose(const std::vector<CompositeEffect> &composite,
+                               const std::shared_ptr<IVibratorCallback> &callback) override;
+    ndk::ScopedAStatus getSupportedAlwaysOnEffects(std::vector<Effect> *_aidl_return) override;
+    ndk::ScopedAStatus alwaysOnEnable(int32_t id, Effect effect, EffectStrength strength) override;
+    ndk::ScopedAStatus alwaysOnDisable(int32_t id) override;
 
-    // Methods from ::android::hardware::vibrator::V1_3::IVibrator follow.
-    Return<bool> supportsExternalControl() override;
-    Return<Status> setExternalControl(bool enabled) override;
-
-    using EffectStrength = ::android::hardware::vibrator::V1_0::EffectStrength;
-    Return<void> perform(V1_0::Effect effect, EffectStrength strength,
-                         perform_cb _hidl_cb) override;
-    Return<void> perform_1_1(V1_1::Effect_1_1 effect, EffectStrength strength,
-                             perform_cb _hidl_cb) override;
-    Return<void> perform_1_2(V1_2::Effect effect, EffectStrength strength,
-                             perform_cb _hidl_cb) override;
-    Return<void> perform_1_3(Effect effect, EffectStrength strength, perform_cb _hidl_cb) override;
-
-    // Methods from ::android.hidl.base::V1_0::IBase follow.
-    Return<void> debug(const hidl_handle &handle, const hidl_vec<hidl_string> &options) override;
+    binder_status_t dump(int fd, const char **args, uint32_t numArgs) override;
 
   private:
-    Return<Status> on(uint32_t timeoutMs, const char mode[],
-                      const std::unique_ptr<VibrationConfig> &config, const int8_t volOffset);
-    template <typename T>
-    Return<void> performWrapper(T effect, EffectStrength strength, perform_cb _hidl_cb);
-    Return<void> performEffect(Effect effect, EffectStrength strength, perform_cb _hidl_cb);
+    ndk::ScopedAStatus on(uint32_t timeoutMs, const char mode[],
+                          const std::unique_ptr<VibrationConfig> &config, const int8_t volOffset);
+    ndk::ScopedAStatus performEffect(Effect effect, EffectStrength strength, int32_t *outTimeMs);
+
     std::unique_ptr<HwApi> mHwApi;
     std::unique_ptr<HwCal> mHwCal;
     uint32_t mCloseLoopThreshold;
@@ -201,10 +197,7 @@
     bool mDynamicConfig;
 };
 
-}  // namespace implementation
-}  // namespace V1_3
 }  // namespace vibrator
 }  // namespace hardware
 }  // namespace android
-
-#endif  // ANDROID_HARDWARE_VIBRATOR_V1_3_VIBRATOR_H
+}  // namespace aidl
diff --git a/vibrator/drv2624/android.hardware.vibrator@1.3-service.redfin.rc b/vibrator/drv2624/android.hardware.vibrator-service.redfin.rc
similarity index 80%
rename from vibrator/drv2624/android.hardware.vibrator@1.3-service.redfin.rc
rename to vibrator/drv2624/android.hardware.vibrator-service.redfin.rc
index 02d6ea4..7fcea9b 100644
--- a/vibrator/drv2624/android.hardware.vibrator@1.3-service.redfin.rc
+++ b/vibrator/drv2624/android.hardware.vibrator-service.redfin.rc
@@ -1,4 +1,4 @@
-service vendor.vibrator-1-3 /vendor/bin/hw/android.hardware.vibrator@1.3-service.redfin
+service vendor.vibrator.redfin /vendor/bin/hw/android.hardware.vibrator-service.redfin
     class hal
     user system
     group system
diff --git a/vibrator/drv2624/android.hardware.vibrator-service.redfin.xml b/vibrator/drv2624/android.hardware.vibrator-service.redfin.xml
new file mode 100644
index 0000000..49b11ec
--- /dev/null
+++ b/vibrator/drv2624/android.hardware.vibrator-service.redfin.xml
@@ -0,0 +1,6 @@
+<manifest version="1.0" type="device">
+    <hal format="aidl">
+        <name>android.hardware.vibrator</name>
+        <fqname>IVibrator/default</fqname>
+    </hal>
+</manifest>
diff --git a/vibrator/drv2624/android.hardware.vibrator@1.3-service.redfin.xml b/vibrator/drv2624/android.hardware.vibrator@1.3-service.redfin.xml
deleted file mode 100644
index 172aa21..0000000
--- a/vibrator/drv2624/android.hardware.vibrator@1.3-service.redfin.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<manifest version="1.0" type="device">
-    <hal format="hidl">
-        <name>android.hardware.vibrator</name>
-        <transport>hwbinder</transport>
-        <version>1.3</version>
-        <interface>
-            <name>IVibrator</name>
-            <instance>default</instance>
-        </interface>
-    </hal>
-</manifest>
diff --git a/vibrator/drv2624/bench/Android.bp b/vibrator/drv2624/bench/Android.bp
index d7b63ef..0db978c 100644
--- a/vibrator/drv2624/bench/Android.bp
+++ b/vibrator/drv2624/bench/Android.bp
@@ -13,20 +13,3 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-cc_benchmark {
-    name: "VibratorHalDrv2624BenchmarkRedfin",
-    defaults: ["VibratorHalDrv2624TestDefaultsRedfin"],
-    srcs: [
-        "benchmark.cpp",
-    ],
-    static_libs: [
-        "libc++fs",
-    ],
-    shared_libs: [
-        "libbase",
-    ],
-    // TODO(b/135767253): Remove when fixed.
-    test_suites: ["device-tests"],
-    // TODO(b/142024316): Remove when fixed.
-    require_root: true,
-}
diff --git a/vibrator/drv2624/bench/benchmark.cpp b/vibrator/drv2624/bench/benchmark.cpp
index e63da43..61f7f47 100644
--- a/vibrator/drv2624/bench/benchmark.cpp
+++ b/vibrator/drv2624/bench/benchmark.cpp
@@ -21,18 +21,12 @@
 #include "Hardware.h"
 #include "Vibrator.h"
 
-using ::android::sp;
-using ::android::hardware::hidl_enum_range;
-
+namespace aidl {
 namespace android {
 namespace hardware {
 namespace vibrator {
-namespace V1_3 {
-namespace implementation {
 
 using ::android::base::SetProperty;
-using ::android::hardware::vibrator::V1_0::EffectStrength;
-using ::android::hardware::vibrator::V1_0::Status;
 
 class VibratorBench : public benchmark::Fixture {
   private:
@@ -71,7 +65,7 @@
 
         SetProperty(std::string() + PROPERTY_PREFIX + "config.dynamic", getDynamicConfig(state));
 
-        mVibrator = new Vibrator(HwApi::Create(), std::make_unique<HwCal>());
+        mVibrator = ndk::SharedRefBase::make<Vibrator>(HwApi::Create(), std::make_unique<HwCal>());
     }
 
     static void DefaultConfig(benchmark::internal::Benchmark *b) {
@@ -95,7 +89,7 @@
 
   protected:
     TemporaryDir mFilesDir;
-    sp<IVibrator> mVibrator;
+    std::shared_ptr<IVibrator> mVibrator;
 };
 
 #define BENCHMARK_WRAPPER(fixt, test, code)                           \
@@ -109,7 +103,7 @@
     uint32_t duration = std::rand() ?: 1;
 
     for (auto _ : state) {
-        mVibrator->on(duration);
+        mVibrator->on(duration, nullptr);
     }
 });
 
@@ -119,12 +113,6 @@
     }
 });
 
-BENCHMARK_WRAPPER(VibratorBench, supportsAmplitudeControl, {
-    for (auto _ : state) {
-        mVibrator->supportsAmplitudeControl();
-    }
-});
-
 BENCHMARK_WRAPPER(VibratorBench, setAmplitude, {
     uint8_t amplitude = std::rand() ?: 1;
 
@@ -133,12 +121,6 @@
     }
 });
 
-BENCHMARK_WRAPPER(VibratorBench, supportsExternalControl, {
-    for (auto _ : state) {
-        mVibrator->supportsExternalControl();
-    }
-});
-
 BENCHMARK_WRAPPER(VibratorBench, setExternalControl_enable, {
     for (auto _ : state) {
         mVibrator->setExternalControl(true);
@@ -151,13 +133,21 @@
     }
 });
 
+BENCHMARK_WRAPPER(VibratorBench, getCapabilities, {
+    int32_t capabilities;
+
+    for (auto _ : state) {
+        mVibrator->getCapabilities(&capabilities);
+    }
+});
+
 class VibratorEffectsBench : public VibratorBench {
   public:
     static void DefaultArgs(benchmark::internal::Benchmark *b) {
         b->ArgNames({"DynamicConfig", "Effect", "Strength"});
         for (const auto &dynamic : {false, true}) {
-            for (const auto &effect : hidl_enum_range<Effect>()) {
-                for (const auto &strength : hidl_enum_range<EffectStrength>()) {
+            for (const auto &effect : ndk::enum_range<Effect>()) {
+                for (const auto &strength : ndk::enum_range<EffectStrength>()) {
                     b->Args({dynamic, static_cast<long>(effect), static_cast<long>(strength)});
                 }
             }
@@ -174,30 +164,25 @@
     }
 };
 
-BENCHMARK_WRAPPER(VibratorEffectsBench, perform_1_3, {
+BENCHMARK_WRAPPER(VibratorEffectsBench, perform, {
     Effect effect = getEffect(state);
     EffectStrength strength = getStrength(state);
-    bool supported = true;
+    int32_t lengthMs;
 
-    mVibrator->perform_1_3(effect, strength, [&](Status status, uint32_t /*lengthMs*/) {
-        if (status == Status::UNSUPPORTED_OPERATION) {
-            supported = false;
-        }
-    });
+    ndk::ScopedAStatus status = mVibrator->perform(effect, strength, nullptr, &lengthMs);
 
-    if (!supported) {
+    if (status.getExceptionCode() == EX_UNSUPPORTED_OPERATION) {
         return;
     }
 
     for (auto _ : state) {
-        mVibrator->perform_1_3(effect, strength, [](Status /*status*/, uint32_t /*lengthMs*/) {});
+        mVibrator->perform(effect, strength, nullptr, &lengthMs);
     }
 });
 
-}  // namespace implementation
-}  // namespace V1_3
 }  // namespace vibrator
 }  // namespace hardware
 }  // namespace android
+}  // namespace aidl
 
 BENCHMARK_MAIN();
diff --git a/vibrator/drv2624/drv2624.bin b/vibrator/drv2624/drv2624.bin
index 7736404..b8c9317 100644
--- a/vibrator/drv2624/drv2624.bin
+++ b/vibrator/drv2624/drv2624.bin
Binary files differ
diff --git a/vibrator/drv2624/service.cpp b/vibrator/drv2624/service.cpp
index c0447a7..acc3b8f 100644
--- a/vibrator/drv2624/service.cpp
+++ b/vibrator/drv2624/service.cpp
@@ -13,45 +13,34 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
-#include <android/hardware/vibrator/1.3/IVibrator.h>
-#include <hidl/HidlSupport.h>
-#include <hidl/HidlTransportSupport.h>
-#include <utils/Errors.h>
-#include <utils/StrongPointer.h>
-
 #include "Hardware.h"
 #include "Vibrator.h"
 
-using android::OK;
-using android::sp;
-using android::status_t;
-using android::UNKNOWN_ERROR;
-using android::hardware::configureRpcThreadpool;
-using android::hardware::joinRpcThreadpool;
-using android::hardware::vibrator::V1_3::implementation::HwApi;
-using android::hardware::vibrator::V1_3::implementation::HwCal;
-using android::hardware::vibrator::V1_3::implementation::Vibrator;
+#include <android/binder_manager.h>
+#include <android/binder_process.h>
+#include <log/log.h>
 
-status_t registerVibratorService() {
+using aidl::android::hardware::vibrator::HwApi;
+using aidl::android::hardware::vibrator::HwCal;
+using aidl::android::hardware::vibrator::Vibrator;
+
+int main() {
     auto hwapi = HwApi::Create();
 
     if (!hwapi) {
-        return UNKNOWN_ERROR;
+        return EXIT_FAILURE;
     }
 
-    sp<Vibrator> vibrator = new Vibrator(std::move(hwapi), std::make_unique<HwCal>());
+    // One thread for vibrator APIs and one for sensor callback
+    // WARN: there could be an issue if two vibrator APIs are called simultaneously
+    ABinderProcess_setThreadPoolMaxThreadCount(1);
+    std::shared_ptr<Vibrator> vib =
+        ndk::SharedRefBase::make<Vibrator>(std::move(hwapi), std::make_unique<HwCal>());
 
-    return vibrator->registerAsService();
-}
+    const std::string instance = std::string() + Vibrator::descriptor + "/default";
+    binder_status_t status = AServiceManager_addService(vib->asBinder().get(), instance.c_str());
+    LOG_ALWAYS_FATAL_IF(status != STATUS_OK);
 
-int main() {
-    configureRpcThreadpool(1, true);
-    status_t status = registerVibratorService();
-
-    if (status != OK) {
-        return status;
-    }
-
-    joinRpcThreadpool();
+    ABinderProcess_joinThreadPool();
+    return EXIT_FAILURE;  // should not reach
 }
diff --git a/vibrator/drv2624/tests/Android.bp b/vibrator/drv2624/tests/Android.bp
index 2adfc84..0db978c 100644
--- a/vibrator/drv2624/tests/Android.bp
+++ b/vibrator/drv2624/tests/Android.bp
@@ -13,19 +13,3 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-cc_test {
-    name: "VibratorHalDrv2624TestSuiteRedfin",
-    defaults: ["VibratorHalDrv2624TestDefaultsRedfin"],
-    srcs: [
-        "test-hwapi.cpp",
-        "test-hwcal.cpp",
-        "test-vibrator.cpp",
-    ],
-    static_libs: [
-        "libc++fs",
-        "libgmock",
-    ],
-    shared_libs: [
-        "libbase",
-    ],
-}
diff --git a/vibrator/drv2624/tests/mocks.h b/vibrator/drv2624/tests/mocks.h
index 07b54e2..e3b0229 100644
--- a/vibrator/drv2624/tests/mocks.h
+++ b/vibrator/drv2624/tests/mocks.h
@@ -18,7 +18,7 @@
 
 #include "Vibrator.h"
 
-class MockApi : public ::android::hardware::vibrator::V1_3::implementation::Vibrator::HwApi {
+class MockApi : public ::aidl::android::hardware::vibrator::Vibrator::HwApi {
   public:
     MOCK_METHOD0(destructor, void());
     MOCK_METHOD1(setAutocal, bool(std::string value));
@@ -41,7 +41,7 @@
     ~MockApi() override { destructor(); };
 };
 
-class MockCal : public ::android::hardware::vibrator::V1_3::implementation::Vibrator::HwCal {
+class MockCal : public ::aidl::android::hardware::vibrator::Vibrator::HwCal {
   public:
     MOCK_METHOD0(destructor, void());
     MOCK_METHOD1(getAutocal, bool(std::string &value));  // NOLINT
diff --git a/vibrator/drv2624/tests/test-hwapi.cpp b/vibrator/drv2624/tests/test-hwapi.cpp
index fc57f85..6065676 100644
--- a/vibrator/drv2624/tests/test-hwapi.cpp
+++ b/vibrator/drv2624/tests/test-hwapi.cpp
@@ -23,11 +23,10 @@
 
 #include "Hardware.h"
 
+namespace aidl {
 namespace android {
 namespace hardware {
 namespace vibrator {
-namespace V1_3 {
-namespace implementation {
 
 using ::testing::Test;
 using ::testing::TestParamInfo;
@@ -394,8 +393,7 @@
     }),
     SetStringTest::PrintParam);
 
-}  // namespace implementation
-}  // namespace V1_3
 }  // namespace vibrator
 }  // namespace hardware
 }  // namespace android
+}  // namespace aidl
diff --git a/vibrator/drv2624/tests/test-hwcal.cpp b/vibrator/drv2624/tests/test-hwcal.cpp
index b95f943..50fe373 100644
--- a/vibrator/drv2624/tests/test-hwcal.cpp
+++ b/vibrator/drv2624/tests/test-hwcal.cpp
@@ -22,11 +22,10 @@
 
 #include "Hardware.h"
 
+namespace aidl {
 namespace android {
 namespace hardware {
 namespace vibrator {
-namespace V1_3 {
-namespace implementation {
 
 using ::android::base::SetProperty;
 using ::android::base::WaitForProperty;
@@ -389,8 +388,7 @@
     EXPECT_EQ(lraPeriodExpect, lraPeriodActual);
 }
 
-}  // namespace implementation
-}  // namespace V1_3
 }  // namespace vibrator
 }  // namespace hardware
 }  // namespace android
+}  // namespace aidl
diff --git a/vibrator/drv2624/tests/test-vibrator.cpp b/vibrator/drv2624/tests/test-vibrator.cpp
index 47bdfad..d41ed52 100644
--- a/vibrator/drv2624/tests/test-vibrator.cpp
+++ b/vibrator/drv2624/tests/test-vibrator.cpp
@@ -23,14 +23,10 @@
 #include "types.h"
 #include "utils.h"
 
+namespace aidl {
 namespace android {
 namespace hardware {
 namespace vibrator {
-namespace V1_3 {
-namespace implementation {
-
-using ::android::hardware::vibrator::V1_0::EffectStrength;
-using ::android::hardware::vibrator::V1_0::Status;
 
 using ::testing::_;
 using ::testing::AnyNumber;
@@ -181,7 +177,7 @@
         if (relaxed) {
             relaxMock(true);
         }
-        mVibrator = new Vibrator(std::move(mockapi), std::move(mockcal));
+        mVibrator = ndk::SharedRefBase::make<Vibrator>(std::move(mockapi), std::move(mockcal));
         if (relaxed) {
             relaxMock(false);
         }
@@ -191,7 +187,7 @@
         if (relaxed) {
             relaxMock(true);
         }
-        mVibrator.clear();
+        mVibrator.reset();
     }
 
     void relaxMock(bool relax) {
@@ -235,7 +231,7 @@
   protected:
     MockApi *mMockApi;
     MockCal *mMockCal;
-    sp<IVibrator> mVibrator;
+    std::shared_ptr<IVibrator> mVibrator;
 
     EffectDuration mCloseLoopThreshold;
     uint32_t mLongFrequencyShift;
@@ -310,7 +306,7 @@
 
     EXPECT_CALL(*mMockApi, setActivate(true)).After(e).WillOnce(DoDefault());
 
-    EXPECT_EQ(Status::OK, mVibrator->on(duration));
+    EXPECT_EQ(EX_NONE, mVibrator->on(duration, nullptr).getExceptionCode());
 }
 
 TEST_P(BasicTest, on_openLoop) {
@@ -320,7 +316,7 @@
 
     EXPECT_CALL(*mMockApi, setCtrlLoop(true)).WillOnce(DoDefault());
 
-    EXPECT_EQ(Status::OK, mVibrator->on(duration));
+    EXPECT_EQ(EX_NONE, mVibrator->on(duration, nullptr).getExceptionCode());
 }
 
 TEST_P(BasicTest, on_closeLoop) {
@@ -330,45 +326,53 @@
 
     EXPECT_CALL(*mMockApi, setCtrlLoop(false)).WillOnce(DoDefault());
 
-    EXPECT_EQ(Status::OK, mVibrator->on(duration));
+    EXPECT_EQ(EX_NONE, mVibrator->on(duration, nullptr).getExceptionCode());
 }
 
 TEST_P(BasicTest, off) {
     EXPECT_CALL(*mMockApi, setActivate(false)).WillOnce(DoDefault());
 
-    EXPECT_EQ(Status::OK, mVibrator->off());
+    EXPECT_EQ(EX_NONE, mVibrator->off().getExceptionCode());
 }
 
 TEST_P(BasicTest, supportsAmplitudeControl_supported) {
     EXPECT_CALL(*mMockApi, hasRtpInput()).WillOnce(Return(true));
 
-    EXPECT_EQ(true, mVibrator->supportsAmplitudeControl());
+    int32_t capabilities;
+    EXPECT_TRUE(mVibrator->getCapabilities(&capabilities).isOk());
+    EXPECT_GT(capabilities & IVibrator::CAP_AMPLITUDE_CONTROL, 0);
 }
 
 TEST_P(BasicTest, supportsAmplitudeControl_unsupported) {
     EXPECT_CALL(*mMockApi, hasRtpInput()).WillOnce(Return(false));
 
-    EXPECT_EQ(false, mVibrator->supportsAmplitudeControl());
+    int32_t capabilities;
+    EXPECT_TRUE(mVibrator->getCapabilities(&capabilities).isOk());
+    EXPECT_EQ(capabilities & IVibrator::CAP_AMPLITUDE_CONTROL, 0);
 }
 
 TEST_P(BasicTest, setAmplitude) {
-    EffectAmplitude amplitude = std::rand();
+    EffectAmplitude amplitude = static_cast<float>(std::rand()) / RAND_MAX ?: 1.0f;
 
     EXPECT_CALL(*mMockApi, setRtpInput(amplitudeToRtpInput(amplitude))).WillOnce(Return(true));
 
-    EXPECT_EQ(Status::OK, mVibrator->setAmplitude(amplitude));
+    EXPECT_EQ(EX_NONE, mVibrator->setAmplitude(amplitude).getExceptionCode());
 }
 
 TEST_P(BasicTest, supportsExternalControl_unsupported) {
-    EXPECT_EQ(false, mVibrator->supportsExternalControl());
+    EXPECT_CALL(*mMockApi, hasRtpInput()).WillOnce(Return(false));
+
+    int32_t capabilities;
+    EXPECT_TRUE(mVibrator->getCapabilities(&capabilities).isOk());
+    EXPECT_EQ(capabilities & IVibrator::CAP_EXTERNAL_CONTROL, 0);
 }
 
 TEST_P(BasicTest, setExternalControl_enable) {
-    EXPECT_EQ(Status::UNSUPPORTED_OPERATION, mVibrator->setExternalControl(true));
+    EXPECT_EQ(EX_UNSUPPORTED_OPERATION, mVibrator->setExternalControl(true).getExceptionCode());
 }
 
 TEST_P(BasicTest, setExternalControl_disable) {
-    EXPECT_EQ(Status::UNSUPPORTED_OPERATION, mVibrator->setExternalControl(false));
+    EXPECT_EQ(EX_UNSUPPORTED_OPERATION, mVibrator->setExternalControl(false).getExceptionCode());
 }
 
 INSTANTIATE_TEST_CASE_P(VibratorTests, BasicTest,
@@ -423,27 +427,25 @@
         duration = 0;
     }
 
-    mVibrator->perform_1_3(effect, strength, [&](Status status, uint32_t lengthMs) {
-        if (duration) {
-            EXPECT_EQ(Status::OK, status);
-            EXPECT_LE(duration, lengthMs);
-        } else {
-            EXPECT_EQ(Status::UNSUPPORTED_OPERATION, status);
-            EXPECT_EQ(0, lengthMs);
-        }
-    });
+    int32_t lengthMs;
+    ndk::ScopedAStatus status = mVibrator->perform(effect, strength, nullptr, &lengthMs);
+    if (duration) {
+        EXPECT_EQ(EX_NONE, status.getExceptionCode());
+        EXPECT_LE(duration, lengthMs);
+    } else {
+        EXPECT_EQ(EX_UNSUPPORTED_OPERATION, status.getExceptionCode());
+    }
 }
 
 INSTANTIATE_TEST_CASE_P(VibratorTests, EffectsTest,
                         Combine(ValuesIn({false, true}),
-                                Combine(ValuesIn(hidl_enum_range<Effect>().begin(),
-                                                 hidl_enum_range<Effect>().end()),
-                                        ValuesIn(hidl_enum_range<EffectStrength>().begin(),
-                                                 hidl_enum_range<EffectStrength>().end()))),
+                                Combine(ValuesIn(ndk::enum_range<Effect>().begin(),
+                                                 ndk::enum_range<Effect>().end()),
+                                        ValuesIn(ndk::enum_range<EffectStrength>().begin(),
+                                                 ndk::enum_range<EffectStrength>().end()))),
                         EffectsTest::PrintParam);
 
-}  // namespace implementation
-}  // namespace V1_3
 }  // namespace vibrator
 }  // namespace hardware
 }  // namespace android
+}  // namespace aidl
diff --git a/vibrator/drv2624/tests/types.h b/vibrator/drv2624/tests/types.h
index 60be69c..6ff21a6 100644
--- a/vibrator/drv2624/tests/types.h
+++ b/vibrator/drv2624/tests/types.h
@@ -16,12 +16,12 @@
 #ifndef ANDROID_HARDWARE_VIBRATOR_TEST_TYPES_H
 #define ANDROID_HARDWARE_VIBRATOR_TEST_TYPES_H
 
-#include <android/hardware/vibrator/1.3/IVibrator.h>
+#include <aidl/android/hardware/vibrator/IVibrator.h>
 
-using EffectAmplitude = uint8_t;
+using EffectAmplitude = float;
 using EffectDuration = uint32_t;
 using EffectSequence = std::tuple<std::string, uint8_t>;
-using EffectTuple = std::tuple<::android::hardware::vibrator::V1_3::Effect,
-                               ::android::hardware::vibrator::V1_0::EffectStrength>;
+using EffectTuple = std::tuple<::aidl::android::hardware::vibrator::Effect,
+                               ::aidl::android::hardware::vibrator::EffectStrength>;
 
 #endif  // ANDROID_HARDWARE_VIBRATOR_TEST_TYPES_H
diff --git a/vibrator/drv2624/tests/utils.h b/vibrator/drv2624/tests/utils.h
index 5fe4b62..766ac5c 100644
--- a/vibrator/drv2624/tests/utils.h
+++ b/vibrator/drv2624/tests/utils.h
@@ -21,7 +21,7 @@
 #include "types.h"
 
 static inline int32_t amplitudeToRtpInput(EffectAmplitude amplitude) {
-    return std::round((amplitude - 1) / 254.0 * 127);
+    return std::round(amplitude * 127);
 }
 
 #endif  // ANDROID_HARDWARE_VIBRATOR_TEST_UTILS_H