mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 05:49:27 +00:00
Add thread management API to PowerHintSession.
Previously the list of threads of a PowerHintSession was only determined when the PowerHintSession was created. This means newly forked threads from existing threads of the PowerHintSession will not get the benefit and the clients have to create new PowerHintSession for that. This patch adds a new method to allow clients to update the threads of the PowerHintSession. Additionally, this patch also removes the oneway annotation at the interface level of IPowerHintSession, all existing methods are converted to oneway methods and setThreads is a bidirectional method. This also allows to do meaningful VTS validation. Bug: b/244216750 Test: atest VtsHalPowerTargetTest Change-Id: If499d6dad20c9d7f6fbda1b5dc9d528396f1f6c1
This commit is contained in:
@@ -40,4 +40,5 @@ interface IPowerHintSession {
|
||||
oneway void resume();
|
||||
oneway void close();
|
||||
oneway void sendHint(android.hardware.power.SessionHint hint);
|
||||
void setThreads(in int[] threadIds);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import android.hardware.power.SessionHint;
|
||||
import android.hardware.power.WorkDuration;
|
||||
|
||||
@VintfStability
|
||||
oneway interface IPowerHintSession {
|
||||
interface IPowerHintSession {
|
||||
/**
|
||||
* Updates the desired duration of a previously-created thread group.
|
||||
*
|
||||
@@ -29,7 +29,7 @@ oneway interface IPowerHintSession {
|
||||
*
|
||||
* @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.
|
||||
@@ -41,22 +41,22 @@ oneway interface IPowerHintSession {
|
||||
* @param actualDurationMicros how long the thread group took to complete its
|
||||
* 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.
|
||||
*/
|
||||
void pause();
|
||||
oneway void pause();
|
||||
|
||||
/**
|
||||
* Resume the session when the application is allowed to send hint in framework.
|
||||
*/
|
||||
void resume();
|
||||
oneway void resume();
|
||||
|
||||
/**
|
||||
* Close the session to release resources.
|
||||
*/
|
||||
void close();
|
||||
oneway void close();
|
||||
|
||||
/**
|
||||
* Gives information to the PowerHintSession about upcoming or unexpected
|
||||
@@ -64,5 +64,21 @@ oneway interface IPowerHintSession {
|
||||
*
|
||||
* @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);
|
||||
}
|
||||
|
||||
@@ -51,4 +51,12 @@ ScopedAStatus PowerHintSession::sendHint(SessionHint /* hint */) {
|
||||
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
|
||||
|
||||
@@ -32,6 +32,7 @@ class PowerHintSession : public BnPowerHintSession {
|
||||
ndk::ScopedAStatus resume() override;
|
||||
ndk::ScopedAStatus close() override;
|
||||
ndk::ScopedAStatus sendHint(SessionHint hint) override;
|
||||
ndk::ScopedAStatus setThreads(const std::vector<int32_t>& threadIds) override;
|
||||
};
|
||||
|
||||
} // namespace aidl::android::hardware::power::impl::example
|
||||
|
||||
@@ -100,6 +100,10 @@ const uint64_t kCompatibilityMatrix5ApiLevel = 30;
|
||||
// target-level=7 compatibility_matrix file.
|
||||
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) {
|
||||
return status.getStatus() == STATUS_UNKNOWN_TRANSACTION ||
|
||||
status.getExceptionCode() == EX_UNSUPPORTED_OPERATION;
|
||||
@@ -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
|
||||
// or later
|
||||
TEST_P(PowerAidl, hasFixedPerformance) {
|
||||
|
||||
Reference in New Issue
Block a user