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

Commit 0142fd6f authored by Greg Kaiser's avatar Greg Kaiser Committed by Android (Google) Code Review
Browse files

Merge changes I0aa147ea,Ib950c2d0 into main

* changes:
  BouncyBall: Allow install on release/older devices
  BouncyBall: Remove some dependencies
parents a27827d9 6a8ce5e4
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -11,7 +11,14 @@ android_app {
    name: "BouncyBallTest",
    manifest: "app/src/main/AndroidManifest.xml",
    srcs: ["app/src/main/java/**/*.java"],
    static_libs: ["com.google.android.material_material"],
    resource_dirs: ["app/src/main/res"],
    // We want to build against the latest APIs in the tree
    sdk_version: "current",
    // We set a specific target version so this can be installed on released
    // devices for testing.
    target_sdk_version: "36",
    // Our focus is on testing more recent devices.  So we limit how far back
    // this goes.  Specifically, we only allow going back to Android 11, where
    // Context.getDisplay() was introduced.
    min_sdk_version: "30",
}
+0 −1
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@
    <application android:allowBackup="true"
         android:icon="@mipmap/ic_launcher"
         android:label="@string/app_name"
         android:theme="@style/AppTheme"
        android:resizeableActivity="true" >
        <activity android:name=".BouncyBallActivity"
             android:label="@string/app_name"
+30 −10
Original line number Diff line number Diff line
@@ -16,7 +16,9 @@

package com.android.test.bouncyball;

import android.app.Activity;
import android.hardware.display.DisplayManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Trace;
import android.util.Log;
@@ -25,11 +27,9 @@ import android.view.Display;
import android.view.Window;
import android.view.WindowManager;

import androidx.appcompat.app.AppCompatActivity;

import java.util.concurrent.Executors;

public class BouncyBallActivity extends AppCompatActivity {
public class BouncyBallActivity extends Activity {
    // Since logging (to logcat) takes system resources, we chose not to log
    // data every frame by default.
    private static final boolean LOG_EVERY_FRAME = false;
@@ -104,7 +104,14 @@ public class BouncyBallActivity extends AppCompatActivity {
                    if (displayId != mDisplayId) {
                        return;
                    }
                    setFrameRate(getDisplay().getMode().getRefreshRate());
                    float frameRate = getDisplay().getMode().getRefreshRate();
                    if (frameRate == mFrameRate) {
                        // On devices with API level < 36, we might get this
                        // called for other reasons (like brightness changing).
                        // We ignore anything but frame rate changes.
                        return;
                    }
                    setFrameRate(frameRate);
                    Log.i(LOG_TAG, "Using frame rate " + mFrameRate + "Hz");
                }
            };
@@ -172,9 +179,17 @@ public class BouncyBallActivity extends AppCompatActivity {
        setContentView(R.layout.activity_bouncy_ball);

        DisplayManager manager = getSystemService(DisplayManager.class);
        if (Build.VERSION.SDK_INT >= 36) {
            // We prefer this newer API, introduced at API level 36.
            manager.registerDisplayListener(Executors.newSingleThreadExecutor(),
                                            DisplayManager.EVENT_TYPE_DISPLAY_REFRESH_RATE,
                                            mDisplayListener);
        } else {
            // We don't need a separate Handler because our listener logic is
            // cheap, and for valid tests only gets invoked before we're looking
            // for dropped frames.
            manager.registerDisplayListener(mDisplayListener, null);
        }

        initFrameRate();
        mChoreographer = Choreographer.getInstance();
@@ -198,10 +213,15 @@ public class BouncyBallActivity extends AppCompatActivity {
        Display display = getDisplay();
        Display.Mode currentMode = display.getMode();
        mDisplayId = display.getDisplayId();
        float minimumFrameRate = MINIMUM_TEST_FRAME_RATE;
        if (Build.VERSION.SDK_INT >= 36) {
            // This API wasn't introduced until API level 36, so for testing
            // on older devices, we'll just stick with our MINIMUM.
            // TODO(b/442635053): Allow switching between NORMAL and HIGH here,
            //     so we can also test against the HIGH rate.
        float minimumFrameRate =
            minimumFrameRate =
                display.getSuggestedFrameRate(Display.FRAME_RATE_CATEGORY_NORMAL);
        }
        if (minimumFrameRate < MINIMUM_TEST_FRAME_RATE) {
            Log.w(LOG_TAG, "getSuggestedFrameRate (" + minimumFrameRate
                    + "Hz) is below our testing minimum (" + MINIMUM_TEST_FRAME_RATE
+0 −24
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2025 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="android:windowLayoutInDisplayCutoutMode">default</item>
    </style>

</resources>