universal7885: SamsungParts: Inital HAL test

This commit is contained in:
roynatech2544 2021-10-25 16:58:45 +09:00
commit e04e91f54f
No known key found for this signature in database
GPG key ID: 9675C32163D88D30
15 changed files with 318 additions and 150 deletions

View file

@ -0,0 +1,21 @@
cc_library_shared {
name: "libsamsungparts_jni",
cflags: [
"-Wall",
"-Wextra",
"-Wno-unused-parameter",
"-Werror",
],
srcs: ["*.cpp"],
header_libs: ["jni_headers"],
shared_libs: [
"libhidlbase",
"liblog",
"libutils",
"vendor.eureka.hardware.battery@1.0",
"vendor.eureka.hardware.flashlight@1.0",
"vendor.eureka.hardware.gpu@1.0",
"vendor.eureka.security.selinux@1.0",
]
}

View file

@ -0,0 +1,93 @@
#include <vendor/eureka/hardware/battery/1.0/IBattery.h>
#include <hidl/Status.h>
#include <hidl/LegacySupport.h>
#include <hardware/hardware.h>
#include <hidl/HidlSupport.h>
#include "jni.h"
using vendor::eureka::hardware::battery::V1_0::IBattery;
using vendor::eureka::hardware::battery::V1_0::SysfsType;
using vendor::eureka::hardware::battery::V1_0::Number;
using android::sp;
extern "C" JNIEXPORT void
JNICALL
Java_com_eurekateam_samsungextras_interfaces_Battery_setChargeSysfs
(JNIEnv *env , __unused jclass obj, jint enable) {
android::sp<IBattery> service = IBattery::getService();
if (enable == 1){
service->setBatteryWritable(SysfsType::CHARGE, Number::ENABLE);
}else{
service->setBatteryWritable(SysfsType::CHARGE, Number::DISABLE);
}
}
extern "C" JNIEXPORT jint
JNICALL
Java_com_eurekateam_samsungextras_interfaces_Battery_getChargeSysfs
(JNIEnv *env , __unused jclass obj) {
android::sp<IBattery> service = IBattery::getService();
int ret = service->getBatteryStats(SysfsType::CHARGE);
return ret;
}
extern "C"
JNIEXPORT void JNICALL
Java_com_eurekateam_samsungextras_interfaces_Battery_setFastCharge(JNIEnv *env, __unused jclass obj,
jint enable) {
android::sp<IBattery> service = IBattery::getService();
if (enable == 1){
service->setBatteryWritable(SysfsType::FASTCHARGE, Number::ENABLE);
}else{
service->setBatteryWritable(SysfsType::FASTCHARGE, Number::DISABLE);
}
}
extern "C"
JNIEXPORT jint JNICALL
Java_com_eurekateam_samsungextras_interfaces_Battery_getFastChargeSysfs(JNIEnv *env, __unused
jclass obj) {
android::sp<IBattery> service = IBattery::getService();
int ret = service->getBatteryStats(SysfsType::FASTCHARGE);
return ret;
}
extern "C"
JNIEXPORT jint JNICALL
Java_com_eurekateam_samsungextras_interfaces_Battery_getGeneralBatteryStats(JNIEnv *env,
__unused
jclass obj, jint id) {
/**
* id:
* 1 = BATTERY_CAPACITY_MAX
* 2 = BATTERY_CAPACITY_CURRENT (%)
* 3 = BATTERY_CAPACITY_CURRENT (mAh)
* 4 = CHARGING_STATE
* 5 = BATTERY_TEMP
* 6 = BATTERY_CURRENT
*/
android::sp<IBattery> service = IBattery::getService();
int ret;
switch (id) {
case 1:
ret = service->getBatteryStats(SysfsType::CAPACITY_MAX) / 1000;
case 2:
ret = service->getBatteryStats(SysfsType::CAPACITY_CURRENT);
case 3:
ret = (float) service->getBatteryStats(SysfsType::CAPACITY_CURRENT) *
(float) service->getBatteryStats(SysfsType::CAPACITY_MAX) / 100000;
case 4:
if (service->getBatteryStats(SysfsType::CURRENT) > 0){
ret = 1;
}else{
ret = 0;
}
case 5:
ret = service->getBatteryStats(SysfsType::TEMP) / 10;
case 6:
ret = service->getBatteryStats(SysfsType::CURRENT);
default:
ret = -1;
}
return ret;
}

View file

