From c3894a4df8d8362fe5b1ccb9ee0ddb6ead046003 Mon Sep 17 00:00:00 2001 From: Matt Buckley Date: Thu, 1 Sep 2022 21:17:15 +0000 Subject: Extend PowerHalWrapper to support HIDL 1.2 and 1.3 * Added support for 1.2 and 1.3 HIDL calls to the PowerHalWrapper * Expanded the wrapper and loader tests to cover these new versions * Lightly tweaked the existing tests to make them more comprehensive Bug: b/244631171 Test: atest libpowermanager_test Change-Id: I5890106817b7cf243cdd21b3acf22ff7fcd8174e --- services/powermanager/PowerHalController.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'services/powermanager/PowerHalController.cpp') diff --git a/services/powermanager/PowerHalController.cpp b/services/powermanager/PowerHalController.cpp index 8c225d5d02..f89035fd1c 100644 --- a/services/powermanager/PowerHalController.cpp +++ b/services/powermanager/PowerHalController.cpp @@ -33,16 +33,20 @@ namespace power { // ------------------------------------------------------------------------------------------------- std::unique_ptr HalConnector::connect() { - sp halAidl = PowerHalLoader::loadAidl(); - if (halAidl) { + if (sp halAidl = PowerHalLoader::loadAidl()) { return std::make_unique(halAidl); } - sp halHidlV1_0 = PowerHalLoader::loadHidlV1_0(); - sp halHidlV1_1 = PowerHalLoader::loadHidlV1_1(); - if (halHidlV1_1) { - return std::make_unique(halHidlV1_0, halHidlV1_1); - } - if (halHidlV1_0) { + // If V1_0 isn't defined, none of them are + if (sp halHidlV1_0 = PowerHalLoader::loadHidlV1_0()) { + if (sp halHidlV1_3 = PowerHalLoader::loadHidlV1_3()) { + return std::make_unique(halHidlV1_3); + } + if (sp halHidlV1_2 = PowerHalLoader::loadHidlV1_2()) { + return std::make_unique(halHidlV1_2); + } + if (sp halHidlV1_1 = PowerHalLoader::loadHidlV1_1()) { + return std::make_unique(halHidlV1_1); + } return std::make_unique(halHidlV1_0); } return nullptr; -- cgit v1.2.3-59-g8ed1b