universal7885: Remove LineageOS hardware samsung deps

And track it with vendorsetup.sh
This commit is contained in:
roynatech2544 2022-04-29 16:18:14 +09:00
commit e53d5db120
No known key found for this signature in database
GPG key ID: 50ABF73F0D19445D
101 changed files with 3 additions and 3387 deletions

View file

@ -0,0 +1,3 @@
hidl_package_root{
name: "vendor.eureka",
}

View file

@ -0,0 +1,12 @@
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,
}

View file

@ -0,0 +1,20 @@
// 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);
};

View file

@ -0,0 +1,20 @@
// 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,
};

View file

@ -0,0 +1,13 @@
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,
}

View file

@ -0,0 +1,22 @@
// 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);
};

View file

@ -0,0 +1,20 @@
// 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,
};

View file

@ -0,0 +1,14 @@
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,
}

View file

@ -0,0 +1,22 @@
// 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);
};

View file

@ -0,0 +1,19 @@
// FIXME: your file license if you have one
cc_binary {
name: "vendor.eureka.hardware.fmradio@1.2-service",
srcs: [
"FMRadio.cpp",
"service.cpp",
],
shared_libs: [
"libhidlbase",
"libutils",
"liblog",
"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" ],
}

View file

@ -0,0 +1,84 @@
// 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>
static int mChannelSpacing = 3;
namespace vendor::eureka::hardware::fmradio::V1_2 {
Return<void> FMRadio::setManualFreq(float freq) {
std::ofstream file;
file.open("/sys/devices/virtual/s610_radio/s610_radio/radio_freq_ctrl");
file << freq * 1000;
file.close();
return Void();
}
Return<void> FMRadio::adjustFreqByStep(fmradio::V1_0::Direction dir) {
std::ofstream file;
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);
}
file.open("/sys/devices/virtual/s610_radio/s610_radio/radio_freq_seek");
file << value;
file.close();
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 = (int)space;
return Void();
}
Return<int32_t> FMRadio::getFreqFromSysfs() {
std::ifstream file;
std::string value;
file.open("/sys/devices/virtual/s610_radio/s610_radio/radio_freq_ctrl");
std::getline(file, value);
file.close();
return std::stoi(value);
}
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) { return new FMRadio(); }
} // namespace vendor::eureka::hardware::fmradio::V1_2

View file

@ -0,0 +1,44 @@
// 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

View file

@ -0,0 +1,47 @@
// 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
}

View file

@ -0,0 +1,7 @@
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

View file

@ -0,0 +1,11 @@
<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>

View file

@ -0,0 +1,23 @@
// 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,
};

View file

@ -0,0 +1,13 @@
hidl_interface {
name: "vendor.eureka.hardware.parts@1.0",
root: "vendor.eureka",
srcs: [
"types.hal",
"IBatteryStats.hal",
"IFlashBrightness.hal",
"IDisplayConfigs.hal",
"ISwapOnData.hal",
],
interfaces: [ "android.hidl.base@1.0" ],
gen_java: false,
}

View file

@ -0,0 +1,20 @@
// 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(SysfsType stats) generates (int32_t result);
setBatteryWritable(SysfsType stats, Number value);
};

View file

@ -0,0 +1,19 @@
// 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(Number enable, Display type);
};

View file

@ -0,0 +1,21 @@
// 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(Value value);
setFlashlightEnable(Number enable);
readFlashlightstats(Device device) generates (int32_t value);
};

View file

@ -0,0 +1,21 @@
// 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();
};

View file

@ -0,0 +1,20 @@
// FIXME: your file license if you have one
cc_binary {
name: "vendor.eureka.hardware.parts@1.0-service",
srcs: [
"Battery.cpp",
"FlashLight.cpp",
"Display.cpp",
"Swap.cpp",
"service.cpp",
],
shared_libs: [
"libhidlbase",
"libutils",
"liblog",
"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" ],
}

View file

