From 43a1aa647b78682fd1f44a8f358d2200010f5684 Mon Sep 17 00:00:00 2001 From: filmaj Date: Thu, 27 Apr 2017 12:26:07 -0700 Subject: [PATCH 01/15] Set VERSION to 1.1.7-dev (via coho) --- package.json | 2 +- plugin.xml | 2 +- tests/plugin.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index bf0958f1..24f80830 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-device", - "version": "1.1.6", + "version": "1.1.7-dev", "description": "Cordova Device Plugin", "types": "./types/index.d.ts", "cordova": { diff --git a/plugin.xml b/plugin.xml index e7a8188b..51bf4a13 100644 --- a/plugin.xml +++ b/plugin.xml @@ -22,7 +22,7 @@ xmlns:rim="http://www.blackberry.com/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-device" - version="1.1.6"> + version="1.1.7-dev"> Device Cordova Device Plugin Apache 2.0 diff --git a/tests/plugin.xml b/tests/plugin.xml index 6873caf1..3b606477 100644 --- a/tests/plugin.xml +++ b/tests/plugin.xml @@ -22,7 +22,7 @@ xmlns:rim="http://www.blackberry.com/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-device-tests" - version="1.1.6"> + version="1.1.7-dev"> Cordova Device Plugin Tests Apache 2.0 From e89ae891f11d1ff01d86df0a17de3072af3fabff Mon Sep 17 00:00:00 2001 From: filmaj Date: Wed, 24 May 2017 21:27:11 +0200 Subject: [PATCH 02/15] CB-12847: added `bugs` entry to package.json. --- package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package.json b/package.json index 24f80830..40610555 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,9 @@ "type": "git", "url": "https://github.com/apache/cordova-plugin-device" }, + "bugs": { + "url": "https://github.com/apache/cordova-website/issues" + }, "keywords": [ "cordova", "device", From 59e0a86e77eadc0d68e789d8bdd551ff358ad8ef Mon Sep 17 00:00:00 2001 From: filmaj Date: Thu, 25 May 2017 12:31:45 +0200 Subject: [PATCH 03/15] CB-12847: fixed `bugs` entry in package.json. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 40610555..67e9a264 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "url": "https://github.com/apache/cordova-plugin-device" }, "bugs": { - "url": "https://github.com/apache/cordova-website/issues" + "url": "https://issues.apache.org/jira/browse/CB" }, "keywords": [ "cordova", From 2d845036befa5152ab9b87011c0970cc95833e69 Mon Sep 17 00:00:00 2001 From: Alexander Sorokin Date: Fri, 23 Jun 2017 14:12:13 +0300 Subject: [PATCH 04/15] CB-12935: (ios, android) Enable paramedic builds on Travis CI --- .travis.yml | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 71 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index b9af4c58..369a64a1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,72 @@ -language: node_js sudo: false -node_js: - - "4.2" +addons: + jwt: + secure: egTo2EERSKVWdBoP+6ewd/JIyyly2XTT1xOVj27v2L148c453uRNPjXwiGRYu7vTw5rkGK+H54n4FG3rUOuEVNX9NDNC5TlkhTfmecXNzjyOIuV7xD0qg5s6Q3IXg8kAp9+JXWbVVR6hoPzmAAnTT4rcoh6cPg4Tf327W2sRGkw= +env: + global: + - SAUCE_USERNAME=snay + - TRAVIS_NODE_VERSION="4.2" +matrix: + include: + - env: PLATFORM=ios-9.3 + os: osx + osx_image: xcode7.3 + language: node_js + node_js: '4.2' + - env: PLATFORM=ios-10.0 + os: osx + osx_image: xcode7.3 + language: node_js + node_js: '4.2' + - env: PLATFORM=android-4.4 + os: linux + language: android + jdk: oraclejdk8 + android: + components: + - tools + - tools + - env: PLATFORM=android-5.1 + os: linux + language: android + jdk: oraclejdk8 + android: + components: + - tools + - tools + - env: PLATFORM=android-6.0 + os: linux + language: android + jdk: oraclejdk8 + android: + components: + - tools + - tools + - env: PLATFORM=android-7.0 + os: linux + language: android + jdk: oraclejdk8 + android: + components: + - tools + - tools +before_install: +- npm cache clean -f +- rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm + && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm + install $TRAVIS_NODE_VERSION +- node --version +- if [[ "$PLATFORM" =~ android ]]; then gradle --version; fi +- if [[ "$PLATFORM" =~ ios ]]; then npm install -g ios-deploy; fi +- if [[ "$PLATFORM" =~ android ]]; then echo y | android update sdk -u --filter android-22,android-23,android-24,android-25; + fi +- git clone https://github.com/apache/cordova-paramedic /tmp/paramedic && pushd /tmp/paramedic + && npm install && popd +- npm install -g cordova +install: +- npm install +script: +- npm test +- node /tmp/paramedic/main.js --config pr/$PLATFORM --plugin $(pwd) --shouldUseSauce + --buildName travis-plugin-device-$TRAVIS_JOB_NUMBER + From 412938d446b228e87f577c3b09449aa7d7eee3ab Mon Sep 17 00:00:00 2001 From: Alexander Sorokin Date: Thu, 29 Jun 2017 15:02:47 +0300 Subject: [PATCH 05/15] CB-12935: (windows) Enable paramedic builds on AppVeyor --- .appveyor.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .appveyor.yml diff --git a/.appveyor.yml b/.appveyor.yml new file mode 100644 index 00000000..4cd6d535 --- /dev/null +++ b/.appveyor.yml @@ -0,0 +1,28 @@ +# appveyor file +# http://www.appveyor.com/docs/appveyor-yml + +max_jobs: 1 + +shallow_clone: true + +init: + - git config --global core.autocrlf true + +image: + - Visual Studio 2017 + +environment: + nodejs_version: "4" + matrix: + - PLATFORM: windows-10-store + +install: + - npm cache clean -f + - node --version + - npm install -g cordova-paramedic@https://github.com/apache/cordova-paramedic.git + - npm install -g cordova + +build: off + +test_script: + - cordova-paramedic --config pr\%PLATFORM% --plugin . --justBuild From 233a8b3cfb2578b22faaf338635a5a226c3c3715 Mon Sep 17 00:00:00 2001 From: Alexander Sorokin Date: Thu, 6 Jul 2017 14:23:14 +0300 Subject: [PATCH 06/15] CB-12991: (CI) Updated CI badges --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 663cc81f..97dd5d4c 100644 --- a/README.md +++ b/README.md @@ -21,9 +21,9 @@ description: Get device information. # under the License. --> -|Android 4.4|Android 5.1|Android 6.0|iOS 9.3|iOS 10.0|Windows 10 Store|Travis CI| -|:-:|:-:|:-:|:-:|:-:|:-:|:-:| -|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=android-4.4,PLUGIN=cordova-plugin-device)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android-4.4,PLUGIN=cordova-plugin-device/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=android-5.1,PLUGIN=cordova-plugin-device)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android-5.1,PLUGIN=cordova-plugin-device/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=android-6.0,PLUGIN=cordova-plugin-device)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android-6.0,PLUGIN=cordova-plugin-device/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=ios-9.3,PLUGIN=cordova-plugin-device)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=ios-9.3,PLUGIN=cordova-plugin-device/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=ios-10.0,PLUGIN=cordova-plugin-device)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=ios-10.0,PLUGIN=cordova-plugin-device/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-device)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-device/)|[![Build Status](https://travis-ci.org/apache/cordova-plugin-device.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-device)| +|AppVeyor|Travis CI| +|:-:|:-:| +|[![Build status](https://ci.appveyor.com/api/projects/status/github/apache/cordova-plugin-device?branch=master)](https://ci.appveyor.com/project/ApacheSoftwareFoundation/cordova-plugin-device)|[![Build Status](https://travis-ci.org/apache/cordova-plugin-device.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-device)| # cordova-plugin-device From 24b6a33ec59fb0fdd318caaad49daea15a8a20a5 Mon Sep 17 00:00:00 2001 From: Alexander Sorokin Date: Mon, 10 Jul 2017 10:33:45 +0300 Subject: [PATCH 07/15] CB-13000: (CI) Speed up android builds --- .travis.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 369a64a1..2f7f545d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,7 +25,6 @@ matrix: android: components: - tools - - tools - env: PLATFORM=android-5.1 os: linux language: android @@ -33,7 +32,6 @@ matrix: android: components: - tools - - tools - env: PLATFORM=android-6.0 os: linux language: android @@ -41,7 +39,6 @@ matrix: android: components: - tools - - tools - env: PLATFORM=android-7.0 os: linux language: android @@ -49,7 +46,6 @@ matrix: android: components: - tools - - tools before_install: - npm cache clean -f - rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm From f32cfc288b3669893f4fb239cc98cbf1552ef151 Mon Sep 17 00:00:00 2001 From: Alexander Sorokin Date: Wed, 26 Jul 2017 10:11:34 +0300 Subject: [PATCH 08/15] CB-13028 (CI) Browser builds on Travis and AppVeyor --- .appveyor.yml | 5 +++-- .travis.yml | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 4cd6d535..6eea8b6a 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -15,7 +15,8 @@ environment: nodejs_version: "4" matrix: - PLATFORM: windows-10-store - + JUST_BUILD: --justBuild + - PLATFORM: local\browser install: - npm cache clean -f - node --version @@ -25,4 +26,4 @@ install: build: off test_script: - - cordova-paramedic --config pr\%PLATFORM% --plugin . --justBuild + - cordova-paramedic --config pr\%PLATFORM% --plugin . %JUST_BUILD% diff --git a/.travis.yml b/.travis.yml index 2f7f545d..9403faf8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,22 @@ env: - TRAVIS_NODE_VERSION="4.2" matrix: include: + - env: PLATFORM=browser-chrome + os: linux + language: node_js + node_js: '4.2' + - env: PLATFORM=browser-firefox + os: linux + language: node_js + node_js: '4.2' + - env: PLATFORM=browser-safari + os: linux + language: node_js + node_js: '4.2' + - env: PLATFORM=browser-edge + os: linux + language: node_js + node_js: '4.2' - env: PLATFORM=ios-9.3 os: osx osx_image: xcode7.3 From a886200d3f9a56a4de21090effca050c94613a2b Mon Sep 17 00:00:00 2001 From: Alexander Sorokin Date: Wed, 26 Jul 2017 10:49:05 +0300 Subject: [PATCH 09/15] CB-13113 (browser) device.isVirtual is always false --- README.md | 5 +++-- src/browser/DeviceProxy.js | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 97dd5d4c..2cdb7083 100644 --- a/README.md +++ b/README.md @@ -287,14 +287,15 @@ var isSim = device.isVirtual; ### Supported Platforms - Android 2.1+ +- Browser - iOS - Windows Phone 8 - Windows - OSX -### OSX Quirk +### OSX and Browser Quirk -The `isVirtual` property on OS X always returns false. +The `isVirtual` property on OS X and Browser always returns false. ## device.serial diff --git a/src/browser/DeviceProxy.js b/src/browser/DeviceProxy.js index bc2e6014..dfb812f5 100644 --- a/src/browser/DeviceProxy.js +++ b/src/browser/DeviceProxy.js @@ -75,7 +75,8 @@ module.exports = { platform: getPlatform(), model: getModel(), version: getVersion(), - uuid: null + uuid: null, + isVirtual: false }); }, 0); } From 965f65d9ddb0973d9a757599fbf92f1d64b30f33 Mon Sep 17 00:00:00 2001 From: filmaj Date: Wed, 26 Jul 2017 08:09:54 -0700 Subject: [PATCH 10/15] Closes #66 From 3dfbb7826fff868179dcc5e028992eedf9cb7121 Mon Sep 17 00:00:00 2001 From: Audrey So Date: Fri, 9 Jun 2017 15:27:27 -0700 Subject: [PATCH 11/15] CB-12895 : setup eslint and removed jshint --- .eslintrc.yml | 10 +++ .jshintrc | 15 ---- package.json | 12 +++- src/blackberry10/index.js | 38 +++++----- src/browser/DeviceProxy.js | 13 ++-- src/firefoxos/DeviceProxy.js | 18 ++--- src/tizen/DeviceProxy.js | 4 +- src/ubuntu/device.js | 14 ++-- src/windows/DeviceProxy.js | 56 +++++++-------- tests/tests.js | 132 +++++++++++++++++------------------ www/device.js | 28 ++++---- 11 files changed, 171 insertions(+), 169 deletions(-) create mode 100644 .eslintrc.yml delete mode 100644 .jshintrc diff --git a/.eslintrc.yml b/.eslintrc.yml new file mode 100644 index 00000000..0cccb8c7 --- /dev/null +++ b/.eslintrc.yml @@ -0,0 +1,10 @@ +root: true +extends: semistandard +rules: + indent: + - error + - 4 + camelcase: off + padded-blocks: off + operator-linebreak: off + no-throw-literal: off \ No newline at end of file diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index dd790476..00000000 --- a/.jshintrc +++ /dev/null @@ -1,15 +0,0 @@ -{ - "browser": true - , "bitwise": true - , "undef": true - , "trailing": true - , "quotmark": false - , "indent": 4 - , "unused": "vars" - , "latedef": "nofunc" - , "globals": { - "module": false, - "exports": false, - "require": false - } -} diff --git a/package.json b/package.json index 67e9a264..fbcba712 100644 --- a/package.json +++ b/package.json @@ -47,8 +47,8 @@ "cordova-osx" ], "scripts": { - "test": "npm run jshint", - "jshint": "node node_modules/jshint/bin/jshint www && node node_modules/jshint/bin/jshint src && node node_modules/jshint/bin/jshint tests" + "test": "npm run eslint", + "eslint": "node node_modules/eslint/bin/eslint www && node node_modules/eslint/bin/eslint src && node node_modules/eslint/bin/eslint tests" }, "author": "Apache Software Foundation", "license": "Apache-2.0", @@ -60,6 +60,12 @@ } }, "devDependencies": { - "jshint": "^2.6.0" + "eslint": "^3.19.0", + "eslint-config-semistandard": "^11.0.0", + "eslint-config-standard": "^10.2.1", + "eslint-plugin-import": "^2.3.0", + "eslint-plugin-node": "^5.0.0", + "eslint-plugin-promise": "^3.5.0", + "eslint-plugin-standard": "^3.0.1" } } diff --git a/src/blackberry10/index.js b/src/blackberry10/index.js index ef0543bc..699b3366 100644 --- a/src/blackberry10/index.js +++ b/src/blackberry10/index.js @@ -23,17 +23,17 @@ function getModelName () { var modelName = window.qnx.webplatform.device.modelName; - //Pre 10.2 (meaning Z10 or Q10) - if (typeof modelName === "undefined") { + // Pre 10.2 (meaning Z10 or Q10) + if (typeof modelName === 'undefined') { if (window.screen.height === 720 && window.screen.width === 720) { - if ( window.matchMedia("(-blackberry-display-technology: -blackberry-display-oled)").matches) { - modelName = "Q10"; + if (window.matchMedia('(-blackberry-display-technology: -blackberry-display-oled)').matches) { + modelName = 'Q10'; } else { - modelName = "Q5"; + modelName = 'Q5'; } } else if ((window.screen.height === 1280 && window.screen.width === 768) || (window.screen.height === 768 && window.screen.width === 1280)) { - modelName = "Z10"; + modelName = 'Z10'; } else { modelName = window.qnx.webplatform.deviceName; } @@ -43,28 +43,28 @@ function getModelName () { } function getUUID () { - var uuid = ""; + var uuid = ''; try { - //Must surround by try catch because this will throw if the app is missing permissions + // Must surround by try catch because this will throw if the app is missing permissions uuid = window.qnx.webplatform.device.devicePin; } catch (e) { - //DO Nothing + // DO Nothing } return uuid; } module.exports = { getDeviceInfo: function (success, fail, args, env) { - var result = new PluginResult(args, env), - modelName = getModelName(), - uuid = getUUID(), - info = { - manufacturer: 'BlackBerry', - platform: "blackberry10", - version: window.qnx.webplatform.device.scmBundle, - model: modelName, - uuid: uuid - }; + var result = new PluginResult(args, env); + var modelName = getModelName(); + var uuid = getUUID(); + var info = { + manufacturer: 'BlackBerry', + platform: 'blackberry10', + version: window.qnx.webplatform.device.scmBundle, + model: modelName, + uuid: uuid + }; result.ok(info); } diff --git a/src/browser/DeviceProxy.js b/src/browser/DeviceProxy.js index dfb812f5..4dc80ec0 100644 --- a/src/browser/DeviceProxy.js +++ b/src/browser/DeviceProxy.js @@ -20,19 +20,19 @@ */ var browser = require('cordova/platform'); -function getPlatform() { - return "browser"; +function getPlatform () { + return 'browser'; } -function getModel() { +function getModel () { return getBrowserInfo(true); } -function getVersion() { +function getVersion () { return getBrowserInfo(false); } -function getBrowserInfo(getModel) { +function getBrowserInfo (getModel) { var userAgent = navigator.userAgent; var returnVal = ''; var offset; @@ -66,7 +66,6 @@ function getBrowserInfo(getModel) { return returnVal; } - module.exports = { getDeviceInfo: function (success, error) { setTimeout(function () { @@ -82,4 +81,4 @@ module.exports = { } }; -require("cordova/exec/proxy").add("Device", module.exports); +require('cordova/exec/proxy').add('Device', module.exports); diff --git a/src/firefoxos/DeviceProxy.js b/src/firefoxos/DeviceProxy.js index a05d7ca0..7dd5df36 100644 --- a/src/firefoxos/DeviceProxy.js +++ b/src/firefoxos/DeviceProxy.js @@ -18,14 +18,14 @@ * under the License. * */ -//example UA String for Firefox OS -//Mozilla/5.0 (Mobile; rv:26.0) Gecko/26.0 Firefox/26.0 +// example UA String for Firefox OS +// Mozilla/5.0 (Mobile; rv:26.0) Gecko/26.0 Firefox/26.0 -//UA parsing not recommended but currently this is the only way to get the Firefox OS version -//https://developer.mozilla.org/en-US/docs/Gecko_user_agent_string_reference +// UA parsing not recommended but currently this is the only way to get the Firefox OS version +// https://developer.mozilla.org/en-US/docs/Gecko_user_agent_string_reference -//Should be replaced when better conversion to Firefox OS Version is available -function convertVersionNumber(ver) { +// Should be replaced when better conversion to Firefox OS Version is available +function convertVersionNumber (ver) { var hashVersion = { '18.0': '1.0.1', '18.1': '1.1', @@ -42,7 +42,7 @@ function convertVersionNumber(ver) { return (rver); } -function getVersion() { +function getVersion () { if (navigator.userAgent.match(/(mobile|tablet)/i)) { var ffVersionArray = (navigator.userAgent.match(/Firefox\/([\d]+\.[\w]?\.?[\w]+)/)); if (ffVersionArray.length === 2) { @@ -52,7 +52,7 @@ function getVersion() { return (null); } -function getModel() { +function getModel () { var uaArray = navigator.userAgent.split(/\s*[;)(]\s*/); if (navigator.userAgent.match(/(mobile|tablet)/i)) { if (uaArray.length === 5) { @@ -74,4 +74,4 @@ module.exports = { } }; -require("cordova/exec/proxy").add("Device", module.exports); +require('cordova/exec/proxy').add('Device', module.exports); diff --git a/src/tizen/DeviceProxy.js b/src/tizen/DeviceProxy.js index 973b7162..90feab42 100644 --- a/src/tizen/DeviceProxy.js +++ b/src/tizen/DeviceProxy.js @@ -22,7 +22,7 @@ var tizen = require('cordova/platform'); module.exports = { - getDeviceInfo: function(success, error) { + getDeviceInfo: function (success, error) { setTimeout(function () { success({ cordova: tizen.cordovaVersion, @@ -35,4 +35,4 @@ module.exports = { } }; -require("cordova/tizen/commandProxy").add("Device", module.exports); +require('cordova/tizen/commandProxy').add('Device', module.exports); diff --git a/src/ubuntu/device.js b/src/ubuntu/device.js index 838586c3..df1632e9 100644 --- a/src/ubuntu/device.js +++ b/src/ubuntu/device.js @@ -22,12 +22,16 @@ /* global Cordova */ module.exports = { - getInfo:function(win,fail,args) { + getInfo: function (win, fail, args) { Cordova.exec(function (model, cordova, platform, uuid, version) { - win({name: name, model: model, cordova: cordova, - platform: platform, uuid: uuid, version: version}); - }, null, "com.cordova.Device", "getInfo", []); + win({name: name, // eslint-disable-line no-undef + model: model, + cordova: cordova, + platform: platform, + uuid: uuid, + version: version}); + }, null, 'com.cordova.Device', 'getInfo', []); } }; -require("cordova/exec/proxy").add("Device", module.exports); +require('cordova/exec/proxy').add('Device', module.exports); diff --git a/src/windows/DeviceProxy.js b/src/windows/DeviceProxy.js index f338ad3a..ccaaaee6 100644 --- a/src/windows/DeviceProxy.js +++ b/src/windows/DeviceProxy.js @@ -21,16 +21,16 @@ /* global Windows, createUUID */ -var ROOT_CONTAINER = "{00000000-0000-0000-FFFF-FFFFFFFFFFFF}"; -var DEVICE_CLASS_KEY = "{A45C254E-DF1C-4EFD-8020-67D146A850E0},10"; -var DEVICE_CLASS_KEY_NO_SEMICOLON = "{A45C254E-DF1C-4EFD-8020-67D146A850E0}10"; -var ROOT_CONTAINER_QUERY = "System.Devices.ContainerId:=\"" + ROOT_CONTAINER + "\""; -var HAL_DEVICE_CLASS = "4d36e966-e325-11ce-bfc1-08002be10318"; -var DEVICE_DRIVER_VERSION_KEY = "{A8B865DD-2E3D-4094-AD97-E593A70C75D6},3"; +var ROOT_CONTAINER = '{00000000-0000-0000-FFFF-FFFFFFFFFFFF}'; +var DEVICE_CLASS_KEY = '{A45C254E-DF1C-4EFD-8020-67D146A850E0},10'; +var DEVICE_CLASS_KEY_NO_SEMICOLON = '{A45C254E-DF1C-4EFD-8020-67D146A850E0}10'; +var ROOT_CONTAINER_QUERY = 'System.Devices.ContainerId:="' + ROOT_CONTAINER + '"'; +var HAL_DEVICE_CLASS = '4d36e966-e325-11ce-bfc1-08002be10318'; +var DEVICE_DRIVER_VERSION_KEY = '{A8B865DD-2E3D-4094-AD97-E593A70C75D6},3'; module.exports = { - getDeviceInfo:function(win, fail, args) { + getDeviceInfo: function (win, fail, args) { // deviceId aka uuid, stored in Windows.Storage.ApplicationData.current.localSettings.values.deviceId var deviceId; @@ -38,8 +38,7 @@ module.exports = { var localSettings = Windows.Storage.ApplicationData.current.localSettings; if (localSettings.values.deviceId) { deviceId = localSettings.values.deviceId; - } - else { + } else { // App-specific hardware id could be used as uuid, but it changes if the hardware changes... try { var ASHWID = Windows.System.Profile.HardwareIdentification.getPackageSpecificToken(null).id; @@ -48,22 +47,21 @@ module.exports = { // Couldn't get the hardware UUID deviceId = createUUID(); } - //...so cache it per-install + // ...so cache it per-install localSettings.values.deviceId = deviceId; } - var userAgent = window.clientInformation.userAgent; // this will report "windows" in windows8.1 and windows phone 8.1 apps // and "windows8" in windows 8.0 apps similar to cordova.js // See https://github.com/apache/cordova-js/blob/master/src/windows/platform.js#L25 - var devicePlatform = userAgent.indexOf("MSAppHost/1.0") == -1 ? "windows" : "windows8"; + var devicePlatform = userAgent.indexOf('MSAppHost/1.0') === -1 ? 'windows' : 'windows8'; var versionString = userAgent.match(/Windows (?:Phone |NT )?([0-9.]+)/)[1]; var deviceInfo = new Windows.Security.ExchangeActiveSyncProvisioning.EasClientDeviceInformation(); // Running in the Windows Simulator is a remote session. // Running in the Windows Phone Emulator has the systemProductName set to "Virtual" - var isVirtual = Windows.System.RemoteDesktop.InteractiveSession.isRemote || deviceInfo.systemProductName == "Virtual"; + var isVirtual = Windows.System.RemoteDesktop.InteractiveSession.isRemote || deviceInfo.systemProductName === 'Virtual'; var manufacturer = deviceInfo.systemManufacturer; var model = deviceInfo.systemProductName; @@ -73,26 +71,26 @@ module.exports = { [DEVICE_DRIVER_VERSION_KEY, DEVICE_CLASS_KEY], ROOT_CONTAINER_QUERY) .then(function (rootDevices) { - for (var i = 0; i < rootDevices.length; i++) { - var rootDevice = rootDevices[i]; - if (!rootDevice.properties) continue; - if (rootDevice.properties[DEVICE_CLASS_KEY_NO_SEMICOLON] == HAL_DEVICE_CLASS) { - versionString = rootDevice.properties[DEVICE_DRIVER_VERSION_KEY]; - break; - } + for (var i = 0; i < rootDevices.length; i++) { + var rootDevice = rootDevices[i]; + if (!rootDevice.properties) continue; + if (rootDevice.properties[DEVICE_CLASS_KEY_NO_SEMICOLON] === HAL_DEVICE_CLASS) { + versionString = rootDevice.properties[DEVICE_DRIVER_VERSION_KEY]; + break; } + } - setTimeout(function () { - win({ platform: devicePlatform, - version: versionString, - uuid: deviceId, - isVirtual: isVirtual, - model: model, - manufacturer:manufacturer}); - }, 0); + setTimeout(function () { + win({ platform: devicePlatform, + version: versionString, + uuid: deviceId, + isVirtual: isVirtual, + model: model, + manufacturer: manufacturer}); + }, 0); }); } }; // exports -require("cordova/exec/proxy").add("Device", module.exports); +require('cordova/exec/proxy').add('Device', module.exports); diff --git a/tests/tests.js b/tests/tests.js index ac9a2810..03e1fc77 100644 --- a/tests/tests.js +++ b/tests/tests.js @@ -19,72 +19,72 @@ * */ -/* jshint jasmine: true */ +/* eslint-env jasmine */ + +exports.defineAutoTests = function () { + describe('Device Information (window.device)', function () { + it('should exist', function () { + expect(window.device).toBeDefined(); + }); + + it('should contain a platform specification that is a string', function () { + expect(window.device.platform).toBeDefined(); + expect((String(window.device.platform)).length > 0).toBe(true); + }); + + it('should contain a version specification that is a string', function () { + expect(window.device.version).toBeDefined(); + expect((String(window.device.version)).length > 0).toBe(true); + }); + + it('should contain a UUID specification that is a string or a number', function () { + expect(window.device.uuid).toBeDefined(); + if (typeof window.device.uuid === 'string' || typeof window.device.uuid === 'object') { + expect((String(window.device.uuid)).length > 0).toBe(true); + } else { + expect(window.device.uuid > 0).toBe(true); + } + }); + + it('should contain a cordova specification that is a string', function () { + expect(window.device.cordova).toBeDefined(); + expect((String(window.device.cordova)).length > 0).toBe(true); + }); + + it('should depend on the presence of cordova.version string', function () { + expect(window.cordova.version).toBeDefined(); + expect((String(window.cordova.version)).length > 0).toBe(true); + }); + + it('should contain device.cordova equal to cordova.version', function () { + expect(window.device.cordova).toBe(window.cordova.version); + }); + + it('should contain a model specification that is a string', function () { + expect(window.device.model).toBeDefined(); + expect((String(window.device.model)).length > 0).toBe(true); + }); + + it('should contain a manufacturer property that is a string', function () { + expect(window.device.manufacturer).toBeDefined(); + expect((String(window.device.manufacturer)).length > 0).toBe(true); + }); + + it('should contain an isVirtual property that is a boolean', function () { + expect(window.device.isVirtual).toBeDefined(); + expect(typeof window.device.isVirtual).toBe('boolean'); + }); + + it('should contain a serial number specification that is a string', function () { + expect(window.device.serial).toBeDefined(); + expect((String(window.device.serial)).length > 0).toBe(true); + + }); -exports.defineAutoTests = function() { - describe('Device Information (window.device)', function () { - it("should exist", function() { - expect(window.device).toBeDefined(); }); - - it("should contain a platform specification that is a string", function() { - expect(window.device.platform).toBeDefined(); - expect((String(window.device.platform)).length > 0).toBe(true); - }); - - it("should contain a version specification that is a string", function() { - expect(window.device.version).toBeDefined(); - expect((String(window.device.version)).length > 0).toBe(true); - }); - - it("should contain a UUID specification that is a string or a number", function() { - expect(window.device.uuid).toBeDefined(); - if (typeof window.device.uuid == 'string' || typeof window.device.uuid == 'object') { - expect((String(window.device.uuid)).length > 0).toBe(true); - } else { - expect(window.device.uuid > 0).toBe(true); - } - }); - - it("should contain a cordova specification that is a string", function() { - expect(window.device.cordova).toBeDefined(); - expect((String(window.device.cordova)).length > 0).toBe(true); - }); - - it("should depend on the presence of cordova.version string", function() { - expect(window.cordova.version).toBeDefined(); - expect((String(window.cordova.version)).length > 0).toBe(true); - }); - - it("should contain device.cordova equal to cordova.version", function() { - expect(window.device.cordova).toBe(window.cordova.version); - }); - - it("should contain a model specification that is a string", function() { - expect(window.device.model).toBeDefined(); - expect((String(window.device.model)).length > 0).toBe(true); - }); - - it("should contain a manufacturer property that is a string", function() { - expect(window.device.manufacturer).toBeDefined(); - expect((String(window.device.manufacturer)).length > 0).toBe(true); - }); - - it("should contain an isVirtual property that is a boolean", function() { - expect(window.device.isVirtual).toBeDefined(); - expect(typeof window.device.isVirtual).toBe("boolean"); - }); - - it("should contain a serial number specification that is a string", function() { - expect(window.device.serial).toBeDefined(); - expect((String(window.device.serial)).length > 0).toBe(true); - - }); - - }); }; -exports.defineManualTests = function(contentEl, createActionButton) { +exports.defineManualTests = function (contentEl, createActionButton) { var logMessage = function (message, color) { var log = document.getElementById('info'); var logLine = document.createElement('div'); @@ -106,8 +106,8 @@ exports.defineManualTests = function(contentEl, createActionButton) { contentEl.innerHTML = '
' + device_tests; - createActionButton('Dump device', function() { - clearLog(); - logMessage(JSON.stringify(window.device, null, '\t')); - }, "dump_device"); + createActionButton('Dump device', function () { + clearLog(); + logMessage(JSON.stringify(window.device, null, '\t')); + }, 'dump_device'); }; diff --git a/www/device.js b/www/device.js index f7ed19f9..41ed04f6 100644 --- a/www/device.js +++ b/www/device.js @@ -19,11 +19,11 @@ * */ -var argscheck = require('cordova/argscheck'), - channel = require('cordova/channel'), - utils = require('cordova/utils'), - exec = require('cordova/exec'), - cordova = require('cordova'); +var argscheck = require('cordova/argscheck'); +var channel = require('cordova/channel'); +var utils = require('cordova/utils'); +var exec = require('cordova/exec'); +var cordova = require('cordova'); channel.createSticky('onCordovaInfoReady'); // Tell cordova channel to wait on the CordovaInfoReady event @@ -34,7 +34,7 @@ channel.waitForInitialization('onCordovaInfoReady'); * phone, etc. * @constructor */ -function Device() { +function Device () { this.available = false; this.platform = null; this.version = null; @@ -47,10 +47,10 @@ function Device() { var me = this; - channel.onCordovaReady.subscribe(function() { - me.getInfo(function(info) { - //ignoring info.cordova returning from native, we should use value from cordova.version defined in cordova.js - //TODO: CB-5105 native implementations should not return info.cordova + channel.onCordovaReady.subscribe(function () { + me.getInfo(function (info) { + // ignoring info.cordova returning from native, we should use value from cordova.version defined in cordova.js + // TODO: CB-5105 native implementations should not return info.cordova var buildLabel = cordova.version; me.available = true; me.platform = info.platform; @@ -62,9 +62,9 @@ function Device() { me.manufacturer = info.manufacturer || 'unknown'; me.serial = info.serial || 'unknown'; channel.onCordovaInfoReady.fire(); - },function(e) { + }, function (e) { me.available = false; - utils.alert("[ERROR] Error initializing Cordova: " + e); + utils.alert('[ERROR] Error initializing Cordova: ' + e); }); }); } @@ -75,9 +75,9 @@ function Device() { * @param {Function} successCallback The function to call when the heading data is available * @param {Function} errorCallback The function to call when there is an error getting the heading data. (OPTIONAL) */ -Device.prototype.getInfo = function(successCallback, errorCallback) { +Device.prototype.getInfo = function (successCallback, errorCallback) { argscheck.checkArgs('fF', 'Device.getInfo', arguments); - exec(successCallback, errorCallback, "Device", "getDeviceInfo", []); + exec(successCallback, errorCallback, 'Device', 'getDeviceInfo', []); }; module.exports = new Device(); From aab47930b969ea74ace1d2637ae2527d316b4e8f Mon Sep 17 00:00:00 2001 From: Alexander Sorokin Date: Tue, 19 Sep 2017 09:05:12 +0300 Subject: [PATCH 12/15] CB-13299 (CI) Fix Android builds --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9403faf8..9886c88c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -63,7 +63,6 @@ matrix: components: - tools before_install: -- npm cache clean -f - rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm install $TRAVIS_NODE_VERSION From 650975ba9c755b4e72a6ff6a114d070e93a19df6 Mon Sep 17 00:00:00 2001 From: Alexander Sorokin Date: Fri, 20 Oct 2017 08:58:30 +0300 Subject: [PATCH 13/15] CB-13472: (CI) Fixed Travis Android builds again --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9886c88c..ae8205e6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -69,7 +69,7 @@ before_install: - node --version - if [[ "$PLATFORM" =~ android ]]; then gradle --version; fi - if [[ "$PLATFORM" =~ ios ]]; then npm install -g ios-deploy; fi -- if [[ "$PLATFORM" =~ android ]]; then echo y | android update sdk -u --filter android-22,android-23,android-24,android-25; +- if [[ "$PLATFORM" =~ android ]]; then echo y | android update sdk -u --filter android-22,android-23,android-24,android-25,android-26; fi - git clone https://github.com/apache/cordova-paramedic /tmp/paramedic && pushd /tmp/paramedic && npm install && popd From a9f76be8c753dc7025b035a329bd6f5b3b25d67b Mon Sep 17 00:00:00 2001 From: Alexander Sorokin Date: Fri, 20 Oct 2017 10:22:26 +0300 Subject: [PATCH 14/15] CB-13473: (CI) Removed browser builds from AppVeyor --- .appveyor.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index 6eea8b6a..a7b2426e 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -16,7 +16,6 @@ environment: matrix: - PLATFORM: windows-10-store JUST_BUILD: --justBuild - - PLATFORM: local\browser install: - npm cache clean -f - node --version From cfd0e2e513592057ea3d39af5255e8336bdba295 Mon Sep 17 00:00:00 2001 From: Alexander Sorokin Date: Fri, 20 Oct 2017 14:59:58 +0300 Subject: [PATCH 15/15] Closing invalid PR: this closes #71