From 5744c93ff7ce51bcd776f90f407fb0359c30e793 Mon Sep 17 00:00:00 2001 From: Doug Turner Date: Tue, 20 Mar 2012 23:36:17 -0700 Subject: [PATCH] Bug 734854 - Merge PROXIMITY_EVENT with SENSOR_EVENT. r=jdm --- mobile/android/base/GeckoEvent.java | 10 ++++------ widget/android/AndroidJavaWrappers.cpp | 6 ------ widget/android/AndroidJavaWrappers.h | 4 +--- widget/android/nsAppShell.cpp | 13 ++++--------- 4 files changed, 9 insertions(+), 24 deletions(-) diff --git a/mobile/android/base/GeckoEvent.java b/mobile/android/base/GeckoEvent.java index 13948c95701..643e8662f16 100644 --- a/mobile/android/base/GeckoEvent.java +++ b/mobile/android/base/GeckoEvent.java @@ -88,7 +88,7 @@ public class GeckoEvent { private static final int VIEWPORT = 20; private static final int VISITED = 21; private static final int NETWORK_CHANGED = 22; - private static final int PROXIMITY_EVENT = 23; + private static final int UNUSED3_EVENT = 23; private static final int ACTIVITY_RESUMING = 24; private static final int SCREENSHOT = 25; private static final int UNUSED2_EVENT = 26; @@ -124,7 +124,6 @@ public class GeckoEvent { public Point[] mPointRadii; public Rect mRect; public double mX, mY, mZ; - public double mDistance; public int mMetaState, mFlags; public int mKeyCode, mUnicodeChar; @@ -340,10 +339,9 @@ public class GeckoEvent { break; case Sensor.TYPE_PROXIMITY: - // bug 734854 - maybe we can get rid of this event. is - // values[1] and values[2] valid? - event = new GeckoEvent(PROXIMITY_EVENT); - event.mDistance = s.values[0]; + event = new GeckoEvent(SENSOR_EVENT); + event.mFlags = GeckoHalDefines.SENSOR_PROXIMITY; + event.mX = s.values[0]; break; } return event; diff --git a/widget/android/AndroidJavaWrappers.cpp b/widget/android/AndroidJavaWrappers.cpp index 43b1800cd3a..94f2d6112d6 100644 --- a/widget/android/AndroidJavaWrappers.cpp +++ b/widget/android/AndroidJavaWrappers.cpp @@ -165,7 +165,6 @@ AndroidGeckoEvent::InitGeckoEventClass(JNIEnv *jEnv) jXField = getField("mX", "D"); jYField = getField("mY", "D"); jZField = getField("mZ", "D"); - jDistanceField = getField("mDistance", "D"); jRectField = getField("mRect", "Landroid/graphics/Rect;"); jCharactersField = getField("mCharacters", "Ljava/lang/String;"); @@ -507,11 +506,6 @@ AndroidGeckoEvent::Init(JNIEnv *jenv, jobject jobj) break; } - case PROXIMITY_EVENT: { - mDistance = jenv->GetDoubleField(jobj, jDistanceField); - break; - } - case ACTIVITY_STOPPING: case ACTIVITY_START: case ACTIVITY_PAUSING: diff --git a/widget/android/AndroidJavaWrappers.h b/widget/android/AndroidJavaWrappers.h index 07dd81beade..3ee2efb637e 100644 --- a/widget/android/AndroidJavaWrappers.h +++ b/widget/android/AndroidJavaWrappers.h @@ -466,7 +466,6 @@ public: double X() { return mX; } double Y() { return mY; } double Z() { return mZ; } - double Distance() { return mDistance; } const nsIntRect& Rect() { return mRect; } nsAString& Characters() { return mCharacters; } nsAString& CharactersExtra() { return mCharactersExtra; } @@ -502,7 +501,6 @@ protected: int mRangeType, mRangeStyles; int mRangeForeColor, mRangeBackColor; double mX, mY, mZ; - double mDistance; int mPointerIndex; nsString mCharacters, mCharactersExtra; nsRefPtr mGeoPosition; @@ -586,7 +584,7 @@ public: VIEWPORT = 20, VISITED = 21, NETWORK_CHANGED = 22, - PROXIMITY_EVENT = 23, + UNUSED3_EVENT = 23, ACTIVITY_RESUMING = 24, SCREENSHOT = 25, UNUSED2_EVENT = 26, diff --git a/widget/android/nsAppShell.cpp b/widget/android/nsAppShell.cpp index fa065b4e530..faf66744578 100644 --- a/widget/android/nsAppShell.cpp +++ b/widget/android/nsAppShell.cpp @@ -352,6 +352,10 @@ nsAppShell::ProcessNextNativeEvent(bool mayWait) values.AppendElement(curEvent->Z()); break; + case hal::SENSOR_PROXIMITY: + values.AppendElement(curEvent->X()); + break; + default: __android_log_print(ANDROID_LOG_ERROR, "Gecko", "### SENSOR_EVENT fired, but type wasn't known %d", @@ -376,15 +380,6 @@ nsAppShell::ProcessNextNativeEvent(bool mayWait) break; } - case AndroidGeckoEvent::PROXIMITY_EVENT: { - InfallibleTArray values; - values.AppendElement(curEvent->Distance()); - - hal::SensorData sdata(hal::SENSOR_PROXIMITY, PR_Now(), values, hal::SENSOR_ACCURACY_UNKNOWN); - hal::NotifySensorChange(sdata); - break; - } - case AndroidGeckoEvent::ACTIVITY_STOPPING: { if (curEvent->Flags() > 0) break;