Loading libs/binder/Parcel.cpp +1 −3 Original line number Diff line number Diff line Loading @@ -2223,9 +2223,7 @@ const char* Parcel::readCString() const const char* eos = reinterpret_cast<const char*>(memchr(str, 0, avail)); if (eos) { const size_t len = eos - str; mDataPos += pad_size(len+1); ALOGV("readCString Setting data pos of %p to %zu", this, mDataPos); return str; return static_cast<const char*>(readInplace(len + 1)); } } return nullptr; Loading libs/binder/tests/binderParcelUnitTest.cpp +32 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,38 @@ using android::String8; using android::binder::Status; using android::binder::unique_fd; static void checkCString(const char* str) { for (size_t i = 0; i < 3; i++) { Parcel p; for (size_t j = 0; j < i; j++) p.writeInt32(3); p.writeCString(str); int32_t pos = p.dataPosition(); p.setDataPosition(0); for (size_t j = 0; j < i; j++) p.readInt32(); const char* str2 = p.readCString(); ASSERT_EQ(std::string(str), str2); ASSERT_EQ(pos, p.dataPosition()); } } TEST(Parcel, TestReadCString) { // we should remove the *CString APIs, but testing them until // they are deleted. checkCString(""); checkCString("a"); checkCString("\n"); checkCString("32"); checkCString("321"); checkCString("3210"); checkCString("3210b"); checkCString("123434"); } TEST(Parcel, NonNullTerminatedString8) { String8 kTestString = String8("test-is-good"); Loading services/surfaceflinger/Scheduler/LayerHistory.cpp +18 −4 Original line number Diff line number Diff line Loading @@ -308,11 +308,14 @@ void LayerHistory::partitionLayers(nsecs_t now, bool isVrrDevice) { const auto setFrameRateVoteType = info->isVisible() ? voteType : LayerVoteType::NoVote; const bool hasSetFrameRateOpinion = frameRate.isValid() && !frameRate.isNoVote(); const bool hasSetFrameRateOpinion = frameRate.isValuelessType() || frameRate.vote.rate.isValid(); const bool hasCategoryOpinion = frameRate.category != FrameRateCategory::NoPreference && frameRate.category != FrameRateCategory::Default; const bool hasFrameRateOpinion = hasSetFrameRateOpinion || hasCategoryOpinion; const bool hasFrameRateOpinionAboveGameDefault = hasSetFrameRateOpinion || hasCategoryOpinion; const bool hasFrameRateOpinionArr = frameRate.isValid() && !frameRate.isNoVote(); if (gameModeFrameRateOverride.isValid()) { info->setLayerVote({gameFrameRateOverrideVoteType, gameModeFrameRateOverride}); Loading @@ -321,7 +324,8 @@ void LayerHistory::partitionLayers(nsecs_t now, bool isVrrDevice) { trace(*info, gameFrameRateOverrideVoteType, gameModeFrameRateOverride.getIntValue()); } } else if (hasFrameRateOpinion && frameRate.isVoteValidForMrr(isVrrDevice)) { } else if (hasFrameRateOpinionAboveGameDefault && frameRate.isVoteValidForMrr(isVrrDevice)) { info->setLayerVote({setFrameRateVoteType, isValuelessVote ? 0_Hz : frameRate.vote.rate, frameRate.vote.seamlessness, frameRate.category}); Loading @@ -337,8 +341,18 @@ void LayerHistory::partitionLayers(nsecs_t now, bool isVrrDevice) { trace(*info, gameFrameRateOverrideVoteType, gameDefaultFrameRateOverride.getIntValue()); } } else if (hasFrameRateOpinionArr && frameRate.isVoteValidForMrr(isVrrDevice)) { // This allows NoPreference votes on ARR devices after considering the // gameDefaultFrameRateOverride (above). info->setLayerVote({setFrameRateVoteType, isValuelessVote ? 0_Hz : frameRate.vote.rate, frameRate.vote.seamlessness, frameRate.category}); if (CC_UNLIKELY(mTraceEnabled)) { trace(*info, gameFrameRateOverrideVoteType, frameRate.vote.rate.getIntValue()); } } else { if (hasFrameRateOpinion && !frameRate.isVoteValidForMrr(isVrrDevice)) { if (hasFrameRateOpinionArr && !frameRate.isVoteValidForMrr(isVrrDevice)) { SFTRACE_FORMAT_INSTANT("Reset layer to ignore explicit vote on MRR %s: %s " "%s %s", info->getName().c_str(), Loading services/surfaceflinger/tests/unittests/LayerHistoryIntegrationTest.cpp +198 −0 Original line number Diff line number Diff line Loading @@ -715,6 +715,204 @@ TEST_F(LayerHistoryIntegrationTest, oneLayerCategoryNoPreference) { EXPECT_EQ(0, frequentLayerCount(time)); } // Tests MRR NoPreference-only vote, no game default override. Expects vote reset. TEST_F(LayerHistoryIntegrationTest, oneLayerCategoryNoPreference_mrr) { SET_FLAG_FOR_TEST(flags::frame_rate_category_mrr, false); SET_FLAG_FOR_TEST(flags::game_default_frame_rate, true); SET_FLAG_FOR_TEST(flags::vrr_config, true); const LayerHistory::LayerVoteType defaultVote = LayerHistory::LayerVoteType::Min; auto layer = createLegacyAndFrontedEndLayer(1); setDefaultLayerVote(layer.get(), defaultVote); showLayer(1); setFrameRate(1, (0_Hz).getValue(), ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT, ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS); setFrameRateCategory(1, ANATIVEWINDOW_FRAME_RATE_CATEGORY_NO_PREFERENCE); EXPECT_EQ(1u, layerCount()); EXPECT_EQ(0u, activeLayerCount()); nsecs_t time = systemTime(); for (size_t i = 0; i < PRESENT_TIME_HISTORY_SIZE; i++) { setBufferWithPresentTime(layer, time); time += HI_FPS_PERIOD; } EXPECT_EQ(1u, summarizeLayerHistory(time).size()); EXPECT_EQ(1u, activeLayerCount()); EXPECT_EQ(1, frequentLayerCount(time)); EXPECT_EQ(defaultVote, summarizeLayerHistory(time)[0].vote); EXPECT_EQ(0_Hz, summarizeLayerHistory(time)[0].desiredRefreshRate); EXPECT_EQ(FrameRateCategory::Default, summarizeLayerHistory(time)[0].frameRateCategory); } // Tests VRR NoPreference-only vote, no game default override. Expects NoPreference, *not* vote // reset. TEST_F(LayerHistoryIntegrationTest, oneLayerCategoryNoPreference_vrr) { SET_FLAG_FOR_TEST(flags::frame_rate_category_mrr, false); SET_FLAG_FOR_TEST(flags::game_default_frame_rate, true); SET_FLAG_FOR_TEST(flags::vrr_config, true); mSelector->setActiveMode(kVrrModeId, HI_FPS); const LayerHistory::LayerVoteType defaultVote = LayerHistory::LayerVoteType::Min; auto layer = createLegacyAndFrontedEndLayer(1); setDefaultLayerVote(layer.get(), defaultVote); showLayer(1); setFrameRate(1, (0_Hz).getValue(), ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT, ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS); setFrameRateCategory(1, ANATIVEWINDOW_FRAME_RATE_CATEGORY_NO_PREFERENCE); EXPECT_EQ(1u, layerCount()); EXPECT_EQ(0u, activeLayerCount()); nsecs_t time = systemTime(); for (size_t i = 0; i < PRESENT_TIME_HISTORY_SIZE; i++) { setBufferWithPresentTime(layer, time); time += HI_FPS_PERIOD; } EXPECT_EQ(1u, summarizeLayerHistory(time).size()); EXPECT_EQ(1u, activeLayerCount()); EXPECT_EQ(1, frequentLayerCount(time)); EXPECT_EQ(LayerHistory::LayerVoteType::ExplicitCategory, summarizeLayerHistory(time)[0].vote); EXPECT_EQ(0_Hz, summarizeLayerHistory(time)[0].desiredRefreshRate); EXPECT_EQ(FrameRateCategory::NoPreference, summarizeLayerHistory(time)[0].frameRateCategory); } TEST_F(LayerHistoryIntegrationTest, oneLayerCategoryNoPreferenceWithGameDefault_vrr) { SET_FLAG_FOR_TEST(flags::frame_rate_category_mrr, false); SET_FLAG_FOR_TEST(flags::game_default_frame_rate, true); SET_FLAG_FOR_TEST(flags::vrr_config, true); mSelector->setActiveMode(kVrrModeId, HI_FPS); const Fps gameDefaultFrameRate = Fps::fromValue(30.0f); const uid_t uid = 456; history().updateGameDefaultFrameRateOverride( FrameRateOverride({uid, gameDefaultFrameRate.getValue()})); auto layer = createLegacyAndFrontedEndLayerWithUid(1, gui::Uid(uid)); showLayer(1); setFrameRate(1, (0_Hz).getValue(), ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT, ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS); setFrameRateCategory(1, ANATIVEWINDOW_FRAME_RATE_CATEGORY_NO_PREFERENCE); EXPECT_EQ(1u, layerCount()); EXPECT_EQ(0u, activeLayerCount()); nsecs_t time = systemTime(); for (size_t i = 0; i < PRESENT_TIME_HISTORY_SIZE; i++) { setBufferWithPresentTime(layer, time); time += HI_FPS_PERIOD; } EXPECT_EQ(1u, summarizeLayerHistory(time).size()); EXPECT_EQ(1u, activeLayerCount()); EXPECT_EQ(1, frequentLayerCount(time)); EXPECT_EQ(LayerHistory::LayerVoteType::ExplicitDefault, summarizeLayerHistory(time)[0].vote); EXPECT_EQ(gameDefaultFrameRate, summarizeLayerHistory(time)[0].desiredRefreshRate); EXPECT_EQ(FrameRateCategory::Default, summarizeLayerHistory(time)[0].frameRateCategory); } TEST_F(LayerHistoryIntegrationTest, oneLayerCategoryNoPreferenceWithGameDefault_mrr) { SET_FLAG_FOR_TEST(flags::frame_rate_category_mrr, false); SET_FLAG_FOR_TEST(flags::game_default_frame_rate, true); SET_FLAG_FOR_TEST(flags::vrr_config, true); const Fps gameDefaultFrameRate = Fps::fromValue(30.0f); const uid_t uid = 456; history().updateGameDefaultFrameRateOverride( FrameRateOverride({uid, gameDefaultFrameRate.getValue()})); auto layer = createLegacyAndFrontedEndLayerWithUid(1, gui::Uid(uid)); showLayer(1); setFrameRate(1, (0_Hz).getValue(), ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT, ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS); setFrameRateCategory(1, ANATIVEWINDOW_FRAME_RATE_CATEGORY_NO_PREFERENCE); EXPECT_EQ(1u, layerCount()); EXPECT_EQ(0u, activeLayerCount()); nsecs_t time = systemTime(); for (size_t i = 0; i < PRESENT_TIME_HISTORY_SIZE; i++) { setBufferWithPresentTime(layer, time); time += HI_FPS_PERIOD; } EXPECT_EQ(1u, summarizeLayerHistory(time).size()); EXPECT_EQ(1u, activeLayerCount()); EXPECT_EQ(1, frequentLayerCount(time)); EXPECT_EQ(LayerHistory::LayerVoteType::ExplicitDefault, summarizeLayerHistory(time)[0].vote); EXPECT_EQ(gameDefaultFrameRate, summarizeLayerHistory(time)[0].desiredRefreshRate); EXPECT_EQ(FrameRateCategory::Default, summarizeLayerHistory(time)[0].frameRateCategory); } TEST_F(LayerHistoryIntegrationTest, oneLayerNoVoteWithGameDefault_vrr) { SET_FLAG_FOR_TEST(flags::frame_rate_category_mrr, false); SET_FLAG_FOR_TEST(flags::game_default_frame_rate, true); SET_FLAG_FOR_TEST(flags::vrr_config, true); mSelector->setActiveMode(kVrrModeId, HI_FPS); const Fps gameDefaultFrameRate = Fps::fromValue(30.0f); const uid_t uid = 456; history().updateGameDefaultFrameRateOverride( FrameRateOverride({uid, gameDefaultFrameRate.getValue()})); auto layer = createLegacyAndFrontedEndLayerWithUid(1, gui::Uid(uid)); showLayer(1); setFrameRate(1, (0_Hz).getValue(), ANATIVEWINDOW_FRAME_RATE_NO_VOTE, ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS); EXPECT_EQ(1u, layerCount()); EXPECT_EQ(0u, activeLayerCount()); nsecs_t time = systemTime(); for (size_t i = 0; i < PRESENT_TIME_HISTORY_SIZE; i++) { setBufferWithPresentTime(layer, time); time += HI_FPS_PERIOD; } // Expect NoVote to be skipped in summarize. EXPECT_EQ(0u, summarizeLayerHistory(time).size()); EXPECT_EQ(1u, activeLayerCount()); EXPECT_EQ(1, frequentLayerCount(time)); } TEST_F(LayerHistoryIntegrationTest, oneLayerNoVoteWithGameDefault_mrr) { SET_FLAG_FOR_TEST(flags::frame_rate_category_mrr, false); SET_FLAG_FOR_TEST(flags::game_default_frame_rate, true); SET_FLAG_FOR_TEST(flags::vrr_config, true); const Fps gameDefaultFrameRate = Fps::fromValue(30.0f); const uid_t uid = 456; history().updateGameDefaultFrameRateOverride( FrameRateOverride({uid, gameDefaultFrameRate.getValue()})); auto layer = createLegacyAndFrontedEndLayerWithUid(1, gui::Uid(uid)); showLayer(1); setFrameRate(1, (0_Hz).getValue(), ANATIVEWINDOW_FRAME_RATE_NO_VOTE, ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS); EXPECT_EQ(1u, layerCount()); EXPECT_EQ(0u, activeLayerCount()); nsecs_t time = systemTime(); for (size_t i = 0; i < PRESENT_TIME_HISTORY_SIZE; i++) { setBufferWithPresentTime(layer, time); time += HI_FPS_PERIOD; } // Expect NoVote to be skipped in summarize. EXPECT_EQ(0u, summarizeLayerHistory(time).size()); EXPECT_EQ(1u, activeLayerCount()); EXPECT_EQ(1, frequentLayerCount(time)); } TEST_F(LayerHistoryIntegrationTest, oneLayerExplicitVoteWithCategory) { SET_FLAG_FOR_TEST(flags::frame_rate_category_mrr, true); Loading Loading
libs/binder/Parcel.cpp +1 −3 Original line number Diff line number Diff line Loading @@ -2223,9 +2223,7 @@ const char* Parcel::readCString() const const char* eos = reinterpret_cast<const char*>(memchr(str, 0, avail)); if (eos) { const size_t len = eos - str; mDataPos += pad_size(len+1); ALOGV("readCString Setting data pos of %p to %zu", this, mDataPos); return str; return static_cast<const char*>(readInplace(len + 1)); } } return nullptr; Loading
libs/binder/tests/binderParcelUnitTest.cpp +32 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,38 @@ using android::String8; using android::binder::Status; using android::binder::unique_fd; static void checkCString(const char* str) { for (size_t i = 0; i < 3; i++) { Parcel p; for (size_t j = 0; j < i; j++) p.writeInt32(3); p.writeCString(str); int32_t pos = p.dataPosition(); p.setDataPosition(0); for (size_t j = 0; j < i; j++) p.readInt32(); const char* str2 = p.readCString(); ASSERT_EQ(std::string(str), str2); ASSERT_EQ(pos, p.dataPosition()); } } TEST(Parcel, TestReadCString) { // we should remove the *CString APIs, but testing them until // they are deleted. checkCString(""); checkCString("a"); checkCString("\n"); checkCString("32"); checkCString("321"); checkCString("3210"); checkCString("3210b"); checkCString("123434"); } TEST(Parcel, NonNullTerminatedString8) { String8 kTestString = String8("test-is-good"); Loading
services/surfaceflinger/Scheduler/LayerHistory.cpp +18 −4 Original line number Diff line number Diff line Loading @@ -308,11 +308,14 @@ void LayerHistory::partitionLayers(nsecs_t now, bool isVrrDevice) { const auto setFrameRateVoteType = info->isVisible() ? voteType : LayerVoteType::NoVote; const bool hasSetFrameRateOpinion = frameRate.isValid() && !frameRate.isNoVote(); const bool hasSetFrameRateOpinion = frameRate.isValuelessType() || frameRate.vote.rate.isValid(); const bool hasCategoryOpinion = frameRate.category != FrameRateCategory::NoPreference && frameRate.category != FrameRateCategory::Default; const bool hasFrameRateOpinion = hasSetFrameRateOpinion || hasCategoryOpinion; const bool hasFrameRateOpinionAboveGameDefault = hasSetFrameRateOpinion || hasCategoryOpinion; const bool hasFrameRateOpinionArr = frameRate.isValid() && !frameRate.isNoVote(); if (gameModeFrameRateOverride.isValid()) { info->setLayerVote({gameFrameRateOverrideVoteType, gameModeFrameRateOverride}); Loading @@ -321,7 +324,8 @@ void LayerHistory::partitionLayers(nsecs_t now, bool isVrrDevice) { trace(*info, gameFrameRateOverrideVoteType, gameModeFrameRateOverride.getIntValue()); } } else if (hasFrameRateOpinion && frameRate.isVoteValidForMrr(isVrrDevice)) { } else if (hasFrameRateOpinionAboveGameDefault && frameRate.isVoteValidForMrr(isVrrDevice)) { info->setLayerVote({setFrameRateVoteType, isValuelessVote ? 0_Hz : frameRate.vote.rate, frameRate.vote.seamlessness, frameRate.category}); Loading @@ -337,8 +341,18 @@ void LayerHistory::partitionLayers(nsecs_t now, bool isVrrDevice) { trace(*info, gameFrameRateOverrideVoteType, gameDefaultFrameRateOverride.getIntValue()); } } else if (hasFrameRateOpinionArr && frameRate.isVoteValidForMrr(isVrrDevice)) { // This allows NoPreference votes on ARR devices after considering the // gameDefaultFrameRateOverride (above). info->setLayerVote({setFrameRateVoteType, isValuelessVote ? 0_Hz : frameRate.vote.rate, frameRate.vote.seamlessness, frameRate.category}); if (CC_UNLIKELY(mTraceEnabled)) { trace(*info, gameFrameRateOverrideVoteType, frameRate.vote.rate.getIntValue()); } } else { if (hasFrameRateOpinion && !frameRate.isVoteValidForMrr(isVrrDevice)) { if (hasFrameRateOpinionArr && !frameRate.isVoteValidForMrr(isVrrDevice)) { SFTRACE_FORMAT_INSTANT("Reset layer to ignore explicit vote on MRR %s: %s " "%s %s", info->getName().c_str(), Loading
services/surfaceflinger/tests/unittests/LayerHistoryIntegrationTest.cpp +198 −0 Original line number Diff line number Diff line Loading @@ -715,6 +715,204 @@ TEST_F(LayerHistoryIntegrationTest, oneLayerCategoryNoPreference) { EXPECT_EQ(0, frequentLayerCount(time)); } // Tests MRR NoPreference-only vote, no game default override. Expects vote reset. TEST_F(LayerHistoryIntegrationTest, oneLayerCategoryNoPreference_mrr) { SET_FLAG_FOR_TEST(flags::frame_rate_category_mrr, false); SET_FLAG_FOR_TEST(flags::game_default_frame_rate, true); SET_FLAG_FOR_TEST(flags::vrr_config, true); const LayerHistory::LayerVoteType defaultVote = LayerHistory::LayerVoteType::Min; auto layer = createLegacyAndFrontedEndLayer(1); setDefaultLayerVote(layer.get(), defaultVote); showLayer(1); setFrameRate(1, (0_Hz).getValue(), ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT, ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS); setFrameRateCategory(1, ANATIVEWINDOW_FRAME_RATE_CATEGORY_NO_PREFERENCE); EXPECT_EQ(1u, layerCount()); EXPECT_EQ(0u, activeLayerCount()); nsecs_t time = systemTime(); for (size_t i = 0; i < PRESENT_TIME_HISTORY_SIZE; i++) { setBufferWithPresentTime(layer, time); time += HI_FPS_PERIOD; } EXPECT_EQ(1u, summarizeLayerHistory(time).size()); EXPECT_EQ(1u, activeLayerCount()); EXPECT_EQ(1, frequentLayerCount(time)); EXPECT_EQ(defaultVote, summarizeLayerHistory(time)[0].vote); EXPECT_EQ(0_Hz, summarizeLayerHistory(time)[0].desiredRefreshRate); EXPECT_EQ(FrameRateCategory::Default, summarizeLayerHistory(time)[0].frameRateCategory); } // Tests VRR NoPreference-only vote, no game default override. Expects NoPreference, *not* vote // reset. TEST_F(LayerHistoryIntegrationTest, oneLayerCategoryNoPreference_vrr) { SET_FLAG_FOR_TEST(flags::frame_rate_category_mrr, false); SET_FLAG_FOR_TEST(flags::game_default_frame_rate, true); SET_FLAG_FOR_TEST(flags::vrr_config, true); mSelector->setActiveMode(kVrrModeId, HI_FPS); const LayerHistory::LayerVoteType defaultVote = LayerHistory::LayerVoteType::Min; auto layer = createLegacyAndFrontedEndLayer(1); setDefaultLayerVote(layer.get(), defaultVote); showLayer(1); setFrameRate(1, (0_Hz).getValue(), ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT, ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS); setFrameRateCategory(1, ANATIVEWINDOW_FRAME_RATE_CATEGORY_NO_PREFERENCE); EXPECT_EQ(1u, layerCount()); EXPECT_EQ(0u, activeLayerCount()); nsecs_t time = systemTime(); for (size_t i = 0; i < PRESENT_TIME_HISTORY_SIZE; i++) { setBufferWithPresentTime(layer, time); time += HI_FPS_PERIOD; } EXPECT_EQ(1u, summarizeLayerHistory(time).size()); EXPECT_EQ(1u, activeLayerCount()); EXPECT_EQ(1, frequentLayerCount(time)); EXPECT_EQ(LayerHistory::LayerVoteType::ExplicitCategory, summarizeLayerHistory(time)[0].vote); EXPECT_EQ(0_Hz, summarizeLayerHistory(time)[0].desiredRefreshRate); EXPECT_EQ(FrameRateCategory::NoPreference, summarizeLayerHistory(time)[0].frameRateCategory); } TEST_F(LayerHistoryIntegrationTest, oneLayerCategoryNoPreferenceWithGameDefault_vrr) { SET_FLAG_FOR_TEST(flags::frame_rate_category_mrr, false); SET_FLAG_FOR_TEST(flags::game_default_frame_rate, true); SET_FLAG_FOR_TEST(flags::vrr_config, true); mSelector->setActiveMode(kVrrModeId, HI_FPS); const Fps gameDefaultFrameRate = Fps::fromValue(30.0f); const uid_t uid = 456; history().updateGameDefaultFrameRateOverride( FrameRateOverride({uid, gameDefaultFrameRate.getValue()})); auto layer = createLegacyAndFrontedEndLayerWithUid(1, gui::Uid(uid)); showLayer(1); setFrameRate(1, (0_Hz).getValue(), ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT, ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS); setFrameRateCategory(1, ANATIVEWINDOW_FRAME_RATE_CATEGORY_NO_PREFERENCE); EXPECT_EQ(1u, layerCount()); EXPECT_EQ(0u, activeLayerCount()); nsecs_t time = systemTime(); for (size_t i = 0; i < PRESENT_TIME_HISTORY_SIZE; i++) { setBufferWithPresentTime(layer, time); time += HI_FPS_PERIOD; } EXPECT_EQ(1u, summarizeLayerHistory(time).size()); EXPECT_EQ(1u, activeLayerCount()); EXPECT_EQ(1, frequentLayerCount(time)); EXPECT_EQ(LayerHistory::LayerVoteType::ExplicitDefault, summarizeLayerHistory(time)[0].vote); EXPECT_EQ(gameDefaultFrameRate, summarizeLayerHistory(time)[0].desiredRefreshRate); EXPECT_EQ(FrameRateCategory::Default, summarizeLayerHistory(time)[0].frameRateCategory); } TEST_F(LayerHistoryIntegrationTest, oneLayerCategoryNoPreferenceWithGameDefault_mrr) { SET_FLAG_FOR_TEST(flags::frame_rate_category_mrr, false); SET_FLAG_FOR_TEST(flags::game_default_frame_rate, true); SET_FLAG_FOR_TEST(flags::vrr_config, true); const Fps gameDefaultFrameRate = Fps::fromValue(30.0f); const uid_t uid = 456; history().updateGameDefaultFrameRateOverride( FrameRateOverride({uid, gameDefaultFrameRate.getValue()})); auto layer = createLegacyAndFrontedEndLayerWithUid(1, gui::Uid(uid)); showLayer(1); setFrameRate(1, (0_Hz).getValue(), ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT, ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS); setFrameRateCategory(1, ANATIVEWINDOW_FRAME_RATE_CATEGORY_NO_PREFERENCE); EXPECT_EQ(1u, layerCount()); EXPECT_EQ(0u, activeLayerCount()); nsecs_t time = systemTime(); for (size_t i = 0; i < PRESENT_TIME_HISTORY_SIZE; i++) { setBufferWithPresentTime(layer, time); time += HI_FPS_PERIOD; } EXPECT_EQ(1u, summarizeLayerHistory(time).size()); EXPECT_EQ(1u, activeLayerCount()); EXPECT_EQ(1, frequentLayerCount(time)); EXPECT_EQ(LayerHistory::LayerVoteType::ExplicitDefault, summarizeLayerHistory(time)[0].vote); EXPECT_EQ(gameDefaultFrameRate, summarizeLayerHistory(time)[0].desiredRefreshRate); EXPECT_EQ(FrameRateCategory::Default, summarizeLayerHistory(time)[0].frameRateCategory); } TEST_F(LayerHistoryIntegrationTest, oneLayerNoVoteWithGameDefault_vrr) { SET_FLAG_FOR_TEST(flags::frame_rate_category_mrr, false); SET_FLAG_FOR_TEST(flags::game_default_frame_rate, true); SET_FLAG_FOR_TEST(flags::vrr_config, true); mSelector->setActiveMode(kVrrModeId, HI_FPS); const Fps gameDefaultFrameRate = Fps::fromValue(30.0f); const uid_t uid = 456; history().updateGameDefaultFrameRateOverride( FrameRateOverride({uid, gameDefaultFrameRate.getValue()})); auto layer = createLegacyAndFrontedEndLayerWithUid(1, gui::Uid(uid)); showLayer(1); setFrameRate(1, (0_Hz).getValue(), ANATIVEWINDOW_FRAME_RATE_NO_VOTE, ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS); EXPECT_EQ(1u, layerCount()); EXPECT_EQ(0u, activeLayerCount()); nsecs_t time = systemTime(); for (size_t i = 0; i < PRESENT_TIME_HISTORY_SIZE; i++) { setBufferWithPresentTime(layer, time); time += HI_FPS_PERIOD; } // Expect NoVote to be skipped in summarize. EXPECT_EQ(0u, summarizeLayerHistory(time).size()); EXPECT_EQ(1u, activeLayerCount()); EXPECT_EQ(1, frequentLayerCount(time)); } TEST_F(LayerHistoryIntegrationTest, oneLayerNoVoteWithGameDefault_mrr) { SET_FLAG_FOR_TEST(flags::frame_rate_category_mrr, false); SET_FLAG_FOR_TEST(flags::game_default_frame_rate, true); SET_FLAG_FOR_TEST(flags::vrr_config, true); const Fps gameDefaultFrameRate = Fps::fromValue(30.0f); const uid_t uid = 456; history().updateGameDefaultFrameRateOverride( FrameRateOverride({uid, gameDefaultFrameRate.getValue()})); auto layer = createLegacyAndFrontedEndLayerWithUid(1, gui::Uid(uid)); showLayer(1); setFrameRate(1, (0_Hz).getValue(), ANATIVEWINDOW_FRAME_RATE_NO_VOTE, ANATIVEWINDOW_CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS); EXPECT_EQ(1u, layerCount()); EXPECT_EQ(0u, activeLayerCount()); nsecs_t time = systemTime(); for (size_t i = 0; i < PRESENT_TIME_HISTORY_SIZE; i++) { setBufferWithPresentTime(layer, time); time += HI_FPS_PERIOD; } // Expect NoVote to be skipped in summarize. EXPECT_EQ(0u, summarizeLayerHistory(time).size()); EXPECT_EQ(1u, activeLayerCount()); EXPECT_EQ(1, frequentLayerCount(time)); } TEST_F(LayerHistoryIntegrationTest, oneLayerExplicitVoteWithCategory) { SET_FLAG_FOR_TEST(flags::frame_rate_category_mrr, true); Loading