@ -0,0 +1,111 @@
// 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 "Battery.h"
#include <fstream>
#include <iostream>
#include <sstream>
#include <unistd.h>
namespace vendor::eureka::hardware::parts::V1_0 {
// Methods from ::android::hardware::battery::V1_0::IBattery follow.
Return<int32_t> BatteryStats::getBatteryStats(parts::V1_0::SysfsType stats) {
std::ifstream file;
std::string filename;
switch (stats) {
case SysfsType::CAPACITY_MAX:
filename = "/sys/devices/platform/battery/power_supply/battery/charge_full";
break;
case SysfsType::TEMP:
filename = "/sys/devices/platform/battery/power_supply/battery/batt_temp";
break;
case SysfsType::CAPACITY_CURRENT:
filename = "/sys/devices/platform/battery/power_supply/battery/capacity";
break;
case SysfsType::CURRENT:
filename = "/sys/devices/platform/battery/power_supply/battery/current_now";
break;
case SysfsType::FASTCHARGE:
filename = "/sys/class/sec/switch/afc_disable";
break;
case SysfsType::CHARGE:
filename =
"/sys/devices/platform/battery/power_supply/battery/batt_slate_mode";
break;
default:
filename = "";
break;
}
std::string value;
int32_t intvalue;
file.open(filename);
if (file.is_open()) {
getline(file, value);
file.close();
std::stringstream val(value);
val >> intvalue;
return intvalue;
}
return -1;
}
Return<void> BatteryStats::setBatteryWritable(parts::V1_0::SysfsType stats,
parts::V1_0::Number value) {
std::ofstream file;
std::string filename;
bool FastCharge = false;
switch (stats) {
case SysfsType::CAPACITY_MAX:
filename = "/sys/devices/platform/battery/power_supply/battery/charge_full";
break;
case SysfsType::TEMP:
filename = "/sys/devices/platform/battery/power_supply/battery/batt_temp";
break;
case SysfsType::CAPACITY_CURRENT:
filename = "/sys/devices/platform/battery/power_supply/battery/capacity";
break;
case SysfsType::CURRENT:
filename = "/sys/devices/platform/battery/power_supply/battery/current_now";
break;
case SysfsType::FASTCHARGE:
filename = "/sys/class/sec/switch/afc_disable";
FastCharge = true;
break;
case SysfsType::CHARGE:
filename =
"/sys/devices/platform/battery/power_supply/battery/batt_slate_mode";
break;
default:
filename = "";
break;
}
if (FastCharge)
seteuid(ANDROID_SYSTEM_UID);
file.open(filename);
int write;
if (value == Number::ENABLE) {
write = 1;
} else {
write = 0;
}
file << write;
file.close();
if (FastCharge)
seteuid(ANDROID_ROOT_UID);
return Void();
}
IBatteryStats *BatteryStats::getInstance(void) { return new BatteryStats(); }
} // namespace vendor::eureka::hardware::parts::V1_0

View file

@ -0,0 +1,42 @@
// 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::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 BatteryStats : public IBatteryStats {
// Methods from ::vendor::eureka::hardware::parts::V1_0::IBatteryStats follow.
Return<int32_t> getBatteryStats(SysfsType stats) override;
Return<void> setBatteryWritable(SysfsType stats, Number value) override;
// Methods from ::android::hidl::base::V1_0::IBase follow.
static IBatteryStats *getInstance(void);
};
} // namespace vendor::eureka::hardware::parts::V1_0

View file

