universal7885: parts: hidl: Make some changes

* Drop useless selinux and gpu
* Instead put display configs (DT2W, Glove mode)

Signed-off-by: roynatech2544 <whiteshell2544@naver.com>
This commit is contained in:
roynatech2544 2022-04-12 11:48:57 +09:00
commit 7156ddca8f
20 changed files with 90 additions and 236 deletions

View file

@ -3,11 +3,10 @@ hidl_interface {
root: "vendor.eureka", root: "vendor.eureka",
srcs: [ srcs: [
"types.hal", "types.hal",
"IBattery.hal", "IBatteryStats.hal",
"IFlashLight.hal", "IFlashBrightness.hal",
"IGpu.hal", "IDisplayConfigs.hal",
"ISELinux.hal",
], ],
interfaces: [ "android.hidl.base@1.0" ], interfaces: [ "android.hidl.base@1.0" ],
gen_java: true, gen_java: false,
} }

View file

@ -14,7 +14,7 @@
package vendor.eureka.hardware.parts@1.0; package vendor.eureka.hardware.parts@1.0;
interface IBattery { interface IBatteryStats {
getBatteryStats(SysfsType stats) generates (int32_t result); getBatteryStats(SysfsType stats) generates (int32_t result);
setBatteryWritable(SysfsType stats, Number value) generates (int32_t result); setBatteryWritable(SysfsType stats, Number value);
}; };

View file

@ -14,7 +14,6 @@
package vendor.eureka.hardware.parts@1.0; package vendor.eureka.hardware.parts@1.0;
interface IGpu { interface IDisplayConfigs {
setGpuWritable(Number enable) generates (int32_t result); writeDisplay(Number enable, Display type);
readGpustats() generates (int32_t value);
}; };

View file

@ -14,8 +14,8 @@
package vendor.eureka.hardware.parts@1.0; package vendor.eureka.hardware.parts@1.0;
interface IFlashLight { interface IFlashBrightness {
setFlashlightWritable(Value value) generates (int32_t result); setFlashlightWritable(Value value);
setFlashlightEnable(Number enable) generates (int32_t result); setFlashlightEnable(Number enable);
readFlashlightstats(Device device) generates (int32_t value); readFlashlightstats(Device device) generates (int32_t value);
}; };

View file

@ -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 ISELinux {
setSELinuxWritable(Number enable) generates (int32_t result);
readSELinuxstats() generates (int32_t value);
};

View file

