Loading core/java/android/view/View.java +3 −2 Original line number Diff line number Diff line Loading @@ -33944,8 +33944,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback, protected int calculateFrameRateCategory() { int category; switch (getViewRootImpl().intermittentUpdateState()) { case ViewRootImpl.INTERMITTENT_STATE_INTERMITTENT -> category = FRAME_RATE_CATEGORY_NORMAL | FRAME_RATE_CATEGORY_REASON_INTERMITTENT; case ViewRootImpl.INTERMITTENT_STATE_INTERMITTENT -> category = (sToolkitFrameRateBySizeReadOnlyFlagValue ? FRAME_RATE_CATEGORY_LOW : FRAME_RATE_CATEGORY_NORMAL) | FRAME_RATE_CATEGORY_REASON_INTERMITTENT; case ViewRootImpl.INTERMITTENT_STATE_NOT_INTERMITTENT -> category = mSizeBasedFrameRateCategoryAndReason; default -> category = mLastFrameRateCategory; core/tests/coretests/src/android/view/ViewFrameRateTest.java +6 −3 Original line number Diff line number Diff line Loading @@ -488,16 +488,19 @@ public class ViewFrameRateTest { waitForFrameRateCategoryToSettle(); for (int i = 0; i < 5; i++) { int expectedCategory; if (i < 4) { if (i < 2) { // not intermittent yet. // It takes 2 frames of intermittency before Views vote as intermittent. // It takes 4 more frames for the category to drop to the next category. expectedCategory = toolkitFrameRateDefaultNormalReadOnly() ? FRAME_RATE_CATEGORY_NORMAL : FRAME_RATE_CATEGORY_HIGH; } else { // intermittent expectedCategory = FRAME_RATE_CATEGORY_NORMAL; // Even though this is not a small View, step 3 is triggered by this flag, which // brings intermittent to LOW expectedCategory = toolkitFrameRateBySizeReadOnly() ? FRAME_RATE_CATEGORY_LOW : FRAME_RATE_CATEGORY_NORMAL; } mActivityRule.runOnUiThread(() -> { mMovingView.invalidate(); Loading core/tests/coretests/src/android/view/ViewRootImplTest.java +9 −2 Original line number Diff line number Diff line Loading @@ -1174,9 +1174,16 @@ public class ViewRootImplTest { // Infrequent update Thread.sleep(delay); // Even though this is not a small View, step 3 is triggered by this flag, which // brings intermittent to LOW int intermittentExpected = toolkitFrameRateBySizeReadOnly() ? FRAME_RATE_CATEGORY_LOW : FRAME_RATE_CATEGORY_NORMAL; sInstrumentation.runOnMainSync(() -> { mView.invalidate(); runAfterDraw(() -> assertEquals(FRAME_RATE_CATEGORY_NORMAL, runAfterDraw(() -> assertEquals(intermittentExpected, mViewRootImpl.getLastPreferredFrameRateCategory())); }); waitForAfterDraw(); Loading @@ -1184,7 +1191,7 @@ public class ViewRootImplTest { // When the View vote, it's still considered as intermittent update state sInstrumentation.runOnMainSync(() -> { mView.invalidate(); runAfterDraw(() -> assertEquals(FRAME_RATE_CATEGORY_NORMAL, runAfterDraw(() -> assertEquals(intermittentExpected, mViewRootImpl.getLastPreferredFrameRateCategory())); }); waitForAfterDraw(); Loading Loading
core/java/android/view/View.java +3 −2 Original line number Diff line number Diff line Loading @@ -33944,8 +33944,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback, protected int calculateFrameRateCategory() { int category; switch (getViewRootImpl().intermittentUpdateState()) { case ViewRootImpl.INTERMITTENT_STATE_INTERMITTENT -> category = FRAME_RATE_CATEGORY_NORMAL | FRAME_RATE_CATEGORY_REASON_INTERMITTENT; case ViewRootImpl.INTERMITTENT_STATE_INTERMITTENT -> category = (sToolkitFrameRateBySizeReadOnlyFlagValue ? FRAME_RATE_CATEGORY_LOW : FRAME_RATE_CATEGORY_NORMAL) | FRAME_RATE_CATEGORY_REASON_INTERMITTENT; case ViewRootImpl.INTERMITTENT_STATE_NOT_INTERMITTENT -> category = mSizeBasedFrameRateCategoryAndReason; default -> category = mLastFrameRateCategory;
core/tests/coretests/src/android/view/ViewFrameRateTest.java +6 −3 Original line number Diff line number Diff line Loading @@ -488,16 +488,19 @@ public class ViewFrameRateTest { waitForFrameRateCategoryToSettle(); for (int i = 0; i < 5; i++) { int expectedCategory; if (i < 4) { if (i < 2) { // not intermittent yet. // It takes 2 frames of intermittency before Views vote as intermittent. // It takes 4 more frames for the category to drop to the next category. expectedCategory = toolkitFrameRateDefaultNormalReadOnly() ? FRAME_RATE_CATEGORY_NORMAL : FRAME_RATE_CATEGORY_HIGH; } else { // intermittent expectedCategory = FRAME_RATE_CATEGORY_NORMAL; // Even though this is not a small View, step 3 is triggered by this flag, which // brings intermittent to LOW expectedCategory = toolkitFrameRateBySizeReadOnly() ? FRAME_RATE_CATEGORY_LOW : FRAME_RATE_CATEGORY_NORMAL; } mActivityRule.runOnUiThread(() -> { mMovingView.invalidate(); Loading
core/tests/coretests/src/android/view/ViewRootImplTest.java +9 −2 Original line number Diff line number Diff line Loading @@ -1174,9 +1174,16 @@ public class ViewRootImplTest { // Infrequent update Thread.sleep(delay); // Even though this is not a small View, step 3 is triggered by this flag, which // brings intermittent to LOW int intermittentExpected = toolkitFrameRateBySizeReadOnly() ? FRAME_RATE_CATEGORY_LOW : FRAME_RATE_CATEGORY_NORMAL; sInstrumentation.runOnMainSync(() -> { mView.invalidate(); runAfterDraw(() -> assertEquals(FRAME_RATE_CATEGORY_NORMAL, runAfterDraw(() -> assertEquals(intermittentExpected, mViewRootImpl.getLastPreferredFrameRateCategory())); }); waitForAfterDraw(); Loading @@ -1184,7 +1191,7 @@ public class ViewRootImplTest { // When the View vote, it's still considered as intermittent update state sInstrumentation.runOnMainSync(() -> { mView.invalidate(); runAfterDraw(() -> assertEquals(FRAME_RATE_CATEGORY_NORMAL, runAfterDraw(() -> assertEquals(intermittentExpected, mViewRootImpl.getLastPreferredFrameRateCategory())); }); waitForAfterDraw(); Loading