Add setThreads to APerformanceHint.
Bug: b/244216750
Test: atest PerformanceHintManagerTest
Change-Id: I98f94a47caf94a9f9027f14ec01f5da531a20d35
diff --git a/include/android/performance_hint.h b/include/android/performance_hint.h
index 5fa47f6..4a5bd5e 100644
--- a/include/android/performance_hint.h
+++ b/include/android/performance_hint.h
@@ -159,6 +159,23 @@
void APerformanceHint_closeSession(
APerformanceHintSession* session) __INTRODUCED_IN(__ANDROID_API_T__);
+/**
+ * Set a list of threads to the performance hint session. This operation will replace
+ * the current list of threads with the given list of threads.
+ *
+ * @param session The performance hint session instance for the threads.
+ * @param threadIds The list of threads to be associated with this session. They must be part of
+ * this app's thread group.
+ * @param size the size of the list of threadIds.
+ * @return 0 on success.
+ * EINVAL if the list of thread ids is empty or if any of the thread ids is not part of the thread group.
+ * EPIPE if communication with the system service has failed.
+ */
+int APerformanceHint_setThreads(
+ APerformanceHintSession* session,
+ const int32_t* threadIds,
+ size_t size) __INTRODUCED_IN(__ANDROID_API_U__);
+
__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 1333bcc..eaf3b5e 100644
--- a/include/private/performance_hint_private.h
+++ b/include/private/performance_hint_private.h
@@ -63,6 +63,12 @@
*/
int APerformanceHint_sendHint(void* session, int hint);
+/**
+ * Return the list of thread ids, this API should only be used for testing only.
+ */
+int APerformanceHint_getThreadIds(void* aPerformanceHintSession,
+ int32_t* const threadIds, size_t* const size);
+
__END_DECLS
#endif // ANDROID_PRIVATE_NATIVE_PERFORMANCE_HINT_PRIVATE_H