Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5f68afa3 authored by Yifan Hong's avatar Yifan Hong Committed by Automerger Merge Worker
Browse files

Merge "Remove impl and VTS for health 1.0." am: c95b5813 am: e9647598 am: a7d8b05b

Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/1552995

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ide7c8a126002220e50133d6ebd9c83116b0bb5d2
parents b9579ecd a7d8b05b
Loading
Loading
Loading
Loading
+0 −59
Original line number Original line Diff line number Diff line
@@ -17,62 +17,3 @@ cc_library_static {
    ],
    ],


}
}

cc_library_static {
    name: "android.hardware.health@1.0-impl-helper",
    vendor: true,
    srcs: ["Health.cpp"],

    header_libs: [
        "libbase_headers",
        "libhealthd_headers",
    ],

    shared_libs: [
        "libcutils",
        "libhidlbase",
        "liblog",
        "libutils",
        "android.hardware.health@1.0",
    ],

    static_libs: [
        "android.hardware.health@1.0-convert",
    ],
}

cc_library_shared {
    name: "android.hardware.health@1.0-impl",
    vendor: true,
    relative_install_path: "hw",

    static_libs: [
        "android.hardware.health@1.0-impl-helper",
        "android.hardware.health@1.0-convert",
        "libhealthd.default",
    ],

    shared_libs: [
        "libhidlbase",
        "libutils",
        "android.hardware.health@1.0",
    ],
}

cc_binary {
    name: "android.hardware.health@1.0-service",
    vendor: true,
    relative_install_path: "hw",
    init_rc: ["android.hardware.health@1.0-service.rc"],
    srcs: ["HealthService.cpp"],

    shared_libs: [
        "liblog",
        "libcutils",
        "libdl",
        "libbase",
        "libutils",
        "libhidlbase",
        "android.hardware.health@1.0",
    ],
}

health/1.0/default/Health.cpp

deleted100644 → 0
+0 −93
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * 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 "health-hal"

#include <Health.h>
#include <include/hal_conversion.h>

namespace android {
namespace hardware {
namespace health {
namespace V1_0 {
namespace implementation {

using ::android::hardware::health::V1_0::hal_conversion::convertToHealthConfig;
using ::android::hardware::health::V1_0::hal_conversion::convertFromHealthConfig;
using ::android::hardware::health::V1_0::hal_conversion::convertToHealthInfo;
using ::android::hardware::health::V1_0::hal_conversion::convertFromHealthInfo;

// Methods from ::android::hardware::health::V1_0::IHealth follow.
Return<void> Health::init(const HealthConfig& config, init_cb _hidl_cb)  {
    struct healthd_config healthd_config = {};
    HealthConfig configOut;

    // To keep working with existing healthd static HALs,
    // convert the new HealthConfig to the old healthd_config
    // and back.

    convertFromHealthConfig(config, &healthd_config);
    healthd_board_init(&healthd_config);
    mGetEnergyCounter = healthd_config.energyCounter;
    convertToHealthConfig(&healthd_config, configOut);

    _hidl_cb(configOut);

    return Void();
}

Return<void> Health::update(const HealthInfo& info, update_cb _hidl_cb)  {
    struct android::BatteryProperties p = {};
    HealthInfo infoOut;

    // To keep working with existing healthd static HALs,
    // convert the new HealthInfo to android::Batteryproperties
    // and back.

    convertFromHealthInfo(info, &p);
    int skipLogging = healthd_board_battery_update(&p);
    convertToHealthInfo(&p, infoOut);

    _hidl_cb(!!skipLogging, infoOut);

    return Void();
}

Return<void> Health::energyCounter(energyCounter_cb _hidl_cb) {
    int64_t energy = 0;
    Result result = Result::NOT_SUPPORTED;

    if (mGetEnergyCounter) {
        int status = mGetEnergyCounter(&energy);
        if (status == 0) {
            result = Result::SUCCESS;
        }
    }

    _hidl_cb(result, energy);

   return Void();
}

IHealth* HIDL_FETCH_IHealth(const char* /* name */) {
    return new Health();
}

} // namespace implementation
}  // namespace V1_0
}  // namespace health
}  // namespace hardware
}  // namespace android

