Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0C60A11EB2 for ; Mon, 5 May 2014 16:13:31 +0000 (UTC) Received: (qmail 34857 invoked by uid 500); 5 May 2014 16:13:15 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 34736 invoked by uid 500); 5 May 2014 16:13:12 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 34078 invoked by uid 99); 5 May 2014 16:12:59 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 May 2014 16:12:59 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 0D465911422; Mon, 5 May 2014 16:12:59 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: mmocny@apache.org To: commits@cordova.apache.org Date: Mon, 05 May 2014 16:13:04 -0000 Message-Id: <8b17df5a5f844a5981ebb9b5550ecddd@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [07/47] git commit: Added amazon-fireos platform + some of the fixes in android code. Added amazon-fireos platform + some of the fixes in android code. Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/commit/9eb9efb6 Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/tree/9eb9efb6 Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/diff/9eb9efb6 Branch: refs/heads/cdvtest Commit: 9eb9efb6eec18e6ea3b3c531f2916b015198ed79 Parents: a2f73ef Author: Archana Naik Authored: Fri Oct 18 14:59:29 2013 -0700 Committer: Archana Naik Committed: Wed Oct 30 13:24:20 2013 -0700 ---------------------------------------------------------------------- plugin.xml | 37 +++++++++++++++++++++++++++ src/android/CordovaLocationListener.java | 3 ++- src/android/GPSListener.java | 4 +-- src/android/GeoBroker.java | 7 ++--- test/cordova-incl.js | 4 ++- 5 files changed, 48 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/9eb9efb6/plugin.xml ---------------------------------------------------------------------- diff --git a/plugin.xml b/plugin.xml index 777a9cc..56f1e97 100644 --- a/plugin.xml +++ b/plugin.xml @@ -50,6 +50,43 @@ xmlns:android="http://schemas.android.com/apk/res/android" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/9eb9efb6/src/android/CordovaLocationListener.java ---------------------------------------------------------------------- diff --git a/src/android/CordovaLocationListener.java b/src/android/CordovaLocationListener.java index f0f70fe..b60bf59 100755 --- a/src/android/CordovaLocationListener.java +++ b/src/android/CordovaLocationListener.java @@ -31,6 +31,7 @@ import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; +import android.os.Looper; import android.util.Log; public class CordovaLocationListener implements LocationListener { @@ -198,7 +199,7 @@ public class CordovaLocationListener implements LocationListener { if (!this.running) { if (this.locationManager.getProvider(LocationManager.NETWORK_PROVIDER) != null) { this.running = true; - this.locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 60000, 10, this); + this.locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 60000, 10, Looper.getMainLooper()); } else { this.fail(CordovaLocationListener.POSITION_UNAVAILABLE, "Network provider is not available."); } http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/9eb9efb6/src/android/GPSListener.java ---------------------------------------------------------------------- diff --git a/src/android/GPSListener.java b/src/android/GPSListener.java index 8c41b2e..1b156d5 100755 --- a/src/android/GPSListener.java +++ b/src/android/GPSListener.java @@ -19,7 +19,7 @@ package org.apache.cordova.geolocation; - +import android.os.Looper; import android.location.LocationManager; /** @@ -42,7 +42,7 @@ public class GPSListener extends CordovaLocationListener { if (!this.running) { if (this.locationManager.getProvider(LocationManager.GPS_PROVIDER) != null) { this.running = true; - this.locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 60000, 0, this); + this.locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 60000, 0, Looper.getMainLooper()); } else { this.fail(CordovaLocationListener.POSITION_UNAVAILABLE, "GPS provider is not available."); } http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/9eb9efb6/src/android/GeoBroker.java ---------------------------------------------------------------------- diff --git a/src/android/GeoBroker.java b/src/android/GeoBroker.java index ea0ad1c..bd88d38 100755 --- a/src/android/GeoBroker.java +++ b/src/android/GeoBroker.java @@ -65,7 +65,8 @@ public class GeoBroker extends CordovaPlugin { if (action.equals("getLocation")) { boolean enableHighAccuracy = args.getBoolean(0); int maximumAge = args.getInt(1); - Location last = this.locationManager.getLastKnownLocation((enableHighAccuracy ? LocationManager.GPS_PROVIDER : LocationManager.NETWORK_PROVIDER)); + String provider = (enableHighAccuracy && locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) ? LocationManager.GPS_PROVIDER : LocationManager.NETWORK_PROVIDER; + Location last = this.locationManager.getLastKnownLocation(provider); // Check if we can use lastKnownLocation to get a quick reading and use less battery if (last != null && (System.currentTimeMillis() - last.getTime()) <= maximumAge) { PluginResult result = new PluginResult(PluginResult.Status.OK, this.returnLocationJSON(last)); @@ -101,7 +102,7 @@ public class GeoBroker extends CordovaPlugin { } private void getCurrentLocation(CallbackContext callbackContext, boolean enableHighAccuracy, int timeout) { - if (enableHighAccuracy) { + if (enableHighAccuracy && locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { this.gpsListener.addCallback(callbackContext, timeout); } else { this.networkListener.addCallback(callbackContext, timeout); @@ -109,7 +110,7 @@ public class GeoBroker extends CordovaPlugin { } private void addWatch(String timerId, CallbackContext callbackContext, boolean enableHighAccuracy) { - if (enableHighAccuracy) { + if (enableHighAccuracy && locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { this.gpsListener.addWatch(timerId, callbackContext); } else { this.networkListener.addWatch(timerId, callbackContext); http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/9eb9efb6/test/cordova-incl.js ---------------------------------------------------------------------- diff --git a/test/cordova-incl.js b/test/cordova-incl.js index dbcd1a6..86c82e3 100644 --- a/test/cordova-incl.js +++ b/test/cordova-incl.js @@ -20,7 +20,9 @@ */ var PLAT; -if (/Android/.exec(navigator.userAgent)) { +if (/Chrome/.exec(navigator.userAgent)) { + PLAT = 'amazon-fireos'; +} else if (/Android/.exec(navigator.userAgent)) { PLAT = 'android'; } else if (/(iPad)|(iPhone)|(iPod)/.exec(navigator.userAgent)) { PLAT = 'ios';