From 81cc093bba28844e59e9aac98b43dee1c845fa3d Mon Sep 17 00:00:00 2001 From: Matt Buckley Date: Thu, 18 Jan 2024 19:56:31 +0000 Subject: Provide error handling for nullptr in the ADPF NDK Currently there is very little error handling for null pointers in the NDK, so this CL aims to remedy that by changing the WorkDuration API to pass status messages, updating the relevant documentation, and making sure that all existing methods check all pointers that are passed. Bug: 321065424 Test: atest PerformanceHintNativeTestCases Test: atest PerformanceHintManagerTest Test: atest HintManagerServiceTest Change-Id: I4439328cc2f551b8325c1a82019a35478a5dd372 --- include/android/performance_hint.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/android/performance_hint.h b/include/android/performance_hint.h index 30200c7e79..08d339b176 100644 --- a/include/android/performance_hint.h +++ b/include/android/performance_hint.h @@ -240,7 +240,7 @@ int APerformanceHint_setPreferPowerEfficiency( * the actual GPU duration is not measured. * * @return 0 on success. - * EINVAL if session is nullptr or any duration is an invalid number. + * EINVAL if any duration is an invalid number. * EPIPE if communication with the system service has failed. */ int APerformanceHint_reportActualWorkDuration2( @@ -269,7 +269,7 @@ void AWorkDuration_release(AWorkDuration* _Nonnull aWorkDuration) * * @param aWorkDuration The {@link AWorkDuration} created by calling {@link AWorkDuration_create()} * @param workPeriodStartTimestampNanos The work period start timestamp in nanoseconds based on - * CLOCK_MONOTONIC about when the work starts, the timestamp must be positive. + * CLOCK_MONOTONIC about when the work starts. This timestamp must be greater than zero. */ void AWorkDuration_setWorkPeriodStartTimestampNanos(AWorkDuration* _Nonnull aWorkDuration, int64_t workPeriodStartTimestampNanos) __INTRODUCED_IN(__ANDROID_API_V__); @@ -278,8 +278,8 @@ void AWorkDuration_setWorkPeriodStartTimestampNanos(AWorkDuration* _Nonnull aWor * Sets the actual total work duration in nanoseconds. * * @param aWorkDuration The {@link AWorkDuration} created by calling {@link AWorkDuration_create()} - * @param actualTotalDurationNanos The actual total work duration in nanoseconds, the number must be - * positive. + * @param actualTotalDurationNanos The actual total work duration in nanoseconds. This number must + * be greater than zero. */ void AWorkDuration_setActualTotalDurationNanos(AWorkDuration* _Nonnull aWorkDuration, int64_t actualTotalDurationNanos) __INTRODUCED_IN(__ANDROID_API_V__); @@ -288,8 +288,8 @@ void AWorkDuration_setActualTotalDurationNanos(AWorkDuration* _Nonnull aWorkDura * Sets the actual CPU work duration in nanoseconds. * * @param aWorkDuration The {@link AWorkDuration} created by calling {@link AWorkDuration_create()} - * @param actualCpuDurationNanos The actual CPU work duration in nanoseconds, the number must be - * positive. + * @param actualCpuDurationNanos The actual CPU work duration in nanoseconds. This number must be + * greater than zero. */ void AWorkDuration_setActualCpuDurationNanos(AWorkDuration* _Nonnull aWorkDuration, int64_t actualCpuDurationNanos) __INTRODUCED_IN(__ANDROID_API_V__); -- cgit v1.2.3-59-g8ed1b