mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 11:36:00 +00:00
Merge "Convert Thermal HIDL to AIDL." am: 793bb7f070
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2239858 Change-Id: I1f60f20c929f411eb1a6278a8b8c9d2b29b6668d Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -672,9 +672,9 @@
|
||||
<instance>default</instance>
|
||||
</interface>
|
||||
</hal>
|
||||
<hal format="hidl" optional="false">
|
||||
<hal format="aidl" optional="false">
|
||||
<name>android.hardware.thermal</name>
|
||||
<version>2.0</version>
|
||||
<version>1</version>
|
||||
<interface>
|
||||
<name>IThermal</name>
|
||||
<instance>default</instance>
|
||||
|
||||
5
thermal/OWNERS
Normal file
5
thermal/OWNERS
Normal file
@@ -0,0 +1,5 @@
|
||||
# Bug component: 826709
|
||||
|
||||
# ADPF virtual team
|
||||
lpy@google.com
|
||||
wvw@google.com
|
||||
39
thermal/aidl/Android.bp
Normal file
39
thermal/aidl/Android.bp
Normal file
@@ -0,0 +1,39 @@
|
||||
// Copyright (C) 2022 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 {
|
||||
// See: http://go/android-license-faq
|
||||
// A large-scale-change added 'default_applicable_licenses' to import
|
||||
// all of the 'license_kinds' from "hardware_interfaces_license"
|
||||
// to get the below license kinds:
|
||||
// SPDX-license-identifier-Apache-2.0
|
||||
default_applicable_licenses: ["hardware_interfaces_license"],
|
||||
}
|
||||
|
||||
aidl_interface {
|
||||
name: "android.hardware.thermal",
|
||||
vendor_available: true,
|
||||
srcs: [
|
||||
"android/hardware/thermal/*.aidl",
|
||||
],
|
||||
stability: "vintf",
|
||||
backend: {
|
||||
cpp: {
|
||||
enabled: true,
|
||||
},
|
||||
java: {
|
||||
platform_apis: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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
|
||||
*
|
||||
1 * 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.
|
||||
*/
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL file. Do not edit it manually. There are
|
||||
// two cases:
|
||||
// 1). this is a frozen version file - do not edit this in any case.
|
||||
// 2). this is a 'current' file. If you make a backwards compatible change to
|
||||
// the interface (from the latest frozen version), the build system will
|
||||
// prompt you to update this file with `m <name>-update-api`.
|
||||
//
|
||||
// You must not make a backward incompatible change to any AIDL file built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.thermal;
|
||||
@VintfStability
|
||||
parcelable CoolingDevice {
|
||||
android.hardware.thermal.CoolingType type;
|
||||
String name;
|
||||
long value;
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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.
|
||||
*/
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL file. Do not edit it manually. There are
|
||||
// two cases:
|
||||
// 1). this is a frozen version file - do not edit this in any case.
|
||||
// 2). this is a 'current' file. If you make a backwards compatible change to
|
||||
// the interface (from the latest frozen version), the build system will
|
||||
// prompt you to update this file with `m <name>-update-api`.
|
||||
//
|
||||
// You must not make a backward incompatible change to any AIDL file built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.thermal;
|
||||
@Backing(type="int") @VintfStability
|
||||
enum CoolingType {
|
||||
FAN = 0,
|
||||
BATTERY = 1,
|
||||
CPU = 2,
|
||||
GPU = 3,
|
||||
MODEM = 4,
|
||||
NPU = 5,
|
||||
COMPONENT = 6,
|
||||
TPU = 7,
|
||||
POWER_AMPLIFIER = 8,
|
||||
DISPLAY = 9,
|
||||
SPEAKER = 10,
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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.
|
||||
*/
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL file. Do not edit it manually. There are
|
||||
// two cases:
|
||||
// 1). this is a frozen version file - do not edit this in any case.
|
||||
// 2). this is a 'current' file. If you make a backwards compatible change to
|
||||
// the interface (from the latest frozen version), the build system will
|
||||
// prompt you to update this file with `m <name>-update-api`.
|
||||
//
|
||||
// You must not make a backward incompatible change to any AIDL file built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.thermal;
|
||||
@VintfStability
|
||||
interface IThermal {
|
||||
android.hardware.thermal.CoolingDevice[] getCoolingDevices();
|
||||
android.hardware.thermal.CoolingDevice[] getCoolingDevicesWithType(in android.hardware.thermal.CoolingType type);
|
||||
android.hardware.thermal.Temperature[] getTemperatures();
|
||||
android.hardware.thermal.Temperature[] getTemperaturesWithType(in android.hardware.thermal.TemperatureType type);
|
||||
android.hardware.thermal.TemperatureThreshold[] getTemperatureThresholds();
|
||||
android.hardware.thermal.TemperatureThreshold[] getTemperatureThresholdsWithType(in android.hardware.thermal.TemperatureType type);
|
||||
void registerThermalChangedCallback(in android.hardware.thermal.IThermalChangedCallback callback);
|
||||
void registerThermalChangedCallbackWithType(in android.hardware.thermal.IThermalChangedCallback callback, in android.hardware.thermal.TemperatureType type);
|
||||
void unregisterThermalChangedCallback(in android.hardware.thermal.IThermalChangedCallback callback);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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.
|
||||
*/
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL file. Do not edit it manually. There are
|
||||
// two cases:
|
||||
// 1). this is a frozen version file - do not edit this in any case.
|
||||
// 2). this is a 'current' file. If you make a backwards compatible change to
|
||||
// the interface (from the latest frozen version), the build system will
|
||||
// prompt you to update this file with `m <name>-update-api`.
|
||||
//
|
||||
// You must not make a backward incompatible change to any AIDL file built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.thermal;
|
||||
@VintfStability
|
||||
interface IThermalChangedCallback {
|
||||
oneway void notifyThrottling(in android.hardware.thermal.Temperature temperature);
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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.
|
||||
*/
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL file. Do not edit it manually. There are
|
||||
// two cases:
|
||||
// 1). this is a frozen version file - do not edit this in any case.
|
||||
// 2). this is a 'current' file. If you make a backwards compatible change to
|
||||
// the interface (from the latest frozen version), the build system will
|
||||
// prompt you to update this file with `m <name>-update-api`.
|
||||
//
|
||||
// You must not make a backward incompatible change to any AIDL file built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.thermal;
|
||||
@VintfStability
|
||||
parcelable Temperature {
|
||||
android.hardware.thermal.TemperatureType type;
|
||||
String name;
|
||||
float value;
|
||||
android.hardware.thermal.ThrottlingSeverity throttlingStatus;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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.
|
||||
*/
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL file. Do not edit it manually. There are
|
||||
// two cases:
|
||||
// 1). this is a frozen version file - do not edit this in any case.
|
||||
// 2). this is a 'current' file. If you make a backwards compatible change to
|
||||
// the interface (from the latest frozen version), the build system will
|
||||
// prompt you to update this file with `m <name>-update-api`.
|
||||
//
|
||||
// You must not make a backward incompatible change to any AIDL file built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.thermal;
|
||||
@VintfStability
|
||||
parcelable TemperatureThreshold {
|
||||
android.hardware.thermal.TemperatureType type;
|
||||
String name;
|
||||
float[] hotThrottlingThresholds;
|
||||
float[] coldThrottlingThresholds;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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.
|
||||
*/
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL file. Do not edit it manually. There are
|
||||
// two cases:
|
||||
// 1). this is a frozen version file - do not edit this in any case.
|
||||
// 2). this is a 'current' file. If you make a backwards compatible change to
|
||||
// the interface (from the latest frozen version), the build system will
|
||||
// prompt you to update this file with `m <name>-update-api`.
|
||||
//
|
||||
// You must not make a backward incompatible change to any AIDL file built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.thermal;
|
||||
@Backing(type="int") @VintfStability
|
||||
enum TemperatureType {
|
||||
UNKNOWN = -1,
|
||||
CPU = 0,
|
||||
GPU = 1,
|
||||
BATTERY = 2,
|
||||
SKIN = 3,
|
||||
USB_PORT = 4,
|
||||
POWER_AMPLIFIER = 5,
|
||||
BCL_VOLTAGE = 6,
|
||||
BCL_CURRENT = 7,
|
||||
BCL_PERCENTAGE = 8,
|
||||
NPU = 9,
|
||||
TPU = 10,
|
||||
DISPLAY = 11,
|
||||
MODEM = 12,
|
||||
SOC = 13,
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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.
|
||||
*/
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// This file is a snapshot of an AIDL file. Do not edit it manually. There are
|
||||
// two cases:
|
||||
// 1). this is a frozen version file - do not edit this in any case.
|
||||
// 2). this is a 'current' file. If you make a backwards compatible change to
|
||||
// the interface (from the latest frozen version), the build system will
|
||||
// prompt you to update this file with `m <name>-update-api`.
|
||||
//
|
||||
// You must not make a backward incompatible change to any AIDL file built
|
||||
// with the aidl_interface module type with versions property set. The module
|
||||
// type is used to build AIDL files in a way that they can be used across
|
||||
// independently updatable components of the system. If a device is shipped
|
||||
// with such a backward incompatible change, it has a high risk of breaking
|
||||
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||
|
||||
package android.hardware.thermal;
|
||||
@Backing(type="int") @VintfStability
|
||||
enum ThrottlingSeverity {
|
||||
NONE = 0,
|
||||
LIGHT = 1,
|
||||
MODERATE = 2,
|
||||
SEVERE = 3,
|
||||
CRITICAL = 4,
|
||||
EMERGENCY = 5,
|
||||
SHUTDOWN = 6,
|
||||
}
|
||||
41
thermal/aidl/android/hardware/thermal/CoolingDevice.aidl
Normal file
41
thermal/aidl/android/hardware/thermal/CoolingDevice.aidl
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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
|
||||
*
|
||||
1 * 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;
|
||||
|
||||
import android.hardware.thermal.CoolingType;
|
||||
|
||||
@VintfStability
|
||||
parcelable CoolingDevice {
|
||||
/**
|
||||
* This cooling device type, CPU, GPU, BATTERY, and etc.
|
||||
*/
|
||||
CoolingType type;
|
||||
/**
|
||||
* Name of this cooling device.
|
||||
* All cooling devices of the same "type" must have a different "name".
|
||||
* The name is usually defined in kernel device tree, and this is for client
|
||||
* logging purpose.
|
||||
*/
|
||||
String name;
|
||||
/**
|
||||
* Current throttle state of the cooling device. The value can any unsigned integer
|
||||
* numbers between 0 and max_state defined in its driver, usually representing the
|
||||
* associated device's power state. 0 means device is not in throttling, higher value
|
||||
* means deeper throttling.
|
||||
*/
|
||||
long value;
|
||||
}
|
||||
36
thermal/aidl/android/hardware/thermal/CoolingType.aidl
Normal file
36
thermal/aidl/android/hardware/thermal/CoolingType.aidl
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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;
|
||||
|
||||
/**
|
||||
* Device cooling device types
|
||||
*/
|
||||
@VintfStability
|
||||
@Backing(type="int")
|
||||
enum CoolingType {
|
||||
FAN,
|
||||
BATTERY,
|
||||
CPU,
|
||||
GPU,
|
||||
MODEM,
|
||||
NPU,
|
||||
COMPONENT,
|
||||
TPU,
|
||||
POWER_AMPLIFIER,
|
||||
DISPLAY,
|
||||
SPEAKER,
|
||||
}
|
||||
202
thermal/aidl/android/hardware/thermal/IThermal.aidl
Normal file
202
thermal/aidl/android/hardware/thermal/IThermal.aidl
Normal file
@@ -0,0 +1,202 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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;
|
||||
|
||||
import android.hardware.thermal.CoolingDevice;
|
||||
import android.hardware.thermal.CoolingType;
|
||||
import android.hardware.thermal.IThermalChangedCallback;
|
||||
import android.hardware.thermal.Temperature;
|
||||
import android.hardware.thermal.TemperatureThreshold;
|
||||
import android.hardware.thermal.TemperatureType;
|
||||
|
||||
@VintfStability
|
||||
interface IThermal {
|
||||
/**
|
||||
* Retrieves the cooling devices information.
|
||||
*
|
||||
* @return devices If succeed, 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 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.
|
||||
*
|
||||
* @throws ScopedAStatus Status of the operation. If status code is not
|
||||
* STATUS_OK, getMessage() must be populated with the human-readable
|
||||
* error message.
|
||||
*/
|
||||
CoolingDevice[] getCoolingDevices();
|
||||
|
||||
/**
|
||||
* Retrieves the cooling devices information of a given CoolingType.
|
||||
*
|
||||
* @param type the CoolingDevice such as CPU/GPU.
|
||||
*
|
||||
* @return devices If succeed, 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.
|
||||
*
|
||||
* @throws ScopedAStatus Status of the operation. If status code is not
|
||||
* STATUS_OK, the getMessage() must be populated with the human-readable
|
||||
* error message.
|
||||
*/
|
||||
CoolingDevice[] getCoolingDevicesWithType(in CoolingType type);
|
||||
|
||||
/**
|
||||
* Retrieves temperatures in Celsius.
|
||||
*
|
||||
* @return temperatures If succeed, 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 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.
|
||||
*
|
||||
* @throws ScopedAStatus Status of the operation. If status code is not
|
||||
* STATUS_OK, the getMessage() must be populated with the human-readable
|
||||
* error message.
|
||||
*/
|
||||
Temperature[] getTemperatures();
|
||||
|
||||
/**
|
||||
* Retrieves temperatures in Celsius with a given TemperatureType.
|
||||
*
|
||||
* @param type the TemperatureType such as battery or skin.
|
||||
*
|
||||
* @return temperatures If succeed, 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.
|
||||
*
|
||||
* @throws ScopedAStatus Status of the operation. If status code is not
|
||||
* STATUS_OK, the getMessage() must be populated with the human-readable
|
||||
* error message.
|
||||
*/
|
||||
Temperature[] getTemperaturesWithType(in TemperatureType type);
|
||||
|
||||
/**
|
||||
* Retrieves static temperature thresholds in Celsius.
|
||||
*
|
||||
* @return temperatureThresholds If succeed, 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. The thresholds
|
||||
* are returned as static values and must not change across calls. The actual
|
||||
* throttling state is determined in device thermal mitigation policy/agorithm
|
||||
* which might not be simple thresholds so these values Thermal HAL provided
|
||||
* may not be accurate to detemin the throttling status. To get accurate
|
||||
* throttling status, use getTemperatures or registerThermalChangedCallback
|
||||
* and listen to the callback.
|
||||
*
|
||||
* @throws ScopedAStatus Status of the operation. If status code is not
|
||||
* STATUS_OK, the getMessage() must be populated with the human-readable
|
||||
* error message.
|
||||
*/
|
||||
TemperatureThreshold[] getTemperatureThresholds();
|
||||
|
||||
/**
|
||||
* Retrieves static temperature thresholds in Celsius of a given temperature
|
||||
* type.
|
||||
*
|
||||
* @param type the TemperatureType such as battery or skin.
|
||||
*
|
||||
* @return temperatureThresholds If succeed, 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. The thresholds
|
||||
* are returned as static values and must not change across calls. The actual
|
||||
* throttling state is determined in device thermal mitigation policy/agorithm
|
||||
* which might not be simple thresholds so these values Thermal HAL provided
|
||||
* may not be accurate to detemin the throttling status. To get accurate
|
||||
* throttling status, use getTemperatures or registerThermalChangedCallback
|
||||
* and listen to the callback.
|
||||
*
|
||||
* @throws ScopedAStatus Status of the operation. If status code is not
|
||||
* STATUS_OK, the getMessage() must be populated with the human-readable
|
||||
* error message.
|
||||
*/
|
||||
TemperatureThreshold[] getTemperatureThresholdsWithType(in TemperatureType type);
|
||||
|
||||
/**
|
||||
* Register an IThermalChangedCallback, used by the Thermal HAL to receive
|
||||
* 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 receiving
|
||||
* thermal events. if nullptr callback is given, the status code will be
|
||||
* STATUS_BAD_VALUE and the operation will fail.
|
||||
*
|
||||
* @throws ScopedAStatus Status of the operation. If status code is not
|
||||
* STATUS_OK, the getMessage() must be populated with the human-readable
|
||||
* error message. If callback is given nullptr, the returned status code
|
||||
* will be STATUS_BAD_VALUE and the exception will be EX_ILLEGAL_ARGUMENT.
|
||||
* if callback is already registered, the returned status code will be
|
||||
* STATUS_INVALID_OPERATION, the exception will be EX_ILLEGAL_ARGUMENT.
|
||||
*/
|
||||
void registerThermalChangedCallback(in IThermalChangedCallback callback);
|
||||
|
||||
/**
|
||||
* Register an IThermalChangedCallback for a given TemperatureType, used by
|
||||
* the Thermal HAL to receive 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 receiving
|
||||
* thermal events. if nullptr callback is given, the status code will be
|
||||
* STATUS_BAD_VALUE and the operation will fail.
|
||||
* @param type the type to be filtered.
|
||||
*
|
||||
* @throws ScopedAStatus Status of the operation. If status code is not
|
||||
* STATUS_OK, the getMessage() must be populated with the human-readable
|
||||
* error message. If callback is given nullptr, the returned status code
|
||||
* will be STATUS_BAD_VALUE and the exception will be EX_ILLEGAL_ARGUMENT.
|
||||
* if callback is already registered, the returned status code will be
|
||||
* STATUS_INVALID_OPERATION, the exception will be EX_ILLEGAL_ARGUMENT.
|
||||
*/
|
||||
void registerThermalChangedCallbackWithType(
|
||||
in IThermalChangedCallback callback, in TemperatureType type);
|
||||
|
||||
/**
|
||||
* Unregister an IThermalChangedCallback, used by the Thermal HAL
|
||||
* to receive thermal events when thermal mitigation status changed.
|
||||
*
|
||||
* @param callback the IThermalChangedCallback to use for receiving
|
||||
* thermal events. if nullptr callback is given, the status code will be
|
||||
* STATUS_BAD_VALUE and the operation will fail.
|
||||
*
|
||||
* @throws ScopedAStatus Status of the operation. If status code is not
|
||||
* STATUS_OK, the getMessage() must be populated with the human-readable
|
||||
* error message. If callback is given nullptr, the returned status code
|
||||
* will be STATUS_BAD_VALUE and the exception will be EX_ILLEGAL_ARGUMENT.
|
||||
* if callback is not registered, the returned status code will be
|
||||
* STATUS_INVALID_OPERATION, the exception will be EX_ILLEGAL_ARGUMENT.
|
||||
*/
|
||||
void unregisterThermalChangedCallback(in IThermalChangedCallback callback);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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;
|
||||
|
||||
import android.hardware.thermal.Temperature;
|
||||
|
||||
/**
|
||||
* IThermalChangedCallback send throttling notification to clients.
|
||||
*/
|
||||
@VintfStability
|
||||
interface IThermalChangedCallback {
|
||||
/**
|
||||
* Send a thermal throttling event to all ThermalHAL
|
||||
* thermal event listeners.
|
||||
*
|
||||
* @param temperature The temperature associated with the
|
||||
* throttling event.
|
||||
*/
|
||||
oneway void notifyThrottling(in Temperature temperature);
|
||||
}
|
||||
46
thermal/aidl/android/hardware/thermal/Temperature.aidl
Normal file
46
thermal/aidl/android/hardware/thermal/Temperature.aidl
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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;
|
||||
|
||||
import android.hardware.thermal.TemperatureType;
|
||||
import android.hardware.thermal.ThrottlingSeverity;
|
||||
|
||||
@VintfStability
|
||||
parcelable Temperature {
|
||||
/**
|
||||
* This temperature's type.
|
||||
*/
|
||||
TemperatureType type;
|
||||
/**
|
||||
* Name of this temperature matching the TemperatureThreshold.
|
||||
* All temperatures of the same "type" must have a different "name",
|
||||
* e.g., cpu0, battery. Clients use it to match with TemperatureThreshold
|
||||
* struct.
|
||||
*/
|
||||
String name;
|
||||
/**
|
||||
* For BCL, this is the current reading of the virtual sensor and the unit is
|
||||
* millivolt, milliamp, percentage for BCL_VOLTAGE, BCL_CURRENT and BCL_PERCENTAGE
|
||||
* respectively. For everything else, this is the current temperature in Celsius.
|
||||
* If not available set by HAL to NAN.
|
||||
*/
|
||||
float value;
|
||||
/**
|
||||
* The current throttling level of the sensor.
|
||||
*/
|
||||
ThrottlingSeverity throttlingStatus;
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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;
|
||||
|
||||
import android.hardware.thermal.TemperatureType;
|
||||
|
||||
@VintfStability
|
||||
parcelable TemperatureThreshold {
|
||||
/**
|
||||
* This temperature's type.
|
||||
*/
|
||||
TemperatureType type;
|
||||
/**
|
||||
* Name of this temperature matching the Temperature struct.
|
||||
* All temperatures of the same "type" must have a different "name",
|
||||
* e.g., cpu0, battery. Clients use it to match Temperature struct.
|
||||
*/
|
||||
String name;
|
||||
/**
|
||||
* Hot throttling temperature constant for this temperature sensor in
|
||||
* level defined in ThrottlingSeverity including shutdown. Throttling
|
||||
* happens when temperature >= threshold. If not available, set to NAN.
|
||||
* Unit is same as Temperature's value.
|
||||
* The number of thresholds must be the same as ThrottlingSeverity#len.
|
||||
*/
|
||||
float[] hotThrottlingThresholds;
|
||||
/**
|
||||
* Cold throttling temperature constant for this temperature sensor in
|
||||
* level defined in ThrottlingSeverity including shutdown. Throttling
|
||||
* happens when temperature <= threshold. If not available, set to NAN.
|
||||
* Unit is same as Temperature's value.
|
||||
* The number of theresholds must be the same as ThrottlingSeverity#len.
|
||||
*/
|
||||
float[] coldThrottlingThresholds;
|
||||
}
|
||||
46
thermal/aidl/android/hardware/thermal/TemperatureType.aidl
Normal file
46
thermal/aidl/android/hardware/thermal/TemperatureType.aidl
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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;
|
||||
|
||||
/**
|
||||
* Device temperature types
|
||||
*/
|
||||
@VintfStability
|
||||
@Backing(type="int")
|
||||
enum TemperatureType {
|
||||
UNKNOWN = -1,
|
||||
CPU = 0,
|
||||
GPU = 1,
|
||||
BATTERY = 2,
|
||||
SKIN = 3,
|
||||
USB_PORT = 4,
|
||||
POWER_AMPLIFIER = 5,
|
||||
/**
|
||||
* Battery Current Limit - virtual sensors
|
||||
*/
|
||||
BCL_VOLTAGE = 6,
|
||||
BCL_CURRENT = 7,
|
||||
BCL_PERCENTAGE = 8,
|
||||
/**
|
||||
* Neural Processing Unit
|
||||
*/
|
||||
NPU = 9,
|
||||
TPU = 10,
|
||||
DISPLAY = 11,
|
||||
MODEM = 12,
|
||||
SOC = 13,
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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;
|
||||
|
||||
/**
|
||||
* Device throttling severity
|
||||
*/
|
||||
@VintfStability
|
||||
@Backing(type="int")
|
||||
enum ThrottlingSeverity {
|
||||
/**
|
||||
* Not under throttling.
|
||||
*/
|
||||
NONE = 0,
|
||||
/**
|
||||
* Light throttling where UX is not impacted.
|
||||
*/
|
||||
LIGHT,
|
||||
/**
|
||||
* Moderate throttling where UX is not largely impacted.
|
||||
*/
|
||||
MODERATE,
|
||||
/**
|
||||
* Severe throttling where UX is largely impacted.
|
||||
* Similar to 1.0 throttlingThreshold.
|
||||
*/
|
||||
SEVERE,
|
||||
/**
|
||||
* Platform has done everything to reduce power.
|
||||
*/
|
||||
CRITICAL,
|
||||
/**
|
||||
* Key components in platform are shutting down due to thermal condition.
|
||||
* Device functionalities will be limited.
|
||||
*/
|
||||
EMERGENCY,
|
||||
/**
|
||||
* Need shutdown immediately.
|
||||
*/
|
||||
SHUTDOWN,
|
||||
}
|
||||
49
thermal/aidl/default/Android.bp
Normal file
49
thermal/aidl/default/Android.bp
Normal file
@@ -0,0 +1,49 @@
|
||||
// Copyright (C) 2022 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 {
|
||||
// See: http://go/android-license-faq
|
||||
// A large-scale-change added 'default_applicable_licenses' to import
|
||||
// all of the 'license_kinds' from "hardware_interfaces_license"
|
||||
// to get the below license kinds:
|
||||
// SPDX-license-identifier-Apache-2.0
|
||||
default_applicable_licenses: ["hardware_interfaces_license"],
|
||||
}
|
||||
|
||||
cc_binary {
|
||||
name: "android.hardware.thermal-service.example",
|
||||
relative_install_path: "hw",
|
||||
init_rc: [":android.hardware.thermal.example.rc"],
|
||||
vintf_fragments: [":android.hardware.thermal.example.xml"],
|
||||
vendor: true,
|
||||
shared_libs: [
|
||||
"libbase",
|
||||
"libbinder_ndk",
|
||||
"android.hardware.thermal-V1-ndk",
|
||||
],
|
||||
srcs: [
|
||||
"main.cpp",
|
||||
"Thermal.cpp",
|
||||
],
|
||||
}
|
||||
|
||||
filegroup {
|
||||
name: "android.hardware.thermal.example.xml",
|
||||
srcs: ["thermal-example.xml"],
|
||||
}
|
||||
|
||||
filegroup {
|
||||
name: "android.hardware.thermal.example.rc",
|
||||
srcs: ["thermal-example.rc"],
|
||||
}
|
||||
101
thermal/aidl/default/Thermal.cpp
Normal file
101
thermal/aidl/default/Thermal.cpp
Normal file
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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.
|
||||
*/
|
||||
|
||||
#include "Thermal.h"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
|
||||
namespace aidl::android::hardware::thermal::impl::example {
|
||||
|
||||
using ndk::ScopedAStatus;
|
||||
|
||||
ScopedAStatus Thermal::getCoolingDevices(std::vector<CoolingDevice>* /* out_devices */) {
|
||||
LOG(VERBOSE) << __func__;
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ScopedAStatus Thermal::getCoolingDevicesWithType(CoolingType in_type,
|
||||
std::vector<CoolingDevice>* /* out_devices */) {
|
||||
LOG(VERBOSE) << __func__ << " CoolingType: " << static_cast<int32_t>(in_type);
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ScopedAStatus Thermal::getTemperatures(std::vector<Temperature>* /* out_temperatures */) {
|
||||
LOG(VERBOSE) << __func__;
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ScopedAStatus Thermal::getTemperaturesWithType(TemperatureType in_type,
|
||||
std::vector<Temperature>* /* out_temperatures */) {
|
||||
LOG(VERBOSE) << __func__ << " TemperatureType: " << static_cast<int32_t>(in_type);
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ScopedAStatus Thermal::getTemperatureThresholds(
|
||||
std::vector<TemperatureThreshold>* /* out_temperatureThresholds */) {
|
||||
LOG(VERBOSE) << __func__;
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ScopedAStatus Thermal::getTemperatureThresholdsWithType(
|
||||
TemperatureType in_type,
|
||||
std::vector<TemperatureThreshold>* /* out_temperatureThresholds */) {
|
||||
LOG(VERBOSE) << __func__ << " TemperatureType: " << static_cast<int32_t>(in_type);
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ScopedAStatus Thermal::registerThermalChangedCallback(
|
||||
const std::shared_ptr<IThermalChangedCallback>& in_callback) {
|
||||
LOG(VERBOSE) << __func__ << " IThermalChangedCallback: " << in_callback;
|
||||
if (in_callback == nullptr) {
|
||||
return ScopedAStatus::fromStatus(STATUS_BAD_VALUE);
|
||||
}
|
||||
if (mCallbacks.find(in_callback) != mCallbacks.end()) {
|
||||
return ScopedAStatus::fromStatus(STATUS_INVALID_OPERATION);
|
||||
}
|
||||
mCallbacks.insert(in_callback);
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ScopedAStatus Thermal::registerThermalChangedCallbackWithType(
|
||||
const std::shared_ptr<IThermalChangedCallback>& in_callback, TemperatureType in_type) {
|
||||
LOG(VERBOSE) << __func__ << " IThermalChangedCallback: " << in_callback
|
||||
<< ", TemperatureType: " << static_cast<int32_t>(in_type);
|
||||
if (in_callback == nullptr) {
|
||||
return ScopedAStatus::fromStatus(STATUS_BAD_VALUE);
|
||||
}
|
||||
if (mCallbacks.find(in_callback) != mCallbacks.end()) {
|
||||
return ScopedAStatus::fromStatus(STATUS_INVALID_OPERATION);
|
||||
}
|
||||
mCallbacks.insert(in_callback);
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ScopedAStatus Thermal::unregisterThermalChangedCallback(
|
||||
const std::shared_ptr<IThermalChangedCallback>& in_callback) {
|
||||
LOG(VERBOSE) << __func__ << " IThermalChangedCallback: " << in_callback;
|
||||
bool found = false;
|
||||
if (in_callback == nullptr) {
|
||||
return ScopedAStatus::fromStatus(STATUS_BAD_VALUE);
|
||||
}
|
||||
if (mCallbacks.find(in_callback) == mCallbacks.end()) {
|
||||
return ScopedAStatus::fromStatus(STATUS_INVALID_OPERATION);
|
||||
}
|
||||
mCallbacks.erase(in_callback);
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
} // namespace aidl::android::hardware::thermal::impl::example
|
||||
65
thermal/aidl/default/Thermal.h
Normal file
65
thermal/aidl/default/Thermal.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <set>
|
||||
|
||||
#include <aidl/android/hardware/thermal/BnThermal.h>
|
||||
|
||||
namespace aidl {
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace thermal {
|
||||
namespace impl {
|
||||
namespace example {
|
||||
|
||||
class Thermal : public BnThermal {
|
||||
public:
|
||||
ndk::ScopedAStatus getCoolingDevices(std::vector<CoolingDevice>* out_devices) override;
|
||||
ndk::ScopedAStatus getCoolingDevicesWithType(CoolingType in_type,
|
||||
std::vector<CoolingDevice>* out_devices) override;
|
||||
|
||||
ndk::ScopedAStatus getTemperatures(std::vector<Temperature>* out_temperatures) override;
|
||||
ndk::ScopedAStatus getTemperaturesWithType(TemperatureType in_type,
|
||||
std::vector<Temperature>* out_temperatures) override;
|
||||
|
||||
ndk::ScopedAStatus getTemperatureThresholds(
|
||||
std::vector<TemperatureThreshold>* out_temperatureThresholds) override;
|
||||
|
||||
ndk::ScopedAStatus getTemperatureThresholdsWithType(
|
||||
TemperatureType in_type,
|
||||
std::vector<TemperatureThreshold>* out_temperatureThresholds) override;
|
||||
|
||||
ndk::ScopedAStatus registerThermalChangedCallback(
|
||||
const std::shared_ptr<IThermalChangedCallback>& in_callback) override;
|
||||
ndk::ScopedAStatus registerThermalChangedCallbackWithType(
|
||||
const std::shared_ptr<IThermalChangedCallback>& in_callback,
|
||||
TemperatureType in_type) override;
|
||||
|
||||
ndk::ScopedAStatus unregisterThermalChangedCallback(
|
||||
const std::shared_ptr<IThermalChangedCallback>& in_callback) override;
|
||||
|
||||
private:
|
||||
std::set<std::shared_ptr<IThermalChangedCallback>> mCallbacks;
|
||||
};
|
||||
|
||||
} // namespace example
|
||||
} // namespace impl
|
||||
} // namespace thermal
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
||||
36
thermal/aidl/default/main.cpp
Normal file
36
thermal/aidl/default/main.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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.
|
||||
*/
|
||||
|
||||
#include "Thermal.h"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
#include <android/binder_manager.h>
|
||||
#include <android/binder_process.h>
|
||||
|
||||
using aidl::android::hardware::thermal::impl::example::Thermal;
|
||||
|
||||
int main() {
|
||||
ABinderProcess_setThreadPoolMaxThreadCount(0);
|
||||
std::shared_ptr<Thermal> thermal = ndk::SharedRefBase::make<Thermal>();
|
||||
|
||||
const std::string instance = std::string() + Thermal::descriptor + "/default";
|
||||
binder_status_t status =
|
||||
AServiceManager_addService(thermal->asBinder().get(), instance.c_str());
|
||||
CHECK(status == STATUS_OK);
|
||||
|
||||
ABinderProcess_joinThreadPool();
|
||||
return EXIT_FAILURE; // should not reach
|
||||
}
|
||||
4
thermal/aidl/default/thermal-example.rc
Normal file
4
thermal/aidl/default/thermal-example.rc
Normal file
@@ -0,0 +1,4 @@
|
||||
service vendor.thermal-example /vendor/bin/hw/android.hardware.thermal-service.example
|
||||
class hal
|
||||
user nobody
|
||||
group system
|
||||
7
thermal/aidl/default/thermal-example.xml
Normal file
7
thermal/aidl/default/thermal-example.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<manifest version="1.0" type="device">
|
||||
<hal format="aidl">
|
||||
<name>android.hardware.thermal</name>
|
||||
<version>1</version>
|
||||
<fqname>IThermal/default</fqname>
|
||||
</hal>
|
||||
</manifest>
|
||||
40
thermal/aidl/vts/Android.bp
Normal file
40
thermal/aidl/vts/Android.bp
Normal file
@@ -0,0 +1,40 @@
|
||||
// Copyright (C) 2022 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 {
|
||||
// See: http://go/android-license-faq
|
||||
// A large-scale-change added 'default_applicable_licenses' to import
|
||||
// all of the 'license_kinds' from "hardware_interfaces_license"
|
||||
// to get the below license kinds:
|
||||
// SPDX-license-identifier-Apache-2.0
|
||||
default_applicable_licenses: ["hardware_interfaces_license"],
|
||||
}
|
||||
|
||||
cc_test {
|
||||
name: "VtsHalThermalTargetTest",
|
||||
defaults: [
|
||||
"VtsHalTargetTestDefaults",
|
||||
"use_libaidlvintf_gtest_helper_static",
|
||||
],
|
||||
srcs: ["VtsHalThermalTargetTest.cpp"],
|
||||
shared_libs: [
|
||||
"libbinder_ndk",
|
||||
],
|
||||
static_libs: [
|
||||
"android.hardware.thermal-V1-ndk",
|
||||
],
|
||||
test_suites: [
|
||||
"vts",
|
||||
],
|
||||
}
|
||||
144
thermal/aidl/vts/VtsHalThermalTargetTest.cpp
Normal file
144
thermal/aidl/vts/VtsHalThermalTargetTest.cpp
Normal file
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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.
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <cmath>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
#define LOG_TAG "thermal_aidl_hal_test"
|
||||
|
||||
#include <aidl/Gtest.h>
|
||||
#include <aidl/Vintf.h>
|
||||
#include <aidl/android/hardware/thermal/BnThermal.h>
|
||||
#include <aidl/android/hardware/thermal/BnThermalChangedCallback.h>
|
||||
#include <android-base/logging.h>
|
||||
#include <android-base/properties.h>
|
||||
#include <android/binder_ibinder.h>
|
||||
#include <android/binder_interface_utils.h>
|
||||
#include <android/binder_manager.h>
|
||||
#include <android/binder_process.h>
|
||||
#include <android/binder_status.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
namespace aidl::android::hardware::thermal {
|
||||
|
||||
namespace {
|
||||
|
||||
using ::android::sp;
|
||||
using android::hardware::thermal::CoolingDevice;
|
||||
using android::hardware::thermal::IThermal;
|
||||
using android::hardware::thermal::Temperature;
|
||||
using android::hardware::thermal::TemperatureType;
|
||||
|
||||
using namespace std::string_literals;
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
static const Temperature kThrottleTemp = {
|
||||
.type = TemperatureType::SKIN,
|
||||
.name = "test temperature sensor",
|
||||
.value = 98.6,
|
||||
.throttlingStatus = ThrottlingSeverity::CRITICAL,
|
||||
};
|
||||
|
||||
// Callback class for receiving thermal event notifications from main class
|
||||
class ThermalCallback : public BnThermalChangedCallback {
|
||||
public:
|
||||
ndk::ScopedAStatus notifyThrottling(const Temperature&) override {
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mMutex);
|
||||
mInvoke = true;
|
||||
}
|
||||
mNotifyThrottling.notify_all();
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
template <typename R, typename P>
|
||||
[[nodiscard]] bool waitForCallback(std::chrono::duration<R, P> duration) {
|
||||
std::unique_lock<std::mutex> lock(mMutex);
|
||||
bool r = mNotifyThrottling.wait_for(lock, duration, [this] { return this->mInvoke; });
|
||||
mInvoke = false;
|
||||
return r;
|
||||
}
|
||||
|
||||
private:
|
||||
std::mutex mMutex;
|
||||
std::condition_variable mNotifyThrottling;
|
||||
bool mInvoke = false;
|
||||
};
|
||||
|
||||
// The main test class for THERMAL HIDL HAL.
|
||||
class ThermalAidlTest : public testing::TestWithParam<std::string> {
|
||||
public:
|
||||
void SetUp() override {
|
||||
AIBinder* binder = AServiceManager_waitForService(GetParam().c_str());
|
||||
ASSERT_NE(binder, nullptr);
|
||||
mThermal = IThermal::fromBinder(ndk::SpAIBinder(binder));
|
||||
|
||||
mThermalCallback = ndk::SharedRefBase::make<ThermalCallback>();
|
||||
ASSERT_NE(mThermalCallback, nullptr);
|
||||
auto ret = mThermal->registerThermalChangedCallback(mThermalCallback);
|
||||
ASSERT_TRUE(ret.isOk());
|
||||
// Expect to fail if register again
|
||||
ret = mThermal->registerThermalChangedCallback(mThermalCallback);
|
||||
ASSERT_FALSE(ret.isOk());
|
||||
ASSERT_TRUE(ret.getStatus() == STATUS_INVALID_OPERATION);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
auto ret = mThermal->unregisterThermalChangedCallback(mThermalCallback);
|
||||
ASSERT_TRUE(ret.isOk());
|
||||
// Expect to fail if unregister again
|
||||
ret = mThermal->unregisterThermalChangedCallback(mThermalCallback);
|
||||
ASSERT_FALSE(ret.isOk());
|
||||
ASSERT_TRUE(ret.getStatus() == STATUS_INVALID_OPERATION);
|
||||
}
|
||||
|
||||
protected:
|
||||
std::shared_ptr<IThermal> mThermal;
|
||||
std::shared_ptr<ThermalCallback> mThermalCallback;
|
||||
};
|
||||
|
||||
// Test ThermalChangedCallback::notifyThrottling().
|
||||
// This just calls into and back from our local ThermalChangedCallback impl.
|
||||
TEST_P(ThermalAidlTest, NotifyThrottlingTest) {
|
||||
std::shared_ptr<ThermalCallback> thermalCallback = ndk::SharedRefBase::make<ThermalCallback>();
|
||||
auto ret = thermalCallback->notifyThrottling(kThrottleTemp);
|
||||
ASSERT_TRUE(ret.isOk());
|
||||
ASSERT_TRUE(thermalCallback->waitForCallback(200ms));
|
||||
}
|
||||
|
||||
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(ThermalAidlTest);
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
Thermal, ThermalAidlTest,
|
||||
testing::ValuesIn(::android::getAidlHalInstanceNames(IThermal::descriptor)),
|
||||
::android::PrintInstanceNameToString);
|
||||
|
||||
} // namespace
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
ABinderProcess_setThreadPoolMaxThreadCount(1);
|
||||
ABinderProcess_startThreadPool();
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
||||
} // namespace aidl::android::hardware::thermal
|
||||
Reference in New Issue
Block a user