health/1.0/default/Health.h

deleted100644 → 0
+0 −57
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * 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.
 */
#ifndef ANDROID_HARDWARE_HEALTH_V1_0_HEALTH_H
#define ANDROID_HARDWARE_HEALTH_V1_0_HEALTH_H

#include <android/hardware/health/1.0/IHealth.h>
#include <hidl/Status.h>
#include <hidl/MQDescriptor.h>
#include <healthd/healthd.h>
#include <utils/String8.h>

namespace android {
namespace hardware {
namespace health {
namespace V1_0 {
namespace implementation {

using ::android::hardware::health::V1_0::HealthInfo;
using ::android::hardware::health::V1_0::HealthConfig;
using ::android::hardware::health::V1_0::IHealth;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::hardware::hidl_vec;
using ::android::hardware::hidl_string;
using ::android::sp;

struct Health : public IHealth {
    // Methods from ::android::hardware::health::V1_0::IHealth follow.
    Return<void> init(const HealthConfig& config, init_cb _hidl_cb)  override;
    Return<void> update(const HealthInfo& info, update_cb _hidl_cb)  override;
    Return<void> energyCounter(energyCounter_cb _hidl_cb) override;
private:
    std::function<int(int64_t *)> mGetEnergyCounter;
};

extern "C" IHealth* HIDL_FETCH_IHealth(const char* name);

}  // namespace implementation
}  // namespace V1_0
}  // namespace health
}  // namespace hardware
}  // namespace android

#endif  // ANDROID_HARDWARE_HEALTH_V1_0_HEALTH_H
+0 −27
Original line number Original line Diff line number Diff line
/*
 * Copyright 2016 The Android Open Source Project
 *
 * 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 "android.hardware.health@1.0-service"

#include <android/hardware/health/1.0/IHealth.h>
#include <hidl/LegacySupport.h>

using android::hardware::health::V1_0::IHealth;
using android::hardware::defaultPassthroughServiceImplementation;

int main() {
    return defaultPassthroughServiceImplementation<IHealth>();
}

health/1.0/default/README.md

deleted100644 → 0
+0 −66
Original line number Original line Diff line number Diff line
# Implement the 2.1 HAL instead!

It is strongly recommended that you implement the 2.1 HAL directly. See
`hardware/interfaces/health/2.1/README.md` for more details.

# Implement Health 1.0 HAL

1. Install common binderized service. The binderized service `dlopen()`s
   passthrough implementations on the device, so there is no need to write
   your own.

    ```mk
    # Install default binderized implementation to vendor.
    PRODUCT_PACKAGES += android.hardware.health@1.0-service
    ```

1. Add proper VINTF manifest entry to your device manifest. Example:

    ```xml
    <hal format="hidl">
        <name>android.hardware.health</name>
        <transport>hwbinder</transport>
        <version>1.0</version>
        <interface>
            <name>IHealth</name>
            <instance>default</instance>
        </interface>
    </hal>
    ```

1. Install the proper passthrough implemetation.

    1. If you want to use the default implementation (with default `libhealthd`),
       add the following to `device.mk`:

        ```mk
        PRODUCT_PACKAGES += \
            android.hardware.health@1.0-impl
        ```

    1. Otherwise, if you have a customized `libhealthd.<board>`:

        1. Define your passthrough implementation. Example (replace `<device>`
           and `<board>` accordingly):

            ```bp
            cc_library_shared {
                name: "android.hardware.health@1.0-impl-<device>",
                vendor: true,
                relative_install_path: "hw",

                static_libs: [
                    "android.hardware.health@1.0-impl-helper",
                    "android.hardware.health@1.0-convert",
                    "libhealthd.<board>",
                ],
            }
            ```

        1. Add to `device.mk`.

            ```
            PRODUCT_PACKAGES += android.hardware.health@1.0-impl-<device>
            ```

        1. Define appropriate SELinux permissions.
Loading