diff --git a/audio/felix/config/mixer_paths.xml b/audio/felix/config/mixer_paths.xml
index d804dc1..0ca9108 100644
--- a/audio/felix/config/mixer_paths.xml
+++ b/audio/felix/config/mixer_paths.xml
@@ -44,9 +44,9 @@
-
-
-
+
+
+
diff --git a/vibrator/Android.bp b/vibrator/Android.bp
new file mode 100644
index 0000000..5d6d481
--- /dev/null
+++ b/vibrator/Android.bp
@@ -0,0 +1,52 @@
+//
+// 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.
+
+package {
+ default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+cc_defaults {
+ name: "PixelVibratorDefaultsPrivate",
+ relative_install_path: "hw",
+ static_libs: [
+ "PixelVibratorCommonPrivate",
+ ],
+ shared_libs: [
+ "libbase",
+ "libbinder_ndk",
+ "libcutils",
+ "libhardware",
+ "liblog",
+ "libutils",
+ ],
+}
+
+cc_defaults {
+ name: "PixelVibratorBinaryDefaultsPrivate",
+ defaults: ["PixelVibratorDefaultsPrivate"],
+ shared_libs: [
+ "android.hardware.vibrator-V2-ndk",
+ ],
+}
+
+cc_defaults {
+ name: "PixelVibratorTestDefaultsPrivate",
+ defaults: ["PixelVibratorDefaultsPrivate"],
+ static_libs: [
+ "android.hardware.vibrator-V2-ndk",
+ ],
+ test_suites: ["device-tests"],
+ require_root: true,
+}
diff --git a/vibrator/OWNERS b/vibrator/OWNERS
new file mode 100644
index 0000000..5d4a9c3
--- /dev/null
+++ b/vibrator/OWNERS
@@ -0,0 +1,3 @@
+chasewu@google.com
+michaelwr@google.com
+taikuo@google.com
diff --git a/vibrator/common/Android.bp b/vibrator/common/Android.bp
new file mode 100644
index 0000000..c80f07c
--- /dev/null
+++ b/vibrator/common/Android.bp
@@ -0,0 +1,37 @@
+//
+// 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.
+
+package {
+ default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+cc_library {
+ name: "PixelVibratorCommonPrivate",
+ 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
new file mode 100644
index 0000000..8e07e99
--- /dev/null
+++ b/vibrator/common/HardwareBase.cpp
@@ -0,0 +1,136 @@
+/*
+ * 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
+#include
+
+#include
+#include
+
+#include "utils.h"
+
+namespace aidl {
+namespace android {
+namespace hardware {
+namespace vibrator {
+
+HwApiBase::HwApiBase() {
+ mPathPrefix = std::getenv("HWAPI_PATH_PREFIX") ?: "";
+ if (mPathPrefix.empty()) {
+ ALOGE("Failed get HWAPI path prefix!");
+ }
+}
+
+void HwApiBase::saveName(const std::string &name, const std::ios *stream) {
+ mNames[stream] = name;
+}
+
+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(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 vibrator
+} // namespace hardware
+} // namespace android
+} // namespace aidl
diff --git a/vibrator/common/HardwareBase.h b/vibrator/common/HardwareBase.h
new file mode 100644
index 0000000..448d29c
--- /dev/null
+++ b/vibrator/common/HardwareBase.h
@@ -0,0 +1,221 @@
+/*
+ * 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.
+ */
+#pragma once
+
+#include
+#include
+#include
+#include
+
+#include
+#include