summaryrefslogtreecommitdiff
path: root/tests/GamePerformance/src
diff options
context:
space:
mode:
authorAndrii Kulian <akulian@google.com>2020-01-26 20:59:07 -0800
committerAndrii Kulian <akulian@google.com>2020-01-31 01:15:21 +0000
commite57f2dc246532d54229046d319d7b907b23288b3 (patch)
treedbb2b0b84814f0fffaf7b80f4c94c4820dfbf2bf /tests/GamePerformance/src
parentea325634d3c465817c48f31ad2d5b047661128a6 (diff)
Exempt-From-Owner-Approval: Fix usages of WindowManager.getDefaultDisplay() in f/b
Replace the existing usages of now-deprecated API WindowManager.getDefaultDisplay() with WindowMetrics or Context.getDisplay() in frameworks/base. Bug: 128338354 Test: Build, auto test Change-Id: I02d38a022c5e0e6e9d699f03d35b65d6c8126da9
Diffstat (limited to 'tests/GamePerformance/src')
-rw-r--r--tests/GamePerformance/src/android/gameperformance/BaseTest.java5
-rw-r--r--tests/GamePerformance/src/android/gameperformance/CustomControlView.java17
2 files changed, 9 insertions, 13 deletions
diff --git a/tests/GamePerformance/src/android/gameperformance/BaseTest.java b/tests/GamePerformance/src/android/gameperformance/BaseTest.java
index b0640b444914..e7057565499c 100644
--- a/tests/GamePerformance/src/android/gameperformance/BaseTest.java
+++ b/tests/GamePerformance/src/android/gameperformance/BaseTest.java
@@ -21,7 +21,6 @@ import java.util.concurrent.TimeUnit;
import android.annotation.NonNull;
import android.content.Context;
import android.util.Log;
-import android.view.WindowManager;
/**
* Base class for a test that performs bisection to determine maximum
@@ -55,9 +54,7 @@ public abstract class BaseTest {
public BaseTest(@NonNull GamePerformanceActivity activity) {
mActivity = activity;
- final WindowManager windowManager =
- (WindowManager)getContext().getSystemService(Context.WINDOW_SERVICE);
- mRefreshRate = windowManager.getDefaultDisplay().getRefreshRate();
+ mRefreshRate = activity.getDisplay().getRefreshRate();
}
@NonNull
diff --git a/tests/GamePerformance/src/android/gameperformance/CustomControlView.java b/tests/GamePerformance/src/android/gameperformance/CustomControlView.java
index 219085a83b2c..e63736b9ee61 100644
--- a/tests/GamePerformance/src/android/gameperformance/CustomControlView.java
+++ b/tests/GamePerformance/src/android/gameperformance/CustomControlView.java
@@ -25,18 +25,16 @@ import android.annotation.WorkerThread;
import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
+import android.graphics.Point;
import android.graphics.drawable.AnimationDrawable;
-import android.util.Log;
-import android.view.WindowManager;
import android.widget.AbsoluteLayout;
import android.widget.ImageView;
-import android.widget.RelativeLayout;
/**
* View that holds requested number of UI controls as ImageView with an infinite animation.
*/
public class CustomControlView extends AbsoluteLayout {
- private final static int CONTROL_DIMENTION = 48;
+ private final static int CONTROL_DIMENSION = 48;
private final int mPerRowControlCount;
private List<Long> mFrameTimes = new ArrayList<>();
@@ -44,8 +42,9 @@ public class CustomControlView extends AbsoluteLayout {
public CustomControlView(@NonNull Context context) {
super(context);
- final WindowManager windowManager = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
- mPerRowControlCount = windowManager.getDefaultDisplay().getWidth() / CONTROL_DIMENTION;
+ final Point size = new Point();
+ context.getDisplay().getSize(size);
+ mPerRowControlCount = size.x / CONTROL_DIMENSION;
}
/**
@@ -76,11 +75,11 @@ public class CustomControlView extends AbsoluteLayout {
for (int i = 0; i < controlCount; ++i) {
final ImageView image = (i == 0) ?
new ReferenceImageView(activity) : new ImageView(activity);
- final int x = (i % mPerRowControlCount) * CONTROL_DIMENTION;
- final int y = (i / mPerRowControlCount) * CONTROL_DIMENTION;
+ final int x = (i % mPerRowControlCount) * CONTROL_DIMENSION;
+ final int y = (i / mPerRowControlCount) * CONTROL_DIMENSION;
final AbsoluteLayout.LayoutParams layoutParams =
new AbsoluteLayout.LayoutParams(
- CONTROL_DIMENTION, CONTROL_DIMENTION, x, y);
+ CONTROL_DIMENSION, CONTROL_DIMENSION, x, y);
image.setLayoutParams(layoutParams);
image.setBackgroundResource(R.drawable.animation);
final AnimationDrawable animation =