Add default input dispatching timeout constant

To use the same number consistently in java and native, add
IInputConstants interface where we will store the constants.

Bug: 161009325
Test: atest inputflinger_tests
Change-Id: I10f45547b1161e3768a134b38bf40d77a3a82f09
diff --git a/libs/gui/tests/EndToEndNativeInputTest.cpp b/libs/gui/tests/EndToEndNativeInputTest.cpp
index 5b429d0..a68ec29 100644
--- a/libs/gui/tests/EndToEndNativeInputTest.cpp
+++ b/libs/gui/tests/EndToEndNativeInputTest.cpp
@@ -207,7 +207,8 @@
         InputApplicationInfo aInfo;
         aInfo.token = new BBinder();
         aInfo.name = "Test app info";
-        aInfo.dispatchingTimeoutNanos = DISPATCHING_TIMEOUT.count();
+        aInfo.dispatchingTimeoutMillis =
+                std::chrono::duration_cast<std::chrono::milliseconds>(DISPATCHING_TIMEOUT).count();
 
         mInputInfo.applicationInfo = aInfo;
     }
diff --git a/libs/input/Android.bp b/libs/input/Android.bp
index 180700d..0c3c1f0 100644
--- a/libs/input/Android.bp
+++ b/libs/input/Android.bp
@@ -14,6 +14,13 @@
 
 // libinput is partially built for the host (used by build time keymap validation tool)
 
+filegroup {
+    name: "inputconstants_aidl",
+    srcs: [
+        "android/os/IInputConstants.aidl",
+    ],
+}
+
 cc_library {
     name: "libinput",
     host_supported: true,
@@ -61,6 +68,7 @@
                 "VelocityTracker.cpp",
                 "android/FocusRequest.aidl",
                 "android/InputApplicationInfo.aidl",
+                "android/os/IInputConstants.aidl",
                 "android/os/IInputFlinger.aidl",
                 "android/os/ISetInputWindowsListener.aidl",
             ],
diff --git a/libs/input/android/InputApplicationInfo.aidl b/libs/input/android/InputApplicationInfo.aidl
index d1161e1..9336039 100644
--- a/libs/input/android/InputApplicationInfo.aidl
+++ b/libs/input/android/InputApplicationInfo.aidl
@@ -19,5 +19,5 @@
 parcelable InputApplicationInfo {
     @nullable IBinder token;
     @utf8InCpp String name;
-    long dispatchingTimeoutNanos;
+    long dispatchingTimeoutMillis;
 }
diff --git a/libs/input/android/os/IInputConstants.aidl b/libs/input/android/os/IInputConstants.aidl
new file mode 100644
index 0000000..82c220f
--- /dev/null
+++ b/libs/input/android/os/IInputConstants.aidl
@@ -0,0 +1,24 @@
+/**
+ * Copyright (c) 2020, 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.
+ */
+
+package android.os;
+
+
+/** @hide */
+interface IInputConstants
+{
+    const int DEFAULT_DISPATCHING_TIMEOUT_MILLIS = 5000; // 5 seconds
+}
diff --git a/libs/input/tests/InputWindow_test.cpp b/libs/input/tests/InputWindow_test.cpp
index 052222e..7e3a40d 100644
--- a/libs/input/tests/InputWindow_test.cpp
+++ b/libs/input/tests/InputWindow_test.cpp
@@ -68,7 +68,7 @@
     i.touchableRegionCropHandle = touchableRegionCropHandle;
     i.applicationInfo.name = "ApplicationFooBar";
     i.applicationInfo.token = new BBinder();
-    i.applicationInfo.dispatchingTimeoutNanos = 0x12345678ABCD;
+    i.applicationInfo.dispatchingTimeoutMillis = 0x12345678ABCD;
 
     Parcel p;
     i.writeToParcel(&p);
@@ -107,7 +107,7 @@
     InputApplicationInfo i;
     i.token = new BBinder();
     i.name = "ApplicationFooBar";
-    i.dispatchingTimeoutNanos = 0x12345678ABCD;
+    i.dispatchingTimeoutMillis = 0x12345678ABCD;
 
     Parcel p;
     ASSERT_EQ(i.writeToParcel(&p), OK);