Modify the y-coordinate of touch events in testTouchEvent

If the status bar height is larger than 100px, the coordinate of
touch events is located on the status bar.
In that case, testTouchEvent() fails because SecurityException is
thrown.
The reason of SecurityException is "Injecting to another application
requires INJECT_EVENTS permission".

Change-Id: I985343f6e7ee6167a1b6c4ebf0d359ff5c85f1b4
diff --git a/tests/tests/app/src/android/app/cts/DialogTest.java b/tests/tests/app/src/android/app/cts/DialogTest.java
old mode 100644
new mode 100755
index 6df2eee..932ff76
--- a/tests/tests/app/src/android/app/cts/DialogTest.java
+++ b/tests/tests/app/src/android/app/cts/DialogTest.java
@@ -30,6 +30,7 @@
 import android.cts.util.PollingCheck;
 import android.graphics.Canvas;
 import android.graphics.ColorFilter;
+import android.graphics.Rect;
 import android.graphics.drawable.Drawable;
 import android.net.Uri;
 import android.os.Handler;
@@ -377,7 +378,7 @@
 
         long now = SystemClock.uptimeMillis();
         MotionEvent touchMotionEvent = MotionEvent.obtain(now, now, MotionEvent.ACTION_DOWN,
-                1, 100, 0);
+                1, getStatusBarHeight(), 0);
         mInstrumentation.sendPointerSync(touchMotionEvent);
 
         new PollingCheck(TEST_TIMEOUT) {
@@ -400,7 +401,7 @@
             d.setCanceledOnTouchOutside(true);
 
             touchMotionEvent = MotionEvent.obtain(now, now + 1, MotionEvent.ACTION_DOWN,
-                    1, 100, 0);
+                    1, getStatusBarHeight(), 0);
             mInstrumentation.sendPointerSync(touchMotionEvent);
 
             new PollingCheck(TEST_TIMEOUT) {
@@ -417,6 +418,13 @@
         }
     }
 
+    private int getStatusBarHeight() {
+        final Rect rect = new Rect();
+        Window window = mActivity.getWindow();
+        window.getDecorView().getWindowVisibleDisplayFrame(rect);
+        return rect.top;
+    }
+
     public void testTrackballEvent() {
         startDialogActivity(DialogStubActivity.TEST_ONSTART_AND_ONSTOP);
         final TestDialog d = (TestDialog) mActivity.getDialog();