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

Commit 84ce54eb authored by Wei Wang's avatar Wei Wang
Browse files

Add thermal HAL 2.0

Bug: 116540200
Test: add default ThermalHAL 2.0 and VtsHalThermalV2_0TargetTest pass
Change-Id: Ib12634459d9ed5071230adf353b9737f5c90e771
parent 6a7e67cc
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -398,6 +398,7 @@
    <hal format="hidl" optional="true">
        <name>android.hardware.thermal</name>
        <version>1.0-1</version>
        <version>2.0</version>
        <interface>
            <name>IThermal</name>
            <instance>default</instance>

thermal/2.0/Android.bp

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

hidl_interface {
    name: "android.hardware.thermal@2.0",
    root: "android.hardware",
    vndk: {
        enabled: true,
    },
    srcs: [
        "types.hal",
        "IThermal.hal",
        "IThermalChangedCallback.hal",
    ],
    interfaces: [
        "android.hardware.thermal@1.0",
        "android.hidl.base@1.0",
    ],
    types: [
        "CoolingDevice",
        "CoolingType",
        "Temperature",
        "TemperatureThreshold",
        "TemperatureType",
        "ThrottlingSeverity",
        "ThrottlingSeverityCount",
    ],
    gen_java: true,
}
+113 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 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.thermal@2.0;

import android.hardware.thermal@1.0::IThermal;
import android.hardware.thermal@1.0::ThermalStatus;
import IThermalChangedCallback;

interface IThermal extends @1.0::IThermal {

    /**
     * Retrieves temperatures in Celsius.
     *
     * @param filterType whether to filter the result for a given type.
     * @param type the TemperatureType such as battery or skin.
     *
     * @return status Status of the operation. If status code is FAILURE,
     *    the status.debugMessage must be populated with a human-readable
     *    error message.
     *
     * @return temperatures If status code is SUCCESS, it's filled with the
     *    current temperatures. The order of temperatures of built-in
     *    devices (such as CPUs, GPUs and etc.) in the list must be kept
     *    the same regardless of the number of calls to this method even if
     *    they go offline, if these devices exist on boot. The method
     *    always returns and never removes such temperatures.
     */
    getCurrentTemperatures(bool filterType, TemperatureType type)
        generates (ThermalStatus status, vec<Temperature> temperatures);

    /**
     * Retrieves temperature thresholds in Celsius.
     *
     * @param filterType whether to filter the result for a given type.
     * @param type the TemperatureType such as battery or skin.
     *
     * @return status Status of the operation. If status code is FAILURE,
     *    the status.debugMessage must be populated with a human-readable error message.
     * @return temperatureThresholds If status code is SUCCESS, it's filled with the
     *    temperatures thresholds. The order of temperatures of built-in
     *    devices (such as CPUs, GPUs and etc.) in the list must be kept
     *    the same regardless of the number of calls to this method even if
     *    they go offline, if these devices exist on boot. The method
     *    always returns and never removes such temperatures.
     */
    getTemperatureThresholds(bool filterType, TemperatureType type)
        generates (ThermalStatus status, vec<TemperatureThreshold> temperatureThresholds);

   /**
    * Register an IThermalChangedCallback, used by the Thermal HAL
    * to send thermal events when thermal mitigation status changed.
    * Multiple registrations with different IThermalChangedCallback must be allowed.
    * Multiple registrations with same IThermalChangedCallback is not allowed, client
    * should unregister the given IThermalChangedCallback first.
    *
    * @param callback the IThermalChangedCallback to use for sending
    *    thermal events (cannot be nullptr).
    * @param filterType if filter for given sensor type.
    * @param type the type to be filtered.
    *
    * @return status Status of the operation. If status code is FAILURE,
    *    the status.debugMessage must be populated with a human-readable error message.
    */
   registerThermalChangedCallback(IThermalChangedCallback callback,
                                  bool filterType,
                                  TemperatureType type)
       generates (ThermalStatus status);

   /**
    * Register an IThermalChangedCallback, used by the Thermal HAL
    * to send thermal events when thermal mitigation status changed.
    *
    * @param callback the IThermalChangedCallback to use for sending
    *    thermal events, or nullptr to set no callback.
    *
    * @return status Status of the operation. If status code is FAILURE,
    *    the status.debugMessage must be populated with a human-readable error message.
    */
   unregisterThermalChangedCallback(IThermalChangedCallback callback)
       generates (ThermalStatus status);

    /**
     * Retrieves the cooling devices information.
     *
     * @param filterType whether to filter the result for a given type.
     * @param type the CoolingDevice such as CPU/GPU.
     *
     * @return status Status of the operation. If status code is FAILURE,
     *    the status.debugMessage must be populated with the human-readable
     *    error message.
     * @return devices If status code is SUCCESS, it's filled with the current
     *    cooling device information. The order of built-in cooling
     *    devices in the list must be kept the same regardless of the number
     *    of calls to this method even if they go offline, if these devices
     *    exist on boot. The method always returns and never removes from
     *    the list such cooling devices.
     */
   getCurrentCoolingDevices(bool filterType, CoolingType type)
       generates (ThermalStatus status, vec<CoolingDevice> devices);
};
+33 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 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.thermal@2.0;

import android.hardware.thermal@2.0::Temperature;

/**
 * IThermalChangedCallback send throttling notification to clients.
 */
interface IThermalChangedCallback {
    /**
     * Send a thermal throttling event to all ThermalHAL
     * thermal event listeners.
     *
     * @param temperature The temperature associated with the
     *    throttling event.
     */
    oneway notifyThrottling (Temperature temperature);
};
+35 −0
Original line number Diff line number Diff line
//
// Copyright (C) 2018 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.

cc_binary {
    name: "android.hardware.thermal@2.0-service",
    defaults: ["hidl_defaults"],
    relative_install_path: "hw",
    vendor: true,
    init_rc: ["android.hardware.thermal@2.0-service.rc"],
    vintf_fragments: ["android.hardware.thermal@2.0-service.xml"],
    srcs: [
        "Thermal.cpp",
        "service.cpp"
    ],
    shared_libs: [
        "libbase",
        "libhidlbase",
        "libhidltransport",
        "libutils",
        "android.hardware.thermal@2.0",
        "android.hardware.thermal@1.0",
    ],
}
Loading