Merge "health: HAL 2.1 for redfin" into rvc-dev
Change-Id: Iedd64fabca7f73b42e95022a0d443fb0d06114bd Change-Id: I7dceb30dde4c78377fa939bf5c183f2f647a6747 Change-Id: I1935f2286c5165bde10068ca32dddcfd325206eb Change-Id: I268c336d96f50d0e712d79f3030e171e405461e2
This commit is contained in:
commit
66ada3e90d
|
@ -71,12 +71,6 @@ user: AID_RADIO
|
||||||
group: AID_RADIO
|
group: AID_RADIO
|
||||||
caps: NET_BIND_SERVICE
|
caps: NET_BIND_SERVICE
|
||||||
|
|
||||||
[vendor/bin/hw/android.hardware.health@2.0-service.redfin]
|
|
||||||
mode: 0755
|
|
||||||
user: AID_SYSTEM
|
|
||||||
group: AID_SYSTEM
|
|
||||||
caps: WAKE_ALARM
|
|
||||||
|
|
||||||
[vendor/bin/loc_launcher]
|
[vendor/bin/loc_launcher]
|
||||||
mode: 0755
|
mode: 0755
|
||||||
user: AID_GPS
|
user: AID_GPS
|
||||||
|
|
|
@ -112,7 +112,8 @@ PRODUCT_PACKAGES += \
|
||||||
android.hardware.usb@1.2-service.redfin
|
android.hardware.usb@1.2-service.redfin
|
||||||
|
|
||||||
PRODUCT_PACKAGES += \
|
PRODUCT_PACKAGES += \
|
||||||
android.hardware.health@2.0-service.redfin
|
android.hardware.health@2.1-impl-redfin \
|
||||||
|
android.hardware.health@2.1-service
|
||||||
|
|
||||||
# Vibrator HAL
|
# Vibrator HAL
|
||||||
PRODUCT_PACKAGES += \
|
PRODUCT_PACKAGES += \
|
||||||
|
|
|
@ -14,13 +14,14 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
cc_binary {
|
cc_library_shared {
|
||||||
name: "android.hardware.health@2.0-service.redfin",
|
name: "android.hardware.health@2.1-impl-redfin",
|
||||||
init_rc: ["android.hardware.health@2.0-service.redfin.rc"],
|
stem: "android.hardware.health@2.0-impl-2.1-redfin",
|
||||||
|
|
||||||
proprietary: true,
|
proprietary: true,
|
||||||
relative_install_path: "hw",
|
relative_install_path: "hw",
|
||||||
srcs: [
|
srcs: [
|
||||||
"HealthService.cpp",
|
"Health.cpp",
|
||||||
],
|
],
|
||||||
|
|
||||||
cflags: [
|
cflags: [
|
||||||
|
@ -29,10 +30,10 @@ cc_binary {
|
||||||
],
|
],
|
||||||
|
|
||||||
static_libs: [
|
static_libs: [
|
||||||
"android.hardware.health@2.0-impl",
|
|
||||||
"android.hardware.health@1.0-convert",
|
"android.hardware.health@1.0-convert",
|
||||||
"libhealthservice",
|
|
||||||
"libbatterymonitor",
|
"libbatterymonitor",
|
||||||
|
"libhealth2impl",
|
||||||
|
"libhealthloop",
|
||||||
],
|
],
|
||||||
|
|
||||||
shared_libs: [
|
shared_libs: [
|
||||||
|
@ -42,11 +43,6 @@ cc_binary {
|
||||||
"libpixelhealth",
|
"libpixelhealth",
|
||||||
"libutils",
|
"libutils",
|
||||||
"android.hardware.health@2.0",
|
"android.hardware.health@2.0",
|
||||||
],
|
"android.hardware.health@2.1",
|
||||||
|
|
||||||
header_libs: ["libhealthd_headers"],
|
|
||||||
|
|
||||||
overrides: [
|
|
||||||
"healthd",
|
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,16 +13,17 @@
|
||||||
* 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.
|
||||||
*/
|
*/
|
||||||
#define LOG_TAG "android.hardware.health@2.0-service.redfin"
|
#define LOG_TAG "android.hardware.health@2.1-impl-redfin"
|
||||||
#include <android-base/logging.h>
|
#include <android-base/logging.h>
|
||||||
|
|
||||||
#include <android-base/file.h>
|
#include <android-base/file.h>
|
||||||
#include <android-base/parseint.h>
|
#include <android-base/parseint.h>
|
||||||
#include <android-base/strings.h>
|
#include <android-base/strings.h>
|
||||||
#include <health2/Health.h>
|
#include <android/hardware/health/2.0/types.h>
|
||||||
#include <health2/service.h>
|
#include <health2impl/Health.h>
|
||||||
#include <healthd/healthd.h>
|
#include <health/utils.h>
|
||||||
#include <hidl/HidlTransportSupport.h>
|
#include <hal_conversion.h>
|
||||||
|
|
||||||
#include <pixelhealth/BatteryMetricsLogger.h>
|
#include <pixelhealth/BatteryMetricsLogger.h>
|
||||||
#include <pixelhealth/DeviceHealth.h>
|
#include <pixelhealth/DeviceHealth.h>
|
||||||
#include <pixelhealth/LowBatteryShutdownMetrics.h>
|
#include <pixelhealth/LowBatteryShutdownMetrics.h>
|
||||||
|
@ -34,9 +35,17 @@
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
using namespace std::literals;
|
||||||
|
|
||||||
|
using android::hardware::health::V1_0::hal_conversion::convertFromHealthInfo;
|
||||||
|
using android::hardware::health::V1_0::hal_conversion::convertToHealthInfo;
|
||||||
using android::hardware::health::V2_0::DiskStats;
|
using android::hardware::health::V2_0::DiskStats;
|
||||||
using android::hardware::health::V2_0::StorageAttribute;
|
using android::hardware::health::V2_0::StorageAttribute;
|
||||||
using android::hardware::health::V2_0::StorageInfo;
|
using android::hardware::health::V2_0::StorageInfo;
|
||||||
|
using android::hardware::health::V2_0::Result;
|
||||||
|
using ::android::hardware::health::V2_1::IHealth;
|
||||||
|
using android::hardware::health::InitHealthdConfig;
|
||||||
|
|
||||||
using hardware::google::pixel::health::BatteryMetricsLogger;
|
using hardware::google::pixel::health::BatteryMetricsLogger;
|
||||||
using hardware::google::pixel::health::DeviceHealth;
|
using hardware::google::pixel::health::DeviceHealth;
|
||||||
using hardware::google::pixel::health::LowBatteryShutdownMetrics;
|
using hardware::google::pixel::health::LowBatteryShutdownMetrics;
|
||||||
|
@ -54,16 +63,11 @@ static DeviceHealth deviceHealth;
|
||||||
constexpr char kUfsHealthEol[]{UFS_DIR "/health_descriptor/eol_info"};
|
constexpr char kUfsHealthEol[]{UFS_DIR "/health_descriptor/eol_info"};
|
||||||
constexpr char kUfsHealthLifetimeA[]{UFS_DIR "/health_descriptor/life_time_estimation_a"};
|
constexpr char kUfsHealthLifetimeA[]{UFS_DIR "/health_descriptor/life_time_estimation_a"};
|
||||||
constexpr char kUfsHealthLifetimeB[]{UFS_DIR "/health_descriptor/life_time_estimation_b"};
|
constexpr char kUfsHealthLifetimeB[]{UFS_DIR "/health_descriptor/life_time_estimation_b"};
|
||||||
|
|
||||||
constexpr char kDiskStatsFile[]{"/sys/block/sda/stat"};
|
constexpr char kDiskStatsFile[]{"/sys/block/sda/stat"};
|
||||||
constexpr char kUFSName[]{"UFS0"};
|
constexpr char kUFSName[]{"UFS0"};
|
||||||
|
|
||||||
constexpr char kTCPMPSYName[]{"tcpm-source-psy-usbpd0"};
|
constexpr char kTCPMPSYName[]{"tcpm-source-psy-usbpd0"};
|
||||||
|
|
||||||
#define WLC_DIR "/sys/class/power_supply/wireless"
|
|
||||||
static bool needs_wlc_updates = false;
|
|
||||||
constexpr char kWlcCapacity[]{WLC_DIR "/capacity"};
|
|
||||||
|
|
||||||
std::ifstream assert_open(const std::string &path) {
|
std::ifstream assert_open(const std::string &path) {
|
||||||
std::ifstream stream(path);
|
std::ifstream stream(path);
|
||||||
if (!stream.is_open()) {
|
if (!stream.is_open()) {
|
||||||
|
@ -85,32 +89,18 @@ void fill_ufs_storage_attribute(StorageAttribute *attr) {
|
||||||
attr->name = kUFSName;
|
attr->name = kUFSName;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // anonymous namespace
|
void private_healthd_board_init(struct healthd_config *hc) {
|
||||||
|
|
||||||
static bool FileExists(const std::string &filename) {
|
|
||||||
struct stat buffer;
|
|
||||||
|
|
||||||
return stat(filename.c_str(), &buffer) == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void healthd_board_init(struct healthd_config *hc) {
|
|
||||||
hc->ignorePowerSupplyNames.push_back(android::String8(kTCPMPSYName));
|
hc->ignorePowerSupplyNames.push_back(android::String8(kTCPMPSYName));
|
||||||
needs_wlc_updates = FileExists(kWlcCapacity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int healthd_board_battery_update(struct android::BatteryProperties *props) {
|
int private_healthd_board_battery_update(struct android::BatteryProperties *props) {
|
||||||
deviceHealth.update(props);
|
deviceHealth.update(props);
|
||||||
battMetricsLogger.logBatteryProperties(props);
|
battMetricsLogger.logBatteryProperties(props);
|
||||||
shutdownMetrics.logShutdownVoltage(props);
|
shutdownMetrics.logShutdownVoltage(props);
|
||||||
|
|
||||||
if (needs_wlc_updates &&
|
|
||||||
!android::base::WriteStringToFile(std::to_string(props->batteryLevel), kWlcCapacity))
|
|
||||||
LOG(INFO) << "Unable to write battery level to wireless capacity";
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_storage_info(std::vector<StorageInfo> &vec_storage_info) {
|
void private_get_storage_info(std::vector<StorageInfo> &vec_storage_info) {
|
||||||
vec_storage_info.resize(1);
|
vec_storage_info.resize(1);
|
||||||
StorageInfo *storage_info = &vec_storage_info[0];
|
StorageInfo *storage_info = &vec_storage_info[0];
|
||||||
fill_ufs_storage_attribute(&storage_info->attr);
|
fill_ufs_storage_attribute(&storage_info->attr);
|
||||||
|
@ -121,7 +111,7 @@ void get_storage_info(std::vector<StorageInfo> &vec_storage_info) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_disk_stats(std::vector<DiskStats> &vec_stats) {
|
void private_get_disk_stats(std::vector<DiskStats> &vec_stats) {
|
||||||
vec_stats.resize(1);
|
vec_stats.resize(1);
|
||||||
DiskStats *stats = &vec_stats[0];
|
DiskStats *stats = &vec_stats[0];
|
||||||
fill_ufs_storage_attribute(&stats->attr);
|
fill_ufs_storage_attribute(&stats->attr);
|
||||||
|
@ -134,5 +124,74 @@ void get_disk_stats(std::vector<DiskStats> &vec_stats) {
|
||||||
stats->ioTicks >> stats->ioInQueue;
|
stats->ioTicks >> stats->ioInQueue;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
} // anonymous namespace
|
||||||
|
|
||||||
int main(void) { return health_service_main(); }
|
namespace android {
|
||||||
|
namespace hardware {
|
||||||
|
namespace health {
|
||||||
|
namespace V2_1 {
|
||||||
|
namespace implementation {
|
||||||
|
class HealthImpl : public Health {
|
||||||
|
public:
|
||||||
|
HealthImpl(std::unique_ptr<healthd_config>&& config)
|
||||||
|
: Health(std::move(config)) {}
|
||||||
|
|
||||||
|
Return<void> getStorageInfo(getStorageInfo_cb _hidl_cb) override;
|
||||||
|
Return<void> getDiskStats(getDiskStats_cb _hidl_cb) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void UpdateHealthInfo(HealthInfo* health_info) override;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
void HealthImpl::UpdateHealthInfo(HealthInfo* health_info) {
|
||||||
|
struct BatteryProperties props;
|
||||||
|
convertFromHealthInfo(health_info->legacy.legacy, &props);
|
||||||
|
private_healthd_board_battery_update(&props);
|
||||||
|
convertToHealthInfo(&props, health_info->legacy.legacy);
|
||||||
|
}
|
||||||
|
|
||||||
|
Return<void> HealthImpl::getStorageInfo(getStorageInfo_cb _hidl_cb)
|
||||||
|
{
|
||||||
|
std::vector<struct StorageInfo> info;
|
||||||
|
private_get_storage_info(info);
|
||||||
|
hidl_vec<struct StorageInfo> info_vec(info);
|
||||||
|
if (!info.size()) {
|
||||||
|
_hidl_cb(Result::NOT_SUPPORTED, info_vec);
|
||||||
|
} else {
|
||||||
|
_hidl_cb(Result::SUCCESS, info_vec);
|
||||||
|
}
|
||||||
|
return Void();
|
||||||
|
}
|
||||||
|
|
||||||
|
Return<void> HealthImpl::getDiskStats(getDiskStats_cb _hidl_cb)
|
||||||
|
{
|
||||||
|
std::vector<struct DiskStats> stats;
|
||||||
|
private_get_disk_stats(stats);
|
||||||
|
hidl_vec<struct DiskStats> stats_vec(stats);
|
||||||
|
if (!stats.size()) {
|
||||||
|
_hidl_cb(Result::NOT_SUPPORTED, stats_vec);
|
||||||
|
} else {
|
||||||
|
_hidl_cb(Result::SUCCESS, stats_vec);
|
||||||
|
}
|
||||||
|
return Void();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace implementation
|
||||||
|
} // namespace V2_1
|
||||||
|
} // namespace health
|
||||||
|
} // namespace hardware
|
||||||
|
} // namespace android
|
||||||
|
|
||||||
|
extern "C" IHealth* HIDL_FETCH_IHealth(const char* instance) {
|
||||||
|
using ::android::hardware::health::V2_1::implementation::HealthImpl;
|
||||||
|
if (instance != "default"sv) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
auto config = std::make_unique<healthd_config>();
|
||||||
|
InitHealthdConfig(config.get());
|
||||||
|
|
||||||
|
private_healthd_board_init(config.get());
|
||||||
|
|
||||||
|
return new HealthImpl(std::move(config));
|
||||||
|
}
|
|
@ -1,5 +0,0 @@
|
||||||
service vendor.health-hal-2-0 /vendor/bin/hw/android.hardware.health@2.0-service.redfin
|
|
||||||
class hal
|
|
||||||
user system
|
|
||||||
group system
|
|
||||||
file /dev/kmsg w
|
|
Loading…
Reference in New Issue