From 375ef173be02a669e722bda56350bfa3e5b2b6de Mon Sep 17 00:00:00 2001 From: Doug Turner Date: Thu, 8 Mar 2012 22:16:25 -0800 Subject: [PATCH] Bug 733652 - Remove geolocation address handling (v2). Little adoption, costly implementation r=jdm --- dom/base/nsDOMClassInfo.cpp | 7 -- dom/base/nsDOMClassInfoClasses.h | 1 - dom/interfaces/geolocation/Makefile.in | 1 - .../geolocation/nsIDOMGeoPosition.idl | 5 +- .../geolocation/nsIDOMGeoPositionAddress.idl | 51 --------- dom/src/geolocation/nsGeoPosition.cpp | 106 +----------------- dom/src/geolocation/nsGeoPosition.h | 38 ------- .../geolocation/nsGeoPositionIPCSerialiser.h | 101 +---------------- embedding/android/GeckoEvent.java | 3 +- embedding/android/GeckoSurfaceView.java | 42 +------ mobile/android/base/GeckoApp.java | 43 +------ mobile/android/base/GeckoEvent.java | 3 +- widget/android/AndroidJavaWrappers.cpp | 76 +------------ widget/android/AndroidJavaWrappers.h | 22 ---- widget/android/nsAppShell.cpp | 6 +- 15 files changed, 11 insertions(+), 494 deletions(-) delete mode 100644 dom/interfaces/geolocation/nsIDOMGeoPositionAddress.idl diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index d672d92484c7..845f556b5815 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -1422,9 +1422,6 @@ static nsDOMClassInfoData sClassInfoData[] = { NS_DEFINE_CLASSINFO_DATA(GeoPositionCoords, nsDOMGenericSH, DOM_DEFAULT_SCRIPTABLE_FLAGS) - NS_DEFINE_CLASSINFO_DATA(GeoPositionAddress, nsDOMGenericSH, - DOM_DEFAULT_SCRIPTABLE_FLAGS) - NS_DEFINE_CLASSINFO_DATA(GeoPositionError, nsDOMGenericSH, DOM_DEFAULT_SCRIPTABLE_FLAGS) @@ -4020,10 +4017,6 @@ nsDOMClassInfo::Init() DOM_CLASSINFO_MAP_ENTRY(nsIDOMGeoPositionCoords) DOM_CLASSINFO_MAP_END - DOM_CLASSINFO_MAP_BEGIN(GeoPositionAddress, nsIDOMGeoPositionAddress) - DOM_CLASSINFO_MAP_ENTRY(nsIDOMGeoPositionAddress) - DOM_CLASSINFO_MAP_END - DOM_CLASSINFO_MAP_BEGIN(GeoPositionError, nsIDOMGeoPositionError) DOM_CLASSINFO_MAP_ENTRY(nsIDOMGeoPositionError) DOM_CLASSINFO_MAP_END diff --git a/dom/base/nsDOMClassInfoClasses.h b/dom/base/nsDOMClassInfoClasses.h index 5885454b460b..311edab11809 100644 --- a/dom/base/nsDOMClassInfoClasses.h +++ b/dom/base/nsDOMClassInfoClasses.h @@ -422,7 +422,6 @@ DOMCI_CLASS(MessageEvent) DOMCI_CLASS(GeoGeolocation) DOMCI_CLASS(GeoPosition) DOMCI_CLASS(GeoPositionCoords) -DOMCI_CLASS(GeoPositionAddress) DOMCI_CLASS(GeoPositionError) DOMCI_CLASS(MozBatteryManager) diff --git a/dom/interfaces/geolocation/Makefile.in b/dom/interfaces/geolocation/Makefile.in index 67655d343924..e775bdc5af9a 100644 --- a/dom/interfaces/geolocation/Makefile.in +++ b/dom/interfaces/geolocation/Makefile.in @@ -49,7 +49,6 @@ GRE_MODULE = 1 XPIDLSRCS = \ nsIDOMGeoGeolocation.idl \ nsIDOMGeoPosition.idl \ - nsIDOMGeoPositionAddress.idl \ nsIDOMGeoPositionCoords.idl \ nsIDOMGeoPositionCallback.idl \ nsIDOMGeoPositionError.idl \ diff --git a/dom/interfaces/geolocation/nsIDOMGeoPosition.idl b/dom/interfaces/geolocation/nsIDOMGeoPosition.idl index 6895356b8a83..ee6c19ff1c28 100644 --- a/dom/interfaces/geolocation/nsIDOMGeoPosition.idl +++ b/dom/interfaces/geolocation/nsIDOMGeoPosition.idl @@ -37,13 +37,10 @@ #include "domstubs.idl" #include "nsIDOMGeoPositionCoords.idl" -#include "nsIDOMGeoPositionAddress.idl" -[scriptable, uuid(23E5269F-4DD7-41C4-B52A-75918694C2DE)] +[scriptable, uuid(dd9f7e81-0f74-4fb5-b361-37019bf60c3f)] interface nsIDOMGeoPosition : nsISupports { readonly attribute DOMTimeStamp timestamp; readonly attribute nsIDOMGeoPositionCoords coords; - readonly attribute nsIDOMGeoPositionAddress address; - }; diff --git a/dom/interfaces/geolocation/nsIDOMGeoPositionAddress.idl b/dom/interfaces/geolocation/nsIDOMGeoPositionAddress.idl deleted file mode 100644 index 63ba4df455b2..000000000000 --- a/dom/interfaces/geolocation/nsIDOMGeoPositionAddress.idl +++ /dev/null @@ -1,51 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (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.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Geolocation. - * - * The Initial Developer of the Original Code is Mozilla Foundation - * Portions created by the Initial Developer are Copyright (C) 2008 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Doug Turner (Original Author) - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - - -#include "domstubs.idl" - -[scriptable, uuid(93abae10-7024-49eb-8e05-1931343b0ebb)] -interface nsIDOMGeoPositionAddress : nsISupports -{ - readonly attribute DOMString streetNumber; - readonly attribute DOMString street; - readonly attribute DOMString premises; - readonly attribute DOMString city; - readonly attribute DOMString county; - readonly attribute DOMString region; - readonly attribute DOMString country; - readonly attribute DOMString postalCode; -}; diff --git a/dom/src/geolocation/nsGeoPosition.cpp b/dom/src/geolocation/nsGeoPosition.cpp index b750b475435f..8981ef7a8144 100644 --- a/dom/src/geolocation/nsGeoPosition.cpp +++ b/dom/src/geolocation/nsGeoPosition.cpp @@ -40,100 +40,6 @@ #include "nsGeoPosition.h" #include "nsDOMClassInfoID.h" -//////////////////////////////////////////////////// -// nsGeoPositionAddress -//////////////////////////////////////////////////// - -nsGeoPositionAddress::nsGeoPositionAddress(const nsAString &aStreetNumber, - const nsAString &aStreet, - const nsAString &aPremises, - const nsAString &aCity, - const nsAString &aCounty, - const nsAString &aRegion, - const nsAString &aCountry, - const nsAString &aPostalCode) - : mStreetNumber(aStreetNumber) - , mStreet(aStreet) - , mPremises(aPremises) - , mCity(aCity) - , mCounty(aCounty) - , mRegion(aRegion) - , mCountry(aCountry) - , mPostalCode(aPostalCode) -{ -} - -nsGeoPositionAddress::~nsGeoPositionAddress() -{ -} - -DOMCI_DATA(GeoPositionAddress, nsGeoPositionAddress) - -NS_INTERFACE_MAP_BEGIN(nsGeoPositionAddress) -NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMGeoPositionAddress) -NS_INTERFACE_MAP_ENTRY(nsIDOMGeoPositionAddress) -NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(GeoPositionAddress) -NS_INTERFACE_MAP_END - -NS_IMPL_THREADSAFE_ADDREF(nsGeoPositionAddress) -NS_IMPL_THREADSAFE_RELEASE(nsGeoPositionAddress) - -NS_IMETHODIMP -nsGeoPositionAddress::GetStreetNumber(nsAString & aStreetNumber) -{ - aStreetNumber = mStreetNumber; - return NS_OK; -} - -NS_IMETHODIMP -nsGeoPositionAddress::GetStreet(nsAString & aStreet) -{ - aStreet = mStreet; - return NS_OK; -} - -NS_IMETHODIMP -nsGeoPositionAddress::GetPremises(nsAString & aPremises) -{ - aPremises = mPremises; - return NS_OK; -} - -NS_IMETHODIMP -nsGeoPositionAddress::GetCity(nsAString & aCity) -{ - aCity = mCity; - return NS_OK; -} - -NS_IMETHODIMP -nsGeoPositionAddress::GetCounty(nsAString & aCounty) -{ - aCounty = mCounty; - return NS_OK; -} - -NS_IMETHODIMP -nsGeoPositionAddress::GetRegion(nsAString & aRegion) -{ - aRegion = mRegion; - return NS_OK; -} - -NS_IMETHODIMP -nsGeoPositionAddress::GetCountry(nsAString & aCountry) -{ - aCountry = mCountry; - return NS_OK; -} - -NS_IMETHODIMP -nsGeoPositionAddress::GetPostalCode(nsAString & aPostalCode) -{ - aPostalCode = mPostalCode; - return NS_OK; -} - //////////////////////////////////////////////////// // nsGeoPositionCoords //////////////////////////////////////////////////// @@ -239,11 +145,9 @@ nsGeoPosition::nsGeoPosition(nsIDOMGeoPositionCoords *aCoords, } nsGeoPosition::nsGeoPosition(nsIDOMGeoPositionCoords *aCoords, - nsIDOMGeoPositionAddress *aAddress, DOMTimeStamp aTimestamp) : mTimestamp(aTimestamp), - mCoords(aCoords), - mAddress(aAddress) + mCoords(aCoords) { } @@ -275,11 +179,3 @@ nsGeoPosition::GetCoords(nsIDOMGeoPositionCoords * *aCoords) NS_IF_ADDREF(*aCoords = mCoords); return NS_OK; } - -NS_IMETHODIMP -nsGeoPosition::GetAddress(nsIDOMGeoPositionAddress** aAddress) -{ - NS_IF_ADDREF(*aAddress = mAddress); - return NS_OK; -} - diff --git a/dom/src/geolocation/nsGeoPosition.h b/dom/src/geolocation/nsGeoPosition.h index c763b5becd85..a7a29770251f 100644 --- a/dom/src/geolocation/nsGeoPosition.h +++ b/dom/src/geolocation/nsGeoPosition.h @@ -43,42 +43,10 @@ #include "nsAutoPtr.h" #include "nsIClassInfo.h" #include "nsDOMClassInfoID.h" -#include "nsIDOMGeoPositionAddress.h" #include "nsIDOMGeoPositionCoords.h" #include "nsIDOMGeoPosition.h" #include "nsString.h" -//////////////////////////////////////////////////// -// nsGeoPositionAddress -//////////////////////////////////////////////////// - -class nsGeoPositionAddress : public nsIDOMGeoPositionAddress -{ -public: - NS_DECL_ISUPPORTS - NS_DECL_NSIDOMGEOPOSITIONADDRESS - - nsGeoPositionAddress( const nsAString &aStreetNumber, - const nsAString &aStreet, - const nsAString &aPremises, - const nsAString &aCity, - const nsAString &aCounty, - const nsAString &aRegion, - const nsAString &aCountry, - const nsAString &aPostalCode); - - ~nsGeoPositionAddress(); - private: - const nsString mStreetNumber; - const nsString mStreet; - const nsString mPremises; - const nsString mCity; - const nsString mCounty; - const nsString mRegion; - const nsString mCountry; - const nsString mPostalCode; -}; - //////////////////////////////////////////////////// // nsGeoPositionCoords //////////////////////////////////////////////////// @@ -122,18 +90,12 @@ public: long long aTimestamp); nsGeoPosition(nsIDOMGeoPositionCoords *aCoords, - nsIDOMGeoPositionAddress *aAddress, DOMTimeStamp aTimestamp); - void SetAddress(nsIDOMGeoPositionAddress *address) { - mAddress = address; - } - private: ~nsGeoPosition(); long long mTimestamp; nsRefPtr mCoords; - nsRefPtr mAddress; }; #endif /* nsGeoPosition_h */ diff --git a/dom/src/geolocation/nsGeoPositionIPCSerialiser.h b/dom/src/geolocation/nsGeoPositionIPCSerialiser.h index f4597f8a52fd..89d0c9215148 100644 --- a/dom/src/geolocation/nsGeoPositionIPCSerialiser.h +++ b/dom/src/geolocation/nsGeoPositionIPCSerialiser.h @@ -41,98 +41,11 @@ #include "nsGeoPosition.h" #include "nsIDOMGeoPosition.h" -typedef nsIDOMGeoPositionAddress *GeoPositionAddress; typedef nsGeoPositionCoords *GeoPositionCoords; typedef nsIDOMGeoPosition *GeoPosition; namespace IPC { -template <> -struct ParamTraits -{ - typedef GeoPositionAddress paramType; - - // Function to serialize a geo position address - static void Write(Message *aMsg, const paramType& aParam) - { - bool isNull = !aParam; - WriteParam(aMsg, isNull); - // If it is null, then we are done - if (isNull) return; - - nsString addressLine; - - aParam->GetStreetNumber(addressLine); - WriteParam(aMsg, addressLine); - - aParam->GetStreet(addressLine); - WriteParam(aMsg, addressLine); - - aParam->GetPremises(addressLine); - WriteParam(aMsg, addressLine); - - aParam->GetCity(addressLine); - WriteParam(aMsg, addressLine); - - aParam->GetCounty(addressLine); - WriteParam(aMsg, addressLine); - - aParam->GetRegion(addressLine); - WriteParam(aMsg, addressLine); - - aParam->GetCountry(addressLine); - WriteParam(aMsg, addressLine); - - aParam->GetPostalCode(addressLine); - WriteParam(aMsg, addressLine); - } - - // Function to de-serialize a geoposition - static bool Read(const Message* aMsg, void **aIter, paramType* aResult) - { - // Check if it is the null pointer we have transfered - bool isNull; - if (!ReadParam(aMsg, aIter, &isNull)) return false; - - if (isNull) { - *aResult = 0; - return true; - } - - // We need somewhere to store the address before we create the object - nsString streetNumber; - nsString street; - nsString premises; - nsString city; - nsString county; - nsString region; - nsString country; - nsString postalCode; - - // It's not important to us where it fails, but rather if it fails - if (!(ReadParam(aMsg, aIter, &streetNumber) && - ReadParam(aMsg, aIter, &street ) && - ReadParam(aMsg, aIter, &premises ) && - ReadParam(aMsg, aIter, &city ) && - ReadParam(aMsg, aIter, &county ) && - ReadParam(aMsg, aIter, ®ion ) && - ReadParam(aMsg, aIter, &country ) && - ReadParam(aMsg, aIter, &postalCode ))) return false; - - // We now have all the data - *aResult = new nsGeoPositionAddress(streetNumber, /* aStreetNumber */ - street, /* aStreet */ - premises, /* aPremises */ - city, /* aCity */ - county, /* aCounty */ - region, /* aRegion */ - country, /* aCountry */ - postalCode /* aPostalCode */ - ); - return true; - } -} ; - template <> struct ParamTraits { @@ -235,11 +148,6 @@ struct ParamTraits aParam->GetCoords(getter_AddRefs(coords)); GeoPositionCoords simpleCoords = static_cast(coords.get()); WriteParam(aMsg, simpleCoords); - - nsCOMPtr address; - aParam->GetAddress(getter_AddRefs(address)); - GeoPositionAddress simpleAddress = address.get(); - WriteParam(aMsg, simpleAddress); } // Function to de-serialize a geoposition @@ -256,20 +164,17 @@ struct ParamTraits DOMTimeStamp timeStamp; GeoPositionCoords coords = nsnull; - GeoPositionAddress address; // It's not important to us where it fails, but rather if it fails if (!( ReadParam(aMsg, aIter, &timeStamp) - && ReadParam(aMsg, aIter, &coords ) - && ReadParam(aMsg, aIter, &address ))) { + && ReadParam(aMsg, aIter, &coords ))) { // note it is fine to do "delete nsnull" in case coords hasn't - // been allocated and we will never have a case where address - // gets allocated and we end here + // been allocated delete coords; return false; } - *aResult = new nsGeoPosition(coords, address, timeStamp); + *aResult = new nsGeoPosition(coords, timeStamp); return true; }; diff --git a/embedding/android/GeckoEvent.java b/embedding/android/GeckoEvent.java index c3f4e892b517..3d178baf87fa 100644 --- a/embedding/android/GeckoEvent.java +++ b/embedding/android/GeckoEvent.java @@ -252,10 +252,9 @@ public class GeckoEvent { } } - public GeckoEvent(Location l, Address a) { + public GeckoEvent(Location l) { mType = LOCATION_EVENT; mLocation = l; - mAddress = a; } public GeckoEvent(int imeAction, int offset, int count) { diff --git a/embedding/android/GeckoSurfaceView.java b/embedding/android/GeckoSurfaceView.java index 385c8d1e29ed..77649a447cf7 100644 --- a/embedding/android/GeckoSurfaceView.java +++ b/embedding/android/GeckoSurfaceView.java @@ -580,47 +580,10 @@ class GeckoSurfaceView GeckoAppShell.sendEventToGecko(new GeckoEvent(event)); } - private class GeocoderTask extends AsyncTask { - protected Void doInBackground(Location... location) { - try { - List
addresses = mGeocoder.getFromLocation(location[0].getLatitude(), - location[0].getLongitude(), 1); - // grab the first address. in the future, - // may want to expose multiple, or filter - // for best. - mLastGeoAddress = addresses.get(0); - GeckoAppShell.sendEventToGecko(new GeckoEvent(location[0], mLastGeoAddress)); - } catch (Exception e) { - Log.w(LOG_FILE_NAME, "GeocoderTask "+e); - } - return null; - } - } - // geolocation public void onLocationChanged(Location location) { - if (mGeocoder == null) - mGeocoder = new Geocoder(getContext(), Locale.getDefault()); - - if (mLastGeoAddress == null) { - new GeocoderTask().execute(location); - } - else { - float[] results = new float[1]; - Location.distanceBetween(location.getLatitude(), - location.getLongitude(), - mLastGeoAddress.getLatitude(), - mLastGeoAddress.getLongitude(), - results); - // pfm value. don't want to slam the - // geocoder with very similar values, so - // only call after about 100m - if (results[0] > 100) - new GeocoderTask().execute(location); - } - - GeckoAppShell.sendEventToGecko(new GeckoEvent(location, mLastGeoAddress)); + GeckoAppShell.sendEventToGecko(new GeckoEvent(location)); } public void onProviderDisabled(String provider) @@ -825,9 +788,6 @@ class GeckoSurfaceView ByteBuffer mSoftwareBuffer; Bitmap mSoftwareBufferCopy; - Geocoder mGeocoder; - Address mLastGeoAddress; - final SynchronousQueue mSyncDraws = new SynchronousQueue(); } diff --git a/mobile/android/base/GeckoApp.java b/mobile/android/base/GeckoApp.java index 59fd71b84add..454418156a39 100644 --- a/mobile/android/base/GeckoApp.java +++ b/mobile/android/base/GeckoApp.java @@ -139,8 +139,6 @@ abstract public class GeckoApp public static FormAssistPopup mFormAssistPopup; public Favicons mFavicons; - private Geocoder mGeocoder; - private Address mLastGeoAddress; private static LayerController mLayerController; private static PlaceholderLayerClient mPlaceholderLayerClient; private static GeckoSoftwareLayerClient mSoftwareLayerClient; @@ -2618,51 +2616,12 @@ abstract public class GeckoApp GeckoAppShell.sendEventToGecko(GeckoEvent.createSensorEvent(event)); } - private class GeocoderRunnable implements Runnable { - Location mLocation; - GeocoderRunnable (Location location) { - mLocation = location; - } - public void run() { - try { - List
addresses = mGeocoder.getFromLocation(mLocation.getLatitude(), - mLocation.getLongitude(), 1); - // grab the first address. in the future, - // may want to expose multiple, or filter - // for best. - mLastGeoAddress = addresses.get(0); - GeckoAppShell.sendEventToGecko(GeckoEvent.createLocationEvent(mLocation, mLastGeoAddress)); - } catch (Exception e) { - Log.w(LOGTAG, "GeocoderTask "+e); - } - } - } - // geolocation public void onLocationChanged(Location location) { Log.w(LOGTAG, "onLocationChanged "+location); - if (mGeocoder == null) - mGeocoder = new Geocoder(mLayerController.getView().getContext(), Locale.getDefault()); - if (mLastGeoAddress == null) { - GeckoAppShell.getHandler().post(new GeocoderRunnable(location)); - } - else { - float[] results = new float[1]; - Location.distanceBetween(location.getLatitude(), - location.getLongitude(), - mLastGeoAddress.getLatitude(), - mLastGeoAddress.getLongitude(), - results); - // pfm value. don't want to slam the - // geocoder with very similar values, so - // only call after about 100m - if (results[0] > 100) - GeckoAppShell.getHandler().post(new GeocoderRunnable(location)); - } - - GeckoAppShell.sendEventToGecko(GeckoEvent.createLocationEvent(location, mLastGeoAddress)); + GeckoAppShell.sendEventToGecko(GeckoEvent.createLocationEvent(location)); } public void onProviderDisabled(String provider) diff --git a/mobile/android/base/GeckoEvent.java b/mobile/android/base/GeckoEvent.java index bfea49b4edce..7310b09a06f2 100644 --- a/mobile/android/base/GeckoEvent.java +++ b/mobile/android/base/GeckoEvent.java @@ -305,10 +305,9 @@ public class GeckoEvent { return event; } - public static GeckoEvent createLocationEvent(Location l, Address a) { + public static GeckoEvent createLocationEvent(Location l) { GeckoEvent event = new GeckoEvent(LOCATION_EVENT); event.mLocation = l; - event.mAddress = a; return event; } diff --git a/widget/android/AndroidJavaWrappers.cpp b/widget/android/AndroidJavaWrappers.cpp index 387a9011ee63..f5b414ba61db 100644 --- a/widget/android/AndroidJavaWrappers.cpp +++ b/widget/android/AndroidJavaWrappers.cpp @@ -1,4 +1,4 @@ -/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- +3/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- * ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -73,7 +73,6 @@ jfieldID AndroidGeckoEvent::jRangeStylesField = 0; jfieldID AndroidGeckoEvent::jRangeForeColorField = 0; jfieldID AndroidGeckoEvent::jRangeBackColorField = 0; jfieldID AndroidGeckoEvent::jLocationField = 0; -jfieldID AndroidGeckoEvent::jAddressField = 0; jfieldID AndroidGeckoEvent::jBandwidthField = 0; jfieldID AndroidGeckoEvent::jCanBeMeteredField = 0; @@ -96,19 +95,6 @@ jmethodID AndroidLocation::jGetBearingMethod = 0; jmethodID AndroidLocation::jGetSpeedMethod = 0; jmethodID AndroidLocation::jGetTimeMethod = 0; -jclass AndroidAddress::jAddressClass = 0; -jmethodID AndroidAddress::jGetAddressLineMethod; -jmethodID AndroidAddress::jGetAdminAreaMethod; -jmethodID AndroidAddress::jGetCountryNameMethod; -jmethodID AndroidAddress::jGetFeatureNameMethod; -jmethodID AndroidAddress::jGetLocalityMethod; -jmethodID AndroidAddress::jGetPostalCodeMethod; -jmethodID AndroidAddress::jGetPremisesMethod; -jmethodID AndroidAddress::jGetSubAdminAreaMethod; -jmethodID AndroidAddress::jGetSubLocalityMethod; -jmethodID AndroidAddress::jGetSubThoroughfareMethod; -jmethodID AndroidAddress::jGetThoroughfareMethod; - jclass AndroidGeckoSoftwareLayerClient::jGeckoSoftwareLayerClientClass = 0; jmethodID AndroidGeckoSoftwareLayerClient::jLockBufferMethod = 0; jmethodID AndroidGeckoSoftwareLayerClient::jUnlockBufferMethod = 0; @@ -142,7 +128,6 @@ mozilla::InitAndroidJavaWrappers(JNIEnv *jEnv) AndroidGeckoEvent::InitGeckoEventClass(jEnv); AndroidPoint::InitPointClass(jEnv); AndroidLocation::InitLocationClass(jEnv); - AndroidAddress::InitAddressClass(jEnv); AndroidRect::InitRectClass(jEnv); AndroidGeckoSoftwareLayerClient::InitGeckoSoftwareLayerClientClass(jEnv); AndroidGeckoSurfaceView::InitGeckoSurfaceViewClass(jEnv); @@ -186,7 +171,6 @@ AndroidGeckoEvent::InitGeckoEventClass(JNIEnv *jEnv) jRangeForeColorField = getField("mRangeForeColor", "I"); jRangeBackColorField = getField("mRangeBackColor", "I"); jLocationField = getField("mLocation", "Landroid/location/Location;"); - jAddressField = getField("mAddress", "Landroid/location/Address;"); jBandwidthField = getField("mBandwidth", "D"); jCanBeMeteredField = getField("mCanBeMetered", "Z"); } @@ -225,60 +209,6 @@ AndroidLocation::InitLocationClass(JNIEnv *jEnv) jGetTimeMethod = getMethod("getTime", "()J"); } -void -AndroidAddress::InitAddressClass(JNIEnv *jEnv) -{ - initInit(); - - jAddressClass = getClassGlobalRef("android/location/Address"); - - jGetAddressLineMethod = getMethod("getAddressLine", "(I)Ljava/lang/String;"); - jGetAdminAreaMethod = getMethod("getAdminArea", "()Ljava/lang/String;"); - jGetCountryNameMethod = getMethod("getCountryName", "()Ljava/lang/String;"); - jGetFeatureNameMethod = getMethod("getFeatureName", "()Ljava/lang/String;"); - jGetLocalityMethod = getMethod("getLocality", "()Ljava/lang/String;"); - jGetPostalCodeMethod = getMethod("getPostalCode", "()Ljava/lang/String;"); - jGetPremisesMethod = getMethod("getPremises", "()Ljava/lang/String;"); - jGetSubAdminAreaMethod = getMethod("getSubAdminArea", "()Ljava/lang/String;"); - jGetSubLocalityMethod = getMethod("getSubLocality", "()Ljava/lang/String;"); - jGetSubThoroughfareMethod = getMethod("getSubThoroughfare", "()Ljava/lang/String;"); - jGetThoroughfareMethod = getMethod("getThoroughfare", "()Ljava/lang/String;"); -} - -nsGeoPositionAddress* -AndroidAddress::CreateGeoPositionAddress(JNIEnv *jenv, jobject jobj) -{ - nsJNIString streetNumber(static_cast(jenv->CallObjectMethod(jobj, jGetSubThoroughfareMethod)), jenv); - nsJNIString street(static_cast(jenv->CallObjectMethod(jobj, jGetThoroughfareMethod)), jenv); - nsJNIString city(static_cast(jenv->CallObjectMethod(jobj, jGetLocalityMethod)), jenv); - nsJNIString county(static_cast(jenv->CallObjectMethod(jobj, jGetSubAdminAreaMethod)), jenv); - nsJNIString country(static_cast(jenv->CallObjectMethod(jobj, jGetCountryNameMethod)), jenv); - nsJNIString premises(static_cast(jenv->CallObjectMethod(jobj, jGetPremisesMethod)), jenv); - nsJNIString postalCode(static_cast(jenv->CallObjectMethod(jobj, jGetPostalCodeMethod)), jenv); - nsJNIString region(static_cast(jenv->CallObjectMethod(jobj, jGetAdminAreaMethod, 0)), jenv); - -#ifdef DEBUG - printf_stderr("!!!!!!!!!!!!!! AndroidAddress::CreateGeoPositionAddress:\n\t%s\n\t%s\n\t%s\n\t%s\n\t%s\n\t%s\n\t%s\n\t%s\n\t%s\n", - NS_LossyConvertUTF16toASCII(streetNumber).get(), - NS_LossyConvertUTF16toASCII(street).get(), - NS_LossyConvertUTF16toASCII(premises).get(), - NS_LossyConvertUTF16toASCII(city).get(), - NS_LossyConvertUTF16toASCII(county).get(), - NS_LossyConvertUTF16toASCII(region).get(), - NS_LossyConvertUTF16toASCII(country).get(), - NS_LossyConvertUTF16toASCII(postalCode).get()); -#endif - - return new nsGeoPositionAddress(streetNumber, - street, - premises, - city, - county, - region, - country, - postalCode); -} - nsGeoPosition* AndroidLocation::CreateGeoPosition(JNIEnv *jenv, jobject jobj) { @@ -511,11 +441,7 @@ AndroidGeckoEvent::Init(JNIEnv *jenv, jobject jobj) case LOCATION_EVENT: { jobject location = jenv->GetObjectField(jobj, jLocationField); - jobject address = jenv->GetObjectField(jobj, jAddressField); - mGeoPosition = AndroidLocation::CreateGeoPosition(jenv, location); - if (address) - mGeoAddress = AndroidAddress::CreateGeoPositionAddress(jenv, address); break; } diff --git a/widget/android/AndroidJavaWrappers.h b/widget/android/AndroidJavaWrappers.h index 3ae573c1a6f8..2bb9cda55bdf 100644 --- a/widget/android/AndroidJavaWrappers.h +++ b/widget/android/AndroidJavaWrappers.h @@ -384,25 +384,6 @@ public: static jmethodID jGetTimeMethod; }; -class AndroidAddress : public WrappedJavaObject -{ -public: - static void InitAddressClass(JNIEnv *jEnv); - static nsGeoPositionAddress* CreateGeoPositionAddress(JNIEnv *jenv, jobject jobj); - static jclass jAddressClass; - static jmethodID jGetAddressLineMethod; - static jmethodID jGetAdminAreaMethod; - static jmethodID jGetCountryNameMethod; - static jmethodID jGetFeatureNameMethod; - static jmethodID jGetLocalityMethod; - static jmethodID jGetPostalCodeMethod; - static jmethodID jGetPremisesMethod; - static jmethodID jGetSubAdminAreaMethod; - static jmethodID jGetSubLocalityMethod; - static jmethodID jGetSubThoroughfareMethod; - static jmethodID jGetThoroughfareMethod; -}; - class AndroidGeckoEvent : public WrappedJavaObject { public: @@ -461,7 +442,6 @@ public: int RangeForeColor() { return mRangeForeColor; } int RangeBackColor() { return mRangeBackColor; } nsGeoPosition* GeoPosition() { return mGeoPosition; } - nsGeoPositionAddress* GeoAddress() { return mGeoAddress; } double Bandwidth() { return mBandwidth; } bool CanBeMetered() { return mCanBeMetered; } @@ -486,7 +466,6 @@ protected: int mPointerIndex; nsString mCharacters, mCharactersExtra; nsRefPtr mGeoPosition; - nsRefPtr mGeoAddress; double mBandwidth; bool mCanBeMetered; @@ -539,7 +518,6 @@ protected: static jfieldID jRangeForeColorField; static jfieldID jRangeBackColorField; static jfieldID jLocationField; - static jfieldID jAddressField; static jfieldID jBandwidthField; static jfieldID jCanBeMeteredField; diff --git a/widget/android/nsAppShell.cpp b/widget/android/nsAppShell.cpp index 83b24aa81e29..4a44ff40311a 100644 --- a/widget/android/nsAppShell.cpp +++ b/widget/android/nsAppShell.cpp @@ -351,12 +351,8 @@ nsAppShell::ProcessNextNativeEvent(bool mayWait) break; nsGeoPosition* p = curEvent->GeoPosition(); - nsGeoPositionAddress* a = curEvent->GeoAddress(); - - if (p) { - p->SetAddress(a); + if (p) gLocationCallback->Update(curEvent->GeoPosition()); - } else NS_WARNING("Received location event without geoposition!"); break;