am 49008693: am 8687f089: am e9dfd94b: am a25a531c: am 895bb6bb: am b21190dc: Use real screen width/height to calculate aspect ratio

* commit '490086936671b9da564401c60811944ac5eaaca5':
  Use real screen width/height to calculate aspect ratio
diff --git a/tests/tests/dpi/src/android/dpi/cts/AspectRatioTest.java b/tests/tests/dpi/src/android/dpi/cts/AspectRatioTest.java
index 74a9f22..572c3f4 100644
--- a/tests/tests/dpi/src/android/dpi/cts/AspectRatioTest.java
+++ b/tests/tests/dpi/src/android/dpi/cts/AspectRatioTest.java
@@ -40,46 +40,27 @@
     }
 
     /**
-     * Get all the aspect rations in different orientations. They could be
-     * different due to the system bar being different sizes. Test that
-     * one of the aspect ratios is within the range.
+     * Get the full screen size directly (including system bar) to calculate
+     * aspect ratio. With this, the screen orientation doesn't affect the aspect
+     * ratio value anymore. Test that the aspect ratio is within the range.
      */
     public void testAspectRatio() throws Exception {
-        List<Double> aspectRatios = getAllAspectRatios();
-        for (double aspectRatio : aspectRatios) {
-            if (aspectRatio >= 1.333 && aspectRatio <= 1.86) {
-                return;
-            }
+        double aspectRatio = getRealAspectRatio(getActivity());
+        if (aspectRatio >= 1.333 && aspectRatio <= 1.86) {
+            return;
         }
-        fail("Aspect ratios were not between 1.333 and 1.86: " + aspectRatios);
+        fail("Aspect ratio was not between 1.333 and 1.86: " + aspectRatio);
     }
 
-    private List<Double> getAllAspectRatios() throws Exception {
-        List<Double> aspectRatios = new ArrayList<Double>();
-        for (int i = 0; i < ORIENTATIONS.length; i++) {
-            Activity activity = startOrientationActivity(ORIENTATIONS[i]);
-            aspectRatios.add(getAspectRatio(activity));
-            tearDown();
-        }
-        return aspectRatios;
-    }
-
-    private double getAspectRatio(Context context) {
+    private double getRealAspectRatio(Context context) {
         WindowManager windowManager =
                 (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
         Display display = windowManager.getDefaultDisplay();
         DisplayMetrics metrics = new DisplayMetrics();
-        display.getMetrics(metrics);
+        display.getRealMetrics(metrics);
 
         int max = Math.max(metrics.widthPixels, metrics.heightPixels);
         int min = Math.min(metrics.widthPixels, metrics.heightPixels);
         return (double) max / min;
     }
-
-    private Activity startOrientationActivity(int orientation) {
-        Intent intent = new Intent();
-        intent.putExtra(OrientationActivity.EXTRA_ORIENTATION, orientation);
-        setActivityIntent(intent);
-        return getActivity();
-    }
 }