Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cordova-plugin-geolocation

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cordova-plugin-geolocation - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

src/android/PermissionHelper.java

2

package.json
{
"name": "cordova-plugin-geolocation",
"version": "2.0.0",
"version": "2.1.0",
"description": "Cordova Geolocation Plugin",

@@ -5,0 +5,0 @@ "cordova": {

@@ -143,2 +143,7 @@ <!--

### Android Quirks
If Geolocation service is turned off the `onError` callback is invoked after `timeout` interval (if specified).
If `timeout` parameter is not specified then no callback is called.
## navigator.geolocation.watchPosition

@@ -210,3 +215,4 @@

Android 2.x emulators do not return a geolocation result unless the `enableHighAccuracy` option is set to `true`.
If Geolocation service is turned off the `onError` callback is invoked after `timeout` interval (if specified).
If `timeout` parameter is not specified then no callback is called.

@@ -213,0 +219,0 @@ ## navigator.geolocation.clearWatch

@@ -23,2 +23,14 @@ <!--

### 2.1.0 (Jan 15, 2016)
* CB-10319 **Android** Adding reflective helper methods for permission requests
* CB-8523 Fixed accuracy when `enableHighAccuracy: false` on **iOS**.
* CB-10286 Don't skip automatic tests on **Android** devices
* CB-10277 Error callback should be called w/ `PositionError` when location access is denied
* CB-10285 Added tests for `PositionError` constants
* CB-10278 geolocation `watchPosition` doesn't return `watchID` string
* CB-8443 **Android** nothing happens if `GPS` is turned off
* CB-10204 Fix `getCurrentPosition` options on **Android**
* CB-7146 Remove built-in `WebView navigator.geolocation` manual tests
* CB-2845 `PositionError` constants not attached to prototype as specified in W3C document
### 2.0.0 (Nov 18, 2015)

@@ -25,0 +37,0 @@ * [CB-10035](https://issues.apache.org/jira/browse/CB-10035) Updated `RELEASENOTES` to be newest to oldest

@@ -58,4 +58,12 @@ /*

// On Windows, some tests prompt user for permission to use geolocation and interrupt autotests run
var isWindowsStore = (cordova.platformId == "windows8") || (cordova.platformId == "windows" && !WinJS.Utilities.isPhone);
var isAndroid = cordova.platformId == "android";
var majorDeviceVersion = null;
var versionRegex = /(\d)\..+/.exec(device.version);
if (versionRegex !== null) {
majorDeviceVersion = Number(versionRegex[1]);
}
// Starting from Android 6.0 there are confirmation dialog which prevents us from running auto tests in silent mode (user interaction needed)
// Also, Android emulator doesn't provide geo fix without manual interactions or mocks
var skipAndroid = cordova.platformId == "android" && (device.isVirtual || majorDeviceVersion >= 6);
var isIOSSim = false; // if iOS simulator does not have a location set, it will fail.

@@ -92,6 +100,3 @@

it("geolocation.spec.5 should be called if we set timeout to 0 and maximumAge to a very small number", function (done) {
// On Windows, this test prompts user for permission to use geolocation and interrupts autotests running.
// On Android geolocation Api is not available on emulator so we pended tests until we found the way to detect
// whether we run on emulator or real device from JavaScript. You can still run the tests on Android manually.
if (isWindowsStore || isAndroid) {
if (isWindowsStore || skipAndroid) {
pending();

@@ -109,2 +114,22 @@ }

it("geolocation.spec.9 on failure should return PositionError object with error code constants", function (done) {
if (isWindowsStore || skipAndroid) {
pending();
}
navigator.geolocation.getCurrentPosition(
fail.bind(this, done),
function(gpsError) {
// W3C specs: http://dev.w3.org/geo/api/spec-source.html#position_error_interface
expect(gpsError.PERMISSION_DENIED).toBe(1);
expect(gpsError.POSITION_UNAVAILABLE).toBe(2);
expect(gpsError.TIMEOUT).toBe(3);
done();
},
{
maximumAge: 0,
timeout: 0
});
});
});

@@ -115,6 +140,3 @@

it("geolocation.spec.6 should be called with a Position object", function (done) {
// On Windows, this test prompts user for permission to use geolocation and interrupts autotests running.
// On Android geolocation Api is not available on emulator so we pended tests until we found the way to detect
// whether we run on emulator or real device from JavaScript. You can still run the tests on Android manually.
if (isWindowsStore || isAndroid) {
if (isWindowsStore || skipAndroid) {
pending();

@@ -164,6 +186,3 @@ }

it("geolocation.spec.7 should be called if we set timeout to 0 and maximumAge to a very small number", function (done) {
// On Windows, this test prompts user for permission to use geolocation and interrupts autotests running.
// On Android geolocation Api is not available on emulator so we pended tests until we found the way to detect
// whether we run on emulator or real device from JavaScript. You can still run the tests on Android manually.
if (isWindowsStore || isAndroid) {
if (isWindowsStore || skipAndroid) {
pending();

@@ -182,2 +201,27 @@ }

it("geolocation.spec.10 on failure should return PositionError object with error code constants", function (done) {
if (isWindowsStore || skipAndroid) {
pending();
}
var context = this;
errorWatch = navigator.geolocation.watchPosition(
fail.bind(this, done, context, 'Unexpected win'),
function(gpsError) {
if (context.done) return;
context.done = true;
// W3C specs: http://dev.w3.org/geo/api/spec-source.html#position_error_interface
expect(gpsError.PERMISSION_DENIED).toBe(1);
expect(gpsError.POSITION_UNAVAILABLE).toBe(2);
expect(gpsError.TIMEOUT).toBe(3);
done();
},
{
maximumAge: 0,
timeout: 0
});
});
});

@@ -193,6 +237,3 @@

it("geolocation.spec.8 should be called with a Position object", function (done) {
// On Windows, this test prompts user for permission to use geolocation and interrupts autotests running.
// On Android geolocation Api is not available on emulator so we pended tests until we found the way to detect
// whether we run on emulator or real device from JavaScript. You can still run the tests on Android manually.
if (isWindowsStore || isAndroid || isIOSSim) {
if (isWindowsStore || skipAndroid || isIOSSim) {
pending();

@@ -219,2 +260,3 @@ }

});
expect(successWatch).toBeDefined();
});

@@ -233,9 +275,2 @@

exports.defineManualTests = function (contentEl, createActionButton) {
var newGeolocation = navigator.geolocation;
var origGeolocation = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation');
if (!origGeolocation) {
origGeolocation = newGeolocation;
newGeolocation = null;
}
var watchLocationId = null;

@@ -246,7 +281,6 @@

*/
var watchLocation = function (usePlugin) {
console.log("watchLocation()");
var geo = usePlugin ? newGeolocation : origGeolocation;
var watchLocation = function () {
var geo = navigator.geolocation;
if (!geo) {
alert('geolocation object is missing. usePlugin = ' + usePlugin);
alert('navigator.geolocation object is missing.');
return;

@@ -274,7 +308,6 @@ }

*/
var stopLocation = function (usePlugin) {
console.log("stopLocation()");
var geo = usePlugin ? newGeolocation : origGeolocation;
var stopLocation = function () {
var geo = navigator.geolocation;
if (!geo) {
alert('geolocation object is missing. usePlugin = ' + usePlugin);
alert('navigator.geolocation object is missing.');
return;

@@ -292,7 +325,6 @@ }

*/
var getLocation = function (usePlugin, opts) {
console.log("getLocation()");
var geo = usePlugin ? newGeolocation : origGeolocation;
var getLocation = function (opts) {
var geo = navigator.geolocation;
if (!geo) {
alert('geolocation object is missing. usePlugin = ' + usePlugin);
alert('navigator.geolocation object is missing.');
return;

@@ -393,12 +425,2 @@ }

actions =
'<h2>Use Built-in WebView navigator.geolocation</h2>' +
'<div id="built-in-getLocation"></div>' +
'Expected result: Will update all applicable values in status box for current location. Status will read Retrieving Location (may not see this if location is retrieved immediately) then Done.' +
'<p/> <div id="built-in-watchLocation"></div>' +
'Expected result: Will update all applicable values in status box for current location and update as location changes. Status will read Running.' +
'<p/> <div id="built-in-stopLocation"></div>' +
'Expected result: Will stop watching the location so values will not be updated. Status will read Stopped.' +
'<p/> <div id="built-in-getOld"></div>' +
'Expected result: Will update location values with a cached position that is up to 30 seconds old. Verify with time value. Status will read Done.' +
'<h2>Use Cordova Geolocation Plugin</h2>' +
'<div id="cordova-getLocation"></div>' +

@@ -417,36 +439,20 @@ 'Expected result: Will update all applicable values in status box for current location. Status will read Retrieving Location (may not see this if location is retrieved immediately) then Done.' +

contentEl.innerHTML = values_info + location_div + latitude + longitude + altitude +
accuracy + heading + speed + altitude_accuracy + time + note + actions;
contentEl.innerHTML = values_info + location_div + latitude + longitude + altitude + accuracy + heading + speed
+ altitude_accuracy + time + note + actions;
createActionButton('Get Location', function () {
getLocation(false);
}, 'built-in-getLocation');
createActionButton('Start Watching Location', function () {
watchLocation(false);
}, 'built-in-watchLocation');
createActionButton('Stop Watching Location', function () {
stopLocation(false);
}, 'built-in-stopLocation');
createActionButton('Get Location Up to 30 Sec Old', function () {
getLocation(false, { maximumAge: 30000 });
}, 'built-in-getOld');
createActionButton('Get Location', function () {
getLocation(true);
getLocation();
}, 'cordova-getLocation');
createActionButton('Start Watching Location', function () {
watchLocation(true);
watchLocation();
}, 'cordova-watchLocation');
createActionButton('Stop Watching Location', function () {
stopLocation(true);
stopLocation();
}, 'cordova-stopLocation');
createActionButton('Get Location Up to 30 Sec Old', function () {
getLocation(true, { maximumAge: 30000 });
getLocation({ maximumAge: 30000 });
}, 'cordova-getOld');
};

@@ -24,36 +24,51 @@ /*

var exec = cordova.require('cordova/exec');
var utils = require('cordova/utils');
var PositionError = require('./PositionError');
module.exports = {
/*TODO: Fix scope issues with this cordova.require. I have no idea exec works, but geo doesn't work */
getCurrentPosition: function(success, error, args) {
var win = function() {
var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation');
geo.getCurrentPosition(success, error, {
enableHighAccuracy: args[0],
maximumAge: args[1]
});
geo.getCurrentPosition(success, error, args);
};
exec(win, error, "Geolocation", "getPermission", []);
var fail = function() {
if (error) {
error(new PositionError (PositionError.PERMISSION_DENIED, 'Illegal Access'));
}
};
exec(win, fail, "Geolocation", "getPermission", []);
},
watchPosition: function(success, error, args) {
var pluginWatchId = utils.createUUID();
var win = function() {
var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation');
geo.watchPosition(success, error, {
enableHighAccuracy: args[1]
});
pluginToNativeWatchMap[pluginWatchId] = geo.watchPosition(success, error, args);
};
exec(win, error, "Geolocation", "getPermission", []);
var fail = function() {
if (error) {
error(new PositionError(PositionError.PERMISSION_DENIED, 'Illegal Access'));
}
};
exec(win, fail, "Geolocation", "getPermission", []);
return pluginWatchId;
},
clearWatch: function(success, error, args) {
clearWatch: function(pluginWatchId) {
var win = function() {
var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation');
geo.clearWatch(args[0]);
}
exec(win, error, "Geolocation", "getPermission", []);
var nativeWatchId = pluginToNativeWatchMap[pluginWatchId];
var geo = cordova.require('cordova/modulemapper').getOriginalSymbol(window, 'navigator.geolocation');
geo.clearWatch(nativeWatchId);
};
exec(win, null, "Geolocation", "getPermission", []);
}
};
// Native watchPosition method is called async after permissions prompt.
// So we use additional map and own ids to return watch id synchronously.
var pluginToNativeWatchMap = {};

@@ -34,6 +34,6 @@ /*

PositionError.PERMISSION_DENIED = 1;
PositionError.POSITION_UNAVAILABLE = 2;
PositionError.TIMEOUT = 3;
PositionError.prototype.PERMISSION_DENIED = PositionError.PERMISSION_DENIED = 1;
PositionError.prototype.POSITION_UNAVAILABLE = PositionError.POSITION_UNAVAILABLE = 2;
PositionError.prototype.TIMEOUT = PositionError.TIMEOUT = 3;
module.exports = PositionError;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc