health: convert to aidl hal
* hardware/interfaces/health/aidl/default
This commit is contained in:
@@ -186,7 +186,7 @@ PRODUCT_COPY_FILES += \
|
||||
|
||||
# Health
|
||||
PRODUCT_PACKAGES += \
|
||||
android.hardware.health@2.0-service.rpi
|
||||
android.hardware.health-service.rpi
|
||||
|
||||
# Kernel
|
||||
PRODUCT_COPY_FILES += \
|
||||
|
@@ -1,33 +1,32 @@
|
||||
// Copyright (C) 2021-2022 KonstaKANG
|
||||
// Copyright (C) 2018 The Android Open Source Project
|
||||
// Copyright (C) 2023 KonstaKANG
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
cc_binary {
|
||||
name: "android.hardware.health@2.0-service.rpi",
|
||||
init_rc: ["android.hardware.health@2.0-service.rpi.rc"],
|
||||
vintf_fragments: ["android.hardware.health@2.0-service.rpi.xml"],
|
||||
proprietary: true,
|
||||
name: "android.hardware.health-service.rpi",
|
||||
relative_install_path: "hw",
|
||||
vendor: true,
|
||||
init_rc: ["android.hardware.health-service.rpi.rc"],
|
||||
vintf_fragments: ["android.hardware.health-service.rpi.xml"],
|
||||
srcs: [
|
||||
"HealthService.cpp",
|
||||
],
|
||||
cflags: [
|
||||
"-Wall",
|
||||
"-Werror",
|
||||
"HealthImpl.cpp",
|
||||
"main.cpp",
|
||||
],
|
||||
static_libs: [
|
||||
"android.hardware.health@2.0-impl",
|
||||
"android.hardware.health@1.0-convert",
|
||||
"libhealthservice",
|
||||
"android.hardware.health-translate-ndk",
|
||||
"libbatterymonitor",
|
||||
"libhealthstoragedefault",
|
||||
"libhealthloop",
|
||||
"libhealth_aidl_impl",
|
||||
],
|
||||
shared_libs: [
|
||||
"libbase",
|
||||
"libbinder_ndk",
|
||||
"libcutils",
|
||||
"libhidlbase",
|
||||
"liblog",
|
||||
"libutils",
|
||||
"android.hardware.health@2.0",
|
||||
"android.hardware.health-V1-ndk",
|
||||
],
|
||||
header_libs: ["libhealthd_headers"],
|
||||
overrides: ["charger"],
|
||||
}
|
||||
|
38
health/HealthImpl.cpp
Normal file
38
health/HealthImpl.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (C) 2021 The Android Open Source Project
|
||||
* Copyright (C) 2023 KonstaKANG
|
||||
*
|
||||
* 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 "HealthImpl.h"
|
||||
|
||||
using ::aidl::android::hardware::health::BatteryHealth;
|
||||
using ::aidl::android::hardware::health::BatteryStatus;
|
||||
using ::aidl::android::hardware::health::HealthInfo;
|
||||
|
||||
namespace aidl::android::hardware::health {
|
||||
|
||||
void HealthImpl::UpdateHealthInfo(HealthInfo* health_info) {
|
||||
health_info->chargerAcOnline = true;
|
||||
health_info->batteryLevel = 100;
|
||||
health_info->batteryStatus = BatteryStatus::CHARGING;
|
||||
health_info->batteryHealth = BatteryHealth::GOOD;
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus HealthImpl::getChargeStatus(BatteryStatus* out) {
|
||||
*out = BatteryStatus::CHARGING;
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
} // namespace aidl::android::hardware::health
|
37
health/HealthImpl.h
Normal file
37
health/HealthImpl.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2021 The Android Open Source Project
|
||||
* Copyright (C) 2023 KonstaKANG
|
||||
*
|
||||
* 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 <health-impl/Health.h>
|
||||
|
||||
using ::aidl::android::hardware::health::Health;
|
||||
|
||||
namespace aidl::android::hardware::health {
|
||||
|
||||
class HealthImpl : public Health {
|
||||
public:
|
||||
using Health::Health;
|
||||
virtual ~HealthImpl() {}
|
||||
|
||||
ndk::ScopedAStatus getChargeStatus(BatteryStatus* out) override;
|
||||
|
||||
protected:
|
||||
void UpdateHealthInfo(HealthInfo* health_info) override;
|
||||
};
|
||||
|
||||
} // namespace aidl::android::hardware::health
|
@@ -1,20 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021-2022 KonstaKANG
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <health2/service.h>
|
||||
#include <healthd/healthd.h>
|
||||
|
||||
int main() {
|
||||
return health_service_main();
|
||||
}
|
||||
|
||||
void healthd_board_init(struct healthd_config*) {}
|
||||
|
||||
int healthd_board_battery_update(struct android::BatteryProperties* battery_props) {
|
||||
battery_props->chargerAcOnline = true;
|
||||
battery_props->batteryLevel = 100;
|
||||
return 0;
|
||||
}
|
6
health/android.hardware.health-service.rpi.rc
Normal file
6
health/android.hardware.health-service.rpi.rc
Normal file
@@ -0,0 +1,6 @@
|
||||
service vendor.health-default /vendor/bin/hw/android.hardware.health-service.rpi
|
||||
class hal
|
||||
user system
|
||||
group system
|
||||
capabilities WAKE_ALARM BLOCK_SUSPEND
|
||||
file /dev/kmsg w
|
7
health/android.hardware.health-service.rpi.xml
Normal file
7
health/android.hardware.health-service.rpi.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<manifest version="1.0" type="device">
|
||||
<hal format="aidl">
|
||||
<name>android.hardware.health</name>
|
||||
<version>1</version>
|
||||
<fqname>IHealth/default</fqname>
|
||||
</hal>
|
||||
</manifest>
|
@@ -1,5 +0,0 @@
|
||||
service vendor.health-hal-2-0 /vendor/bin/hw/android.hardware.health@2.0-service.rpi
|
||||
class hal
|
||||
user system
|
||||
group system
|
||||
file /dev/kmsg w
|
@@ -1,11 +0,0 @@
|
||||
<manifest version="1.0" type="device">
|
||||
<hal format="hidl">
|
||||
<name>android.hardware.health</name>
|
||||
<transport>hwbinder</transport>
|
||||
<version>2.0</version>
|
||||
<interface>
|
||||
<name>IHealth</name>
|
||||
<instance>default</instance>
|
||||
</interface>
|
||||
</hal>
|
||||
</manifest>
|
32
health/main.cpp
Normal file
32
health/main.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) 2021 The Android Open Source Project
|
||||
* Copyright (C) 2023 KonstaKANG
|
||||
*
|
||||
* 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 "HealthImpl.h"
|
||||
|
||||
#include <android/binder_interface_utils.h>
|
||||
#include <health/utils.h>
|
||||
|
||||
using ::aidl::android::hardware::health::HalHealthLoop;
|
||||
using ::aidl::android::hardware::health::HealthImpl;
|
||||
|
||||
int main() {
|
||||
auto config = std::make_unique<healthd_config>();
|
||||
android::hardware::health::InitHealthdConfig(config.get());
|
||||
auto binder = ndk::SharedRefBase::make<HealthImpl>("default", std::move(config));
|
||||
auto hal_health_loop = std::make_shared<HalHealthLoop>(binder, binder);
|
||||
return hal_health_loop->StartLoop();
|
||||
}
|
@@ -31,7 +31,7 @@
|
||||
/vendor/lib(64)?/libminigbm_gralloc_gbm_mesa\.so u:object_r:same_process_hal_file:s0
|
||||
|
||||
# Health
|
||||
/vendor/bin/hw/android\.hardware\.health@2\.0-service.rpi u:object_r:hal_health_default_exec:s0
|
||||
/vendor/bin/hw/android\.hardware\.health-service\.rpi u:object_r:hal_health_default_exec:s0
|
||||
|
||||
# Lights
|
||||
/sys/class/backlight/rpi_backlight/brightness u:object_r:sysfs_leds:s0
|
||||
|
Reference in New Issue
Block a user