diff options
author | qctecmdr <qctecmdr@localhost> | 2020-09-14 22:10:08 -0700 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2020-09-14 22:10:08 -0700 |
commit | 7a587394f34079d54d39ba301eabfa52be26823f (patch) | |
tree | 780427692e862410de19d62ef3fa26f63fd11ced | |
parent | 835d4bad3f67ba364029c38b078cf271c1f9e11f (diff) | |
parent | dba338467f6403ead26ed0f4dc81ccdad7748eb3 (diff) |
Merge "vibrator: Remove unused HAL implementations"
-rw-r--r-- | 1.2/Android.bp | 46 | ||||
-rw-r--r-- | 1.2/Vibrator.cpp | 361 | ||||
-rw-r--r-- | 1.2/Vibrator_1_2.h | 82 | ||||
-rw-r--r-- | 1.2/service.cpp | 55 | ||||
-rw-r--r-- | 1.2/vendor.qti.hardware.vibrator@1.2-service.rc | 4 | ||||
-rw-r--r-- | 1.2/vendor.qti.hardware.vibrator@1.2-service.xml | 38 | ||||
-rw-r--r-- | 1.3/Android.bp | 29 | ||||
-rw-r--r-- | 1.3/Vibrator.cpp | 153 | ||||
-rw-r--r-- | 1.3/Vibrator_1_3.h | 70 | ||||
-rw-r--r-- | 1.3/service.cpp | 55 | ||||
-rw-r--r-- | 1.3/vendor.qti.hardware.vibrator@1.3-service.rc | 4 | ||||
-rw-r--r-- | 1.3/vendor.qti.hardware.vibrator@1.3-service.xml | 38 | ||||
-rw-r--r-- | qmaa/Android.bp | 22 | ||||
-rw-r--r-- | qmaa/Vibrator_qmaa.h | 76 | ||||
-rw-r--r-- | qmaa/service_qmaa.cpp | 142 | ||||
-rw-r--r-- | qmaa/vendor.qti.hardware.vibrator@1.2-service.rc | 4 |
16 files changed, 0 insertions, 1179 deletions
diff --git a/1.2/Android.bp b/1.2/Android.bp deleted file mode 100644 index 134bb55..0000000 --- a/1.2/Android.bp +++ /dev/null @@ -1,46 +0,0 @@ -Common_CFlags = ["-Wall"] -Common_CFlags += ["-Werror"] - -cc_library_shared { - name: "vendor.qti.hardware.vibrator@1.2-impl", - vendor: true, - cflags: Common_CFlags, - srcs: [ - "Vibrator.cpp", - ], - shared_libs: [ - "libcutils", - "liblog", - "libutils", - "libhardware", - "libhidlbase", - "libqtivibratoreffect", - "android.hardware.vibrator@1.0", - "android.hardware.vibrator@1.1", - "android.hardware.vibrator@1.2", - ], - export_include_dirs: ["."] -} - -cc_binary { - name: "vendor.qti.hardware.vibrator@1.2-service", - vendor: true, - relative_install_path: "hw", - init_rc: ["vendor.qti.hardware.vibrator@1.2-service.rc"], - cflags: Common_CFlags, - srcs: [ - "service.cpp", - ], - shared_libs: [ - "libcutils", - "liblog", - "libutils", - "libhardware", - "libhidlbase", - "android.hardware.vibrator@1.2", - "vendor.qti.hardware.vibrator@1.2-impl", - ], - vintf_fragments: [ - "vendor.qti.hardware.vibrator@1.2-service.xml", - ], -} diff --git a/1.2/Vibrator.cpp b/1.2/Vibrator.cpp deleted file mode 100644 index faff619..0000000 --- a/1.2/Vibrator.cpp +++ /dev/null @@ -1,361 +0,0 @@ -/* - * Copyright (c) 2018-2020, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#define LOG_TAG "vendor.qti.vibrator@1.2-impl" - -#include <hardware/hardware.h> -#include <hardware/vibrator.h> -#include <dirent.h> -#include <inttypes.h> -#include <linux/input.h> -#include <log/log.h> -#include <string.h> -#include <sys/ioctl.h> - -#include "Vibrator_1_2.h" -#ifdef USE_EFFECT_STREAM -#include "effect.h" -#endif - -namespace android { -namespace hardware { -namespace vibrator { -namespace V1_2 { -namespace implementation { - -using Status = ::android::hardware::vibrator::V1_0::Status; -using EffectStrength = ::android::hardware::vibrator::V1_0::EffectStrength; - -#define STRONG_MAGNITUDE 0x7fff -#define MEDIUM_MAGNITUDE 0x5fff -#define LIGHT_MAGNITUDE 0x3fff -#define INVALID_VALUE -1 - -#define test_bit(bit, array) ((array)[(bit)/8] & (1<<((bit)%8))) - -InputFFDevice::InputFFDevice() -{ - DIR *dp; - struct dirent *dir; - uint8_t ffBitmask[FF_CNT / 8]; - char devicename[PATH_MAX]; - const char *INPUT_DIR = "/dev/input/"; - int fd, ret; - - mVibraFd = INVALID_VALUE; - mSupportGain = false; - mSupportEffects = false; - mCurrAppId = INVALID_VALUE; - mCurrMagnitude = 0x7fff; - - dp = opendir(INPUT_DIR); - if (!dp) { - ALOGE("open %s failed, errno = %d", INPUT_DIR, errno); - return; - } - - memset(ffBitmask, 0, sizeof(ffBitmask)); - while ((dir = readdir(dp)) != NULL){ - if (dir->d_name[0] == '.' && - (dir->d_name[1] == '\0' || - (dir->d_name[1] == '.' && dir->d_name[2] == '\0'))) - continue; - - snprintf(devicename, PATH_MAX, "%s%s", INPUT_DIR, dir->d_name); - fd = TEMP_FAILURE_RETRY(open(devicename, O_RDWR)); - if (fd < 0) { - ALOGE("open %s failed, errno = %d", devicename, errno); - continue; - } - - ret = TEMP_FAILURE_RETRY(ioctl(fd, EVIOCGBIT(EV_FF, sizeof(ffBitmask)), ffBitmask)); - if (ret == -1) { - ALOGE("ioctl failed, errno = %d", errno); - close(fd); - continue; - } - - if (test_bit(FF_CONSTANT, ffBitmask) || - test_bit(FF_PERIODIC, ffBitmask)) { - mVibraFd = fd; - if (test_bit(FF_CUSTOM, ffBitmask)) - mSupportEffects = true; - if (test_bit(FF_GAIN, ffBitmask)) - mSupportGain = true; - break; - } - - close(fd); - } - - closedir(dp); -} - -/** Play vibration - * - * @param effectId: ID of the predefined effect will be played. If effectId is valid - * (non-negative value), the timeoutMs value will be ignored, and the - * real playing length will be set in param@playLengtMs and returned - * to VibratorService. If effectId is invalid, value in param@timeoutMs - * will be used as the play length for playing a constant effect. - * @param timeoutMs: playing length, non-zero means playing, zero means stop playing. - * @param playLengthMs: the playing length in ms unit which will be returned to - * VibratorService if the request is playing a predefined effect. - * The custom_data in periodic is reused for returning the playLengthMs - * from kernel space to userspace if the pattern is defined in kernel - * driver. It's been defined with following format: - * <effect-ID, play-time-in-seconds, play-time-in-milliseconds>. - * The effect-ID is used for passing down the predefined effect to - * kernel driver, and the rest two parameters are used for returning - * back the real playing length from kernel driver. - */ -Return<Status> InputFFDevice::play(int effectId, uint32_t timeoutMs, long *playLengthMs) { - struct ff_effect effect; - struct input_event play; - #define CUSTOM_DATA_LEN 3 - int16_t data[CUSTOM_DATA_LEN] = {0, 0, 0}; - int ret; -#ifdef USE_EFFECT_STREAM - const struct effect_stream *stream; -#endif - - /* For QMAA compliance, return OK even if vibrator device doesn't exist */ - if (mVibraFd == INVALID_VALUE) { - if (playLengthMs != NULL) - *playLengthMs = 0; - return Status::OK; - } - - if (timeoutMs != 0) { - if (mCurrAppId != INVALID_VALUE) { - ret = TEMP_FAILURE_RETRY(ioctl(mVibraFd, EVIOCRMFF, mCurrAppId)); - if (ret == -1) { - ALOGE("ioctl EVIOCRMFF failed, errno = %d", -errno); - goto errout; - } - mCurrAppId = INVALID_VALUE; - } - - memset(&effect, 0, sizeof(effect)); - if (effectId != INVALID_VALUE) { - data[0] = effectId; - effect.type = FF_PERIODIC; - effect.u.periodic.waveform = FF_CUSTOM; - effect.u.periodic.magnitude = mCurrMagnitude; - effect.u.periodic.custom_data = data; - effect.u.periodic.custom_len = sizeof(int16_t) * CUSTOM_DATA_LEN; -#ifdef USE_EFFECT_STREAM - stream = get_effect_stream(effectId); - if (stream != NULL) { - effect.u.periodic.custom_data = (int16_t *)stream; - effect.u.periodic.custom_len = sizeof(*stream); - } -#endif - } else { - effect.type = FF_CONSTANT; - effect.u.constant.level = mCurrMagnitude; - effect.replay.length = timeoutMs; - } - - effect.id = mCurrAppId; - effect.replay.delay = 0; - - ret = TEMP_FAILURE_RETRY(ioctl(mVibraFd, EVIOCSFF, &effect)); - if (ret == -1) { - ALOGE("ioctl EVIOCSFF failed, errno = %d", -errno); - goto errout; - } - - mCurrAppId = effect.id; - if (effectId != INVALID_VALUE && playLengthMs != NULL) { - *playLengthMs = data[1] * 1000 + data[2]; -#ifdef USE_EFFECT_STREAM - if (stream != NULL && stream->play_rate_hz != 0) - *playLengthMs = ((stream->length * 1000) / stream->play_rate_hz) + 1; -#endif - } - - play.value = 1; - play.type = EV_FF; - play.code = mCurrAppId; - play.time.tv_sec = 0; - play.time.tv_usec = 0; - ret = TEMP_FAILURE_RETRY(write(mVibraFd, (const void*)&play, sizeof(play))); - if (ret == -1) { - ALOGE("write failed, errno = %d", -errno); - ret = TEMP_FAILURE_RETRY(ioctl(mVibraFd, EVIOCRMFF, mCurrAppId)); - if (ret == -1) - ALOGE("ioctl EVIOCRMFF failed, errno = %d", -errno); - goto errout; - } - } else if (mCurrAppId != INVALID_VALUE) { - ret = TEMP_FAILURE_RETRY(ioctl(mVibraFd, EVIOCRMFF, mCurrAppId)); - if (ret == -1) { - ALOGE("ioctl EVIOCRMFF failed, errno = %d", -errno); - goto errout; - } - mCurrAppId = INVALID_VALUE; - } - return Status::OK; - -errout: - mCurrAppId = INVALID_VALUE; - return Status::UNSUPPORTED_OPERATION; -} - -Return<Status> InputFFDevice::on(uint32_t timeoutMs) { - return play(INVALID_VALUE, timeoutMs, NULL); -} - -Return<Status> InputFFDevice::off() { - return play(INVALID_VALUE, 0, NULL); -} - -Return<bool> InputFFDevice::supportsAmplitudeControl() { - return mSupportGain ? true : false; -} - -Return<Status> InputFFDevice::setAmplitude(uint8_t amplitude) { - int tmp, ret; - struct input_event ie; - - if (!mSupportGain) - return Status::UNSUPPORTED_OPERATION; - - if (amplitude == 0) - return Status::BAD_VALUE; - - /* For QMAA compliance, return OK even if vibrator device doesn't exist */ - if (mVibraFd == INVALID_VALUE) - return Status::OK; - - tmp = amplitude * (STRONG_MAGNITUDE - LIGHT_MAGNITUDE) / 255; - tmp += LIGHT_MAGNITUDE; - ie.type = EV_FF; - ie.code = FF_GAIN; - ie.value = tmp; - - ret = TEMP_FAILURE_RETRY(write(mVibraFd, &ie, sizeof(ie))); - if (ret == -1) { - ALOGE("write FF_GAIN failed, errno = %d", -errno); - return Status::UNSUPPORTED_OPERATION; - } - - mCurrMagnitude = tmp; - return Status::OK; -} - -Return<Status> InputFFDevice::playEffect(int effectId, EffectStrength es, long *playLengthMs) { - if (!mSupportEffects) - return Status::UNSUPPORTED_OPERATION; - - switch (es) { - case EffectStrength::LIGHT: - mCurrMagnitude = LIGHT_MAGNITUDE; - break; - case EffectStrength::MEDIUM: - mCurrMagnitude = MEDIUM_MAGNITUDE; - break; - case EffectStrength::STRONG: - mCurrMagnitude = STRONG_MAGNITUDE; - break; - default: - return Status::UNSUPPORTED_OPERATION; - } - - return play(effectId, INVALID_VALUE, playLengthMs); -} - -using Effect_1_0 = ::android::hardware::vibrator::V1_0::Effect; -Return<void> Vibrator::perform(Effect_1_0 effect, EffectStrength es, perform_cb _hidl_cb) { - Status status; - int effectId = static_cast<int16_t>(effect); - long playLengthMs; - - if (effectId < (static_cast<int16_t>(Effect_1_0::CLICK)) || - effectId > (static_cast<int16_t>(Effect_1_0::DOUBLE_CLICK))) { - _hidl_cb(Status::UNSUPPORTED_OPERATION, 0); - return Void(); - } - - status = ff.playEffect(effectId, es, &playLengthMs); - if (status == Status::OK) - _hidl_cb(Status::OK, playLengthMs); - else - _hidl_cb(Status::UNSUPPORTED_OPERATION, 0); - - return Void(); -} - -using Effect_1_1 = ::android::hardware::vibrator::V1_1::Effect_1_1; -Return<void> Vibrator::perform_1_1(Effect_1_1 effect, EffectStrength es, perform_cb _hidl_cb) { - Status status; - int effectId = static_cast<int16_t>(effect); - long playLengthMs; - - if (effectId < (static_cast<int16_t>(Effect_1_1::CLICK)) || - effectId > (static_cast<int16_t>(Effect_1_1::TICK))) { - _hidl_cb(Status::UNSUPPORTED_OPERATION, 0); - return Void(); - } - - status = ff.playEffect(effectId, es, &playLengthMs); - if (status == Status::OK) - _hidl_cb(Status::OK, playLengthMs); - else - _hidl_cb(Status::UNSUPPORTED_OPERATION, 0); - - return Void(); -} - -using Effect_1_2 = ::android::hardware::vibrator::V1_2::Effect; -Return<void> Vibrator::perform_1_2(Effect_1_2 effect, EffectStrength es, perform_cb _hidl_cb) { - Status status; - int effectId = static_cast<int16_t>(effect); - long playLengthMs; - - if (effectId < (static_cast<int16_t>(Effect_1_2::CLICK)) || - effectId > (static_cast<int16_t>(Effect_1_2::RINGTONE_15))) { - _hidl_cb(Status::UNSUPPORTED_OPERATION, 0); - return Void(); - } - - status = ff.playEffect(effectId, es, &playLengthMs); - if (status == Status::OK) - _hidl_cb(Status::OK, playLengthMs); - else - _hidl_cb(Status::UNSUPPORTED_OPERATION, 0); - - return Void(); -} -} // namespace implementation -} // namespace V1_2 -} // namespace vibrator -} // namespace hardware -} // namespace android diff --git a/1.2/Vibrator_1_2.h b/1.2/Vibrator_1_2.h deleted file mode 100644 index 06ccd93..0000000 --- a/1.2/Vibrator_1_2.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2018,2020, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef ANDROID_HARDWARE_VIBRATOR_V1_2_VIBRATOR_H -#define ANDROID_HARDWARE_VIBRATOR_V1_2_VIBRATOR_H - -#include <android/hardware/vibrator/1.2/IVibrator.h> -#include <hidl/Status.h> - -namespace android { -namespace hardware { -namespace vibrator { -namespace V1_2 { -namespace implementation { - -using Status = ::android::hardware::vibrator::V1_0::Status; -using EffectStrength = ::android::hardware::vibrator::V1_0::EffectStrength; - -class InputFFDevice { -public: - InputFFDevice(); - Return<Status> playEffect(int effectId, EffectStrength es, long *playLengthMs); - - Return<Status> on(uint32_t timeoutMs); - Return<Status> off(); - Return<bool> supportsAmplitudeControl(); - Return<Status> setAmplitude(uint8_t amplitude); -private: - Return<Status> play(int effectId, uint32_t timeoutMs, long *playLengthMs); - int mVibraFd; - int16_t mCurrAppId; - int16_t mCurrMagnitude; - bool mSupportGain; - bool mSupportEffects; -}; - -class Vibrator : public IVibrator { -public: - class InputFFDevice ff; - Return<Status> on(uint32_t timeoutMs) {return ff.on(timeoutMs);}; - Return<Status> off() {return ff.off();}; - Return<bool> supportsAmplitudeControl() {return ff.supportsAmplitudeControl();}; - Return<Status> setAmplitude(uint8_t amplitude) {return ff.setAmplitude(amplitude);}; - - Return<void> perform(::android::hardware::vibrator::V1_0::Effect effect, EffectStrength strength, perform_cb _hidl_cb) override; - Return<void> perform_1_1(::android::hardware::vibrator::V1_1::Effect_1_1 effect, EffectStrength strength, perform_cb _hidl_cb) override; - Return<void> perform_1_2(::android::hardware::vibrator::V1_2::Effect effect, EffectStrength strength, perform_cb _hidl_cb) override; -}; - -} // namespace implementation -} // namespace V1_2 -} // namespace vibrator -} // namespace hardware -} // namespace android - -#endif // ANDROID_HARDWARE_VIBRATOR_V1_2_VIBRATOR_H diff --git a/1.2/service.cpp b/1.2/service.cpp deleted file mode 100644 index 0f637b8..0000000 --- a/1.2/service.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2018,2020, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#define LOG_TAG "android.hardware.vibrator@1.2-service.qti" - -#include <android/hardware/vibrator/1.2/IVibrator.h> -#include <hidl/LegacySupport.h> -#include <hidl/HidlSupport.h> -#include <hidl/HidlTransportSupport.h> - -#include "Vibrator_1_2.h" - -using android::hardware::configureRpcThreadpool; -using android::hardware::joinRpcThreadpool; -using android::hardware::vibrator::V1_2::IVibrator; -using android::hardware::vibrator::V1_2::implementation::Vibrator; -using namespace android; - -int main() { - int ret; - - configureRpcThreadpool(1, true); - - sp<IVibrator> vibrator = new Vibrator(); - ret = vibrator->registerAsService(); - - joinRpcThreadpool(); - return ret; -} diff --git a/1.2/vendor.qti.hardware.vibrator@1.2-service.rc b/1.2/vendor.qti.hardware.vibrator@1.2-service.rc deleted file mode 100644 index 639d739..0000000 --- a/1.2/vendor.qti.hardware.vibrator@1.2-service.rc +++ /dev/null @@ -1,4 +0,0 @@ -service vendor.qti.vibrator-1-2 /vendor/bin/hw/vendor.qti.hardware.vibrator@1.2-service - class hal - user system - group system input diff --git a/1.2/vendor.qti.hardware.vibrator@1.2-service.xml b/1.2/vendor.qti.hardware.vibrator@1.2-service.xml deleted file mode 100644 index f5b4ebd..0000000 --- a/1.2/vendor.qti.hardware.vibrator@1.2-service.xml +++ /dev/null @@ -1,38 +0,0 @@ -<!-- Copyright (c) 2019-2020 The Linux Foundation. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - * Neither the name of The Linux Foundation nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED -WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS -BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---> -<manifest version="1.0" type="device"> - <hal format="hidl"> - <name>android.hardware.vibrator</name> - <transport>hwbinder</transport> - <version>1.2</version> - <interface> - <name>IVibrator</name> - <instance>default</instance> - </interface> - </hal> -</manifest> diff --git a/1.3/Android.bp b/1.3/Android.bp deleted file mode 100644 index 82b12ca..0000000 --- a/1.3/Android.bp +++ /dev/null @@ -1,29 +0,0 @@ -Common_CFlags = ["-Wall"] -Common_CFlags += ["-Werror"] - -cc_binary { - name: "vendor.qti.hardware.vibrator@1.3-service", - vendor: true, - relative_install_path: "hw", - init_rc: ["vendor.qti.hardware.vibrator@1.3-service.rc"], - cflags: Common_CFlags, - srcs: [ - "service.cpp", - "Vibrator.cpp", - ], - shared_libs: [ - "libhidlbase", - "libcutils", - "liblog", - "libutils", - "libhardware", - "android.hardware.vibrator@1.0", - "android.hardware.vibrator@1.1", - "android.hardware.vibrator@1.2", - "android.hardware.vibrator@1.3", - "vendor.qti.hardware.vibrator@1.2-impl", - ], - vintf_fragments: [ - "vendor.qti.hardware.vibrator@1.3-service.xml", - ], -} diff --git a/1.3/Vibrator.cpp b/1.3/Vibrator.cpp deleted file mode 100644 index f965107..0000000 --- a/1.3/Vibrator.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (c) 2018-2020, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#define LOG_TAG "vendor.qti.vibrator@1.3-impl" - -#include <hardware/hardware.h> -#include <hardware/vibrator.h> -#include <inttypes.h> -#include <log/log.h> - -#include "Vibrator_1_3.h" - -namespace android { -namespace hardware { -namespace vibrator { -namespace V1_3 { -namespace implementation { - -using android::hardware::vibrator::V1_0::Status; -using android::hardware::vibrator::V1_0::EffectStrength; -using android::hardware::vibrator::V1_3::Effect; - -/** - * Any targets using V1.3 vibrator interface will support - * external control by default - */ -Return<bool> Vibrator::supportsExternalControl() { - return true; -} - -/** - * The existing hardware module would cease current vibration - * and switch to the external control vibration automatically, - * so nothing need to be done in sw, hence return OK directly. - */ -Return<Status> Vibrator::setExternalControl(__attribute__((unused))bool enable) { - return Status::OK; -} - -using Effect_1_0 = ::android::hardware::vibrator::V1_0::Effect; -Return<void> Vibrator::perform(Effect_1_0 effect, EffectStrength es, perform_cb _hidl_cb) { - Status status; - int effectId = static_cast<int16_t>(effect); - long playLengthMs; - - if (effectId < (static_cast<int16_t>(Effect_1_0::CLICK)) || - effectId > (static_cast<int16_t>(Effect_1_0::DOUBLE_CLICK))) { - _hidl_cb(Status::UNSUPPORTED_OPERATION, 0); - return Void(); - } - - status = ff.playEffect(effectId, es, &playLengthMs); - if (status == Status::OK) - _hidl_cb(Status::OK, playLengthMs); - else - _hidl_cb(Status::UNSUPPORTED_OPERATION, 0); - - return Void(); -} - -using Effect_1_1 = ::android::hardware::vibrator::V1_1::Effect_1_1; -Return<void> Vibrator::perform_1_1(Effect_1_1 effect, EffectStrength es, perform_cb _hidl_cb) { - Status status; - int effectId = static_cast<int16_t>(effect); - long playLengthMs; - - if (effectId < (static_cast<int16_t>(Effect_1_1::CLICK)) || - effectId > (static_cast<int16_t>(Effect_1_1::TICK))) { - _hidl_cb(Status::UNSUPPORTED_OPERATION, 0); - return Void(); - } - - status = ff.playEffect(effectId, es, &playLengthMs); - if (status == Status::OK) - _hidl_cb(Status::OK, playLengthMs); - else - _hidl_cb(Status::UNSUPPORTED_OPERATION, 0); - - return Void(); -} - -using Effect_1_2 = ::android::hardware::vibrator::V1_2::Effect; -Return<void> Vibrator::perform_1_2(Effect_1_2 effect, EffectStrength es, perform_cb _hidl_cb) { - Status status; - int effectId = static_cast<int16_t>(effect); - long playLengthMs; - - if (effectId < (static_cast<int16_t>(Effect_1_2::CLICK)) || - effectId > (static_cast<int16_t>(Effect_1_2::RINGTONE_15))) { - _hidl_cb(Status::UNSUPPORTED_OPERATION, 0); - return Void(); - } - - status = ff.playEffect(effectId, es, &playLengthMs); - if (status == Status::OK) - _hidl_cb(Status::OK, playLengthMs); - else - _hidl_cb(Status::UNSUPPORTED_OPERATION, 0); - - return Void(); -} - -using Effect_1_3 = ::android::hardware::vibrator::V1_3::Effect; -Return<void> Vibrator::perform_1_3(Effect_1_3 effect, EffectStrength es, perform_1_3_cb _hidl_cb) { - Status status; - int effectId = static_cast<int16_t>(effect); - long playLengthMs; - - if (effectId < (static_cast<int16_t>(Effect_1_3::CLICK)) || - effectId > (static_cast<int16_t>(Effect_1_3::TEXTURE_TICK))) { - _hidl_cb(Status::UNSUPPORTED_OPERATION, 0); - return Void(); - } - - status = ff.playEffect(effectId, es, &playLengthMs); - if (status == Status::OK) - _hidl_cb(Status::OK, playLengthMs); - else - _hidl_cb(Status::UNSUPPORTED_OPERATION, 0); - - return Void(); -} -} // namespace implementation -} // namespace V1_3 -} // namespace vibrator -} // namespace hardware -} // namespace android diff --git a/1.3/Vibrator_1_3.h b/1.3/Vibrator_1_3.h deleted file mode 100644 index 34a15ad..0000000 --- a/1.3/Vibrator_1_3.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2018,2020, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef ANDROID_HARDWARE_VIBRATOR_V1_3_VIBRATOR_H -#define ANDROID_HARDWARE_VIBRATOR_V1_3_VIBRATOR_H - -#include <android/hardware/vibrator/1.3/IVibrator.h> -#include <hidl/Status.h> - -#include "Vibrator_1_2.h" - -namespace android { -namespace hardware { -namespace vibrator { -namespace V1_3 { -namespace implementation { - -using android::hardware::vibrator::V1_2::implementation::InputFFDevice; -using android::hardware::vibrator::V1_0::Status; -using android::hardware::vibrator::V1_0::EffectStrength; - -class Vibrator : public IVibrator { -public: - class InputFFDevice ff; - Return<Status> on(uint32_t timeoutMs) {return ff.on(timeoutMs);}; - Return<Status> off() {return ff.off();}; - Return<bool> supportsAmplitudeControl() {return ff.supportsAmplitudeControl();}; - Return<Status> setAmplitude(uint8_t amplitude) {return ff.setAmplitude(amplitude);}; - - Return<bool> supportsExternalControl() override; - Return<Status> setExternalControl(bool enable) override; - Return<void> perform(::android::hardware::vibrator::V1_0::Effect effect, EffectStrength strength, perform_cb _hidl_cb) override; - Return<void> perform_1_1(::android::hardware::vibrator::V1_1::Effect_1_1 effect, EffectStrength strength, perform_cb _hidl_cb) override; - Return<void> perform_1_2(::android::hardware::vibrator::V1_2::Effect effect, EffectStrength strength, perform_cb _hidl_cb) override; - Return<void> perform_1_3(::android::hardware::vibrator::V1_3::Effect effect, EffectStrength strength, perform_cb _hidl_cb) override; -}; - -} // namespace implementation -} // namespace V1_3 -} // namespace vibrator -} // namespace hardware -} // namespace android - -#endif // ANDROID_HARDWARE_VIBRATOR_V1_3_VIBRATOR_H diff --git a/1.3/service.cpp b/1.3/service.cpp deleted file mode 100644 index 7b283d0..0000000 --- a/1.3/service.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2018,2020, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#define LOG_TAG "android.hardware.vibrator@1.3-service.qti" - -#include <android/hardware/vibrator/1.3/IVibrator.h> -#include <hidl/LegacySupport.h> -#include <hidl/HidlSupport.h> -#include <hidl/HidlTransportSupport.h> - -#include "Vibrator_1_3.h" - -using android::hardware::configureRpcThreadpool; -using android::hardware::joinRpcThreadpool; -using android::hardware::vibrator::V1_3::IVibrator; -using android::hardware::vibrator::V1_3::implementation::Vibrator; -using namespace android; - -int main() { - int ret; - - configureRpcThreadpool(1, true); - - sp<IVibrator> vibrator = new Vibrator(); - ret = vibrator->registerAsService(); - - joinRpcThreadpool(); - return ret; -} diff --git a/1.3/vendor.qti.hardware.vibrator@1.3-service.rc b/1.3/vendor.qti.hardware.vibrator@1.3-service.rc deleted file mode 100644 index b87c3c1..0000000 --- a/1.3/vendor.qti.hardware.vibrator@1.3-service.rc +++ /dev/null @@ -1,4 +0,0 @@ -service vendor.qti.vibrator-1-3 /vendor/bin/hw/vendor.qti.hardware.vibrator@1.3-service - class hal - user system - group system input diff --git a/1.3/vendor.qti.hardware.vibrator@1.3-service.xml b/1.3/vendor.qti.hardware.vibrator@1.3-service.xml deleted file mode 100644 index db5113e..0000000 --- a/1.3/vendor.qti.hardware.vibrator@1.3-service.xml +++ /dev/null @@ -1,38 +0,0 @@ -<!-- Copyright (c) 2019-2020 The Linux Foundation. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - * Neither the name of The Linux Foundation nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED -WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS -BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---> -<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/qmaa/Android.bp b/qmaa/Android.bp deleted file mode 100644 index 3ad7524..0000000 --- a/qmaa/Android.bp +++ /dev/null @@ -1,22 +0,0 @@ -Common_CFlags = ["-Wall"] -Common_CFlags += ["-Werror"] - -Common_SharedLibs = ["libhidlbase"] -Common_SharedLibs += ["libcutils"] -Common_SharedLibs += ["liblog"] -Common_SharedLibs += ["libutils"] -Common_SharedLibs += ["libhardware"] -Common_SharedLibs += ["android.hardware.vibrator@1.0"] -Common_SharedLibs += ["android.hardware.vibrator@1.1"] -Common_SharedLibs += ["android.hardware.vibrator@1.2"] - -cc_binary { - name: "vendor.qti.hardware.vibrator.qmaa@1.2-service", - relative_install_path: "hw", - init_rc: ["vendor.qti.hardware.vibrator@1.2-service.rc"], - cflags: Common_CFlags, - srcs: ["service_qmaa.cpp"], - shared_libs: Common_SharedLibs, - vendor: true, - stem : "vendor.qti.hardware.vibrator@1.2-service", -} diff --git a/qmaa/Vibrator_qmaa.h b/qmaa/Vibrator_qmaa.h deleted file mode 100644 index b297a95..0000000 --- a/qmaa/Vibrator_qmaa.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2018, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef ANDROID_HARDWARE_VIBRATOR_V1_2_VIBRATOR_H -#define ANDROID_HARDWARE_VIBRATOR_V1_2_VIBRATOR_H - -#include <android/hardware/vibrator/1.2/IVibrator.h> -#include <hidl/Status.h> - -namespace android { -namespace hardware { -namespace vibrator { -namespace V1_2 { -namespace implementation { - -class Vibrator : public IVibrator { -public: - Vibrator(int vibraFd, bool supportGain, bool supportEffect); - - 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; - - using EffectStrength = ::android::hardware::vibrator::V1_0::EffectStrength; - Return<void> perform(::android::hardware::vibrator::V1_0::Effect effect, EffectStrength strength, perform_cb _hidl_cb) override; - - Return<void> perform_1_1(::android::hardware::vibrator::V1_1::Effect_1_1 effect, EffectStrength strength, perform_1_1_cb _hidl_cb) override; - - Return<void> perform_1_2(::android::hardware::vibrator::V1_2::Effect effect, EffectStrength strength, perform_1_2_cb _hidl_cb) override; - -private: - Return<Status> play(uint32_t timeoutMs); - int mVibraFd; - int16_t mCurrAppId; - int16_t mCurrEffectId; - int16_t mCurrMagnitude; - long mPlayLengthMs; - bool mSupportGain; - bool mSupportEffects; -}; - -} // namespace implementation -} // namespace V1_2 -} // namespace vibrator -} // namespace hardware -} // namespace android - -#endif // ANDROID_HARDWARE_VIBRATOR_V1_2_VIBRATOR_H diff --git a/qmaa/service_qmaa.cpp b/qmaa/service_qmaa.cpp deleted file mode 100644 index c9b5bad..0000000 --- a/qmaa/service_qmaa.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (c) 2020, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#define LOG_TAG "android.hardware.vibrator@1.2-service.qmaa" - -#include <hidl/HidlSupport.h> -#include <hidl/HidlTransportSupport.h> - -#include "Vibrator_qmaa.h" - -using android::hardware::configureRpcThreadpool; -using android::hardware::joinRpcThreadpool; -using android::hardware::vibrator::V1_2::IVibrator; -using android::hardware::vibrator::V1_2::implementation::Vibrator; -using namespace android; - -namespace android { -namespace hardware { -namespace vibrator { -namespace V1_2 { -namespace implementation { - - -using Status = ::android::hardware::vibrator::V1_0::Status; - -Vibrator::Vibrator(int vibraFd, bool supportGain, bool supportEffects) : - mVibraFd(vibraFd), mSupportGain(supportGain), - mSupportEffects(supportEffects) { - mCurrAppId = -1; - mCurrEffectId = -1; - mCurrMagnitude = 0x7fff; - mPlayLengthMs = 0; -} - -/** Play vibration - * - * @param timeoutMs: playing length, non-zero means playing; zero means stop playing. - * - * If the request is playing with a predefined effect, the timeoutMs value is - * ignored, and the real playing length is required to be returned from the kernel - * driver for userspace service to wait until the vibration done. - * - * The custom_data in periodic is reused for this usage. It's been defined with - * following format: <effect-ID, play-time-in-seconds, play-time-in-milliseconds>. - * The effect-ID is used for passing down the predefined effect to kernel driver, - * and play-time-xxx is used for return back the real playing length from kernel - * driver. - */ -Return<Status> Vibrator::play(__attribute__((unused)) uint32_t timeoutMs) { - mVibraFd = 0; - return Status::OK; - -} - -Return<Status> Vibrator::on(__attribute__((unused)) uint32_t timeoutMs) { - return play(timeoutMs); -} - -Return<Status> Vibrator::off() { - return play(0); -} - -Return<bool> Vibrator::supportsAmplitudeControl() { - return mSupportGain ? true : false; -} - -Return<Status> Vibrator::setAmplitude(__attribute__((unused)) uint8_t amplitude) { - return Status::OK; -} - - -using Effect_1_0 = ::android::hardware::vibrator::V1_0::Effect; -Return<void> Vibrator::perform(__attribute__((unused))Effect_1_0 effect,__attribute__((unused)) EffectStrength es, perform_cb _hidl_cb) { - if (!mSupportEffects) { - _hidl_cb(Status::UNSUPPORTED_OPERATION, 0); - return Void(); - } - - _hidl_cb(Status::OK, mPlayLengthMs); - return Void(); -} - -using Effect_1_1 = ::android::hardware::vibrator::V1_1::Effect_1_1; -Return<void> Vibrator::perform_1_1(__attribute__((unused)) Effect_1_1 effect,__attribute__((unused)) EffectStrength es, perform_1_1_cb _hidl_cb) { - - _hidl_cb(Status::OK, mPlayLengthMs); - return Void(); -} - -using Effect_1_2 = ::android::hardware::vibrator::V1_2::Effect; -Return<void> Vibrator::perform_1_2(__attribute__((unused)) Effect_1_2 effect,__attribute__((unused)) EffectStrength es, perform_1_2_cb _hidl_cb) { - _hidl_cb(Status::OK, mPlayLengthMs); - return Void(); -} -} // namespace implementation -} // namespace V1_2 -} // namespace vibrator -} // namespace hardware -} // namespace android - - - -int main() { - bool supportGain = false, supportEffects = false; - int ret = -1; - int vibraFd = -1; - - configureRpcThreadpool(1, true); - - sp<IVibrator> vibrator = new Vibrator(vibraFd, supportGain, supportEffects); - ret = vibrator->registerAsService(); - - - joinRpcThreadpool(); - return ret; -} diff --git a/qmaa/vendor.qti.hardware.vibrator@1.2-service.rc b/qmaa/vendor.qti.hardware.vibrator@1.2-service.rc deleted file mode 100644 index 639d739..0000000 --- a/qmaa/vendor.qti.hardware.vibrator@1.2-service.rc +++ /dev/null @@ -1,4 +0,0 @@ -service vendor.qti.vibrator-1-2 /vendor/bin/hw/vendor.qti.hardware.vibrator@1.2-service - class hal - user system - group system input |