mirror of
https://github.com/chararomandroid/android_device_samsung_a20
synced 2026-08-21 11:55:31 -04:00
universal7885: RIP hidl-support
This commit is contained in:
parent
efc9f1063b
commit
9f508f12ae
43 changed files with 0 additions and 1348 deletions
|
|
@ -1,3 +0,0 @@
|
|||
hidl_package_root {
|
||||
name: "vendor.eureka",
|
||||
}
|
||||
|
|
@ -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,
|
||||
}
|
||||
|
|
@ -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);
|
||||
};
|
||||
|
|
@ -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,
|
||||
};
|
||||
|
|
@ -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,
|
||||
}
|
||||
|
|
@ -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);
|
||||
};
|
||||
|
|
@ -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,
|
||||
};
|
||||
|
|
@ -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,
|
||||
}
|
||||
|
|
@ -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);
|
||||
};
|
||||
|
|
@ -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"],
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
template <class C> static inline C *cachedClass(C *cached) {
|
||||
if (cached != nullptr) {
|
||||
return cached;
|
||||
}
|
||||
cached = new C();
|
||||
return cached;
|
||||
}
|
||||
|
||||
#define USE_CACHED(cache) ({ return cachedClass((cache)); })
|
||||
|
|
@ -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 <fstream>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <FileIO.h>
|
||||
#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<void> FMRadio::setManualFreq(float freq) {
|
||||
FileIO::writeline(FM_FREQ_CTL, freq * 1000);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> 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<V1_1::Status> 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<void> FMRadio::setChannelSpacing(V1_2::Space space) {
|
||||
mChannelSpacing = static_cast<int>(space);
|
||||
return Void();
|
||||
}
|
||||
Return<int32_t> FMRadio::getFreqFromSysfs() {
|
||||
return FileIO::readline(FM_FREQ_CTL);
|
||||
}
|
||||
Return<V1_2::Space> 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
|
||||
|
|
@ -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 <hidl/MQDescriptor.h>
|
||||
#include <hidl/Status.h>
|
||||
#include <vendor/eureka/hardware/fmradio/1.2/IFMRadio.h>
|
||||
|
||||
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<void> setManualFreq(float freq);
|
||||
Return<void> adjustFreqByStep(V1_0::Direction dir);
|
||||
// Methods from ::vendor::eureka::hardware::fmradio::V1_1::IFMRadio follow.
|
||||
Return<V1_1::Status> isAvailable();
|
||||
Return<int32_t> getFreqFromSysfs();
|
||||
// Methods from ::vendor::eureka::hardware::fmradio::V1_2::IFMRadio follow.
|
||||
Return<void> setChannelSpacing(V1_2::Space space);
|
||||
Return<V1_2::Space> getChannelSpacing();
|
||||
// Methods from ::android::hidl::base::V1_0::IBase follow.
|
||||
static IFMRadio *getInstance(void);
|
||||
};
|
||||
} // namespace vendor::eureka::hardware::fmradio::V1_2
|
||||
|
|
@ -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 <vendor/eureka/hardware/fmradio/1.2/IFMRadio.h>
|
||||
|
||||
#include <hidl/LegacySupport.h>
|
||||
|
||||
#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<IFMRadio> 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
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
<manifest version="1.0" type="framework">
|
||||
<hal>
|
||||
<name>vendor.eureka.hardware.fmradio</name>
|
||||
<transport>hwbinder</transport>
|
||||
<version>1.2</version>
|
||||
<interface>
|
||||
<name>IFMRadio</name>
|
||||
<instance>default</instance>
|
||||
</interface>
|
||||
</hal>
|
||||
</manifest>
|
||||
|
|
@ -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,
|
||||
};
|
||||
|
|
@ -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,
|
||||
}
|
||||
|
|
@ -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);
|
||||
};
|
||||
|
|
@ -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);
|
||||
};
|
||||
|
|
@ -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);
|
||||
};
|
||||
|
|
@ -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);
|
||||
};
|
||||
|
|
@ -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);
|
||||
};
|
||||
|
|
@ -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"],
|
||||
}
|
||||
|
|
@ -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 <unistd.h>
|
||||
|
||||
#include "Battery.h"
|
||||
#include "BatteryConstants.h"
|
||||
#include "CachedClass.h"
|
||||
|
||||
#include <FileIO.h>
|
||||
|
||||
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<int32_t> BatteryStats::getBatteryStats(parts::V1_0::BatterySys stats) {
|
||||
return FileIO::readline(BatterySysToPath(stats));
|
||||
}
|
||||
|
||||
Return<void> 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<int32_t>(value));
|
||||
|
||||
if (FastCharge)
|
||||
seteuid(ANDROID_ROOT_UID);
|
||||
|
||||
return Void();
|
||||
}
|
||||
|
||||
IBatteryStats *BatteryStats::getInstance(void) { USE_CACHED(kCached); }
|
||||
} // namespace vendor::eureka::hardware::parts::V1_0
|
||||
|
|
@ -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 <hidl/MQDescriptor.h>
|
||||
#include <hidl/Status.h>
|
||||
#include <vendor/eureka/hardware/parts/1.0/IBatteryStats.h>
|
||||
|
||||
#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<int32_t> getBatteryStats(BatterySys stats) override;
|
||||
Return<void> 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
|
||||
|
|
@ -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";
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
template <class C> static inline C *cachedClass(C *cached) {
|
||||
if (cached != nullptr) {
|
||||
return cached;
|
||||
}
|
||||
cached = new C();
|
||||
return cached;
|
||||
}
|
||||
|
||||
#define USE_CACHED(cache) ({ return cachedClass((cache)); })
|
||||
|
|
@ -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 <string>
|
||||
|
||||
#include <FileIO.h>
|
||||
|
||||
namespace vendor::eureka::hardware::parts::V1_0 {
|
||||
|
||||
static DisplayConfigs *kCached;
|
||||
|
||||
constexpr const char *SEC_TSP_CMD = "/sys/class/sec/tsp/cmd";
|
||||
|
||||
Return<void> 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
|
||||
|
|
@ -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 <hidl/MQDescriptor.h>
|
||||
#include <hidl/Status.h>
|
||||
#include <vendor/eureka/hardware/parts/1.0/IDisplayConfigs.h>
|
||||
|
||||
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<void> 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
|
||||
|
|
@ -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 <FileIO.h>
|
||||
|
||||
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<void> FlashBrightness::setFlashlightEnable(parts::V1_0::Status enable) {
|
||||
FileIO::writeline(TORCH_ENABLE, static_cast<int32_t>(enable));
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> FlashBrightness::setFlashlightWritable(int32_t value) {
|
||||
FileIO::writeline(TORCH_LVL, value);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<int32_t> 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
|
||||
|
|
@ -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 <hidl/MQDescriptor.h>
|
||||
#include <hidl/Status.h>
|
||||
#include <vendor/eureka/hardware/parts/1.0/IFlashBrightness.h>
|
||||
|
||||
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<void> setFlashlightEnable(Status enable);
|
||||
Return<void> setFlashlightWritable(int32_t value);
|
||||
Return<int32_t> readFlashlightstats(bool s2mu106);
|
||||
// Methods from ::android::hidl::base::V1_0::IBase follow.
|
||||
static IFlashBrightness *getInstance(void);
|
||||
};
|
||||
} // namespace vendor::eureka::hardware::parts::V1_0
|
||||
|
|
@ -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 <fstream>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
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<void> SmartCharge::start(void) {
|
||||
if (limit == 0 || restart == 0)
|
||||
return Void();
|
||||
kInst = new SmartChargeImpl(limit, restart);
|
||||
kInst->start();
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> 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<void> SmartCharge::setConfig(int32_t limit_user, int32_t restart_user) {
|
||||
limit = limit_user;
|
||||
restart = restart_user;
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<int32_t> SmartCharge::getLimitCnt(void) { return limit_stat; }
|
||||
|
||||
Return<int32_t> SmartCharge::getRestartCnt(void) { return restart_stat; }
|
||||
|
||||
ISmartCharge *SmartCharge::getInstance(void) { USE_CACHED(kCached); }
|
||||
} // namespace vendor::eureka::hardware::parts::V1_0
|
||||
|
|
@ -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 <hidl/MQDescriptor.h>
|
||||
#include <hidl/Status.h>
|
||||
#include <vendor/eureka/hardware/parts/1.0/ISmartCharge.h>
|
||||
|
||||
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<void> start(void);
|
||||
Return<void> stop(void);
|
||||
Return<void> setConfig(int32_t limit, int32_t restart);
|
||||
Return<int32_t> getLimitCnt(void);
|
||||
Return<int32_t> getRestartCnt(void);
|
||||
// Methods from ::android::hidl::base::V1_0::IBase follow.
|
||||
static ISmartCharge *getInstance(void);
|
||||
};
|
||||
} // namespace vendor::eureka::hardware::parts::V1_0
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
#include "SmartChargingImpl.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
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
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
#include "BatteryConstants.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
#include <FileIO.h>
|
||||
|
||||
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); }
|
||||
|
|
@ -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 <fstream>
|
||||
#include <iostream>
|
||||
#include <mutex>
|
||||
#include <sys/swap.h>
|
||||
#include <thread>
|
||||
#include <unistd.h>
|
||||
|
||||
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<void> SwapOnData::setSwapSize(int32_t size) {
|
||||
mSwapSize = size;
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> SwapOnData::removeSwapFile(void) {
|
||||
const std::lock_guard<std::mutex> lock(thread_lock);
|
||||
std::remove(SWAP_PATH);
|
||||
return Void();
|
||||
}
|
||||
|
||||
static void mkfile_swapon_thread(void) {
|
||||
const std::lock_guard<std::mutex> 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<void> SwapOnData::setSwapOn() {
|
||||
const std::lock_guard<std::mutex> lock(thread_lock);
|
||||
std::thread mkswapfile(mkfile_swapon_thread);
|
||||
mkswapfile.join();
|
||||
return Void();
|
||||
}
|
||||
|
||||
static void swapoff_thread(void) {
|
||||
const std::lock_guard<std::mutex> lock(thread_lock);
|
||||
swapoff(SWAP_PATH);
|
||||
}
|
||||
|
||||
Return<void> SwapOnData::setSwapOff() {
|
||||
std::thread swapoff(swapoff_thread);
|
||||
swapoff.join();
|
||||
return Void();
|
||||
}
|
||||
Return<bool> SwapOnData::getSwapOnResult(void) { return swapOnRes; }
|
||||
|
||||
Return<bool> SwapOnData::isMutexLocked() { return !thread_lock.try_lock(); }
|
||||
|
||||
ISwapOnData *SwapOnData::getInstance(void) { USE_CACHED(kCached); }
|
||||
|
||||
} // namespace vendor::eureka::hardware::parts::V1_0
|
||||
|
|
@ -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 <hidl/MQDescriptor.h>
|
||||
#include <hidl/Status.h>
|
||||
#include <vendor/eureka/hardware/parts/1.0/ISwapOnData.h>
|
||||
|
||||
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<void> setSwapSize(int32_t size);
|
||||
Return<void> setSwapOn(void);
|
||||
Return<void> removeSwapFile(void);
|
||||
Return<void> setSwapOff(void);
|
||||
Return<bool> getSwapOnResult(void);
|
||||
Return<bool> isMutexLocked(void);
|
||||
// Methods from ::android::hidl::base::V2_0::IBase follow.
|
||||
static ISwapOnData *getInstance(void);
|
||||
};
|
||||
} // namespace vendor::eureka::hardware::parts::V1_0
|
||||
|
|
@ -1,82 +0,0 @@
|
|||
#include <cerrno>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <fcntl.h>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/swap.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <vector>
|
||||
/* 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<char> 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;
|
||||
}
|
||||
|
|
@ -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 <hidl/LegacySupport.h>
|
||||
#include <vendor/eureka/hardware/parts/1.0/IBatteryStats.h>
|
||||
#include <vendor/eureka/hardware/parts/1.0/IDisplayConfigs.h>
|
||||
#include <vendor/eureka/hardware/parts/1.0/IFlashBrightness.h>
|
||||
#include <vendor/eureka/hardware/parts/1.0/ISmartCharge.h>
|
||||
#include <vendor/eureka/hardware/parts/1.0/ISwapOnData.h>
|
||||
|
||||
#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 <class C> static inline int registerAsService(C kClass) {
|
||||
int ret = -1;
|
||||
if (kClass != nullptr) {
|
||||
ret = kClass->registerAsService();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int main() {
|
||||
android::sp<IBatteryStats> mBatteryService = BatteryStats::getInstance();
|
||||
android::sp<IFlashBrightness> mFlashLightService =
|
||||
FlashBrightness::getInstance();
|
||||
android::sp<IDisplayConfigs> mDisplayService = DisplayConfigs::getInstance();
|
||||
android::sp<ISwapOnData> mSwapService = SwapOnData::getInstance();
|
||||
android::sp<ISmartCharge> mSmartChargeService = SmartCharge::getInstance();
|
||||
|
||||
configureRpcThreadpool(4, true /*callerWillJoin*/);
|
||||
|
||||
registerAsService(mBatteryService);
|
||||
registerAsService(mFlashLightService);
|
||||
registerAsService(mDisplayService);
|
||||
registerAsService(mSwapService);
|
||||
registerAsService(mSmartChargeService);
|
||||
|
||||
joinRpcThreadpool();
|
||||
|
||||
return -1; // should never get here
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
<manifest version="1.0" type="framework">
|
||||
<hal>
|
||||
<name>vendor.eureka.hardware.parts</name>
|
||||
<transport>hwbinder</transport>
|
||||
<version>1.0</version>
|
||||
<interface>
|
||||
<name>IBatteryStats</name>
|
||||
<instance>default</instance>
|
||||
</interface>
|
||||
<interface>
|
||||
<name>IFlashBrightness</name>
|
||||
<instance>default</instance>
|
||||
</interface>
|
||||
<interface>
|
||||
<name>IDisplayConfigs</name>
|
||||
<instance>default</instance>
|
||||
</interface>
|
||||
<interface>
|
||||
<name>ISwapOnData</name>
|
||||
<instance>default</instance>
|
||||
</interface>
|
||||
<interface>
|
||||
<name>ISmartCharge</name>
|
||||
<instance>default</instance>
|
||||
</interface>
|
||||
</hal>
|
||||
</manifest>
|
||||
|
|
@ -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,
|
||||
};
|
||||
Loading…
Reference in a new issue