From 9f508f12ae2469ad37f44a58df9f4c59d93116c3 Mon Sep 17 00:00:00 2001 From: roynatech2544 Date: Wed, 5 Oct 2022 09:59:35 +0000 Subject: [PATCH] universal7885: RIP hidl-support --- .../hidl-packages/parts/Android.bp | 3 - .../parts/hardware/fmradio/1.0/Android.bp | 12 --- .../parts/hardware/fmradio/1.0/IFMRadio.hal | 20 ----- .../parts/hardware/fmradio/1.0/types.hal | 20 ----- .../parts/hardware/fmradio/1.1/Android.bp | 13 --- .../parts/hardware/fmradio/1.1/IFMRadio.hal | 22 ----- .../parts/hardware/fmradio/1.1/types.hal | 20 ----- .../parts/hardware/fmradio/1.2/Android.bp | 14 ---- .../parts/hardware/fmradio/1.2/IFMRadio.hal | 22 ----- .../hardware/fmradio/1.2/default/Android.bp | 21 ----- .../fmradio/1.2/default/CachedClass.h | 9 -- .../hardware/fmradio/1.2/default/FMRadio.cpp | 81 ------------------ .../hardware/fmradio/1.2/default/FMRadio.h | 44 ---------- .../hardware/fmradio/1.2/default/service.cpp | 47 ----------- ...dor.eureka.hardware.fmradio@1.2-service.rc | 7 -- .../vendor.eureka.hardware.fmradio@1.2.xml | 11 --- .../parts/hardware/fmradio/1.2/types.hal | 23 ----- .../parts/hardware/parts/1.0/Android.bp | 14 ---- .../hardware/parts/1.0/IBatteryStats.hal | 20 ----- .../hardware/parts/1.0/IDisplayConfigs.hal | 19 ----- .../hardware/parts/1.0/IFlashBrightness.hal | 21 ----- .../parts/hardware/parts/1.0/ISmartCharge.hal | 23 ----- .../parts/hardware/parts/1.0/ISwapOnData.hal | 24 ------ .../hardware/parts/1.0/default/Android.bp | 26 ------ .../hardware/parts/1.0/default/Battery.cpp | 66 --------------- .../hardware/parts/1.0/default/Battery.h | 38 --------- .../parts/1.0/default/BatteryConstants.h | 13 --- .../hardware/parts/1.0/default/CachedClass.h | 9 -- .../hardware/parts/1.0/default/Display.cpp | 47 ----------- .../hardware/parts/1.0/default/Display.h | 34 -------- .../hardware/parts/1.0/default/FlashLight.cpp | 47 ----------- .../hardware/parts/1.0/default/FlashLight.h | 36 -------- .../parts/1.0/default/SmartCharge.cpp | 63 -------------- .../hardware/parts/1.0/default/SmartCharge.h | 38 --------- .../parts/1.0/default/SmartChargingImpl.cpp | 43 ---------- .../parts/1.0/default/SmartChargingImpl.h | 30 ------- .../parts/hardware/parts/1.0/default/Swap.cpp | 83 ------------------- .../parts/hardware/parts/1.0/default/Swap.h | 39 --------- .../parts/1.0/default/SwapHelpers.cpp | 82 ------------------ .../hardware/parts/1.0/default/service.cpp | 71 ---------------- ...endor.eureka.hardware.parts@1.0-service.rc | 12 --- .../vendor.eureka.hardware.parts@1.0.xml | 27 ------ .../parts/hardware/parts/1.0/types.hal | 34 -------- 43 files changed, 1348 deletions(-) delete mode 100644 universal7885-common/hidl-packages/parts/Android.bp delete mode 100644 universal7885-common/hidl-packages/parts/hardware/fmradio/1.0/Android.bp delete mode 100644 universal7885-common/hidl-packages/parts/hardware/fmradio/1.0/IFMRadio.hal delete mode 100644 universal7885-common/hidl-packages/parts/hardware/fmradio/1.0/types.hal delete mode 100644 universal7885-common/hidl-packages/parts/hardware/fmradio/1.1/Android.bp delete mode 100644 universal7885-common/hidl-packages/parts/hardware/fmradio/1.1/IFMRadio.hal delete mode 100644 universal7885-common/hidl-packages/parts/hardware/fmradio/1.1/types.hal delete mode 100644 universal7885-common/hidl-packages/parts/hardware/fmradio/1.2/Android.bp delete mode 100644 universal7885-common/hidl-packages/parts/hardware/fmradio/1.2/IFMRadio.hal delete mode 100644 universal7885-common/hidl-packages/parts/hardware/fmradio/1.2/default/Android.bp delete mode 100644 universal7885-common/hidl-packages/parts/hardware/fmradio/1.2/default/CachedClass.h delete mode 100644 universal7885-common/hidl-packages/parts/hardware/fmradio/1.2/default/FMRadio.cpp delete mode 100644 universal7885-common/hidl-packages/parts/hardware/fmradio/1.2/default/FMRadio.h delete mode 100644 universal7885-common/hidl-packages/parts/hardware/fmradio/1.2/default/service.cpp delete mode 100644 universal7885-common/hidl-packages/parts/hardware/fmradio/1.2/default/vendor.eureka.hardware.fmradio@1.2-service.rc delete mode 100644 universal7885-common/hidl-packages/parts/hardware/fmradio/1.2/default/vendor.eureka.hardware.fmradio@1.2.xml delete mode 100644 universal7885-common/hidl-packages/parts/hardware/fmradio/1.2/types.hal delete mode 100644 universal7885-common/hidl-packages/parts/hardware/parts/1.0/Android.bp delete mode 100644 universal7885-common/hidl-packages/parts/hardware/parts/1.0/IBatteryStats.hal delete mode 100644 universal7885-common/hidl-packages/parts/hardware/parts/1.0/IDisplayConfigs.hal delete mode 100644 universal7885-common/hidl-packages/parts/hardware/parts/1.0/IFlashBrightness.hal delete mode 100644 universal7885-common/hidl-packages/parts/hardware/parts/1.0/ISmartCharge.hal delete mode 100644 universal7885-common/hidl-packages/parts/hardware/parts/1.0/ISwapOnData.hal delete mode 100644 universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/Android.bp delete mode 100644 universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/Battery.cpp delete mode 100644 universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/Battery.h delete mode 100644 universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/BatteryConstants.h delete mode 100644 universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/CachedClass.h delete mode 100644 universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/Display.cpp delete mode 100644 universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/Display.h delete mode 100644 universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/FlashLight.cpp delete mode 100644 universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/FlashLight.h delete mode 100644 universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/SmartCharge.cpp delete mode 100644 universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/SmartCharge.h delete mode 100644 universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/SmartChargingImpl.cpp delete mode 100644 universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/SmartChargingImpl.h delete mode 100644 universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/Swap.cpp delete mode 100644 universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/Swap.h delete mode 100644 universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/SwapHelpers.cpp delete mode 100644 universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/service.cpp delete mode 100644 universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/vendor.eureka.hardware.parts@1.0-service.rc delete mode 100644 universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/vendor.eureka.hardware.parts@1.0.xml delete mode 100644 universal7885-common/hidl-packages/parts/hardware/parts/1.0/types.hal diff --git a/universal7885-common/hidl-packages/parts/Android.bp b/universal7885-common/hidl-packages/parts/Android.bp deleted file mode 100644 index c835f67..0000000 --- a/universal7885-common/hidl-packages/parts/Android.bp +++ /dev/null @@ -1,3 +0,0 @@ -hidl_package_root { - name: "vendor.eureka", -} diff --git a/universal7885-common/hidl-packages/parts/hardware/fmradio/1.0/Android.bp b/universal7885-common/hidl-packages/parts/hardware/fmradio/1.0/Android.bp deleted file mode 100644 index 8215d84..0000000 --- a/universal7885-common/hidl-packages/parts/hardware/fmradio/1.0/Android.bp +++ /dev/null @@ -1,12 +0,0 @@ -hidl_interface { - name: "vendor.eureka.hardware.fmradio@1.0", - root: "vendor.eureka", - srcs: [ - "types.hal", - "IFMRadio.hal", - ], - interfaces: [ - "android.hidl.base@1.0", - ], - gen_java: true, -} diff --git a/universal7885-common/hidl-packages/parts/hardware/fmradio/1.0/IFMRadio.hal b/universal7885-common/hidl-packages/parts/hardware/fmradio/1.0/IFMRadio.hal deleted file mode 100644 index d7abe17..0000000 --- a/universal7885-common/hidl-packages/parts/hardware/fmradio/1.0/IFMRadio.hal +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Eureka Team -// -// 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 vendor.eureka.hardware.fmradio@1.0; - -interface IFMRadio { - setManualFreq(float freq); - adjustFreqByStep(Direction dir); -}; diff --git a/universal7885-common/hidl-packages/parts/hardware/fmradio/1.0/types.hal b/universal7885-common/hidl-packages/parts/hardware/fmradio/1.0/types.hal deleted file mode 100644 index 7b53ac3..0000000 --- a/universal7885-common/hidl-packages/parts/hardware/fmradio/1.0/types.hal +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Eureka Team -// -// 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 vendor.eureka.hardware.fmradio@1.0; - -enum Direction : int32_t { - UP, - DOWN, -}; diff --git a/universal7885-common/hidl-packages/parts/hardware/fmradio/1.1/Android.bp b/universal7885-common/hidl-packages/parts/hardware/fmradio/1.1/Android.bp deleted file mode 100644 index 1e4f282..0000000 --- a/universal7885-common/hidl-packages/parts/hardware/fmradio/1.1/Android.bp +++ /dev/null @@ -1,13 +0,0 @@ -hidl_interface { - name: "vendor.eureka.hardware.fmradio@1.1", - root: "vendor.eureka", - srcs: [ - "types.hal", - "IFMRadio.hal", - ], - interfaces: [ - "android.hidl.base@1.0", - "vendor.eureka.hardware.fmradio@1.0", - ], - gen_java: true, -} diff --git a/universal7885-common/hidl-packages/parts/hardware/fmradio/1.1/IFMRadio.hal b/universal7885-common/hidl-packages/parts/hardware/fmradio/1.1/IFMRadio.hal deleted file mode 100644 index 4ac9a13..0000000 --- a/universal7885-common/hidl-packages/parts/hardware/fmradio/1.1/IFMRadio.hal +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2021 Eureka Team -// -// 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 vendor.eureka.hardware.fmradio@1.1; - -import @1.0::IFMRadio; - -interface IFMRadio extends @1.0::IFMRadio { - getFreqFromSysfs() generates (int32_t freq); - isAvailable() generates (Status status); -}; diff --git a/universal7885-common/hidl-packages/parts/hardware/fmradio/1.1/types.hal b/universal7885-common/hidl-packages/parts/hardware/fmradio/1.1/types.hal deleted file mode 100644 index b3b2c21..0000000 --- a/universal7885-common/hidl-packages/parts/hardware/fmradio/1.1/types.hal +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Eureka Team -// -// 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 vendor.eureka.hardware.fmradio@1.1; - -enum Status : int32_t { - YES, - NO, -}; diff --git a/universal7885-common/hidl-packages/parts/hardware/fmradio/1.2/Android.bp b/universal7885-common/hidl-packages/parts/hardware/fmradio/1.2/Android.bp deleted file mode 100644 index d1d24a6..0000000 --- a/universal7885-common/hidl-packages/parts/hardware/fmradio/1.2/Android.bp +++ /dev/null @@ -1,14 +0,0 @@ -hidl_interface { - name: "vendor.eureka.hardware.fmradio@1.2", - root: "vendor.eureka", - srcs: [ - "types.hal", - "IFMRadio.hal", - ], - interfaces: [ - "android.hidl.base@1.0", - "vendor.eureka.hardware.fmradio@1.1", - "vendor.eureka.hardware.fmradio@1.0", - ], - gen_java: true, -} diff --git a/universal7885-common/hidl-packages/parts/hardware/fmradio/1.2/IFMRadio.hal b/universal7885-common/hidl-packages/parts/hardware/fmradio/1.2/IFMRadio.hal deleted file mode 100644 index fe078f8..0000000 --- a/universal7885-common/hidl-packages/parts/hardware/fmradio/1.2/IFMRadio.hal +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2021 Eureka Team -// -// 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 vendor.eureka.hardware.fmradio@1.2; - -import @1.1::IFMRadio; - -interface IFMRadio extends @1.1::IFMRadio { - setChannelSpacing(Space space); - getChannelSpacing() generates (Space space); -}; diff --git a/universal7885-common/hidl-packages/parts/hardware/fmradio/1.2/default/Android.bp b/universal7885-common/hidl-packages/parts/hardware/fmradio/1.2/default/Android.bp deleted file mode 100644 index 11fee26..0000000 --- a/universal7885-common/hidl-packages/parts/hardware/fmradio/1.2/default/Android.bp +++ /dev/null @@ -1,21 +0,0 @@ -// FIXME: your file license if you have one - -cc_binary { - name: "vendor.eureka.hardware.fmradio@1.2-service", - srcs: [ - "FMRadio.cpp", - "service.cpp", - ], - defaults: ["eureka_defaults"], - shared_libs: [ - "libhidlbase", - "libutils", - "liblog", - "libfileio", - "vendor.eureka.hardware.fmradio@1.0", - "vendor.eureka.hardware.fmradio@1.1", - "vendor.eureka.hardware.fmradio@1.2", - ], - init_rc: ["vendor.eureka.hardware.fmradio@1.2-service.rc"], - vintf_fragments: ["vendor.eureka.hardware.fmradio@1.2.xml"], -} diff --git a/universal7885-common/hidl-packages/parts/hardware/fmradio/1.2/default/CachedClass.h b/universal7885-common/hidl-packages/parts/hardware/fmradio/1.2/default/CachedClass.h deleted file mode 100644 index 96cea46..0000000 --- a/universal7885-common/hidl-packages/parts/hardware/fmradio/1.2/default/CachedClass.h +++ /dev/null @@ -1,9 +0,0 @@ -template static inline C *cachedClass(C *cached) { - if (cached != nullptr) { - return cached; - } - cached = new C(); - return cached; -} - -#define USE_CACHED(cache) ({ return cachedClass((cache)); }) diff --git a/universal7885-common/hidl-packages/parts/hardware/fmradio/1.2/default/FMRadio.cpp b/universal7885-common/hidl-packages/parts/hardware/fmradio/1.2/default/FMRadio.cpp deleted file mode 100644 index 97c30d3..0000000 --- a/universal7885-common/hidl-packages/parts/hardware/fmradio/1.2/default/FMRadio.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (C) 2021 Eureka Team -// -// 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 "FMRadio.h" -#include -#include -#include -#include -#include - -#include -#include "CachedClass.h" - -static int mChannelSpacing = 3; - -namespace vendor::eureka::hardware::fmradio::V1_2 { - -static FMRadio *kCached = nullptr; - -constexpr const char* FM_FREQ_CTL = "/sys/devices/virtual/s610_radio/s610_radio/radio_freq_ctrl"; -constexpr const char* FM_FREQ_SEEK = "/sys/devices/virtual/s610_radio/s610_radio/radio_freq_seek"; - -Return FMRadio::setManualFreq(float freq) { - FileIO::writeline(FM_FREQ_CTL, freq * 1000); - return Void(); -} - -Return FMRadio::adjustFreqByStep(fmradio::V1_0::Direction dir) { - std::string value = ""; - if (dir == V1_0::Direction::UP) { - value = "1 " + std::to_string(mChannelSpacing * 10); - } else if (dir == V1_0::Direction::DOWN) { - value = "0 " + std::to_string(mChannelSpacing * 10); - } - FileIO::writeline(FM_FREQ_SEEK, value); - return Void(); -} -Return FMRadio::isAvailable() { - struct stat info; - if (stat("/sys/devices/virtual/s610_radio/s610_radio/", &info) != 0) { - return V1_1::Status::NO; - } else { - return V1_1::Status::YES; - } -} -Return FMRadio::setChannelSpacing(V1_2::Space space) { - mChannelSpacing = static_cast(space); - return Void(); -} -Return FMRadio::getFreqFromSysfs() { - return FileIO::readline(FM_FREQ_CTL); -} -Return FMRadio::getChannelSpacing() { - switch (mChannelSpacing) { - case 1: - return V1_2::Space::CHANNEL_SPACING_10HZ; - case 2: - return V1_2::Space::CHANNEL_SPACING_20HZ; - case 3: - return V1_2::Space::CHANNEL_SPACING_30HZ; - case 4: - return V1_2::Space::CHANNEL_SPACING_40HZ; - case 5: - return V1_2::Space::CHANNEL_SPACING_50HZ; - default: - return V1_2::Space::CHANNEL_SPACING_30HZ; - } -} -IFMRadio *FMRadio::getInstance(void) { USE_CACHED(kCached); } -} // namespace vendor::eureka::hardware::fmradio::V1_2 diff --git a/universal7885-common/hidl-packages/parts/hardware/fmradio/1.2/default/FMRadio.h b/universal7885-common/hidl-packages/parts/hardware/fmradio/1.2/default/FMRadio.h deleted file mode 100644 index 364ea2c..0000000 --- a/universal7885-common/hidl-packages/parts/hardware/fmradio/1.2/default/FMRadio.h +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (C) 2021 Eureka Team -// -// 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 - -namespace vendor::eureka::hardware::fmradio::V1_2 { - -using ::android::sp; -using ::android::hardware::hidl_array; -using ::android::hardware::hidl_memory; -using ::android::hardware::hidl_string; -using ::android::hardware::hidl_vec; -using ::android::hardware::Return; -using ::android::hardware::Void; - -struct FMRadio : public IFMRadio { - // Methods from ::vendor::eureka::hardware::fmradio::V1_0::IFMRadio follow. - Return setManualFreq(float freq); - Return adjustFreqByStep(V1_0::Direction dir); - // Methods from ::vendor::eureka::hardware::fmradio::V1_1::IFMRadio follow. - Return isAvailable(); - Return getFreqFromSysfs(); - // Methods from ::vendor::eureka::hardware::fmradio::V1_2::IFMRadio follow. - Return setChannelSpacing(V1_2::Space space); - Return getChannelSpacing(); - // Methods from ::android::hidl::base::V1_0::IBase follow. - static IFMRadio *getInstance(void); -}; -} // namespace vendor::eureka::hardware::fmradio::V1_2 diff --git a/universal7885-common/hidl-packages/parts/hardware/fmradio/1.2/default/service.cpp b/universal7885-common/hidl-packages/parts/hardware/fmradio/1.2/default/service.cpp deleted file mode 100644 index 6b494ac..0000000 --- a/universal7885-common/hidl-packages/parts/hardware/fmradio/1.2/default/service.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2021 Eureka Team -// -// 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 "vendor.eureka.hardware.fmradio@1.2-service" - -#include - -#include - -#include "FMRadio.h" - -using android::sp; -using android::hardware::configureRpcThreadpool; -using android::hardware::joinRpcThreadpool; -using vendor::eureka::hardware::fmradio::V1_2::FMRadio; -using vendor::eureka::hardware::fmradio::V1_2::IFMRadio; - -int main() { - int ret; - android::sp mFMService = FMRadio::getInstance(); - configureRpcThreadpool(1, true /*callerWillJoin*/); - - if (mFMService != nullptr) { - ret = mFMService->registerAsService(); - if (ret != 0) { - ALOGE("Can't register instance of FMRadio HAL, nullptr"); - } else { - ALOGI("registered FMRadio HAL"); - } - } else { - ALOGE("Can't create instance of FMRadio HAL, nullptr"); - } - joinRpcThreadpool(); - - return -1; // should never get here -} diff --git a/universal7885-common/hidl-packages/parts/hardware/fmradio/1.2/default/vendor.eureka.hardware.fmradio@1.2-service.rc b/universal7885-common/hidl-packages/parts/hardware/fmradio/1.2/default/vendor.eureka.hardware.fmradio@1.2-service.rc deleted file mode 100644 index f5a6245..0000000 --- a/universal7885-common/hidl-packages/parts/hardware/fmradio/1.2/default/vendor.eureka.hardware.fmradio@1.2-service.rc +++ /dev/null @@ -1,7 +0,0 @@ -service fm-hal /system/bin/vendor.eureka.hardware.fmradio@1.2-service - interface vendor.eureka.hardware.fmradio@1.0::IFMRadio default - interface vendor.eureka.hardware.fmradio@1.1::IFMRadio default - interface vendor.eureka.hardware.fmradio@1.2::IFMRadio default - class hal - user root - group root diff --git a/universal7885-common/hidl-packages/parts/hardware/fmradio/1.2/default/vendor.eureka.hardware.fmradio@1.2.xml b/universal7885-common/hidl-packages/parts/hardware/fmradio/1.2/default/vendor.eureka.hardware.fmradio@1.2.xml deleted file mode 100644 index cf64d21..0000000 --- a/universal7885-common/hidl-packages/parts/hardware/fmradio/1.2/default/vendor.eureka.hardware.fmradio@1.2.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - vendor.eureka.hardware.fmradio - hwbinder - 1.2 - - IFMRadio - default - - - diff --git a/universal7885-common/hidl-packages/parts/hardware/fmradio/1.2/types.hal b/universal7885-common/hidl-packages/parts/hardware/fmradio/1.2/types.hal deleted file mode 100644 index a3d55e0..0000000 --- a/universal7885-common/hidl-packages/parts/hardware/fmradio/1.2/types.hal +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Eureka Team -// -// 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 vendor.eureka.hardware.fmradio@1.2; - -enum Space : int32_t { - CHANNEL_SPACING_10HZ = 1, - CHANNEL_SPACING_20HZ, - CHANNEL_SPACING_30HZ, - CHANNEL_SPACING_40HZ, - CHANNEL_SPACING_50HZ = 5, -}; diff --git a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/Android.bp b/universal7885-common/hidl-packages/parts/hardware/parts/1.0/Android.bp deleted file mode 100644 index e799463..0000000 --- a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/Android.bp +++ /dev/null @@ -1,14 +0,0 @@ -hidl_interface { - name: "vendor.eureka.hardware.parts@1.0", - root: "vendor.eureka", - srcs: [ - "types.hal", - "IBatteryStats.hal", - "IFlashBrightness.hal", - "IDisplayConfigs.hal", - "ISwapOnData.hal", - "ISmartCharge.hal" - ], - interfaces: ["android.hidl.base@1.0"], - gen_java: false, -} diff --git a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/IBatteryStats.hal b/universal7885-common/hidl-packages/parts/hardware/parts/1.0/IBatteryStats.hal deleted file mode 100644 index 9de3e75..0000000 --- a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/IBatteryStats.hal +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Eureka Team -// -// 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 vendor.eureka.hardware.parts@1.0; - -interface IBatteryStats { - getBatteryStats(BatterySys stats) generates (int32_t result); - setBatteryWritable(BatterySys stats, Status value); -}; diff --git a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/IDisplayConfigs.hal b/universal7885-common/hidl-packages/parts/hardware/parts/1.0/IDisplayConfigs.hal deleted file mode 100644 index 1f7be24..0000000 --- a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/IDisplayConfigs.hal +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Eureka Team -// -// 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 vendor.eureka.hardware.parts@1.0; - -interface IDisplayConfigs { - writeDisplay(Status enable, DisplaySys type); -}; diff --git a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/IFlashBrightness.hal b/universal7885-common/hidl-packages/parts/hardware/parts/1.0/IFlashBrightness.hal deleted file mode 100644 index 49154a3..0000000 --- a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/IFlashBrightness.hal +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Eureka Team -// -// 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 vendor.eureka.hardware.parts@1.0; - -interface IFlashBrightness { - setFlashlightWritable(int32_t value); - setFlashlightEnable(Status enable); - readFlashlightstats(bool s2mu106) generates (int32_t value); -}; diff --git a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/ISmartCharge.hal b/universal7885-common/hidl-packages/parts/hardware/parts/1.0/ISmartCharge.hal deleted file mode 100644 index 96bffb8..0000000 --- a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/ISmartCharge.hal +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Eureka Team -// -// 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 vendor.eureka.hardware.parts@1.0; - -interface ISmartCharge { - start(); - stop(); - setConfig(int32_t limit, int32_t restart); - getLimitCnt() generates (int32_t cnt); - getRestartCnt() generates (int32_t cnt); -}; diff --git a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/ISwapOnData.hal b/universal7885-common/hidl-packages/parts/hardware/parts/1.0/ISwapOnData.hal deleted file mode 100644 index 7bc4536..0000000 --- a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/ISwapOnData.hal +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Eureka Team -// -// 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 vendor.eureka.hardware.parts@1.0; - -interface ISwapOnData { - setSwapSize(int32_t size /* Size in megabytes */); - setSwapOn(); - setSwapOff(); - removeSwapFile(); - getSwapOnResult() generates (bool result); - isMutexLocked() generates (bool islocked); -}; diff --git a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/Android.bp b/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/Android.bp deleted file mode 100644 index 486aae0..0000000 --- a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/Android.bp +++ /dev/null @@ -1,26 +0,0 @@ -// FIXME: your file license if you have one - -cc_binary { - name: "vendor.eureka.hardware.parts@1.0-service", - defaults: ["eureka_defaults"], - srcs: [ - "Battery.cpp", - "FlashLight.cpp", - "Display.cpp", - "Swap.cpp", - "SwapHelpers.cpp", - "SmartChargingImpl.cpp", - "SmartCharge.cpp", - "service.cpp", - ], - cflags: ["-Wno-thread-safety-negative"], - shared_libs: [ - "libhidlbase", - "libutils", - "liblog", - "libfileio", - "vendor.eureka.hardware.parts@1.0", - ], - init_rc: ["vendor.eureka.hardware.parts@1.0-service.rc"], - vintf_fragments: ["vendor.eureka.hardware.parts@1.0.xml"], -} diff --git a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/Battery.cpp b/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/Battery.cpp deleted file mode 100644 index f99a423..0000000 --- a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/Battery.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (C) 2021 Eureka Team -// -// 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 - -#include "Battery.h" -#include "BatteryConstants.h" -#include "CachedClass.h" - -#include - -namespace vendor::eureka::hardware::parts::V1_0 { - -static BatteryStats *kCached = nullptr; - -static inline const char *BatterySysToPath(parts::V1_0::BatterySys type) { - switch (type) { - case BatterySys::CAPACITY_MAX: - return BATTERY_CAPACITY_MAX; - case BatterySys::TEMP: - return BATTERY_TEMP; - case BatterySys::CAPACITY_CURRENT: - return BATTERY_CAPACITY_CURRENT; - case BatterySys::CURRENT: - return BATTERY_CURRENT; - case BatterySys::FASTCHARGE: - return BATTERY_FASTCHARGE; - case BatterySys::CHARGE: - return BATTERY_CHARGE; - default: - return ""; - } -} - -// Methods from ::android::hardware::battery::V1_0::IBattery follow. -Return BatteryStats::getBatteryStats(parts::V1_0::BatterySys stats) { - return FileIO::readline(BatterySysToPath(stats)); -} - -Return BatteryStats::setBatteryWritable(parts::V1_0::BatterySys stats, - parts::V1_0::Status value) { - bool FastCharge = false; - if (FastCharge) - seteuid(ANDROID_SYSTEM_UID); - - FileIO::writeline(BatterySysToPath(stats), static_cast(value)); - - if (FastCharge) - seteuid(ANDROID_ROOT_UID); - - return Void(); -} - -IBatteryStats *BatteryStats::getInstance(void) { USE_CACHED(kCached); } -} // namespace vendor::eureka::hardware::parts::V1_0 diff --git a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/Battery.h b/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/Battery.h deleted file mode 100644 index ec646cb..0000000 --- a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/Battery.h +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2021 Eureka Team -// -// 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 - -#define ANDROID_SYSTEM_UID 1000 -#define ANDROID_ROOT_UID 0 - -namespace vendor::eureka::hardware::parts::V1_0 { - -using ::android::sp; -using ::android::hardware::Return; -using ::android::hardware::Void; - -struct BatteryStats : public IBatteryStats { - // Methods from ::vendor::eureka::hardware::parts::V1_0::IBatteryStats follow. - Return getBatteryStats(BatterySys stats) override; - Return setBatteryWritable(BatterySys stats, Status value) override; - - // Methods from ::android::hidl::base::V1_0::IBase follow. - static IBatteryStats *getInstance(void); -}; -} // namespace vendor::eureka::hardware::parts::V1_0 diff --git a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/BatteryConstants.h b/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/BatteryConstants.h deleted file mode 100644 index c066181..0000000 --- a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/BatteryConstants.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -constexpr const char *BATTERY_CAPACITY_MAX = - "/sys/devices/platform/battery/power_supply/battery/charge_full"; -constexpr const char *BATTERY_TEMP = - "/sys/devices/platform/battery/power_supply/battery/batt_temp"; -constexpr const char *BATTERY_CAPACITY_CURRENT = - "/sys/devices/platform/battery/power_supply/battery/capacity"; -constexpr const char *BATTERY_CURRENT = - "/sys/devices/platform/battery/power_supply/battery/current_now"; -constexpr const char *BATTERY_FASTCHARGE = "/sys/class/sec/switch/afc_disable"; -constexpr const char *BATTERY_CHARGE = - "/sys/devices/platform/battery/power_supply/battery/batt_slate_mode"; diff --git a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/CachedClass.h b/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/CachedClass.h deleted file mode 100644 index 96cea46..0000000 --- a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/CachedClass.h +++ /dev/null @@ -1,9 +0,0 @@ -template static inline C *cachedClass(C *cached) { - if (cached != nullptr) { - return cached; - } - cached = new C(); - return cached; -} - -#define USE_CACHED(cache) ({ return cachedClass((cache)); }) diff --git a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/Display.cpp b/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/Display.cpp deleted file mode 100644 index f8ad44a..0000000 --- a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/Display.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2021 Eureka Team -// -// 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 "Display.h" -#include "CachedClass.h" - -#include - -#include - -namespace vendor::eureka::hardware::parts::V1_0 { - -static DisplayConfigs *kCached; - -constexpr const char *SEC_TSP_CMD = "/sys/class/sec/tsp/cmd"; - -Return DisplayConfigs::writeDisplay(parts::V1_0::Status enable, - parts::V1_0::DisplaySys type) { - std::string writevalue; - if (type == DisplaySys::DOUBLE_TAP) { - writevalue = "aot_enable"; - } else if (type == DisplaySys::GLOVE_MODE) { - writevalue = "glove_mode"; - } - writevalue += ","; - if (enable == Status::ENABLE) { - writevalue += "1"; - } else { - writevalue += "0"; - } - FileIO::writeline(SEC_TSP_CMD, writevalue); - return Void(); -} - -IDisplayConfigs *DisplayConfigs::getInstance(void) { USE_CACHED(kCached); } -} // namespace vendor::eureka::hardware::parts::V1_0 diff --git a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/Display.h b/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/Display.h deleted file mode 100644 index 4f85b64..0000000 --- a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/Display.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2021 Eureka Team -// -// 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 - -namespace vendor::eureka::hardware::parts::V1_0 { - -using ::android::sp; -using ::android::hardware::Return; -using ::android::hardware::Void; - -struct DisplayConfigs : public IDisplayConfigs { - // Methods from ::vendor::eureka::hardware::parts::V1_0::IDisplayConfigs - // follow. - Return writeDisplay(Status enable, DisplaySys type); - // Methods from ::android::hidl::base::V1_0::IBase follow. - static IDisplayConfigs *getInstance(void); -}; -} // namespace vendor::eureka::hardware::parts::V1_0 diff --git a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/FlashLight.cpp b/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/FlashLight.cpp deleted file mode 100644 index 8f23f4a..0000000 --- a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/FlashLight.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2021 Eureka Team -// -// 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 "FlashLight.h" -#include "CachedClass.h" - -#include - -namespace vendor::eureka::hardware::parts::V1_0 { - -static FlashBrightness *kCached; - -constexpr const char *TORCH_ENABLE = - "/sys/class/camera/flash/torch_brightness_lvl_enable"; -constexpr const char *TORCH_LVL = - "/sys/class/camera/flash/torch_brightness_lvl"; - -// Methods from ::android::hardware::parts::V1_0::IFlashLight follow. -Return FlashBrightness::setFlashlightEnable(parts::V1_0::Status enable) { - FileIO::writeline(TORCH_ENABLE, static_cast(enable)); - return Void(); -} - -Return FlashBrightness::setFlashlightWritable(int32_t value) { - FileIO::writeline(TORCH_LVL, value); - return Void(); -} - -Return FlashBrightness::readFlashlightstats(bool s2mu106) { - return s2mu106 ? FileIO::readline(TORCH_LVL) / 21 - : FileIO::readline(TORCH_LVL); -} - -IFlashBrightness *FlashBrightness::getInstance(void) { USE_CACHED(kCached); } - -} // namespace vendor::eureka::hardware::parts::V1_0 diff --git a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/FlashLight.h b/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/FlashLight.h deleted file mode 100644 index 9c249bd..0000000 --- a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/FlashLight.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2021 Eureka Team -// -// 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 - -namespace vendor::eureka::hardware::parts::V1_0 { - -using ::android::sp; -using ::android::hardware::Return; -using ::android::hardware::Void; - -struct FlashBrightness : public IFlashBrightness { - // Methods from ::vendor::eureka::hardware::parts::V1_0::IFlashBrightness - // follow. - Return setFlashlightEnable(Status enable); - Return setFlashlightWritable(int32_t value); - Return readFlashlightstats(bool s2mu106); - // Methods from ::android::hidl::base::V1_0::IBase follow. - static IFlashBrightness *getInstance(void); -}; -} // namespace vendor::eureka::hardware::parts::V1_0 diff --git a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/SmartCharge.cpp b/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/SmartCharge.cpp deleted file mode 100644 index a4e1328..0000000 --- a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/SmartCharge.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (C) 2021 Eureka Team -// -// 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 "SmartCharge.h" -#include "CachedClass.h" -#include "SmartChargingImpl.h" -#include -#include -#include - -namespace vendor::eureka::hardware::parts::V1_0 { - -static SmartCharge *kCached; -static SmartChargeImpl *kInst = nullptr; - -static int limit = 0; -static int restart = 0; - -static int limit_stat = 0; -static int restart_stat = 0; - -Return SmartCharge::start(void) { - if (limit == 0 || restart == 0) - return Void(); - kInst = new SmartChargeImpl(limit, restart); - kInst->start(); - return Void(); -} - -Return SmartCharge::stop(void) { - if (kInst != nullptr) { - kInst->stop(); - limit_stat += kInst->charge_limit_cnt; - restart_stat += kInst->restart_cnt; - delete kInst; - kInst = nullptr; - } - return Void(); -} - -Return SmartCharge::setConfig(int32_t limit_user, int32_t restart_user) { - limit = limit_user; - restart = restart_user; - return Void(); -} - -Return SmartCharge::getLimitCnt(void) { return limit_stat; } - -Return SmartCharge::getRestartCnt(void) { return restart_stat; } - -ISmartCharge *SmartCharge::getInstance(void) { USE_CACHED(kCached); } -} // namespace vendor::eureka::hardware::parts::V1_0 diff --git a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/SmartCharge.h b/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/SmartCharge.h deleted file mode 100644 index 861e8ee..0000000 --- a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/SmartCharge.h +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2021 Eureka Team -// -// 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 - -namespace vendor::eureka::hardware::parts::V1_0 { - -using ::android::sp; -using ::android::hardware::Return; -using ::android::hardware::Void; - -struct SmartCharge : public ISmartCharge { - // Methods from ::vendor::eureka::hardware::parts::V1_0::ISmartCharge - // follow. - Return start(void); - Return stop(void); - Return setConfig(int32_t limit, int32_t restart); - Return getLimitCnt(void); - Return getRestartCnt(void); - // Methods from ::android::hidl::base::V1_0::IBase follow. - static ISmartCharge *getInstance(void); -}; -} // namespace vendor::eureka::hardware::parts::V1_0 diff --git a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/SmartChargingImpl.cpp b/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/SmartChargingImpl.cpp deleted file mode 100644 index f904865..0000000 --- a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/SmartChargingImpl.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include "SmartChargingImpl.h" - -#include -#include - -namespace vendor::eureka::hardware::parts::V1_0 { - -static std::thread *monitor; -static bool shouldRun = false; - -SmartChargeImpl::SmartChargeImpl(int limit, int restart) - : limit_percent(limit), restart_percent(restart) { - charge_limit_cnt = 0; - restart_cnt = 0; -} - -static void battery_monitor(const int limit_percent, const int restart_percent, - int *charge_limit_cnt, int *restart_cnt) { - while (shouldRun) { - auto batt = FileIO::readline(BATTERY_CAPACITY_CURRENT); - if (batt >= limit_percent) { - disableSysfs(BATTERY_CHARGE); - *charge_limit_cnt += 1; - } else if (batt <= restart_percent) { - enableSysfs(BATTERY_CHARGE); - *restart_cnt += 1; - } - std::this_thread::sleep_for(std::chrono::minutes(5)); - } -} - -void SmartChargeImpl::start(void) { - shouldRun = true; - monitor = new std::thread(battery_monitor, limit_percent, restart_percent, - &charge_limit_cnt, &restart_cnt); - monitor->join(); -} - -void SmartChargeImpl::stop(void) { - shouldRun = false; - monitor = nullptr; -} -} // namespace vendor::eureka::hardware::parts::V1_0 diff --git a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/SmartChargingImpl.h b/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/SmartChargingImpl.h deleted file mode 100644 index 9982260..0000000 --- a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/SmartChargingImpl.h +++ /dev/null @@ -1,30 +0,0 @@ -#include "BatteryConstants.h" - -#include -#include - -#include - -namespace vendor::eureka::hardware::parts::V1_0 { - -class SmartChargeImpl { -public: - SmartChargeImpl(int limit, int restart); - void start(void); - void stop(void); - - int charge_limit_cnt; - int restart_cnt; - -private: - const int limit_percent; - const int restart_percent; -}; - -} // namespace vendor::eureka::hardware::parts::V1_0 - -static inline void disableSysfs(const char *path) { - FileIO::writeline(path, 0); -} - -static inline void enableSysfs(const char *path) { FileIO::writeline(path, 1); } diff --git a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/Swap.cpp b/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/Swap.cpp deleted file mode 100644 index 695c4a0..0000000 --- a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/Swap.cpp +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (C) 2021 Eureka Team -// -// 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 "Swap.h" -#include "CachedClass.h" -#include -#include -#include -#include -#include -#include - -static int mSwapSize = 100; -extern int mkswap(const char *filename); -extern void mkfile(int filesize, const char *name); - -constexpr const char *SWAP_PATH = "/data/swap/swapfile"; - -namespace vendor::eureka::hardware::parts::V1_0 { - -static SwapOnData *kCached = nullptr; - -static std::mutex thread_lock; - -static bool swapOnRes = false; - -Return SwapOnData::setSwapSize(int32_t size) { - mSwapSize = size; - return Void(); -} - -Return SwapOnData::removeSwapFile(void) { - const std::lock_guard lock(thread_lock); - std::remove(SWAP_PATH); - return Void(); -} - -static void mkfile_swapon_thread(void) { - const std::lock_guard lock(thread_lock); - if (access(SWAP_PATH, F_OK) == 0) { - mkfile(mSwapSize * 10, SWAP_PATH); - mkswap(SWAP_PATH); - } - int res = - swapon(SWAP_PATH, (10 << SWAP_FLAG_PRIO_SHIFT) & SWAP_FLAG_PRIO_MASK); - swapOnRes = res == 0; -} - -Return SwapOnData::setSwapOn() { - const std::lock_guard lock(thread_lock); - std::thread mkswapfile(mkfile_swapon_thread); - mkswapfile.join(); - return Void(); -} - -static void swapoff_thread(void) { - const std::lock_guard lock(thread_lock); - swapoff(SWAP_PATH); -} - -Return SwapOnData::setSwapOff() { - std::thread swapoff(swapoff_thread); - swapoff.join(); - return Void(); -} -Return SwapOnData::getSwapOnResult(void) { return swapOnRes; } - -Return SwapOnData::isMutexLocked() { return !thread_lock.try_lock(); } - -ISwapOnData *SwapOnData::getInstance(void) { USE_CACHED(kCached); } - -} // namespace vendor::eureka::hardware::parts::V1_0 diff --git a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/Swap.h b/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/Swap.h deleted file mode 100644 index ee6420f..0000000 --- a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/Swap.h +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (C) 2021 Eureka Team -// -// 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 - -namespace vendor::eureka::hardware::parts::V1_0 { - -using ::android::sp; -using ::android::hardware::Return; -using ::android::hardware::Void; - -struct SwapOnData : public ISwapOnData { - // Methods from ::vendor::eureka::hardware::parts::V1_0::ISwapOnData - // follow. - Return setSwapSize(int32_t size); - Return setSwapOn(void); - Return removeSwapFile(void); - Return setSwapOff(void); - Return getSwapOnResult(void); - Return isMutexLocked(void); - // Methods from ::android::hidl::base::V2_0::IBase follow. - static ISwapOnData *getInstance(void); -}; -} // namespace vendor::eureka::hardware::parts::V1_0 diff --git a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/SwapHelpers.cpp b/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/SwapHelpers.cpp deleted file mode 100644 index 20b06f3..0000000 --- a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/SwapHelpers.cpp +++ /dev/null @@ -1,82 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -/* XXX This needs to be obtained from kernel headers. See b/9336527 */ -struct linux_swap_header { - char bootbits[1024]; /* Space for disklabel etc. */ - u_int32_t version; - u_int32_t last_page; - u_int32_t nr_badpages; - unsigned char sws_uuid[16]; - unsigned char sws_volume[16]; - u_int32_t padding[117]; - u_int32_t badpages[1]; -}; -void mkfile(int filesize, const char *path) { - std::vector empty(1024, 0); - std::ofstream ofs(std::string(path), std::ios::binary | std::ios::out); - - for (int i = 0; i < 1024 * filesize; i++) { - ofs.write(&empty[0], empty.size()); - } -} -#define MAGIC_SWAP_HEADER "SWAPSPACE2" -#define MAGIC_SWAP_HEADER_LEN 10 -#define MIN_PAGES 10 -int mkswap(const char *filename) { - int err = 0; - int fd; - ssize_t len; - off_t swap_size; - int pagesize; - struct linux_swap_header sw_hdr; - fd = open(filename, O_WRONLY | O_CLOEXEC); - if (fd < 0) { - err = errno; - return err; - } - pagesize = getpagesize(); - /* Determine the length of the swap file */ - swap_size = lseek(fd, 0, SEEK_END); - if (swap_size < MIN_PAGES * pagesize) { - err = -ENOSPC; - goto err; - } - if (lseek(fd, 0, SEEK_SET)) { - err = errno; - goto err; - } - memset(&sw_hdr, 0, sizeof(sw_hdr)); - sw_hdr.version = 1; - sw_hdr.last_page = (swap_size / pagesize) - 1; - len = write(fd, &sw_hdr, sizeof(sw_hdr)); - if (len != sizeof(sw_hdr)) { - err = errno; - goto err; - } - /* Write the magic header */ - if (lseek(fd, pagesize - MAGIC_SWAP_HEADER_LEN, SEEK_SET) < 0) { - err = errno; - goto err; - } - len = write(fd, MAGIC_SWAP_HEADER, MAGIC_SWAP_HEADER_LEN); - if (len != MAGIC_SWAP_HEADER_LEN) { - err = errno; - goto err; - } - if (fsync(fd) < 0) { - err = errno; - goto err; - } -err: - close(fd); - return err; -} diff --git a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/service.cpp b/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/service.cpp deleted file mode 100644 index 8c34de5..0000000 --- a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/service.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (C) 2021 Eureka Team -// -// 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 "vendor.eureka.hardware.parts@1.0-service" - -#include -#include -#include -#include -#include -#include - -#include "Battery.h" -#include "Display.h" -#include "FlashLight.h" -#include "SmartCharge.h" -#include "Swap.h" - -using android::sp; -using android::hardware::configureRpcThreadpool; -using android::hardware::joinRpcThreadpool; -using vendor::eureka::hardware::parts::V1_0::BatteryStats; -using vendor::eureka::hardware::parts::V1_0::DisplayConfigs; -using vendor::eureka::hardware::parts::V1_0::FlashBrightness; -using vendor::eureka::hardware::parts::V1_0::IBatteryStats; -using vendor::eureka::hardware::parts::V1_0::IDisplayConfigs; -using vendor::eureka::hardware::parts::V1_0::IFlashBrightness; -using vendor::eureka::hardware::parts::V1_0::ISmartCharge; -using vendor::eureka::hardware::parts::V1_0::ISwapOnData; -using vendor::eureka::hardware::parts::V1_0::SmartCharge; -using vendor::eureka::hardware::parts::V1_0::SwapOnData; - -template static inline int registerAsService(C kClass) { - int ret = -1; - if (kClass != nullptr) { - ret = kClass->registerAsService(); - } - return ret; -} - -int main() { - android::sp mBatteryService = BatteryStats::getInstance(); - android::sp mFlashLightService = - FlashBrightness::getInstance(); - android::sp mDisplayService = DisplayConfigs::getInstance(); - android::sp mSwapService = SwapOnData::getInstance(); - android::sp mSmartChargeService = SmartCharge::getInstance(); - - configureRpcThreadpool(4, true /*callerWillJoin*/); - - registerAsService(mBatteryService); - registerAsService(mFlashLightService); - registerAsService(mDisplayService); - registerAsService(mSwapService); - registerAsService(mSmartChargeService); - - joinRpcThreadpool(); - - return -1; // should never get here -} diff --git a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/vendor.eureka.hardware.parts@1.0-service.rc b/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/vendor.eureka.hardware.parts@1.0-service.rc deleted file mode 100644 index 9094590..0000000 --- a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/vendor.eureka.hardware.parts@1.0-service.rc +++ /dev/null @@ -1,12 +0,0 @@ -service parts-hal /system/bin/vendor.eureka.hardware.parts@1.0-service - interface vendor.eureka.hardware.parts@1.0::IBatteryStats default - interface vendor.eureka.hardware.parts@1.0::IDisplayConfigs default - interface vendor.eureka.hardware.parts@1.0::IFlashBrightness default - interface vendor.eureka.hardware.parts@1.0::ISwapOnData default - interface vendor.eureka.hardware.parts@1.0::ISmartCharge default - class hal - user root - group root - -on post-fs-data - mkdir /data/swap 0755 root root encryption=None diff --git a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/vendor.eureka.hardware.parts@1.0.xml b/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/vendor.eureka.hardware.parts@1.0.xml deleted file mode 100644 index 12792cb..0000000 --- a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/default/vendor.eureka.hardware.parts@1.0.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - vendor.eureka.hardware.parts - hwbinder - 1.0 - - IBatteryStats - default - - - IFlashBrightness - default - - - IDisplayConfigs - default - - - ISwapOnData - default - - - ISmartCharge - default - - - diff --git a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/types.hal b/universal7885-common/hidl-packages/parts/hardware/parts/1.0/types.hal deleted file mode 100644 index b8d8738..0000000 --- a/universal7885-common/hidl-packages/parts/hardware/parts/1.0/types.hal +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2021 Eureka Team -// -// 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 vendor.eureka.hardware.parts@1.0; - -enum BatterySys : int32_t { - CAPACITY_MAX, - TEMP, - CAPACITY_CURRENT, - CURRENT, - FASTCHARGE, - CHARGE, -}; - -enum DisplaySys : int32_t { - DOUBLE_TAP, - GLOVE_MODE, -}; - -enum Status : int32_t { - ENABLE = 1, - DISABLE = 0, -};