@ -0,0 +1,45 @@
// 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 <fstream>
#include <iostream>
#include <sstream>
namespace vendor::eureka::hardware::parts::V1_0 {
Return<void> DisplayConfigs::writeDisplay(parts::V1_0::Number enable,
parts::V1_0::Display type) {
std::ofstream file;
std::string writevalue;
if (type == Display::DOUBLE_TAP) {
writevalue = "aot_enable";
} else if (type == Display::GLOVE_MODE) {
writevalue = "glove_mode";
}
writevalue += ",";
if (enable == Number::ENABLE) {
writevalue += "1";
} else {
writevalue += "0";
}
file.open("/sys/class/sec/tsp/cmd");
file << writevalue;
file.close();
return Void();
}
IDisplayConfigs *DisplayConfigs::getInstance(void) {
return new DisplayConfigs();
}
} // namespace vendor::eureka::hardware::parts::V1_0

View file

@ -0,0 +1,38 @@
// 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::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 DisplayConfigs : public IDisplayConfigs {
// Methods from ::vendor::eureka::hardware::parts::V1_0::IDisplayConfigs
// follow.
Return<void> writeDisplay(Number enable, Display type);
// Methods from ::android::hidl::base::V1_0::IBase follow.
static IDisplayConfigs *getInstance(void);
};
} // namespace vendor::eureka::hardware::parts::V1_0

View file

@ -0,0 +1,76 @@
// 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 <fstream>
#include <iostream>
#include <sstream>
namespace vendor::eureka::hardware::parts::V1_0 {
// Methods from ::android::hardware::parts::V1_0::IFlashLight follow.
Return<void> FlashBrightness::setFlashlightEnable(parts::V1_0::Number enable) {
std::ofstream file;
std::string writevalue;
switch (enable) {
case Number::ENABLE:
writevalue = "1";
break;
case Number::DISABLE:
writevalue = "0";
break;
default:
writevalue = "";
break;
}
file.open("/sys/class/camera/flash/torch_brightness_lvl_enable");
file << writevalue;
file.close();
return Void();
}
Return<void> FlashBrightness::setFlashlightWritable(parts::V1_0::Value value) {
std::ofstream file;
std::string writevalue = std::to_string((int)value);
file.open("/sys/class/camera/flash/torch_brightness_lvl");
file << writevalue;
file.close();
return Void();
}
Return<int32_t>
FlashBrightness::readFlashlightstats(parts::V1_0::Device device) {
std::ifstream file;
std::string value;
int32_t intvalue;
file.open("/sys/class/camera/flash/torch_brightness_lvl");
if (file.is_open()) {
getline(file, value);
file.close();
std::stringstream val(value);
val >> intvalue;
if (device == Device::A10) {
return intvalue;
} else if (device == Device::NOTA10) {
return intvalue / 21;
}
// Never Here
return -1;
}
return -1;
}
IFlashBrightness *FlashBrightness::getInstance(void) {
return new FlashBrightness();
}
} // namespace vendor::eureka::hardware::parts::V1_0

View file

@ -0,0 +1,40 @@
// 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::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 FlashBrightness : public IFlashBrightness {
// Methods from ::vendor::eureka::hardware::parts::V1_0::IFlashBrightness
// follow.
Return<void> setFlashlightEnable(Number enable);
Return<void> setFlashlightWritable(Value value);
Return<int32_t> readFlashlightstats(Device device);
// Methods from ::android::hidl::base::V1_0::IBase follow.
static IFlashBrightness *getInstance(void);
};
} // namespace vendor::eureka::hardware::parts::V1_0

View file

@ -0,0 +1,50 @@
// 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 <fstream>
#include <iostream>
static int mSwapSize = 100;
#define SWAP_PATH "/data/swap/swapfile"
using namespace std;
namespace vendor::eureka::hardware::parts::V1_0 {
Return<void> SwapOnData::setSwapSize(int32_t size) {
mSwapSize = size;
return Void();
}
Return<void> SwapOnData::setSwapOn() {
string cmd = string("dd if=/dev/zero of=") + string(SWAP_PATH) +
string(" bs=") + std::to_string(mSwapSize) + "M count=10";
system(cmd.c_str());
cmd = string("mkswap ") + string(SWAP_PATH);
system(cmd.c_str());
cmd = string("swapon -p 99 ") + string(SWAP_PATH);
system(cmd.c_str());
return Void();
}
Return<void> SwapOnData::setSwapOff() {
std::string cmd = string("swapoff ") + string(SWAP_PATH);
system(cmd.c_str());
cmd = string("rm ") + string(SWAP_PATH);
system(cmd.c_str());
return Void();
}
ISwapOnData *SwapOnData::getInstance(void) { return new SwapOnData(); }
} // namespace vendor::eureka::hardware::parts::V1_0

