mirror of
https://github.com/chararomandroid/android_device_samsung_a20
synced 2026-08-21 11:55:31 -04:00
universal7885: SamsungParts: Add new HIDL
* Related to flashlight * Also, build it
This commit is contained in:
parent
703c0edf61
commit
1bcf57f719
15 changed files with 316 additions and 4 deletions
|
|
@ -1,5 +1,5 @@
|
|||
service vendor.battery-hal /vendor/bin/hw/vendor.eureka.hardware.battery@1.0-service
|
||||
interface vendor.eureka.hardware.battery@1.0::IBattery default
|
||||
class hal
|
||||
user system
|
||||
group system
|
||||
user root
|
||||
group root
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
hidl_interface {
|
||||
name: "vendor.eureka.hardware.flashlight@1.0",
|
||||
root: "vendor.eureka",
|
||||
srcs: [
|
||||
"types.hal",
|
||||
"IFlashlight.hal",
|
||||
],
|
||||
interfaces: [ "android.hidl.base@1.0" ],
|
||||
gen_java: true,
|
||||
}
|
||||
|
|
@ -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.flashlight@1.0;
|
||||
|
||||
interface IFlashLight {
|
||||
setFlashlightWritable(Number value) generates (int32_t result);
|
||||
setFlashlightEnable(Enable enable) generates (int32_t result);
|
||||
readFlashlightstats(Device device) generates (int32_t value);
|
||||
};
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
// FIXME: your file license if you have one
|
||||
|
||||
cc_binary {
|
||||
name: "vendor.eureka.hardware.flashlight@1.0-service",
|
||||
relative_install_path: "hw",
|
||||
proprietary: true,
|
||||
srcs: [
|
||||
"Flashlight.cpp",
|
||||
"service.cpp",
|
||||
],
|
||||
shared_libs: [
|
||||
"libhidlbase",
|
||||
"libutils",
|
||||
"liblog",
|
||||
"vendor.eureka.hardware.flashlight@1.0",
|
||||
],
|
||||
init_rc: [ "vendor.eureka.hardware.flashlight@1.0-service.rc" ],
|
||||
vintf_fragments: [ "vendor.eureka.hardware.flashlight@1.0.xml" ],
|
||||
}
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
// 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 <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
namespace vendor::eureka::hardware::flashlight::V1_0 {
|
||||
|
||||
// Methods from ::android::hardware::flashlight::V1_0::IFlashlight follow.
|
||||
Return<int32_t> Flashlight::getFlashlightStats(flashlight::V1_0::Enable enable) {
|
||||
std::ofstream file;
|
||||
std::string writevalue;
|
||||
switch (enable){
|
||||
case Number::ENABLE:
|
||||
writevalue = "1";
|
||||
break;
|
||||
case Number::DISABLE:
|
||||
writevalue = "0";
|
||||
break;
|
||||
default:
|
||||
filename = "";
|
||||
break;
|
||||
}
|
||||
file.open("/sys/class/camera/flash/torch_brightness_lvl_enable");
|
||||
file << writevalue;
|
||||
file.close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Return<int32_t> Flashlight::setFlashlightWritable(flashlight::V1_0::Number value) {
|
||||
std::ofstream file;
|
||||
std::string writevalue;
|
||||
switch (value){
|
||||
case Number::ONEUI:
|
||||
writevalue = "1";
|
||||
break;
|
||||
case Number::TWOUI:
|
||||
writevalue = "2";
|
||||
break;
|
||||
case Number::THREEUI:
|
||||
writevalue = "3";
|
||||
break;
|
||||
case Number::FOURUI:
|
||||
writevalue = "4";
|
||||
break;
|
||||
case Number::FIVEUI:
|
||||
writevalue = "5";
|
||||
break;
|
||||
case Number::SIXUI:
|
||||
writevalue = "6";
|
||||
break;
|
||||
case Number::SEVENUI:
|
||||
writevalue = "7";
|
||||
break;
|
||||
case Number::EIGHTUI:
|
||||
writevalue = "8";
|
||||
break;
|
||||
case Number::NINEUI:
|
||||
writevalue = "9";
|
||||
break;
|
||||
case Number::TENUI:
|
||||
writevalue = "10";
|
||||
break;
|
||||
default:
|
||||
filename = "";
|
||||
break;
|
||||
}
|
||||
file.open("/sys/class/camera/flash/torch_brightness_lvl");
|
||||
file << writevalue;
|
||||
file.close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Return<int32_t> Flashlight::readFlashlightstats(flashlight::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;
|
||||
}
|
||||
|
||||
IFlashlight *Flashlight::getInstance(void){
|
||||
return new Flashlight();
|
||||
}
|
||||
} // namespace android::hardware::flashlight::implementation
|
||||
|
|
@ -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 <vendor/eureka/hardware/flashlight/1.0/IFlashlight.h>
|
||||
#include <hidl/MQDescriptor.h>
|
||||
#include <hidl/Status.h>
|
||||
|
||||
namespace vendor::eureka::hardware::flashlight::V1_0 {
|
||||
|
||||
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;
|
||||
using ::android::sp;
|
||||
|
||||
struct Flashlight : public IFlashlight {
|
||||
// Methods from ::vendor::eureka::hardware::flashlight::V1_0::IFlashlight follow.
|
||||
Return<int32_t> Flashlight::getFlashlightStats(flashlight::V1_0::Enable enable);
|
||||
Return<int32_t> Flashlight::setFlashlightWritable(flashlight::V1_0::Number value);
|
||||
Return<int32_t> Flashlight::readFlashlightstats(flashlight::V1_0::Device device);
|
||||
// Methods from ::android::hidl::base::V1_0::IBase follow.
|
||||
static IFlashlight* getInstance(void);
|
||||
|
||||
};
|
||||
} // namespace android::hardware::flashlight::implementation
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
// 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.flashlight@1.0-service"
|
||||
|
||||
#include <vendor/eureka/hardware/flashlight/1.0/IFlashlight.h>
|
||||
|
||||
#include <hidl/LegacySupport.h>
|
||||
|
||||
#include "Flashlight.h"
|
||||
|
||||
using vendor::eureka::hardware::flashlight::V1_0::IFlashlight;
|
||||
using vendor::eureka::hardware::flashlight::V1_0::Flashlight;
|
||||
using android::hardware::configureRpcThreadpool;
|
||||
using android::hardware::joinRpcThreadpool;
|
||||
using android::sp;
|
||||
|
||||
int main() {
|
||||
int ret;
|
||||
android::sp<IFlashlight> service = Flashlight::getInstance();
|
||||
configureRpcThreadpool(1, true /*callerWillJoin*/);
|
||||
|
||||
if (service != nullptr) {
|
||||
ret = service->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");
|
||||
}
|
||||
|
||||
joinRpcThreadpool();
|
||||
|
||||
return -1; // should never get here
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
service vendor.flashlight-hal /vendor/bin/hw/vendor.eureka.hardware.flashlight@1.0-service
|
||||
interface vendor.eureka.hardware.flashlight@1.0::IFlashlight default
|
||||
class hal
|
||||
user root
|
||||
group root
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<manifest version="1.0" type="device" target-level="3">
|
||||
<hal format="hidl">
|
||||
<name>vendor.eureka.hardware.flashlight</name>
|
||||
<transport>hwbinder</transport>
|
||||
<version>1.0</version>
|
||||
<interface>
|
||||
<name>IFlashlight</name>
|
||||
<instance>default</instance>
|
||||
</interface>
|
||||
</hal>
|
||||
</manifest>
|
||||
|
|
@ -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.
|
||||
|
||||
package vendor.eureka.hardware.flashlight@1.0;
|
||||
|
||||
enum Device : int32_t {
|
||||
A10,
|
||||
NOTA10,
|
||||
};
|
||||
|
||||
enum Number : int32_t {
|
||||
ONEUI,
|
||||
TWOUI,
|
||||
THREEUI,
|
||||
FOURUI,
|
||||
FIVEUI,
|
||||
SIXUI,
|
||||
SEVENUI,
|
||||
EIGHTUI,
|
||||
NINEUI,
|
||||
TENUI,
|
||||
};
|
||||
|
||||
enum Enable : int32_t {
|
||||
ENABLE,
|
||||
DISABLE,
|
||||
}
|
||||
|
|
@ -215,3 +215,4 @@
|
|||
|
||||
# SamsungParts
|
||||
/(vendor|system/vendor)/bin/hw/vendor\.eureka\.hardware\.battery@1\.0-service u:object_r:hal_battery_default_exec:s0
|
||||
/(vendor|system/vendor)/bin/hw/vendor\.eureka\.hardware\.flashlight@1\.0-service u:object_r:hal_flashlight_default_exec:s0
|
||||
|
|
|
|||
4
universal7885-common/sepolicy/vendor/hal_flashlight_default.te
vendored
Normal file
4
universal7885-common/sepolicy/vendor/hal_flashlight_default.te
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
type hal_flashlight_default, domain;
|
||||
type hal_flashlight_default_exec, exec_type, file_type, vendor_file_type;
|
||||
add_hwservice(hal_flashlight_default, hal_flashlight_hwservice);
|
||||
init_daemon_domain(hal_flashlight_default);
|
||||
|
|
@ -1,2 +1,3 @@
|
|||
type rild_hwservice, hwservice_manager_type;
|
||||
type hal_battery_hwservice, hwservice_manager_type;
|
||||
type hal_flashlight_hwservice, hwservice_manager_type;
|
||||
|
|
|
|||
|
|
@ -6,4 +6,5 @@ vendor.lineage.power::ILineagePower u:object_r:hal_power_hwservice:s0
|
|||
|
||||
# SamsungParts
|
||||
vendor.eureka.hardware.battery::IBattery u:object_r:hal_battery_hwservice:s0
|
||||
vendor.eureka.hardware.flashlight::IFlashlight u:object_r:hal_flashlight_hwservice:s0
|
||||
|
||||
|
|
|
|||
|
|
@ -278,8 +278,10 @@ PRODUCT_CFI_INCLUDE_PATHS += hardware/samsung_slsi/scsc_wifibt/wpa_supplicant_li
|
|||
|
||||
# SamsungParts
|
||||
PRODUCT_PACKAGES += \
|
||||
SamsungParts \
|
||||
android.software.samsungparts@1.0-service
|
||||
SamsungParts \
|
||||
init.samsungparts.rc \
|
||||
vendor.eureka.hardware.battery@1.0-service \
|
||||
vendor.eureka.hardware.flashlight@1.0-service
|
||||
|
||||
# Debug
|
||||
ifeq ($(TARGET_BUILD_VARIENT),eng)
|
||||
|
|
|
|||
Loading…
Reference in a new issue