Bug 1149861 - Implement getMaxTouchPoints for Android. r=snorp
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Fri, 24 Apr 2015 18:43:31 +0900
changeset 241133 91f9679c4665857372a039a177246057866d53f2
parent 241132 4d9970eb3c804a9261070d0ee0d6008946fb2166
child 241134 072ad532173db3cd9a7adc7b12b87d84de82364c
push id59036
push usercbook@mozilla.com
push dateMon, 27 Apr 2015 10:37:48 +0000
treeherdermozilla-inbound@ad388474898c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp
bugs1149861
milestone40.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1149861 - Implement getMaxTouchPoints for Android. r=snorp
mobile/android/base/GeckoAppShell.java
widget/android/GeneratedJNIWrappers.cpp
widget/android/GeneratedJNIWrappers.h
widget/android/nsWindow.cpp
widget/android/nsWindow.h
--- a/mobile/android/base/GeckoAppShell.java
+++ b/mobile/android/base/GeckoAppShell.java
@@ -2646,9 +2646,28 @@ public class GeckoAppShell
             systemType = Environment.DIRECTORY_MOVIES;
         } else if ("music".equals(type)) {
             systemType = Environment.DIRECTORY_MUSIC;
         } else {
             return null;
         }
         return Environment.getExternalStoragePublicDirectory(systemType).getAbsolutePath();
     }
+
+    @WrapElementForJNI
+    static int getMaxTouchPoints() {
+        PackageManager pm = getContext().getPackageManager();
+        if (pm.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND)) {
+            // at least, 5+ fingers.
+            return 5;
+        } else if (pm.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT)) {
+            // at least, 2+ fingers.
+            return 2;
+        } else if (pm.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH)) {
+            // 2 fingers
+            return 2;
+        } else if (pm.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN)) {
+            // 1 finger
+            return 1;
+        }
+        return 0;
+    }
 }
--- a/widget/android/GeneratedJNIWrappers.cpp
+++ b/widget/android/GeneratedJNIWrappers.cpp
@@ -297,16 +297,24 @@ mozilla::jni::ObjectArray::LocalRef Geck
 constexpr char GeckoAppShell::GetIconForExtensionWrapper_t::name[];
 constexpr char GeckoAppShell::GetIconForExtensionWrapper_t::signature[];
 
 mozilla::jni::ByteArray::LocalRef GeckoAppShell::GetIconForExtensionWrapper(mozilla::jni::String::Param a0, int32_t a1)
 {
     return mozilla::jni::Method<GetIconForExtensionWrapper_t>::Call(nullptr, nullptr, a0, a1);
 }
 
+constexpr char GeckoAppShell::GetMaxTouchPoints_t::name[];
+constexpr char GeckoAppShell::GetMaxTouchPoints_t::signature[];
+
+int32_t GeckoAppShell::GetMaxTouchPoints()
+{
+    return mozilla::jni::Method<GetMaxTouchPoints_t>::Call(nullptr, nullptr);
+}
+
 constexpr char GeckoAppShell::GetMessageWrapper_t::name[];
 constexpr char GeckoAppShell::GetMessageWrapper_t::signature[];
 
 void GeckoAppShell::GetMessageWrapper(int32_t a0, int32_t a1)
 {
     return mozilla::jni::Method<GetMessageWrapper_t>::Call(nullptr, nullptr, a0, a1);
 }
 
--- a/widget/android/GeneratedJNIWrappers.h
+++ b/widget/android/GeneratedJNIWrappers.h
@@ -578,16 +578,31 @@ public:
         static const bool isStatic = true;
         static const bool isMultithreaded = false;
         static const mozilla::jni::ExceptionMode exceptionMode = mozilla::jni::ExceptionMode::ABORT;
     };
 
     static mozilla::jni::ByteArray::LocalRef GetIconForExtensionWrapper(mozilla::jni::String::Param, int32_t);
 
 public:
+    struct GetMaxTouchPoints_t {
+        typedef GeckoAppShell Owner;
+        typedef int32_t ReturnType;
+        typedef int32_t SetterType;
+        static constexpr char name[] = "getMaxTouchPoints";
+        static constexpr char signature[] =
+                "()I";
+        static const bool isStatic = true;
+        static const bool isMultithreaded = false;
+        static const mozilla::jni::ExceptionMode exceptionMode = mozilla::jni::ExceptionMode::ABORT;
+    };
+
+    static int32_t GetMaxTouchPoints();
+
+public:
     struct GetMessageWrapper_t {
         typedef GeckoAppShell Owner;
         typedef void ReturnType;
         typedef void SetterType;
         static constexpr char name[] = "getMessage";
         static constexpr char signature[] =
                 "(II)V";
         static const bool isStatic = true;
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -2537,8 +2537,14 @@ nsWindow::CreateRootContentController()
 }
 
 uint64_t
 nsWindow::RootLayerTreeId()
 {
     MOZ_ASSERT(sCompositorParent);
     return sCompositorParent->RootLayerTreeId();
 }
+
+uint32_t
+nsWindow::GetMaxTouchPoints() const
+{
+    return GeckoAppShell::GetMaxTouchPoints();
+}
--- a/widget/android/nsWindow.h
+++ b/widget/android/nsWindow.h
@@ -162,16 +162,18 @@ public:
     static void ForceIsFirstPaint();
     static float ComputeRenderIntegrity();
     static mozilla::layers::APZCTreeManager* GetAPZCTreeManager();
     /* RootLayerTreeId() can only be called when GetAPZCTreeManager() returns non-null */
     static uint64_t RootLayerTreeId();
 
     virtual bool WidgetPaintsBackground();
 
+    virtual uint32_t GetMaxTouchPoints() const override;
+
 protected:
     void BringToFront();
     nsWindow *FindTopLevel();
     bool IsTopLevel();
 
     struct IMEChange {
         int32_t mStart, mOldEnd, mNewEnd;