View file

@ -0,0 +1,40 @@
// 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::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 SwapOnData : public ISwapOnData {
// Methods from ::vendor::eureka::hardware::parts::V1_0::ISwapOnData
// follow.
Return<void> setSwapSize(int32_t size);
Return<void> setSwapOn();
Return<void> setSwapOff();
// Methods from ::android::hidl::base::V2_0::IBase follow.
static ISwapOnData *getInstance(void);
};
} // namespace vendor::eureka::hardware::parts::V1_0

View file

@ -0,0 +1,92 @@
// 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/ISwapOnData.h>
#include "Battery.h"
#include "Display.h"
#include "FlashLight.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::ISwapOnData;
using vendor::eureka::hardware::parts::V1_0::SwapOnData;
int main() {
int ret;
android::sp<IBatteryStats> mBatteryService = BatteryStats::getInstance();
android::sp<IFlashBrightness> mFlashLightService =
FlashBrightness::getInstance();
android::sp<IDisplayConfigs> mDisplayService = DisplayConfigs::getInstance();
android::sp<ISwapOnData> mSwapService = SwapOnData::getInstance();
configureRpcThreadpool(4, true /*callerWillJoin*/);
if (mBatteryService != nullptr) {
ret = mBatteryService->registerAsService();
if (ret != 0) {
ALOGE("Can't register instance of Battery HAL, nullptr");
} else {
ALOGI("registered Battery HAL");
}
} else {
ALOGE("Can't create instance of Battery HAL, nullptr");
}
if (mFlashLightService != nullptr) {
ret = mFlashLightService->registerAsService();
if (ret != 0) {
ALOGE("Can't register instance of FlashLight HAL, nullptr");
} else {
ALOGI("registered FlashLight HAL");
}
} else {
ALOGE("Can't create instance of FlashLight HAL, nullptr");
}
if (mDisplayService != nullptr) {
ret = mDisplayService->registerAsService();
if (ret != 0) {
ALOGE("Can't register instance of Display HAL, nullptr");
} else {
ALOGI("registered Display HAL");
}
} else {
ALOGE("Can't create instance of Display HAL, nullptr");
}
if (mSwapService != nullptr) {
ret = mSwapService->registerAsService();
if (ret != 0) {
ALOGE("Can't register instance of Swap HAL, nullptr");
} else {
ALOGI("registered Swap HAL");
}
} else {
ALOGE("Can't create instance of Swap HAL, nullptr");
}
joinRpcThreadpool();
return -1; // should never get here
}

View file

@ -0,0 +1,11 @@
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
class hal
user root
group root
on post-fs-data
mkdir /data/swap 0755 root root encryption=None

View file

@ -0,0 +1,23 @@
<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>
</hal>
</manifest>

View file

@ -0,0 +1,52 @@
// 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 SysfsType : int32_t {
CAPACITY_MAX,
TEMP,
CAPACITY_CURRENT,
CURRENT,
FASTCHARGE,
CHARGE,
};
enum Display : int32_t {
DOUBLE_TAP,
GLOVE_MODE,
};
enum Number : int32_t {
ENABLE = 1,
DISABLE = 0,
};
enum Device : int32_t {
A10,
NOTA10,
};
enum Value : int32_t {
ONEUI = 1,
TWOUI,
THREEUI,
FOURUI,
FIVEUI,
SIXUI,
SEVENUI,
EIGHTUI,
NINEUI,
TENUI = 10,
};