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

Commit a5c81755 authored by Shane's avatar Shane
Browse files

Make toolkit_frame_rate_function_enabling_read_only only avoid calls to

SurfaceFling

Use toolkit_frame_rate_function_enabling_read_only to only gate the
setFrameRate and setFrameRateCategory calls, and
toolkit_frame_rate_view_enabling_read_only to gate the changes by made
Toolkit for VRR.

Test: atest ViewRootImpl / ViewFrameRateTest / ViewTest
Change-Id: I6a10dc44f61501dc5e9293c6b240d46c79e25736
parent 4f1fc19f
Loading
Loading
Loading
Loading
+16 −6
Original line number Diff line number Diff line
@@ -112,6 +112,7 @@ import static android.view.flags.Flags.toolkitFrameRateVelocityMappingReadOnly;
import static android.view.flags.Flags.toolkitMetricsForFrameRateDecision;
import static android.view.flags.Flags.toolkitSetFrameRateReadOnly;
import static android.view.flags.Flags.toolkitFrameRateFunctionEnablingReadOnly;
import static android.view.flags.Flags.toolkitFrameRateViewEnablingReadOnly;
import static android.view.inputmethod.InputMethodEditorTraceProto.InputMethodClientsTraceProto.ClientSideProto.IME_FOCUS_CONTROLLER;
import static android.view.inputmethod.InputMethodEditorTraceProto.InputMethodClientsTraceProto.ClientSideProto.INSETS_CONTROLLER;
@@ -1155,6 +1156,7 @@ public final class ViewRootImpl implements ViewParent,
    private static boolean sToolkitFrameRateFunctionEnablingReadOnlyFlagValue;
    private static boolean sToolkitMetricsForFrameRateDecisionFlagValue;
    private static boolean sToolkitFrameRateTypingReadOnlyFlagValue;
    private static final boolean sToolkitFrameRateViewEnablingReadOnlyFlagValue;
    private static boolean sToolkitFrameRateVelocityMappingReadOnlyFlagValue =
            toolkitFrameRateVelocityMappingReadOnly();;
@@ -1164,6 +1166,8 @@ public final class ViewRootImpl implements ViewParent,
        sToolkitFrameRateTypingReadOnlyFlagValue = toolkitFrameRateTypingReadOnly();
        sToolkitFrameRateFunctionEnablingReadOnlyFlagValue =
                toolkitFrameRateFunctionEnablingReadOnly();
        sToolkitFrameRateViewEnablingReadOnlyFlagValue =
                toolkitFrameRateViewEnablingReadOnly();
    }
    // The latest input event from the gesture that was used to resolve the pointer icon.
@@ -2627,8 +2631,10 @@ public final class ViewRootImpl implements ViewParent,
        // no longer needed if the dVRR feature is disabled.
        if (shouldEnableDvrr()) {
            try {
                if (sToolkitFrameRateFunctionEnablingReadOnlyFlagValue) {
                    mFrameRateTransaction.setFrameRateSelectionStrategy(sc,
                        sc.FRAME_RATE_SELECTION_STRATEGY_SELF).applyAsyncUnsafe();
                }
            } catch (Exception e) {
                Log.e(mTag, "Unable to set frame rate selection strategy ", e);
            }
@@ -12528,10 +12534,12 @@ public final class ViewRootImpl implements ViewParent,
                                    + category + ", reason " + reason + ", "
                                    + sourceView);
                }
                if (sToolkitFrameRateFunctionEnablingReadOnlyFlagValue) {
                    mFrameRateTransaction.setFrameRateCategory(mSurfaceControl,
                        frameRateCategory, false).applyAsyncUnsafe();
                    mLastPreferredFrameRateCategory = frameRateCategory;
                }
            }
        } catch (Exception e) {
            Log.e(mTag, "Unable to set frame rate category", e);
        } finally {
@@ -12587,10 +12595,12 @@ public final class ViewRootImpl implements ViewParent,
                                + preferredFrameRate + " compatibility "
                                + mFrameRateCompatibility);
                }
                if (sToolkitFrameRateFunctionEnablingReadOnlyFlagValue) {
                    mFrameRateTransaction.setFrameRate(mSurfaceControl, preferredFrameRate,
                    mFrameRateCompatibility).applyAsyncUnsafe();
                    mLastPreferredFrameRate = preferredFrameRate;
                }
            }
        } catch (Exception e) {
            Log.e(mTag, "Unable to set frame rate", e);
        } finally {
@@ -12816,7 +12826,7 @@ public final class ViewRootImpl implements ViewParent,
    private boolean shouldEnableDvrr() {
        // uncomment this when we are ready for enabling dVRR
        if (sToolkitFrameRateFunctionEnablingReadOnlyFlagValue) {
        if (sToolkitFrameRateViewEnablingReadOnlyFlagValue) {
            return sToolkitSetFrameRateReadOnlyFlagValue && isFrameRatePowerSavingsBalanced();
        }
        return false;