Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[question] How to use thermal API? #1271

Closed
pille5 opened this issue Jun 2, 2020 · 6 comments
Closed

[question] How to use thermal API? #1271

pille5 opened this issue Jun 2, 2020 · 6 comments
Assignees
Labels

Comments

@pille5
Copy link

pille5 commented Jun 2, 2020

I would like to use the thermal API (https://developer.android.com/ndk/reference/group/thermal) in my native application, but there is no such header in my NDK bundle (v21.0.6113669).

To reproduce the issue you can instert the line #include <android/thermal.h> into the main.cpp of this sample: https://github.com/android/ndk-samples/tree/master/native-activity

Compiler error:

fatal error: 'android/thermal.h' file not found
  #include <android/thermal.h>
           ^~~~~~~~~~~~~~~~~~~
  1 error generated.
  ninja: build stopped: subcommand failed.

I did not find the header, when I tried to search for it in the ndk's directory (search command: find ./ndk-bundle -name 'thermal.h'). There is a thermal.h under the linux directory, but it is not what I need for android builds. I also tried with the latest NDK (v21.2.6472646), but the result was the same. What am I doing wrong?

@pille5 pille5 added the question label Jun 2, 2020
@enh-google
Copy link
Collaborator

that stuff is new in API level 30, so you'll need an Android 11 developer preview/beta and NDK r21c.

i'll get the docs improved to at least include the availability. (danalbert: we should get that into the NDK API review process until/unless we get tool support for automating it.)

@enh-google enh-google self-assigned this Jun 2, 2020
@ggfan
Copy link

ggfan commented Jun 2, 2020

v21.0.6113669. not suppose to have it; v21.2.6472646 has it
It may depend on which/how you configure:

  • AGP version
  • target/minSDK version ( which decides which API level in the header ) ( whether "R" or 30 )

Thermal is Android R feature, so minSdkVersion must be for "Android R":

  • either "R" for Android R Preview
  • or 30 for future beta/formal release
    and only one of the above work, you have to try it out ( I am still trying now ).

you could try to follow this one for the example

  • project's build.gradle
  • app/build.gradle
    If you use the sample's configure, it will work for sure: but it is NOT using formal AGP 4.0.0 release.

I am trying with the formal AGP 4.0.0 version, so far, I could not build with this formal version + formal release of NDK (21.2.6472646). if I get something, I will update you.

@ggfan
Copy link

ggfan commented Jun 2, 2020

Actually both of your NDK versions does not have new things for Android R, so use the available versions of:
21.1.6363665
21.1.6352464

@pille5
Copy link
Author

pille5 commented Jun 2, 2020

Thank you guys for the quick answers. It is quite unfortunate that it depends on Android 11, because the same feature exist on the JAVA side since Android 10 (https://source.android.com/devices/architecture/hidl/thermal-mitigation#thermal-api). I just hoped I do not have to write my own wrappers for it.

@pille5 pille5 closed this as completed Jun 2, 2020
@DanAlbert
Copy link
Member

r21d is the first stable release that will include the API, FYI.

@ggfan
Copy link

ggfan commented Jun 2, 2020

yeah, NDK API sometimes behind Java API by one generation: getThermalHeadroom() is not part of Android R's NDK Thermal API yet, if you need that one, you would need your wrapper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants