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

Commit cb87ee64 authored by petsjonkin's avatar petsjonkin
Browse files

Adding IntDef annotation to Vote priority

Bug: b/266789924
Test: -
Change-Id: Ib72de5b8750a4fd5e870163858c28de68106c2d3
parent 74f9c104
Loading
Loading
Loading
Loading
+32 −4
Original line number Diff line number Diff line
@@ -16,10 +16,13 @@

package com.android.server.display.mode;

import android.annotation.IntDef;
import android.annotation.NonNull;

import com.android.server.display.config.SupportedModeData;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.List;

@@ -132,15 +135,40 @@ interface Vote {
    // to function, so this needs to be the highest priority of all votes.
    int PRIORITY_UDFPS = 20;

    @IntDef(prefix = { "PRIORITY_" }, value = {
            PRIORITY_DEFAULT_RENDER_FRAME_RATE,
            PRIORITY_FLICKER_REFRESH_RATE,
            PRIORITY_HIGH_BRIGHTNESS_MODE,
            PRIORITY_USER_SETTING_MIN_RENDER_FRAME_RATE,
            PRIORITY_USER_SETTING_DISPLAY_PREFERRED_SIZE,
            PRIORITY_APP_REQUEST_RENDER_FRAME_RATE_RANGE,
            PRIORITY_APP_REQUEST_BASE_MODE_REFRESH_RATE,
            PRIORITY_APP_REQUEST_SIZE,
            PRIORITY_USER_SETTING_PEAK_REFRESH_RATE,
            PRIORITY_USER_SETTING_PEAK_RENDER_FRAME_RATE,
            PRIORITY_SYNCHRONIZED_REFRESH_RATE,
            PRIORITY_LIMIT_MODE,
            PRIORITY_AUTH_OPTIMIZER_RENDER_FRAME_RATE,
            PRIORITY_LAYOUT_LIMITED_FRAME_RATE,
            PRIORITY_SYSTEM_REQUESTED_MODES,
            PRIORITY_LOW_POWER_MODE_MODES,
            PRIORITY_LOW_POWER_MODE_RENDER_RATE,
            PRIORITY_FLICKER_REFRESH_RATE_SWITCH,
            PRIORITY_SKIN_TEMPERATURE,
            PRIORITY_PROXIMITY,
            PRIORITY_UDFPS
    })
    @Retention(RetentionPolicy.SOURCE)
    @interface Priority {}

    // Whenever a new priority is added, remember to update MIN_PRIORITY, MAX_PRIORITY, and
    // APP_REQUEST_REFRESH_RATE_RANGE_PRIORITY_CUTOFF, as well as priorityToString.

    int MIN_PRIORITY = PRIORITY_DEFAULT_RENDER_FRAME_RATE;
    int MAX_PRIORITY = PRIORITY_UDFPS;
    @Priority int MIN_PRIORITY = PRIORITY_DEFAULT_RENDER_FRAME_RATE;
    @Priority int MAX_PRIORITY = PRIORITY_UDFPS;

    // The cutoff for the app request refresh rate range. Votes with priorities lower than this
    // value will not be considered when constructing the app request refresh rate range.
    int APP_REQUEST_REFRESH_RATE_RANGE_PRIORITY_CUTOFF =
    @Priority int APP_REQUEST_REFRESH_RATE_RANGE_PRIORITY_CUTOFF =
            PRIORITY_APP_REQUEST_RENDER_FRAME_RATE_RANGE;

    /**
+3 −3
Original line number Diff line number Diff line
@@ -79,12 +79,12 @@ class VotesStorage {
    }

    /** updates vote storage for all displays */
    void updateGlobalVote(int priority, @Nullable Vote vote) {
    void updateGlobalVote(@Vote.Priority int priority, @Nullable Vote vote) {
        updateVote(GLOBAL_ID, priority, vote);
    }

    /** updates vote storage */
    void updateVote(int displayId, int priority, @Nullable Vote vote) {
    void updateVote(int displayId, @Vote.Priority int priority, @Nullable Vote vote) {
        if (mLoggingEnabled) {
            Slog.i(TAG, "updateVoteLocked(displayId=" + displayId
                    + ", priority=" + Vote.priorityToString(priority)
@@ -126,7 +126,7 @@ class VotesStorage {
    }

    /** removes all votes with certain priority from vote storage */
    void removeAllVotesForPriority(int priority) {
    void removeAllVotesForPriority(@Vote.Priority int priority) {
        if (mLoggingEnabled) {
            Slog.i(TAG, "removeAllVotesForPriority(priority="
                    + Vote.priorityToString(priority) + ")");
+2 −2
Original line number Diff line number Diff line
@@ -38,10 +38,10 @@ import org.mockito.MockitoAnnotations;
@RunWith(AndroidJUnit4.class)
public class VotesStorageTest {
    private static final int DISPLAY_ID = 100;
    private static final int PRIORITY = Vote.PRIORITY_APP_REQUEST_SIZE;
    private static final @Vote.Priority int PRIORITY = Vote.PRIORITY_APP_REQUEST_SIZE;
    private static final Vote VOTE = Vote.forDisableRefreshRateSwitching();
    private static final int DISPLAY_ID_OTHER = 101;
    private static final int PRIORITY_OTHER = Vote.PRIORITY_FLICKER_REFRESH_RATE;
    private static final @Vote.Priority int PRIORITY_OTHER = Vote.PRIORITY_FLICKER_REFRESH_RATE;
    private static final Vote VOTE_OTHER = Vote.forBaseModeRefreshRate(10f);

    @Mock