-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hardware/health: Upgrade to
2.1
via libhealth2impl
The `libhealthservice` and `libhealthstoragedefault` helper libraries to implement Health HALs have been removed in Android 14 QPR 3. At the same time a newer 2.1 HIDL HAL has been made available (which is already deprecated too, in favour of an AIDL HAL). Upgrade our custom implementation - which backs up the battery cycles and learned capacity - to leverage `libhealth2impl` and automatically implement `[email protected]`. Its implementation and header even describe how to upgrade away from the old `healthd_board_*()` callback symbols. Furthermore, the default implementation already provides a passthrough service, which allows us to convert this service to an `impl` library and use the builtin service (plus all the files it needs) instead.
- Loading branch information
Showing
6 changed files
with
84 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,7 +88,8 @@ PRODUCT_PACKAGES += \ | |
|
||
# Health | ||
PRODUCT_PACKAGES += \ | ||
[email protected] | ||
[email protected] \ | ||
[email protected] | ||
|
||
ifeq ($(TARGET_VIBRATOR_V1_2),true) | ||
# QTI Haptics Vibrator | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,23 @@ | ||
cc_binary { | ||
name: "[email protected]", | ||
init_rc: ["[email protected]"], | ||
cc_library_shared { | ||
name: "[email protected]", | ||
|
||
// Only vendor and recovery variants are allowed, not core. | ||
vendor: true, | ||
relative_install_path: "hw", | ||
recovery_available: true, | ||
cflags: [ | ||
"-Wall", | ||
"-Werror", | ||
"-Wno-unused", | ||
"-fexceptions", | ||
], | ||
|
||
defaults: ["[email protected]"], | ||
|
||
srcs: [ | ||
"HealthService.cpp", | ||
"impl.cpp", | ||
"CycleCountBackupRestore.cpp", | ||
"LearnedCapacityBackupRestore.cpp", | ||
], | ||
static_libs: [ | ||
"[email protected]", | ||
"[email protected]", | ||
"libbatterymonitor", | ||
// libhealthservice is needed for health_service_main() | ||
"libhealthservice", | ||
// Storage is needed by the HAL definition, use default | ||
"libhealthstoragedefault", | ||
], | ||
shared_libs: [ | ||
"[email protected]", | ||
"libbase", | ||
"libcutils", | ||
"libhidlbase", | ||
"liblog", | ||
"libutils", | ||
], | ||
header_libs: [ | ||
// We only need BatteryService.h | ||
"libbatteryservice_headers", | ||
], | ||
|
||
vintf_fragments: [ | ||
"[email protected]", | ||
], | ||
// No vintf_fragments because both -impl and -service should have been | ||
// installed. | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Entrypoint for the main HAL service. | ||
* | ||
* Copyright (C) 2018 The Android Open Source Project | ||
* Copyright (C) 2019 Felix Elsner | ||
* | ||
* 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 "[email protected]" | ||
|
||
#include <batteryservice/BatteryService.h> | ||
#include <health/utils.h> | ||
#include <health2impl/Health.h> | ||
|
||
#include <string_view> | ||
|
||
#include "CycleCountBackupRestore.h" | ||
#include "LearnedCapacityBackupRestore.h" | ||
|
||
using ::android::hardware::health::InitHealthdConfig; | ||
using ::android::hardware::health::V2_1::IHealth; | ||
|
||
using namespace std::literals; | ||
|
||
namespace device { | ||
namespace sony { | ||
namespace health { | ||
using ::android::hardware::health::V2_1::HealthInfo; | ||
using ::android::hardware::health::V2_1::implementation::Health; | ||
using ::device::sony::health::CycleCountBackupRestore; | ||
using ::device::sony::health::LearnedCapacityBackupRestore; | ||
|
||
class SonyHealth : public Health { | ||
CycleCountBackupRestore ccBackupRestore; | ||
LearnedCapacityBackupRestore lcBackupRestore; | ||
|
||
virtual void UpdateHealthInfo(HealthInfo *health_info) { | ||
ccBackupRestore.Backup(health_info->legacy.legacy.batteryLevel); | ||
lcBackupRestore.Backup(); | ||
} | ||
|
||
public: | ||
SonyHealth(std::unique_ptr<struct healthd_config> &&config) : Health(std::move(config)) { | ||
ccBackupRestore.Restore(); | ||
lcBackupRestore.Restore(); | ||
} | ||
}; | ||
} // namespace health | ||
} // namespace sony | ||
} // namespace device | ||
|
||
extern "C" IHealth *HIDL_FETCH_IHealth(const char *instance) { | ||
if (instance != "default"sv) { | ||
return nullptr; | ||
} | ||
auto config = std::make_unique<healthd_config>(); | ||
InitHealthdConfig(config.get()); | ||
|
||
return new device::sony::health::SonyHealth(std::move(config)); | ||
} |
This file was deleted.
Oops, something went wrong.