diff options
author | 2024-11-18 20:28:21 +0000 | |
---|---|---|
committer | 2024-11-18 20:28:21 +0000 | |
commit | d0efb16703d706e67884af64f145e47fc2e67eb1 (patch) | |
tree | 4e8813bbc9a5949aded7f68493bb1dc8fb091738 | |
parent | 2302280cc0c73dfb06e2e97a6ea67ff35e98bd17 (diff) | |
parent | feb30df98609fc7f1a290187092b97dba423eff5 (diff) |
Merge "Add support for converting java hint sessions to native hint sessions" into main
-rw-r--r-- | include/android/performance_hint.h | 19 | ||||
-rw-r--r-- | include/private/performance_hint_private.h | 12 |
2 files changed, 31 insertions, 0 deletions
diff --git a/include/android/performance_hint.h b/include/android/performance_hint.h index 976c7d6fb3..22eab9410c 100644 --- a/include/android/performance_hint.h +++ b/include/android/performance_hint.h @@ -49,6 +49,7 @@ #define ANDROID_NATIVE_PERFORMANCE_HINT_H #include <sys/cdefs.h> +#include <jni.h> /****************************************************************** * @@ -202,6 +203,9 @@ int APerformanceHint_reportActualWorkDuration( * Release the performance hint manager pointer acquired via * {@link APerformanceHint_createSession}. * + * This cannot be used to close a Java PerformanceHintManager.Session, as its + * lifecycle is tied to the object in the SDK. + * * @param session The performance hint session instance to release. */ void APerformanceHint_closeSession( @@ -370,6 +374,21 @@ void AWorkDuration_setActualCpuDurationNanos(AWorkDuration* _Nonnull aWorkDurati void AWorkDuration_setActualGpuDurationNanos(AWorkDuration* _Nonnull aWorkDuration, int64_t actualGpuDurationNanos) __INTRODUCED_IN(__ANDROID_API_V__); +/** + * Return the APerformanceHintSession wrapped by a Java PerformanceHintManager.Session object. + * + * The Java session maintains ownership over the wrapped native session, so it cannot be + * closed using {@link APerformanceHint_closeSession}. + * + * @param env The Java environment where the PerformanceHintManager.Session lives. + * @param sessionObj The Java Session to unwrap. + * + * @return A pointer to the APerformanceHintManager that backs the Java Session. + */ +APerformanceHintSession* _Nonnull APerformanceHint_borrowSessionFromJava( + JNIEnv* _Nonnull env, jobject _Nonnull sessionObj) __INTRODUCED_IN(36); + + __END_DECLS #endif // ANDROID_NATIVE_PERFORMANCE_HINT_H diff --git a/include/private/performance_hint_private.h b/include/private/performance_hint_private.h index 3229e45203..fb31351807 100644 --- a/include/private/performance_hint_private.h +++ b/include/private/performance_hint_private.h @@ -110,6 +110,18 @@ APerformanceHintSession* APerformanceHint_createSessionInternal(APerformanceHint int64_t initialTargetWorkDurationNanos, SessionTag tag); /** + * Creates a session from the Java SDK implementation + */ +APerformanceHintSession* APerformanceHint_createSessionFromJava(APerformanceHintManager* manager, + const int32_t* threadIds, size_t size, + int64_t initialTargetWorkDurationNanos); + +/** + * Special method for Java SDK implementation to kill sessions + */ +void APerformanceHint_closeSessionFromJava(APerformanceHintSession* session); + +/** * Forces FMQ to be enabled or disabled, for testing only. */ void APerformanceHint_setUseFMQForTesting(bool enabled); |