Loading power/aidl/aidl_api/android.hardware.power/current/android/hardware/power/IPowerHintSession.aidl +1 −0 Original line number Original line Diff line number Diff line Loading @@ -40,4 +40,5 @@ interface IPowerHintSession { oneway void resume(); oneway void resume(); oneway void close(); oneway void close(); oneway void sendHint(android.hardware.power.SessionHint hint); oneway void sendHint(android.hardware.power.SessionHint hint); void setThreads(in int[] threadIds); } } power/aidl/android/hardware/power/IPowerHintSession.aidl +23 −7 Original line number Original line Diff line number Diff line Loading @@ -20,7 +20,7 @@ import android.hardware.power.SessionHint; import android.hardware.power.WorkDuration; import android.hardware.power.WorkDuration; @VintfStability @VintfStability oneway interface IPowerHintSession { interface IPowerHintSession { /** /** * Updates the desired duration of a previously-created thread group. * Updates the desired duration of a previously-created thread group. * * Loading @@ -29,7 +29,7 @@ oneway interface IPowerHintSession { * * * @param targetDurationNanos the new desired duration in nanoseconds * @param targetDurationNanos the new desired duration in nanoseconds */ */ void updateTargetWorkDuration(long targetDurationNanos); oneway void updateTargetWorkDuration(long targetDurationNanos); /** /** * Reports the actual duration of a thread group. * Reports the actual duration of a thread group. Loading @@ -41,22 +41,22 @@ oneway interface IPowerHintSession { * @param actualDurationMicros how long the thread group took to complete its * @param actualDurationMicros how long the thread group took to complete its * last task in nanoseconds * last task in nanoseconds */ */ void reportActualWorkDuration(in WorkDuration[] durations); oneway void reportActualWorkDuration(in WorkDuration[] durations); /** /** * Pause the session when the application is not allowed to send hint in framework. * Pause the session when the application is not allowed to send hint in framework. */ */ void pause(); oneway void pause(); /** /** * Resume the session when the application is allowed to send hint in framework. * Resume the session when the application is allowed to send hint in framework. */ */ void resume(); oneway void resume(); /** /** * Close the session to release resources. * Close the session to release resources. */ */ void close(); oneway void close(); /** /** * Gives information to the PowerHintSession about upcoming or unexpected * Gives information to the PowerHintSession about upcoming or unexpected Loading @@ -64,5 +64,21 @@ oneway interface IPowerHintSession { * * * @param hint The hint to provide to the PowerHintSession * @param hint The hint to provide to the PowerHintSession */ */ void sendHint(SessionHint hint); oneway void sendHint(SessionHint hint); /** * Sets a list of threads to the power hint session. This operation will replace * the current list of threads with the given list of threads. If there's already * boost for the replaced threads, a reset must be performed for the replaced * threads. Note that this is not an oneway method. * * @param threadIds The list of threads to be associated * with this session. * * @throws ScopedAStatus Status of the operation. If status code is not * STATUS_OK, getMessage() must be populated with the human-readable * error message. If the list of thread ids is empty, EX_ILLEGAL_ARGUMENT * must be thrown. */ void setThreads(in int[] threadIds); } } power/aidl/default/PowerHintSession.cpp +8 −0 Original line number Original line Diff line number Diff line Loading @@ -51,4 +51,12 @@ ScopedAStatus PowerHintSession::sendHint(SessionHint /* hint */) { return ScopedAStatus::ok(); return ScopedAStatus::ok(); } } ScopedAStatus PowerHintSession::setThreads(const std::vector<int32_t>& threadIds) { if (threadIds.size() == 0) { LOG(ERROR) << "Error: threadIds.size() shouldn't be " << threadIds.size(); return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT); } return ScopedAStatus::ok(); } } // namespace aidl::android::hardware::power::impl::example } // namespace aidl::android::hardware::power::impl::example power/aidl/default/PowerHintSession.h +1 −0 Original line number Original line Diff line number Diff line Loading @@ -32,6 +32,7 @@ class PowerHintSession : public BnPowerHintSession { ndk::ScopedAStatus resume() override; ndk::ScopedAStatus resume() override; ndk::ScopedAStatus close() override; ndk::ScopedAStatus close() override; ndk::ScopedAStatus sendHint(SessionHint hint) override; ndk::ScopedAStatus sendHint(SessionHint hint) override; ndk::ScopedAStatus setThreads(const std::vector<int32_t>& threadIds) override; }; }; } // namespace aidl::android::hardware::power::impl::example } // namespace aidl::android::hardware::power::impl::example power/aidl/vts/VtsHalPowerTargetTest.cpp +25 −0 Original line number Original line Diff line number Diff line Loading @@ -100,6 +100,10 @@ const uint64_t kCompatibilityMatrix5ApiLevel = 30; // target-level=7 compatibility_matrix file. // target-level=7 compatibility_matrix file. const uint64_t kCompatibilityMatrix7ApiLevel = 33; const uint64_t kCompatibilityMatrix7ApiLevel = 33; // DEVICEs launching with Android 14 MUST meet the requirements for the // target-level=8 compatibility_matrix file. const uint64_t kCompatibilityMatrix8ApiLevel = 34; inline bool isUnknownOrUnsupported(const ndk::ScopedAStatus& status) { inline bool isUnknownOrUnsupported(const ndk::ScopedAStatus& status) { return status.getStatus() == STATUS_UNKNOWN_TRANSACTION || return status.getStatus() == STATUS_UNKNOWN_TRANSACTION || status.getExceptionCode() == EX_UNSUPPORTED_OPERATION; status.getExceptionCode() == EX_UNSUPPORTED_OPERATION; Loading Loading @@ -242,6 +246,27 @@ TEST_P(PowerAidl, sendSessionHint) { } } } } TEST_P(PowerAidl, setThreads) { std::shared_ptr<IPowerHintSession> session; auto status = power->createHintSession(getpid(), getuid(), kSelfTids, 16666666L, &session); if (mApiLevel < kCompatibilityMatrix7ApiLevel && !status.isOk()) { EXPECT_TRUE(isUnknownOrUnsupported(status)); GTEST_SKIP() << "DEVICE not launching with Android 13 and beyond."; } ASSERT_TRUE(status.isOk()); if (mApiLevel < kCompatibilityMatrix8ApiLevel) { GTEST_SKIP() << "DEVICE not launching with Android 14 and beyond."; } status = session->setThreads(kEmptyTids); ASSERT_FALSE(status.isOk()); ASSERT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode()); status = session->setThreads(kSelfTids); ASSERT_TRUE(status.isOk()); } // FIXED_PERFORMANCE mode is required for all devices which ship on Android 11 // FIXED_PERFORMANCE mode is required for all devices which ship on Android 11 // or later // or later TEST_P(PowerAidl, hasFixedPerformance) { TEST_P(PowerAidl, hasFixedPerformance) { Loading Loading
power/aidl/aidl_api/android.hardware.power/current/android/hardware/power/IPowerHintSession.aidl +1 −0 Original line number Original line Diff line number Diff line Loading @@ -40,4 +40,5 @@ interface IPowerHintSession { oneway void resume(); oneway void resume(); oneway void close(); oneway void close(); oneway void sendHint(android.hardware.power.SessionHint hint); oneway void sendHint(android.hardware.power.SessionHint hint); void setThreads(in int[] threadIds); } }
power/aidl/android/hardware/power/IPowerHintSession.aidl +23 −7 Original line number Original line Diff line number Diff line Loading @@ -20,7 +20,7 @@ import android.hardware.power.SessionHint; import android.hardware.power.WorkDuration; import android.hardware.power.WorkDuration; @VintfStability @VintfStability oneway interface IPowerHintSession { interface IPowerHintSession { /** /** * Updates the desired duration of a previously-created thread group. * Updates the desired duration of a previously-created thread group. * * Loading @@ -29,7 +29,7 @@ oneway interface IPowerHintSession { * * * @param targetDurationNanos the new desired duration in nanoseconds * @param targetDurationNanos the new desired duration in nanoseconds */ */ void updateTargetWorkDuration(long targetDurationNanos); oneway void updateTargetWorkDuration(long targetDurationNanos); /** /** * Reports the actual duration of a thread group. * Reports the actual duration of a thread group. Loading @@ -41,22 +41,22 @@ oneway interface IPowerHintSession { * @param actualDurationMicros how long the thread group took to complete its * @param actualDurationMicros how long the thread group took to complete its * last task in nanoseconds * last task in nanoseconds */ */ void reportActualWorkDuration(in WorkDuration[] durations); oneway void reportActualWorkDuration(in WorkDuration[] durations); /** /** * Pause the session when the application is not allowed to send hint in framework. * Pause the session when the application is not allowed to send hint in framework. */ */ void pause(); oneway void pause(); /** /** * Resume the session when the application is allowed to send hint in framework. * Resume the session when the application is allowed to send hint in framework. */ */ void resume(); oneway void resume(); /** /** * Close the session to release resources. * Close the session to release resources. */ */ void close(); oneway void close(); /** /** * Gives information to the PowerHintSession about upcoming or unexpected * Gives information to the PowerHintSession about upcoming or unexpected Loading @@ -64,5 +64,21 @@ oneway interface IPowerHintSession { * * * @param hint The hint to provide to the PowerHintSession * @param hint The hint to provide to the PowerHintSession */ */ void sendHint(SessionHint hint); oneway void sendHint(SessionHint hint); /** * Sets a list of threads to the power hint session. This operation will replace * the current list of threads with the given list of threads. If there's already * boost for the replaced threads, a reset must be performed for the replaced * threads. Note that this is not an oneway method. * * @param threadIds The list of threads to be associated * with this session. * * @throws ScopedAStatus Status of the operation. If status code is not * STATUS_OK, getMessage() must be populated with the human-readable * error message. If the list of thread ids is empty, EX_ILLEGAL_ARGUMENT * must be thrown. */ void setThreads(in int[] threadIds); } }
power/aidl/default/PowerHintSession.cpp +8 −0 Original line number Original line Diff line number Diff line Loading @@ -51,4 +51,12 @@ ScopedAStatus PowerHintSession::sendHint(SessionHint /* hint */) { return ScopedAStatus::ok(); return ScopedAStatus::ok(); } } ScopedAStatus PowerHintSession::setThreads(const std::vector<int32_t>& threadIds) { if (threadIds.size() == 0) { LOG(ERROR) << "Error: threadIds.size() shouldn't be " << threadIds.size(); return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT); } return ScopedAStatus::ok(); } } // namespace aidl::android::hardware::power::impl::example } // namespace aidl::android::hardware::power::impl::example
power/aidl/default/PowerHintSession.h +1 −0 Original line number Original line Diff line number Diff line Loading @@ -32,6 +32,7 @@ class PowerHintSession : public BnPowerHintSession { ndk::ScopedAStatus resume() override; ndk::ScopedAStatus resume() override; ndk::ScopedAStatus close() override; ndk::ScopedAStatus close() override; ndk::ScopedAStatus sendHint(SessionHint hint) override; ndk::ScopedAStatus sendHint(SessionHint hint) override; ndk::ScopedAStatus setThreads(const std::vector<int32_t>& threadIds) override; }; }; } // namespace aidl::android::hardware::power::impl::example } // namespace aidl::android::hardware::power::impl::example
power/aidl/vts/VtsHalPowerTargetTest.cpp +25 −0 Original line number Original line Diff line number Diff line Loading @@ -100,6 +100,10 @@ const uint64_t kCompatibilityMatrix5ApiLevel = 30; // target-level=7 compatibility_matrix file. // target-level=7 compatibility_matrix file. const uint64_t kCompatibilityMatrix7ApiLevel = 33; const uint64_t kCompatibilityMatrix7ApiLevel = 33; // DEVICEs launching with Android 14 MUST meet the requirements for the // target-level=8 compatibility_matrix file. const uint64_t kCompatibilityMatrix8ApiLevel = 34; inline bool isUnknownOrUnsupported(const ndk::ScopedAStatus& status) { inline bool isUnknownOrUnsupported(const ndk::ScopedAStatus& status) { return status.getStatus() == STATUS_UNKNOWN_TRANSACTION || return status.getStatus() == STATUS_UNKNOWN_TRANSACTION || status.getExceptionCode() == EX_UNSUPPORTED_OPERATION; status.getExceptionCode() == EX_UNSUPPORTED_OPERATION; Loading Loading @@ -242,6 +246,27 @@ TEST_P(PowerAidl, sendSessionHint) { } } } } TEST_P(PowerAidl, setThreads) { std::shared_ptr<IPowerHintSession> session; auto status = power->createHintSession(getpid(), getuid(), kSelfTids, 16666666L, &session); if (mApiLevel < kCompatibilityMatrix7ApiLevel && !status.isOk()) { EXPECT_TRUE(isUnknownOrUnsupported(status)); GTEST_SKIP() << "DEVICE not launching with Android 13 and beyond."; } ASSERT_TRUE(status.isOk()); if (mApiLevel < kCompatibilityMatrix8ApiLevel) { GTEST_SKIP() << "DEVICE not launching with Android 14 and beyond."; } status = session->setThreads(kEmptyTids); ASSERT_FALSE(status.isOk()); ASSERT_EQ(EX_ILLEGAL_ARGUMENT, status.getExceptionCode()); status = session->setThreads(kSelfTids); ASSERT_TRUE(status.isOk()); } // FIXED_PERFORMANCE mode is required for all devices which ship on Android 11 // FIXED_PERFORMANCE mode is required for all devices which ship on Android 11 // or later // or later TEST_P(PowerAidl, hasFixedPerformance) { TEST_P(PowerAidl, hasFixedPerformance) { Loading