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

Commit f523a0a1 authored by Xiang Wang's avatar Xiang Wang Committed by Android (Google) Code Review
Browse files

Merge "Add forecastSkinTemperature HAL API" into main

parents 4d6ef649 d3aa7c7c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -46,4 +46,5 @@ interface IThermal {
  void unregisterThermalChangedCallback(in android.hardware.thermal.IThermalChangedCallback callback);
  void registerCoolingDeviceChangedCallbackWithType(in android.hardware.thermal.ICoolingDeviceChangedCallback callback, in android.hardware.thermal.CoolingType type);
  void unregisterCoolingDeviceChangedCallback(in android.hardware.thermal.ICoolingDeviceChangedCallback callback);
  float forecastSkinTemperature(in int forecastSeconds);
}
+16 −0
Original line number Diff line number Diff line
@@ -225,4 +225,20 @@ interface IThermal {
     *         getMessage() must be populated with human-readable error message.
     */
    void unregisterCoolingDeviceChangedCallback(in ICoolingDeviceChangedCallback callback);

    /**
     * Retrieves the forecasted skin temperature in Celsius.
     *
     * @param forecastSeconds the number of seconds to forecast the skin temperature, it should
     *                        at least support superset of [0, 60] seconds range.
     *
     * @return forecasted skin temperature in Celsius.
     *
     * @throws EX_ILLEGAL_STATE If the Thermal HAL is not initialized successfully
     * @throws EX_ILLEGAL_ARGUMENT If the provided forecastSeconds is negative
     * @throws EX_UNSUPPORTED_OPERATION if API is not supported or the forecastSeconds exceeds the
     *         supported range. And the getMessage() must be populated with human-readable
     *         error message.
     */
    float forecastSkinTemperature(in int forecastSeconds);
}
+5 −0
Original line number Diff line number Diff line
@@ -191,4 +191,9 @@ ScopedAStatus Thermal::unregisterCoolingDeviceChangedCallback(
    }
    return ScopedAStatus::ok();
}

ndk::ScopedAStatus Thermal::forecastSkinTemperature(int32_t, float*) {
    return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
}

}  // namespace aidl::android::hardware::thermal::impl::example
+2 −0
Original line number Diff line number Diff line
@@ -60,6 +60,8 @@ class Thermal : public BnThermal {

    ndk::ScopedAStatus unregisterCoolingDeviceChangedCallback(
            const std::shared_ptr<ICoolingDeviceChangedCallback>& in_callback) override;
    ndk::ScopedAStatus forecastSkinTemperature(int32_t forecastSeconds,
                                               float* _aidl_return) override;

  private:
    std::mutex thermal_callback_mutex_;
+17 −0
Original line number Diff line number Diff line
@@ -426,6 +426,23 @@ TEST_P(ThermalAidlTest, CoolingDeviceTest) {
    }
}

// Test Thermal->forecastSkinTemperature.
TEST_P(ThermalAidlTest, ForecastSkinTemperatureTest) {
    auto apiLevel = ::android::base::GetIntProperty<int32_t>("ro.vendor.api_level", 0);
    if (apiLevel < 202504) {
        GTEST_SKIP() << "Skipping test as the vendor level is below 202504: " << apiLevel;
    }
    float temperature = 0.0f;
    ::ndk::ScopedAStatus status = mThermal->forecastSkinTemperature(1, &temperature);
    if (status.getExceptionCode() == EX_UNSUPPORTED_OPERATION) {
        GTEST_SKIP() << "Skipping test as temperature forecast is not supported";
    }
    for (int i = 0; i <= 60; i++) {
        status = mThermal->forecastSkinTemperature(i, &temperature);
        ASSERT_NE(NAN, temperature);
    }
}

GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(ThermalAidlTest);
INSTANTIATE_TEST_SUITE_P(
        Thermal, ThermalAidlTest,