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

Commit 231b24b6 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 14058385 from e5734fd9 to 25Q4-release

Change-Id: I1b9db38bae8704aba1d3f56689cae7a74c0085c6
parents cd463938 e5734fd9
Loading
Loading
Loading
Loading
+19 −9
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ import com.android.internal.display.BrightnessSynchronizer;
import com.android.server.display.feature.flags.Flags;

import java.util.Arrays;
import java.util.EnumSet;
import java.util.Objects;

/**
@@ -958,6 +959,23 @@ public final class DisplayInfo implements Parcelable {
        }
    }

    /**
     * Same as {@link #getBasicChangedGroups(DisplayInfo)} except here we only compare
     * the specified groups i.e. if changes happen to other groups they will not be identified.
     */
    public int getBasicChangedGroups(@Nullable DisplayInfo other,
            EnumSet<DisplayInfoGroup> groupsToCompare) {
        int changedGroups = 0;

        for (DisplayInfoGroup group : groupsToCompare) {
            if (hasDisplayInfoGroupChanged(group, other)) {
                changedGroups |= group.getMask();
            }
        }

        return changedGroups;
    }

    /**
     * Compares this {@link DisplayInfo} with another for "basic" changes
     * (i.e. when a {@link android.hardware.display.DisplayManager.EVENT_TYPE_DISPLAY_CHANGED}
@@ -970,15 +988,7 @@ public final class DisplayInfo implements Parcelable {
     * changed. If none have changed, the bitmask will be 0.
     */
    public int getBasicChangedGroups(@Nullable DisplayInfo other) {
        int changedGroups = 0;

        for (DisplayInfoGroup group : DisplayInfoGroup.values()) {
            if (hasDisplayInfoGroupChanged(group, other)) {
                changedGroups |= group.getMask();
            }
        }

        return changedGroups;
        return getBasicChangedGroups(other, EnumSet.allOf(DisplayInfoGroup.class));
    }

    /**
+64 −0
Original line number Diff line number Diff line
@@ -32,6 +32,8 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.util.EnumSet;

@RunWith(AndroidJUnit4.class)
@SmallTest
public class DisplayInfoTest {
@@ -318,6 +320,68 @@ public class DisplayInfoTest {
        );
    }

    @Test
    public void getBasicChangedGroups_otherIsNull_returns_some_groups() {
        DisplayInfo base = new DisplayInfo();
        int changedGroups = base.getBasicChangedGroups(null,
                EnumSet.of(DisplayInfo.DisplayInfoGroup.BASIC_PROPERTIES,
                        DisplayInfo.DisplayInfoGroup.ORIENTATION_AND_ROTATION));
        assertThat(changedGroups).isEqualTo(
                DisplayInfo.DisplayInfoGroup.BASIC_PROPERTIES.getMask()
                        | DisplayInfo.DisplayInfoGroup.ORIENTATION_AND_ROTATION.getMask()
        );
    }

    @Test
    public void getBasicChangedGroups_withGroupsToCompare_singleGroupChanged_Matches() {
        DisplayInfo base = new DisplayInfo();
        DisplayInfo other = new DisplayInfo(base);
        other.logicalWidth = 1440; // Belongs to DIMENSIONS_AND_SHAPES

        EnumSet<DisplayInfo.DisplayInfoGroup> groupsToCompare =
                EnumSet.of(DisplayInfo.DisplayInfoGroup.DIMENSIONS_AND_SHAPES);

        int changedGroups = base.getBasicChangedGroups(other, groupsToCompare);

        assertThat(changedGroups)
                .isEqualTo(DisplayInfo.DisplayInfoGroup.DIMENSIONS_AND_SHAPES.getMask());
    }

    @Test
    public void getBasicChangedGroups_withGroupsToCompare_singleGroupChanged_DoesNotMatch() {
        DisplayInfo base = new DisplayInfo();
        DisplayInfo other = new DisplayInfo(base);
        other.logicalWidth = 1440; // Belongs to DIMENSIONS_AND_SHAPES

        // Compare a different group that has not changed.
        EnumSet<DisplayInfo.DisplayInfoGroup> groupsToCompare =
                EnumSet.of(DisplayInfo.DisplayInfoGroup.BASIC_PROPERTIES);

        int changedGroups = base.getBasicChangedGroups(other, groupsToCompare);

        assertThat(changedGroups).isEqualTo(0);
    }

    @Test
    public void getBasicChangedGroups_withGroupsToCompare_multipleGroupsChanged() {
        DisplayInfo base = new DisplayInfo();
        DisplayInfo other = new DisplayInfo(base);
        other.flags = Display.FLAG_PRIVATE; // BASIC_PROPERTIES
        other.rotation = Surface.ROTATION_180; // ORIENTATION_AND_ROTATION
        other.state = Display.STATE_VR; // STATE

        // Only compare two of the three changed groups.
        EnumSet<DisplayInfo.DisplayInfoGroup> groupsToCompare =
                EnumSet.of(DisplayInfo.DisplayInfoGroup.BASIC_PROPERTIES,
                        DisplayInfo.DisplayInfoGroup.STATE);

        int changedGroups = base.getBasicChangedGroups(other, groupsToCompare);

        assertThat(changedGroups).isEqualTo(
                DisplayInfo.DisplayInfoGroup.BASIC_PROPERTIES.getMask()
                        | DisplayInfo.DisplayInfoGroup.STATE.getMask());
    }

    private void setSupportedModes(DisplayInfo info, Display.Mode[] modes, int modeId) {
        info.supportedModes = modes;
        info.modeId = modeId;
+1 −2
Original line number Diff line number Diff line
@@ -4283,8 +4283,7 @@ public final class MediaCodecInfo {
                            maxBlocks, maxBlocksPerSecond,
                            blockSize, blockSize,
                            1 /* widthAlignment */, 1 /* heightAlignment */);
                } else if (GetFlag(() -> android.media.codec.Flags.apvSupport())
                            && mime.equalsIgnoreCase(MediaFormat.MIMETYPE_VIDEO_APV)) {
                } else if (mime.equalsIgnoreCase(MediaFormat.MIMETYPE_VIDEO_APV)) {
                    maxBlocksPerSecond = 11880;
                    maxBps = 7000000;

+19 −20
Original line number Diff line number Diff line
@@ -337,7 +337,7 @@ public abstract class OomAdjuster {
     * OOM scores.
     */
    @GuardedBy("mService")
    protected final ArrayList<ProcessRecord> mProcsToOomAdj = new ArrayList<ProcessRecord>();
    protected final ArrayList<ProcessRecordInternal> mProcsToOomAdj = new ArrayList<>();

    /**
     * Flag to mark if there is an ongoing oomAdjUpdate: potentially the oomAdjUpdate
@@ -426,7 +426,7 @@ public abstract class OomAdjuster {
            return SystemClock.elapsedRealtime();
        }

        void batchSetOomAdj(ArrayList<ProcessRecord> procsToOomAdj) {
        void batchSetOomAdj(ArrayList<ProcessRecordInternal> procsToOomAdj) {
            ProcessList.batchSetOomAdj(procsToOomAdj);
        }

@@ -2389,47 +2389,46 @@ public abstract class OomAdjuster {
    }

    @GuardedBy({"mService", "mProcLock"})
    private void maybeUpdateUsageStatsLSP(ProcessRecord app, long nowElapsed) {
        final ProcessRecordInternal state = app;
    private void maybeUpdateUsageStatsLSP(ProcessRecordInternal app, long nowElapsed) {
        if (DEBUG_USAGE_STATS) {
            Slog.d(TAG, "Checking proc [" + Arrays.toString(app.getPackageList())
                    + "] state changes: old = " + state.getSetProcState() + ", new = "
                    + state.getCurProcState());
                    + "] state changes: old = " + app.getSetProcState() + ", new = "
                    + app.getCurProcState());
        }
        if (mService.mUsageStatsService == null) {
            return;
        }
        final boolean fgsInteractionChangeEnabled = state.getCachedCompatChange(
        final boolean fgsInteractionChangeEnabled = app.getCachedCompatChange(
                CACHED_COMPAT_CHANGE_USE_SHORT_FGS_USAGE_INTERACTION_TIME);
        boolean isInteraction;
        // To avoid some abuse patterns, we are going to be careful about what we consider
        // to be an app interaction.  Being the top activity doesn't count while the display
        // is sleeping, nor do short foreground services.
        if (ActivityManager.isProcStateConsideredInteraction(state.getCurProcState())) {
        if (ActivityManager.isProcStateConsideredInteraction(app.getCurProcState())) {
            isInteraction = true;
            state.setFgInteractionTime(0);
        } else if (state.getCurProcState() <= PROCESS_STATE_FOREGROUND_SERVICE) {
            if (state.getFgInteractionTime() == 0) {
                state.setFgInteractionTime(nowElapsed);
            app.setFgInteractionTime(0);
        } else if (app.getCurProcState() <= PROCESS_STATE_FOREGROUND_SERVICE) {
            if (app.getFgInteractionTime() == 0) {
                app.setFgInteractionTime(nowElapsed);
                isInteraction = false;
            } else {
                final long interactionTime = fgsInteractionChangeEnabled
                        ? mConstants.SERVICE_USAGE_INTERACTION_TIME_POST_S
                        : mConstants.SERVICE_USAGE_INTERACTION_TIME_PRE_S;
                isInteraction = nowElapsed > state.getFgInteractionTime() + interactionTime;
                isInteraction = nowElapsed > app.getFgInteractionTime() + interactionTime;
            }
        } else {
            isInteraction =
                    state.getCurProcState() <= PROCESS_STATE_IMPORTANT_FOREGROUND;
            state.setFgInteractionTime(0);
                    app.getCurProcState() <= PROCESS_STATE_IMPORTANT_FOREGROUND;
            app.setFgInteractionTime(0);
        }
        final long interactionThreshold = fgsInteractionChangeEnabled
                ? mConstants.USAGE_STATS_INTERACTION_INTERVAL_POST_S
                : mConstants.USAGE_STATS_INTERACTION_INTERVAL_PRE_S;
        if (isInteraction
                && (!state.getHasReportedInteraction()
                    || (nowElapsed - state.getInteractionEventTime()) > interactionThreshold)) {
            state.setInteractionEventTime(nowElapsed);
                && (!app.getHasReportedInteraction()
                    || (nowElapsed - app.getInteractionEventTime()) > interactionThreshold)) {
            app.setInteractionEventTime(nowElapsed);
            String[] packages = app.getPackageList();
            if (packages != null) {
                for (int i = 0; i < packages.length; i++) {
@@ -2438,9 +2437,9 @@ public abstract class OomAdjuster {
                }
            }
        }
        state.setHasReportedInteraction(isInteraction);
        app.setHasReportedInteraction(isInteraction);
        if (!isInteraction) {
            state.setInteractionEventTime(0);
            app.setInteractionEventTime(0);
        }
    }

+1 −1
Original line number Diff line number Diff line
@@ -1610,7 +1610,7 @@ public final class ProcessList implements ProcessStateController.ProcessLruUpdat
     *
     * @hide
     */
    public static void batchSetOomAdj(ArrayList<ProcessRecord> apps) {
    public static void batchSetOomAdj(ArrayList<ProcessRecordInternal> apps) {
        final int totalApps = apps.size();
        if (totalApps == 0) {
            return;
Loading