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

Commit 0c5a924e authored by Yury Khmel's avatar Yury Khmel Committed by Android (Google) Code Review
Browse files

Merge "Distinguish Andromeda and Android for SurfaceComposition test."

parents 6b05f803 7578d10f
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.app.Activity;
import android.app.ActivityManager;
import android.app.ActivityManager.MemoryInfo;
import android.content.Context;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.graphics.PixelFormat;
import android.graphics.Rect;
@@ -95,11 +96,9 @@ public class SurfaceCompositionMeasuringActivity extends Activity implements OnC
    private boolean mResumed;

    // Drop one frame per half second.
    // TODO(khmel)
    // Add a feature flag and set the target FPS dependent on the target system as e.g.:
    // 59FPS for MULTI_WINDOW and 54 otherwise (to satisfy the default lax Android requirements).
    private double mRefreshRate;
    private double mTargetFPS;
    private boolean mAndromeda;

    private int mWidth;
    private int mHeight;
@@ -182,6 +181,10 @@ public class SurfaceCompositionMeasuringActivity extends Activity implements OnC
        return score;
    }

    public boolean isAndromeda() {
        return mAndromeda;
    }

    @Override
    public void onClick(View view) {
        if (view == mMeasureCompositionButton) {
@@ -247,6 +250,9 @@ public class SurfaceCompositionMeasuringActivity extends Activity implements OnC

        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

        // Detect Andromeda devices by having free-form window management feature.
        mAndromeda = getPackageManager().hasSystemFeature(
                PackageManager.FEATURE_FREEFORM_WINDOW_MANAGEMENT);
        detectRefreshRate();

        // To layouts in parent. First contains list of Surfaces and second
@@ -513,7 +519,8 @@ public class SurfaceCompositionMeasuringActivity extends Activity implements OnC
        }

        MemoryInfo memInfo = getMemoryInfo();
        String info = "Available " +
        String platformName = mAndromeda ? "Andromeda" : "Android";
        String info = platformName + ": available " +
                getReadableMemory(memInfo.availMem) + " from " +
                getReadableMemory(memInfo.totalMem) + ".\nVisible " +
                visibleCnt + " from " + mViews.size() + " " +
+14 −5
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ package android.surfacecomposition;

import android.app.Activity;
import android.graphics.PixelFormat;
import android.os.Build;
import android.os.Bundle;
import android.surfacecomposition.SurfaceCompositionMeasuringActivity.AllocationScore;
import android.surfacecomposition.SurfaceCompositionMeasuringActivity.CompositorScore;
@@ -44,11 +45,16 @@ public class SurfaceCompositionTest extends
        PixelFormat.OPAQUE,
    };

    // Based on Nexus 9 performance which is usually < 9.0.
    private final static double[] MIN_ACCEPTED_COMPOSITION_SCORE = new double[] {
    // Nexus 9 performance is around 8.8. We distinguish results for Andromeda and
    // Android devices. Andromeda devices require higher performance score.
    private final static double[] MIN_ACCEPTED_COMPOSITION_SCORE_ANDROMDEDA = new double[] {
        8.0,
        8.0,
    };
    private final static double[] MIN_ACCEPTED_COMPOSITION_SCORE_ANDROID = new double[] {
        4.0,
        4.0,
    };

    // Based on Nexus 6 performance which is usually < 28.0.
    private final static double[] MIN_ACCEPTED_ALLOCATION_SCORE = new double[] {
@@ -66,6 +72,8 @@ public class SurfaceCompositionTest extends
    @SmallTest
    public void testSurfaceCompositionPerformance() {
        Bundle status = new Bundle();
        double[] minScores = getActivity().isAndromeda() ?
                MIN_ACCEPTED_COMPOSITION_SCORE_ANDROMDEDA : MIN_ACCEPTED_COMPOSITION_SCORE_ANDROID;
        for (int i = 0; i < TEST_PIXEL_FORMATS.length; ++i) {
            int pixelFormat = TEST_PIXEL_FORMATS[i];
            String formatName = SurfaceCompositionMeasuringActivity.getPixelFormatInfo(pixelFormat);
@@ -73,8 +81,8 @@ public class SurfaceCompositionTest extends
            Log.i(TAG, "testSurfaceCompositionPerformance(" + formatName + ") = " + score);
            assertTrue("Device does not support surface(" + formatName + ") composition " +
                    "performance score. " + score.mSurfaces + " < " +
                    MIN_ACCEPTED_COMPOSITION_SCORE[i] + ".",
                    score.mSurfaces >= MIN_ACCEPTED_COMPOSITION_SCORE[i]);
                    minScores[i] + ". Build: " + Build.FINGERPRINT + ".",
                    score.mSurfaces >= minScores[i]);
            // Send status only for TRANSLUCENT format.
            if (pixelFormat == PixelFormat.TRANSLUCENT) {
                status.putDouble(KEY_SURFACE_COMPOSITION_PERFORMANCE, score.mSurfaces);
@@ -96,7 +104,8 @@ public class SurfaceCompositionTest extends
            Log.i(TAG, "testSurfaceAllocationPerformance(" + formatName + ") = " + score);
            assertTrue("Device does not support surface(" + formatName + ") allocation " +
                    "performance score. " + score.mMedian + " < " +
                    MIN_ACCEPTED_ALLOCATION_SCORE[i] + ".",
                    MIN_ACCEPTED_ALLOCATION_SCORE[i] + ". Build: " +
                    Build.FINGERPRINT + ".",
                    score.mMedian >= MIN_ACCEPTED_ALLOCATION_SCORE[i]);
            // Send status only for TRANSLUCENT format.
            if (pixelFormat == PixelFormat.TRANSLUCENT) {