Updating surface validator code to limit validation to actual app content

Updates common test code to leverage full screen size for size of screenshot and the limits pixel validation to bounds of the app under test

Bug: 158463007
Fixes: 161743768
Test: cts-tradefed run cts --module CtsViewTestCases
Verified on Pixel 4 & development device

Change-Id: I29cef2b43961e1f79043598ec41130ebf1d4d307
diff --git a/tests/tests/view/surfacevalidator/src/android/view/cts/surfacevalidator/CapturedActivity.java b/tests/tests/view/surfacevalidator/src/android/view/cts/surfacevalidator/CapturedActivity.java
index 84cbd00..ab35c55 100644
--- a/tests/tests/view/surfacevalidator/src/android/view/cts/surfacevalidator/CapturedActivity.java
+++ b/tests/tests/view/surfacevalidator/src/android/view/cts/surfacevalidator/CapturedActivity.java
@@ -250,9 +250,16 @@
             Display display = getWindow().getDecorView().getDisplay();
             Point size = new Point();
             DisplayMetrics metrics = new DisplayMetrics();
-            display.getRealSize(size);
             display.getMetrics(metrics);
 
+            final DisplayManager displayManager =
+                    (DisplayManager) CapturedActivity.this.getSystemService(
+                    Context.DISPLAY_SERVICE);
+            final Display defaultDisplay = displayManager.getDisplay(Display.DEFAULT_DISPLAY);
+            final int rotation = defaultDisplay.getRotation();
+            Display.Mode mode = defaultDisplay.getMode();
+            size = new Point(mode.getPhysicalWidth(), mode.getPhysicalHeight());
+
             View testAreaView = findViewById(android.R.id.content);
             Rect boundsToCheck = new Rect(0, 0, testAreaView.getWidth(), testAreaView.getHeight());
             int[] topLeft = new int[2];