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

Commit a1e654d8 authored by Yifan Hong's avatar Yifan Hong Committed by Gerrit Code Review
Browse files

Merge changes from topic "health21"

* changes:
  Require health 2.1 on R devices
  health 2.1
parents fac4d204 abdf4198
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -221,7 +221,7 @@
    </hal>
    <hal format="hidl" optional="false">
        <name>android.hardware.health</name>
        <version>2.0</version>
        <version>2.1</version>
        <interface>
            <name>IHealth</name>
            <instance>default</instance>

health/2.1/Android.bp

0 → 100644
+20 −0
Original line number Diff line number Diff line
// This file is autogenerated by hidl-gen -Landroidbp.

hidl_interface {
    name: "android.hardware.health@2.1",
    root: "android.hardware",
    vndk: {
        enabled: true,
    },
    srcs: [
        "types.hal",
        "IHealth.hal",
        "IHealthInfoCallback.hal",
    ],
    interfaces: [
        "android.hardware.health@1.0",
        "android.hardware.health@2.0",
        "android.hidl.base@1.0",
    ],
    gen_java: true,
}

health/2.1/IHealth.hal

0 → 100644
+80 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 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.
 */

package android.hardware.health@2.1;

import @2.0::IHealth;
import @2.0::Result;
import HealthConfig;
import HealthInfo;
import IHealthInfoCallback;

/**
 * IHealth manages health info and posts events on registered callbacks.
 *
 * An implementation of @2.1::IHealth must be able to handle both
 * @2.0::IHealthInfoCallback and @2.1::IHealthInfoCallback.
 * - When registerCallback() is called, an implementation must cast the callback
 * to @2.1::IHealthInfoCallback.
 *   - If the cast is successful, when a health info broadcast is sent, the
 *     implementation must call
 *     @2.1::IHealthInfoCallback.healthInfoChanged_2_1(). All fields introduced
 *     in 2.1 must be set appropriately. The implementation must not call
 *     @2.0::IHealthInfoCallback.healthInfoChanged().
 *   - If the cast is unsuccessful, the implementation must call
 *     @2.0::IHealthInfoCallback.healthInfoChanged().
 * - When unregisterCallback() is called, from then on, updates must not be sent
 *   through either healthInfoChanged_2_1() or healthInfoChanged().
 *
 * Passthrough implementations are not required to send health info to all
 * callbacks periodically, but they must do so when update() is called.
 * Binderized implementations must send health info to all callbacks
 * periodically. The intervals between two notifications must be retrieved from
 * the passthrough implementation through the getHealthConfig() function.
 */
interface IHealth extends @2.0::IHealth {
    /**
     * Get configuration of this HAL.
     *
     * @return result SUCCESS if successful,
     *                NOT_SUPPORTED if this API is not supported,
     *                UNKNOWN for other errors.
     * @return config HAL configuration, to be ignored if result is not
     *                SUCCESS.
     */
    getHealthConfig() generates (Result result, HealthConfig config);

    /**
     * Get Health Information.
     *
     * @return result SUCCESS if successful,
     *                NOT_SUPPORTED if this API is not supported,
     *                UNKNOWN for other errors.
     * @return value  Health information, to be ignored if result is not
     *                SUCCESS.
     */
    getHealthInfo_2_1() generates (Result result, @2.1::HealthInfo value);

    /**
     * Return whether the screen should be kept on in charger mode.
     *
     * @return result SUCCESS if successful,
     *                NOT_SUPPORTED if this API is not supported,
     *                UNKNOWN for other errors.
     * @return value whether screen should be kept on.
     */
    shouldKeepScreenOn() generates (Result result, bool value);
};
+36 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 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.
 */

package android.hardware.health@2.1;

import @2.0::IHealthInfoCallback;

/**
 * IHealthInfoCallback is the updated callback interface to
 * {@link IHealth.registerCallback}.
 *
 * A @2.1::IHealthInfoCallback must implement healthInfoChanged_2_1(). The
 * inherited healthInfoChanged() function is never called when the HAL
 * implementation post events. See documentation on @2.1::IHealth for details.
 */
interface IHealthInfoCallback extends @2.0::IHealthInfoCallback {
    /**
     * An implementation of IHealth must call healthInfoChanged on all
     * registered callbacks after health info changes.
     * @param info the updated HealthInfo
     */
    oneway healthInfoChanged_2_1(HealthInfo info);
};

health/2.1/types.hal

0 → 100644
+109 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 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.
 */

package android.hardware.health@2.1;

import @1.0::HealthConfig;
import @2.0::HealthInfo;

/**
 * Battery capacity level. This enum provides additional information along side
 * with the battery capacity.
 * Clients of this HAL must use this value before inferring it from the
 * battery capacity.
 */
enum BatteryCapacityLevel : int32_t {
    /**
     * Battery capacity level is unknown.
     * Battery capacity level must be set to this value if and only if battery
     * is not present.
     */
    UNKNOWN = 0,
    /**
     * Battery is at critical level. The Android framework must schedule a
     * shutdown when it sees this value from the HAL.
     */
    CRITICAL,
    /**
     * Battery is low. The Android framework may limit the performance of
     * the device when it sees this value from the HAL.
     */
    LOW,
    /**
     * Battery level is normal.
     */
    NORMAL,
    /**
     * Battery level is high.
     */
    HIGH,
    /**
     * Battery is full. It must be set to FULL if and only if battery level is
     * 100.
     */
    FULL,
};

/**
 * Combined Health Information.
 */
struct HealthInfo {
    /**
     * V2.0 HealthInfo.
     * If a member is unsupported, it is filled with:
     * - 0 (for integers);
     * - false (for booleans);
     * - empty string (for strings);
     * - UNKNOWN (for BatteryStatus and BatteryHealth).
     */
    @2.0::HealthInfo legacy;

    /**
     * Battery capacity level. See BatteryCapacityLevel for more details.
     */
    BatteryCapacityLevel batteryCapacityLevel;

    /**
     * Estimated time to fully charge the device (in seconds).
     * Value must be 0 if and only if batteryCapacityLevel is FULL or UNKNOWN.
     * Otherwise, value must be positive.
     */
    int64_t batteryChargeTimeToFullNowSeconds;

    /**
     * Estimated battery full capacity (in microamp hours, uAh).
     * Value must be 0 if unknown.
     * Value must be positive if known, and must be between [50%, 120%] of
     * batteryFullCharge (the designed capacity).
     */
    int32_t batteryFullCapacityUah;
};

/**
 * Combined configuration of a health HAL implementation.
 */
struct HealthConfig {
    /**
     * 1.0 version of health config.
     */
    @1.0::HealthConfig battery;

    /**
     * Minimum battery level for charger to reboot into Android (in percent).
     * Value should be in range [0, 100].
     */
    int32_t bootMinCap;
};
Loading