@ -7,8 +7,7 @@ cc_binary {
srcs: [ srcs: [
"Battery.cpp", "Battery.cpp",
"FlashLight.cpp", "FlashLight.cpp",
"Gpu.cpp", "Display.cpp",
"SELinux.cpp",
"service.cpp", "service.cpp",
], ],
shared_libs: [ shared_libs: [

View file

@ -21,7 +21,7 @@
namespace vendor::eureka::hardware::parts::V1_0 { namespace vendor::eureka::hardware::parts::V1_0 {
// Methods from ::android::hardware::battery::V1_0::IBattery follow. // Methods from ::android::hardware::battery::V1_0::IBattery follow.
Return<int32_t> Battery::getBatteryStats(parts::V1_0::SysfsType stats) { Return<int32_t> BatteryStats::getBatteryStats(parts::V1_0::SysfsType stats) {
std::ifstream file; std::ifstream file;
std::string filename; std::string filename;
switch (stats) { switch (stats) {
@ -60,7 +60,7 @@ Return<int32_t> Battery::getBatteryStats(parts::V1_0::SysfsType stats) {
return -1; return -1;
} }
Return<int32_t> Battery::setBatteryWritable(parts::V1_0::SysfsType stats, Return<void> BatteryStats::setBatteryWritable(parts::V1_0::SysfsType stats,
parts::V1_0::Number value) { parts::V1_0::Number value) {
std::ofstream file; std::ofstream file;
std::string filename; std::string filename;
@ -100,10 +100,10 @@ Return<int32_t> Battery::setBatteryWritable(parts::V1_0::SysfsType stats,
file << write; file << write;
file.close(); file.close();
if (FastCharge) seteuid(ANDROID_ROOT_UID); if (FastCharge) seteuid(ANDROID_ROOT_UID);
return 0; return Void();
} }
IBattery* Battery::getInstance(void) { IBatteryStats* BatteryStats::getInstance(void) {
return new Battery(); return new BatteryStats();
} }
} // namespace vendor::eureka::hardware::parts::V1_0 } // namespace vendor::eureka::hardware::parts::V1_0

View file

@ -16,7 +16,7 @@
#include <hidl/MQDescriptor.h> #include <hidl/MQDescriptor.h>
#include <hidl/Status.h> #include <hidl/Status.h>
#include <vendor/eureka/hardware/parts/1.0/IBattery.h> #include <vendor/eureka/hardware/parts/1.0/IBatteryStats.h>
#define ANDROID_SYSTEM_UID 1000 #define ANDROID_SYSTEM_UID 1000
#define ANDROID_ROOT_UID 0 #define ANDROID_ROOT_UID 0
@ -31,12 +31,12 @@ using ::android::hardware::hidl_vec;
using ::android::hardware::Return; using ::android::hardware::Return;
using ::android::hardware::Void; using ::android::hardware::Void;
struct Battery : public IBattery { struct BatteryStats : public IBatteryStats {
// Methods from ::vendor::eureka::hardware::parts::V1_0::IBattery follow. // Methods from ::vendor::eureka::hardware::parts::V1_0::IBatteryStats follow.
Return<int32_t> getBatteryStats(SysfsType stats) override; Return<int32_t> getBatteryStats(SysfsType stats) override;
Return<int32_t> setBatteryWritable(SysfsType stats, Number value) override; Return<void> setBatteryWritable(SysfsType stats, Number value) override;
// Methods from ::android::hidl::base::V1_0::IBase follow. // Methods from ::android::hidl::base::V1_0::IBase follow.
static IBattery* getInstance(void); static IBatteryStats* getInstance(void);
}; };
} // namespace vendor::eureka::hardware::parts::V1_0 } // namespace vendor::eureka::hardware::parts::V1_0

View file

@ -12,42 +12,33 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "Gpu.h" #include "Display.h"
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
namespace vendor::eureka::hardware::parts::V1_0 { namespace vendor::eureka::hardware::parts::V1_0 {
Return<int32_t> Gpu::setGpuWritable(parts::V1_0::Number enable) { Return<void> DisplayConfigs::writeDisplay(parts::V1_0::Number enable, parts::V1_0::Display type) {
std::ofstream file; std::ofstream file;
std::string writevalue; std::string writevalue;
if (enable == Number::ENABLE) { if (type == Display::DOUBLE_TAP){
writevalue = "1"; writevalue = "aot_enable";
} else { } else if (type == Display::GLOVE_MODE){
writevalue = "0"; writevalue = "glove_mode";
} }
file.open("/sys/devices/platform/11500000.mali/tmu");
if (enable == Number::ENABLE) {
writevalue += ",1";
} else {
writevalue += ",0";
}
file.open("/sys/class/sec/tsp/cmd");
file << writevalue; file << writevalue;
file.close(); file.close();
return 0; return Void();
} }
Return<int32_t> Gpu::readGpustats(void) { IDisplayConfigs* DisplayConfigs::getInstance(void) {
std::ifstream file; return new DisplayConfigs();
std::string value;
int32_t intvalue;
file.open("/sys/devices/platform/11500000.mali/tmu");
if (file.is_open()) {
getline(file, value);
file.close();
std::stringstream val(value);
val >> intvalue;
return intvalue;
}
return -1;
}
IGpu* Gpu::getInstance(void) {
return new Gpu();
} }
} // namespace vendor::eureka::hardware::parts::V1_0 } // namespace vendor::eureka::hardware::parts::V1_0

View file

@ -16,7 +16,7 @@
#include <hidl/MQDescriptor.h> #include <hidl/MQDescriptor.h>
#include <hidl/Status.h> #include <hidl/Status.h>
#include <vendor/eureka/hardware/parts/1.0/ISELinux.h> #include <vendor/eureka/hardware/parts/1.0/IDisplayConfigs.h>
namespace vendor::eureka::hardware::parts::V1_0 { namespace vendor::eureka::hardware::parts::V1_0 {
@ -28,11 +28,10 @@ using ::android::hardware::hidl_vec;
using ::android::hardware::Return; using ::android::hardware::Return;
using ::android::hardware::Void; using ::android::hardware::Void;
struct SELinux : public ISELinux { struct DisplayConfigs : public IDisplayConfigs {
// Methods from ::vendor::eureka::hardware::parts::V1_0::ISELinux follow. // Methods from ::vendor::eureka::hardware::parts::V1_0::IDisplayConfigs follow.
Return<int32_t> setSELinuxWritable(Number enable); Return<void> writeDisplay(Number enable, Display type);
Return<int32_t> readSELinuxstats(void);
// Methods from ::android::hidl::base::V1_0::IBase follow. // Methods from ::android::hidl::base::V1_0::IBase follow.
static ISELinux* getInstance(void); static IDisplayConfigs* getInstance(void);
}; };
} // namespace vendor::eureka::hardware::parts::V1_0 } // namespace vendor::eureka::hardware::parts::V1_0

View file

@ -19,7 +19,7 @@
namespace vendor::eureka::hardware::parts::V1_0 { namespace vendor::eureka::hardware::parts::V1_0 {
// Methods from ::android::hardware::parts::V1_0::IFlashLight follow. // Methods from ::android::hardware::parts::V1_0::IFlashLight follow.
Return<int32_t> FlashLight::setFlashlightEnable(parts::V1_0::Number enable) { Return<void> FlashBrightness::setFlashlightEnable(parts::V1_0::Number enable) {
std::ofstream file; std::ofstream file;
std::string writevalue; std::string writevalue;
switch (enable) { switch (enable) {
@ -36,10 +36,10 @@ Return<int32_t> FlashLight::setFlashlightEnable(parts::V1_0::Number enable) {
file.open("/sys/class/camera/flash/torch_brightness_lvl_enable"); file.open("/sys/class/camera/flash/torch_brightness_lvl_enable");
file << writevalue; file << writevalue;
file.close(); file.close();
return 0; return Void();
} }
Return<int32_t> FlashLight::setFlashlightWritable(parts::V1_0::Value value) { Return<void> FlashBrightness::setFlashlightWritable(parts::V1_0::Value value) {
std::ofstream file; std::ofstream file;
std::string writevalue; std::string writevalue;
switch (value) { switch (value) {
@ -80,10 +80,10 @@ Return<int32_t> FlashLight::setFlashlightWritable(parts::V1_0::Value value) {
file.open("/sys/class/camera/flash/torch_brightness_lvl"); file.open("/sys/class/camera/flash/torch_brightness_lvl");
file << writevalue; file << writevalue;
file.close(); file.close();
return 0; return Void();
} }
Return<int32_t> FlashLight::readFlashlightstats(parts::V1_0::Device device) { Return<int32_t> FlashBrightness::readFlashlightstats(parts::V1_0::Device device) {
std::ifstream file; std::ifstream file;
std::string value; std::string value;
int32_t intvalue; int32_t intvalue;
@ -104,7 +104,7 @@ Return<int32_t> FlashLight::readFlashlightstats(parts::V1_0::Device device) {
return -1; return -1;
} }
IFlashLight* FlashLight::getInstance(void) { IFlashBrightness* FlashBrightness::getInstance(void) {
return new FlashLight(); return new FlashBrightness();
} }
} // namespace vendor::eureka::hardware::parts::V1_0 } // namespace vendor::eureka::hardware::parts::V1_0

View file

@ -16,7 +16,7 @@
#include <hidl/MQDescriptor.h> #include <hidl/MQDescriptor.h>
#include <hidl/Status.h> #include <hidl/Status.h>
#include <vendor/eureka/hardware/parts/1.0/IFlashLight.h> #include <vendor/eureka/hardware/parts/1.0/IFlashBrightness.h>
namespace vendor::eureka::hardware::parts::V1_0 { namespace vendor::eureka::hardware::parts::V1_0 {
@ -28,12 +28,12 @@ using ::android::hardware::hidl_vec;
using ::android::hardware::Return; using ::android::hardware::Return;
using ::android::hardware::Void; using ::android::hardware::Void;
struct FlashLight : public IFlashLight { struct FlashBrightness : public IFlashBrightness {
// Methods from ::vendor::eureka::hardware::flashlight::V1_0::IFlashLight follow. // Methods from ::vendor::eureka::hardware::parts::V1_0::IFlashBrightness follow.
Return<int32_t> setFlashlightEnable(Number enable); Return<void> setFlashlightEnable(Number enable);
Return<int32_t> setFlashlightWritable(Value value); Return<void> setFlashlightWritable(Value value);
Return<int32_t> readFlashlightstats(Device device); Return<int32_t> readFlashlightstats(Device device);
// Methods from ::android::hidl::base::V1_0::IBase follow. // Methods from ::android::hidl::base::V1_0::IBase follow.
static IFlashLight* getInstance(void); static IFlashBrightness* getInstance(void);
}; };
} // namespace vendor::eureka::hardware::parts::V1_0 } // namespace vendor::eureka::hardware::parts::V1_0

View file

@ -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/IGpu.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 Gpu : public IGpu {
// Methods from ::vendor::eureka::hardware::parts::V1_0::IGpu follow.
Return<int32_t> setGpuWritable(Number enable);
Return<int32_t> readGpustats(void);
// Methods from ::android::hidl::base::V1_0::IBase follow.
static IGpu* getInstance(void);
};
} // namespace vendor::eureka::hardware::parss::V1_0

View file

@ -1,53 +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 "SELinux.h"
#include <fstream>
#include <iostream>
#include <sstream>
namespace vendor::eureka::hardware::parts::V1_0 {
Return<int32_t> SELinux::setSELinuxWritable(parts::V1_0::Number enable) {
std::ofstream file;
std::string writevalue;
if (enable == Number::ENABLE) {
writevalue = "1";
} else {
writevalue = "0";
}
file.open("/sys/fs/selinux/enforce");
file << writevalue;
file.close();
return 0;
}
Return<int32_t> SELinux::readSELinuxstats(void) {
std::ifstream file;
std::string value;
int32_t intvalue;
file.open("/sys/fs/selinux/enforce");
if (file.is_open()) {
getline(file, value);
file.close();
std::stringstream val(value);
val >> intvalue;
return intvalue;
}
return -1;
}
ISELinux* SELinux::getInstance(void) {
return new SELinux();
}
} // namespace vendor::eureka::hardware::parts::V1_0

View file

@ -14,37 +14,31 @@
#define LOG_TAG "vendor.eureka.hardware.parts@1.0-service" #define LOG_TAG "vendor.eureka.hardware.parts@1.0-service"
#include <vendor/eureka/hardware/parts/1.0/IBattery.h> #include <vendor/eureka/hardware/parts/1.0/IBatteryStats.h>
#include <vendor/eureka/hardware/parts/1.0/IFlashLight.h> #include <vendor/eureka/hardware/parts/1.0/IFlashBrightness.h>
#include <vendor/eureka/hardware/parts/1.0/IGpu.h> #include <vendor/eureka/hardware/parts/1.0/IDisplayConfigs.h>
#include <vendor/eureka/hardware/parts/1.0/ISELinux.h>
#include <hidl/LegacySupport.h> #include <hidl/LegacySupport.h>
#include "Battery.h" #include "Battery.h"
#include "FlashLight.h" #include "FlashLight.h"
#include "Gpu.h" #include "Display.h"
#include "SELinux.h"
using android::sp; using android::sp;
using android::hardware::configureRpcThreadpool; using android::hardware::configureRpcThreadpool;
using android::hardware::joinRpcThreadpool; using android::hardware::joinRpcThreadpool;
using vendor::eureka::hardware::parts::V1_0::Battery; using vendor::eureka::hardware::parts::V1_0::BatteryStats;
using vendor::eureka::hardware::parts::V1_0::IBattery; using vendor::eureka::hardware::parts::V1_0::IBatteryStats;
using vendor::eureka::hardware::parts::V1_0::FlashLight; using vendor::eureka::hardware::parts::V1_0::FlashBrightness;
using vendor::eureka::hardware::parts::V1_0::IFlashLight; using vendor::eureka::hardware::parts::V1_0::IFlashBrightness;
using vendor::eureka::hardware::parts::V1_0::Gpu; using vendor::eureka::hardware::parts::V1_0::DisplayConfigs;
using vendor::eureka::hardware::parts::V1_0::IGpu; using vendor::eureka::hardware::parts::V1_0::IDisplayConfigs;
using vendor::eureka::hardware::parts::V1_0::SELinux;
using vendor::eureka::hardware::parts::V1_0::ISELinux;
int main() { int main() {
int ret; int ret;
android::sp<IBattery> mBatteryService = Battery::getInstance(); android::sp<IBatteryStats> mBatteryService = BatteryStats::getInstance();
android::sp<IFlashLight> mFlashLightService = FlashLight::getInstance(); android::sp<IFlashBrightness> mFlashLightService = FlashBrightness::getInstance();
android::sp<IGpu> mGPUService = Gpu::getInstance(); android::sp<IDisplayConfigs> mDisplayService = DisplayConfigs::getInstance();
android::sp<ISELinux> mSEService = SELinux::getInstance(); configureRpcThreadpool(4, true /*callerWillJoin*/);
configureRpcThreadpool(1, true /*callerWillJoin*/);
if (mBatteryService != nullptr) { if (mBatteryService != nullptr) {
ret = mBatteryService->registerAsService(); ret = mBatteryService->registerAsService();
@ -66,25 +60,15 @@ int main() {
} else { } else {
ALOGE("Can't create instance of FlashLight HAL, nullptr"); ALOGE("Can't create instance of FlashLight HAL, nullptr");
} }
if (mGPUService != nullptr) { if (mDisplayService != nullptr) {
ret = mGPUService->registerAsService(); ret = mDisplayService->registerAsService();
if (ret != 0) { if (ret != 0) {
ALOGE("Can't register instance of GPU HAL, nullptr"); ALOGE("Can't register instance of Display HAL, nullptr");
} else { } else {
ALOGI("registered GPU HAL"); ALOGI("registered Display HAL");
} }
} else { } else {
ALOGE("Can't create instance of GPU HAL, nullptr"); ALOGE("Can't create instance of Display HAL, nullptr");
}
if (mSEService != nullptr) {
ret = mSEService->registerAsService();
if (ret != 0) {
ALOGE("Can't register instance of SELinux HAL, nullptr");
} else {
ALOGI("registered SELinux HAL");
}
} else {
ALOGE("Can't create instance of SELinux HAL, nullptr");
} }
joinRpcThreadpool(); joinRpcThreadpool();

View file

@ -1,8 +1,7 @@
service vendor.parts-hal /vendor/bin/hw/vendor.eureka.hardware.parts@1.0-service service vendor.parts-hal /vendor/bin/hw/vendor.eureka.hardware.parts@1.0-service
interface vendor.eureka.hardware.parts@1.0::IBattery default interface vendor.eureka.hardware.parts@1.0::IBatteryStats default
interface vendor.eureka.hardware.parts@1.0::IGpu default interface vendor.eureka.hardware.parts@1.0::IDisplayConfigs default
interface vendor.eureka.hardware.parts@1.0::IFlashLight default interface vendor.eureka.hardware.parts@1.0::IFlashBrightness default
interface vendor.eureka.hardware.parts@1.0::ISELinux default
class hal class hal
user root user root
group root group root

View file

@ -4,19 +4,15 @@
<transport>hwbinder</transport> <transport>hwbinder</transport>
<version>1.0</version> <version>1.0</version>
<interface> <interface>
<name>IBattery</name> <name>IBatteryStats</name>
<instance>default</instance> <instance>default</instance>
</interface> </interface>
<interface> <interface>
<name>IFlashLight</name> <name>IFlashBrightness</name>
<instance>default</instance> <instance>default</instance>
</interface> </interface>
<interface> <interface>
<name>IGpu</name> <name>IDisplayConfigs</name>
<instance>default</instance>
</interface>
<interface>
<name>ISELinux</name>
<instance>default</instance> <instance>default</instance>
</interface> </interface>
</hal> </hal>

View file

@ -23,6 +23,11 @@ enum SysfsType : int32_t {
CHARGE, CHARGE,
}; };
enum Display : int32_t {
DOUBLE_TAP,
GLOVE_MODE,
};
enum Number : int32_t { enum Number : int32_t {
ENABLE = 1, ENABLE = 1,
DISABLE = 0, DISABLE = 0,

View file

@ -21,11 +21,6 @@ allow hal_parts_default sysfs_flashlight:file { read open write getattr };
allow hal_parts_default sysfs_flashlight:dir search; allow hal_parts_default sysfs_flashlight:dir search;
allow hal_parts_default sysfs_virtual:dir search; allow hal_parts_default sysfs_virtual:dir search;
# GPU # Display
allow hal_parts_default sysfs_gpu_tmu:file { read open write getattr }; allow hal_parts_default sysfs_sec_touchscreen:dir search;
allow hal_parts_default sysfs_gpu_tmu:dir search; allow hal_parts_default sysfs_touchscreen_writable:file rw_file_perms;
# SELinux
allow hal_parts_default selinuxfs:file rw_file_perms;
allow hal_parts_default selinuxfs:dir search;

View file

@ -5,10 +5,9 @@ vendor.samsung.hardware.radio.channel::ISehChannel u:object_r:rild_hwse
vendor.lineage.power::ILineagePower u:object_r:hal_power_hwservice:s0 vendor.lineage.power::ILineagePower u:object_r:hal_power_hwservice:s0
# SamsungParts # SamsungParts
vendor.eureka.hardware.parts::IBattery u:object_r:hal_parts_hwservice:s0 vendor.eureka.hardware.parts::IBatteryStats u:object_r:hal_parts_hwservice:s0
vendor.eureka.hardware.parts::IFlashLight u:object_r:hal_parts_hwservice:s0 vendor.eureka.hardware.parts::IFlashBrightness u:object_r:hal_parts_hwservice:s0
vendor.eureka.hardware.parts::IGpu u:object_r:hal_parts_hwservice:s0 vendor.eureka.hardware.parts::IDisplayConfigs u:object_r:hal_parts_hwservice:s0
vendor.eureka.hardware.parts::ISELinux u:object_r:hal_parts_hwservice:s0
# FMRadio # FMRadio
vendor.eureka.hardware.fmradio::IFMRadio u:object_r:hal_fmradio_hwservice:s0 vendor.eureka.hardware.fmradio::IFMRadio u:object_r:hal_fmradio_hwservice:s0