Refactor adpf cpu hints to use TimePoint and Duration
Replace nsecs_t in adpf cpu hint sessions in PowerAdvisor with new
TimePoints and Durations
Additionally, added TimePoint::now() to make getting current time
cleaner
Bug: b/244358432
Test: atest libsurfaceflinger_unittest
Change-Id: I8b4d6f3de8204aa34cd9d8687febfde580deea92
diff --git a/services/surfaceflinger/tests/unittests/AidlPowerHalWrapperTest.cpp b/services/surfaceflinger/tests/unittests/AidlPowerHalWrapperTest.cpp
index ab38b29..513f779 100644
--- a/services/surfaceflinger/tests/unittests/AidlPowerHalWrapperTest.cpp
+++ b/services/surfaceflinger/tests/unittests/AidlPowerHalWrapperTest.cpp
@@ -69,7 +69,8 @@
void AidlPowerHalWrapperTest::sendActualWorkDurationGroup(std::vector<WorkDuration> durations) {
for (size_t i = 0; i < durations.size(); i++) {
auto duration = durations[i];
- mWrapper->sendActualWorkDuration(duration.durationNanos, duration.timeStampNanos);
+ mWrapper->sendActualWorkDuration(Duration::fromNs(duration.durationNanos),
+ TimePoint::fromNs(duration.timeStampNanos));
}
}
@@ -155,13 +156,13 @@
for (const auto& test : testCases) {
// reset to 100ms baseline
- mWrapper->setTargetWorkDuration(1);
- mWrapper->setTargetWorkDuration(base.count());
+ mWrapper->setTargetWorkDuration(1ns);
+ mWrapper->setTargetWorkDuration(base);
- auto target = test.first;
+ std::chrono::nanoseconds target = test.first;
EXPECT_CALL(*mMockSession.get(), updateTargetWorkDuration(target.count()))
.Times(test.second ? 1 : 0);
- mWrapper->setTargetWorkDuration(target.count());
+ mWrapper->setTargetWorkDuration(target);
verifyAndClearExpectations();
}
}
@@ -178,7 +179,7 @@
EXPECT_CALL(*mMockSession.get(), updateTargetWorkDuration(1))
.WillOnce(Return(Status::fromExceptionCode(Status::Exception::EX_ILLEGAL_STATE)));
- mWrapper->setTargetWorkDuration(1);
+ mWrapper->setTargetWorkDuration(1ns);
EXPECT_TRUE(mWrapper->shouldReconnectHAL());
}