@ -0,0 +1,56 @@
#include <vendor/eureka/hardware/flashlight/1.0/IFlashlight.h>
#include <hidl/Status.h>
#include <hidl/LegacySupport.h>
#include <hardware/hardware.h>
#include <hidl/HidlSupport.h>
#include "jni.h"
using vendor::eureka::hardware::battery::V1_0::IFlashlight;
using vendor::eureka::hardware::battery::V1_0::Device;
using vendor::eureka::hardware::battery::V1_0::Enable;
using vendor::eureka::hardware::battery::V1_0::Number;
using android::sp;
extern "C"
JNIEXPORT void JNICALL
Java_com_eurekateam_samsungextras_interfaces_Flashlight_setFlash(JNIEnv *env, __unused jclass obj,
jint value) {
android::sp<IFlashlight> service = IFlashlight::getService();
service->setFlashlightEnable(Enable::ENABLE);
switch (value) {
case 1:
service->setFlashlightWritable(Number::ONEUI);
case 2:
service->setFlashlightWritable(Number::TWOUI);
case 3:
service->setFlashlightWritable(Number::THREEUI);
case 4:
service->setFlashlightWritable(Number::FOURUI);
case 5:
service->setFlashlightWritable(Number::FIVEUI);
case 6:
service->setFlashlightWritable(Number::SIXUI);
case 7:
service->setFlashlightWritable(Number::SEVENUI);
case 8:
service->setFlashlightWritable(Number::EIGHTUI);
case 9:
service->setFlashlightWritable(Number::NINEUI);
case 10:
service->setFlashlightWritable(Number::TENUI);
}
}
extern "C"
JNIEXPORT jint JNICALL
Java_com_eurekateam_samsungextras_interfaces_Flashlight_getFlash(JNIEnv *env, jclass clazz,
jint isA10) {
android::sp<IFlashlight> service = IFlashlight::getService();
int ret;
if(isA10 == 1) {
ret = service->readFlashlightstats(Device::A10);
}else{
ret = service->readFlashlightstats(Device::NOTA10);
}
return ret;
}

View file

@ -0,0 +1,40 @@
#include <vendor/eureka/hardware/gpu/1.0/IGpu.h>
#include <hidl/Status.h>
#include <hidl/LegacySupport.h>
#include <hardware/hardware.h>
#include <hidl/HidlSupport.h>
#include "jni.h"
using vendor::eureka::hardware::gpu::V1_0::IGpu;
using vendor::eureka::hardware::gpu::V1_0::Enable;
using android::sp;
extern "C" JNIEXPORT void
JNICALL
Java_com_eurekateam_samsungextras_interfaces_Battery_setChargeSysfs
(JNIEnv *env , __unused jclass obj, jint enable) {
android::sp<IBattery> service = IBattery::getService();
if (enable == 1){
service->setBatteryWritable(SysfsType::CHARGE, Number::ENABLE);
}else{
service->setBatteryWritable(SysfsType::CHARGE, Number::DISABLE);
}
}
extern "C"
JNIEXPORT void JNICALL
Java_com_eurekateam_samsungextras_interfaces_GPU_setGPU(JNIEnv *env, jclass clazz, jint enable) {
android::sp<IGpu> service = IGpu::getService();
if (enable == 1){
service->setGpuWritable(Enable::ENABLE);
}else{
service->setGpuWritable(Enable::DISABLE);
}
}
extern "C"
JNIEXPORT jint JNICALL
Java_com_eurekateam_samsungextras_interfaces_GPU_getGPU(JNIEnv *env, jclass clazz) {
android::sp<IGpu> service = IGpu::getService();
int ret = service->readGpustats();
return ret;
}

View file

@ -0,0 +1,29 @@
#include <vendor/eureka/security/selinux/1.0/ISELinux.h>
#include <hidl/Status.h>
#include <hidl/LegacySupport.h>
#include <hardware/hardware.h>
#include <hidl/HidlSupport.h>
#include "jni.h"
using vendor::eureka::security::selinux::V1_0::ISELinux;
using vendor::eureka::security::selinux::V1_0::Enable;
using android::sp;
extern "C"
JNIEXPORT jint JNICALL
Java_com_eurekateam_samsungextras_interfaces_SELinux_getSELinux(JNIEnv *env, jclass clazz) {
android::sp<ISELinux> service = ISELinux::getService();
int ret = service->readSELinuxstats();
return ret;
}
extern "C"
JNIEXPORT void JNICALL
Java_com_eurekateam_samsungextras_interfaces_SELinux_setSELinux(JNIEnv *env, jclass clazz,
jint enable) {
android::sp<ISELinux> service = ISELinux::getService();
if (enable == 1){
service->setSELinuxWritable(Enable::ENABLE);
}else{
service->setSELinuxWritable(Enable::DISABLE);
}
}