Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e16ad281 authored by Xiang Wang's avatar Xiang Wang
Browse files

Skip binder call if it's the same target

Bug: 349632685
Flag: EXEMPT NDK
Test: atest PerformanceHintTest
Change-Id: I0b3bd63da15ec8690cd86806cbe86fce31b299bd
parent 1754db7d
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -244,6 +244,12 @@ int APerformanceHintSession::updateTargetWorkDuration(int64_t targetDurationNano
        ALOGE("%s: targetDurationNanos must be positive", __FUNCTION__);
        return EINVAL;
    }
    {
        std::scoped_lock lock(sHintMutex);
        if (mTargetDurationNanos == targetDurationNanos) {
            return 0;
        }
    }
    ndk::ScopedAStatus ret = mHintSession->updateTargetWorkDuration(targetDurationNanos);
    if (!ret.isOk()) {
        ALOGE("%s: HintSession updateTargetWorkDuration failed: %s", __FUNCTION__,
+4 −0
Original line number Diff line number Diff line
@@ -159,6 +159,10 @@ TEST_F(PerformanceHintTest, TestSession) {
    int result = APerformanceHint_updateTargetWorkDuration(session, targetDurationNanos);
    EXPECT_EQ(0, result);

    // subsequent call with same target should be ignored but return no error
    result = APerformanceHint_updateTargetWorkDuration(session, targetDurationNanos);
    EXPECT_EQ(0, result);

    usleep(2); // Sleep for longer than preferredUpdateRateNanos.
    int64_t actualDurationNanos = 20;
    std::vector<int64_t> actualDurations;