From 83e3f55b3873a52d56c15f45e01bd51b114a8709 Mon Sep 17 00:00:00 2001 From: Stricted Date: Mon, 3 Feb 2020 20:47:51 +0000 Subject: [PATCH] universal8895: move vibrator hal to hardware/samsung Change-Id: Ia481ec90ba1a60ec9b1ce45a50b7cc39f354c800 --- device-common.mk | 2 +- hidl/vibrator/Android.mk | 40 ------ hidl/vibrator/Vibrator.cpp | 119 ------------------ hidl/vibrator/Vibrator.h | 55 -------- ...ware.vibrator@1.0-service.universal8895.rc | 4 - hidl/vibrator/service.cpp | 61 --------- 6 files changed, 1 insertion(+), 280 deletions(-) delete mode 100644 hidl/vibrator/Android.mk delete mode 100644 hidl/vibrator/Vibrator.cpp delete mode 100644 hidl/vibrator/Vibrator.h delete mode 100644 hidl/vibrator/android.hardware.vibrator@1.0-service.universal8895.rc delete mode 100644 hidl/vibrator/service.cpp diff --git a/device-common.mk b/device-common.mk index 8612abf..453b61d 100644 --- a/device-common.mk +++ b/device-common.mk @@ -286,7 +286,7 @@ PRODUCT_PROPERTY_OVERRIDES += \ # Vibrator PRODUCT_PACKAGES += \ - android.hardware.vibrator@1.0-service.universal8895 + android.hardware.vibrator@1.0-service.samsung-haptic # Wifi PRODUCT_PACKAGES += \ diff --git a/hidl/vibrator/Android.mk b/hidl/vibrator/Android.mk deleted file mode 100644 index b497326..0000000 --- a/hidl/vibrator/Android.mk +++ /dev/null @@ -1,40 +0,0 @@ -# -# Copyright (C) 2019 The LineageOS 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. -# - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE_RELATIVE_PATH := hw -LOCAL_MODULE_TAGS := optional -LOCAL_VENDOR_MODULE := true - -LOCAL_MODULE := android.hardware.vibrator@1.0-service.universal8895 -LOCAL_INIT_RC := android.hardware.vibrator@1.0-service.universal8895.rc -LOCAL_SRC_FILES := service.cpp \ - Vibrator.cpp - -LOCAL_SHARED_LIBRARIES := \ - libbase \ - liblog \ - libdl \ - libhidlbase \ - libhidltransport \ - libhardware \ - libutils \ - android.hardware.vibrator@1.0 - -include $(BUILD_EXECUTABLE) diff --git a/hidl/vibrator/Vibrator.cpp b/hidl/vibrator/Vibrator.cpp deleted file mode 100644 index dbc2175..0000000 --- a/hidl/vibrator/Vibrator.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (C) 2019 The LineageOS Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define LOG_TAG "android.hardware.vibrator@1.0-service.universal8895" - -#include - -#include -#include - -#include "Vibrator.h" - -#include -#include -#include -#include - -namespace android { -namespace hardware { -namespace vibrator { -namespace V1_0 { -namespace implementation { - -/* - * Write value to path and close file. - */ -template -static void set(const std::string& path, const T& value) { - std::ofstream file(path); - file << value << std::endl; -} - -Vibrator::Vibrator() { - mIntensity = 10000; -} - -// SEC Haptic Engine -Return Vibrator::doHaptic(int timeout, int intensity, int freq, int overdrive) { - char haptic[32]; - snprintf(haptic, sizeof(haptic) - 1, "4 %d %d %d %d", timeout, intensity, freq, overdrive); - set("/sys/class/timed_output/vibrator/haptic_engine", haptic); - set("/sys/class/timed_output/vibrator/enable", 1); - - return Status::OK; -} - -// Methods from ::android::hardware::vibrator::V1_0::IVibrator follow. -Return Vibrator::on(uint32_t timeout_ms) { - return doHaptic(timeout_ms, mIntensity, 0, 0); -} - -Return Vibrator::off() { - set("/sys/class/timed_output/vibrator/enable", 0); - return Status::OK; -} - -Return Vibrator::supportsAmplitudeControl() { - return true; -} - -Return Vibrator::setAmplitude(uint8_t amplitude) { - if (amplitude == 0) { - return Status::BAD_VALUE; - } - mIntensity = amplitude * 10000 / 255; - return Status::OK; -} - -Return Vibrator::perform(Effect effect, EffectStrength strength, perform_cb _hidl_cb) { - Status status = Status::OK; - uint32_t timeMS; - uint32_t intensity; - - switch (strength) { - case EffectStrength::LIGHT: - intensity = 1000; - break; - case EffectStrength::STRONG: - intensity = 5000; - break; - default: - intensity = 3000; - break; - } - - switch (effect) { - case Effect::CLICK: - case Effect::DOUBLE_CLICK: - status = doHaptic(7, intensity, 2000, 1); - timeMS = 7; - break; - default: - status = Status::UNSUPPORTED_OPERATION; - timeMS = 0; - break; - } - - _hidl_cb(status, timeMS); - return Void(); -} - -} // namespace implementation -} // namespace V1_0 -} // namespace vibrator -} // namespace hardware -} // namespace android diff --git a/hidl/vibrator/Vibrator.h b/hidl/vibrator/Vibrator.h deleted file mode 100644 index 25950e2..0000000 --- a/hidl/vibrator/Vibrator.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2019 The LineageOS 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_V1_0_VIBRATOR_H -#define ANDROID_HARDWARE_VIBRATOR_V1_0_VIBRATOR_H - -#include -#include - -#include - -namespace android { -namespace hardware { -namespace vibrator { -namespace V1_0 { -namespace implementation { - -class Vibrator : public IVibrator { -public: - Vibrator(); - - // Methods from ::android::hardware::vibrator::V1_0::IVibrator follow. - Return on(uint32_t timeoutMs) override; - Return off() override; - Return supportsAmplitudeControl() override; - Return setAmplitude(uint8_t) override; - Return perform(Effect effect, EffectStrength strength, perform_cb _hidl_cb) override; - -private: - Return doHaptic(int timeout, int intensity, int freq, int overdrive); - std::ofstream mEnable; - std::ofstream mHaptic; - uint32_t mIntensity; -}; - -} // namespace implementation -} // namespace V1_0 -} // namespace vibrator -} // namespace hardware -} // namespace android - -#endif // ANDROID_HARDWARE_VIBRATOR_V1_0_VIBRATOR_H diff --git a/hidl/vibrator/android.hardware.vibrator@1.0-service.universal8895.rc b/hidl/vibrator/android.hardware.vibrator@1.0-service.universal8895.rc deleted file mode 100644 index 7281e2b..0000000 --- a/hidl/vibrator/android.hardware.vibrator@1.0-service.universal8895.rc +++ /dev/null @@ -1,4 +0,0 @@ -service vendor.vibrator-1-0 /vendor/bin/hw/android.hardware.vibrator@1.0-service.universal8895 - class hal - user system - group system diff --git a/hidl/vibrator/service.cpp b/hidl/vibrator/service.cpp deleted file mode 100644 index 186ce31..0000000 --- a/hidl/vibrator/service.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2019 The LineageOS Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define LOG_TAG "android.hardware.vibrator@1.0-service.universal8895" - -#include -#include -#include -#include -#include -#include - -#include "Vibrator.h" - -using android::hardware::configureRpcThreadpool; -using android::hardware::joinRpcThreadpool; -using android::hardware::vibrator::V1_0::IVibrator; -using android::hardware::vibrator::V1_0::implementation::Vibrator; -using namespace android; - -int main() { - status_t status; - sp vibrator; - - LOG(INFO) << "Light HAL service is starting."; - - vibrator = new Vibrator(); - if (vibrator == nullptr) { - LOG(ERROR) << "Can not create an instance of Vibrator HAL IVibrator, exiting."; - goto shutdown; - } - - configureRpcThreadpool(1, true); - - status = vibrator->registerAsService(); - if (status != OK) { - LOG(ERROR) << "Could not register service for Vibrator HAL"; - goto shutdown; - } - - LOG(INFO) << "Vibrator HAL service is Ready."; - joinRpcThreadpool(); - -shutdown: - // In normal operation, we don't expect the thread pool to shutdown - LOG(ERROR) << "Vibrator HAL failed to join thread pool."; - return 1; -} -- 2.20.1