diff options
Diffstat (limited to 'StoneIsland/plugins/cordova-plugin-device')
41 files changed, 576 insertions, 297 deletions
diff --git a/StoneIsland/plugins/cordova-plugin-device/CONTRIBUTING.md b/StoneIsland/plugins/cordova-plugin-device/CONTRIBUTING.md index f7dbcaba..4c8e6a5e 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-device/CONTRIBUTING.md +++ b/StoneIsland/plugins/cordova-plugin-device/CONTRIBUTING.md @@ -27,7 +27,7 @@ There are multiple ways to contribute: report bugs, improve the docs, and contribute code. For instructions on this, start with the -[contribution overview](http://cordova.apache.org/#contribute). +[contribution overview](http://cordova.apache.org/contribute/). The details are explained there, but the important items are: - Sign and submit an Apache ICLA (Contributor License Agreement). diff --git a/StoneIsland/plugins/cordova-plugin-device/LICENSE b/StoneIsland/plugins/cordova-plugin-device/LICENSE index 7a4a3ea2..7a4a3ea2 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-device/LICENSE +++ b/StoneIsland/plugins/cordova-plugin-device/LICENSE diff --git a/StoneIsland/plugins/cordova-plugin-device/NOTICE b/StoneIsland/plugins/cordova-plugin-device/NOTICE index 8ec56a52..8ec56a52 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-device/NOTICE +++ b/StoneIsland/plugins/cordova-plugin-device/NOTICE diff --git a/StoneIsland/plugins/cordova-plugin-device/README.md b/StoneIsland/plugins/cordova-plugin-device/README.md index d3d7673d..10b80160 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-device/README.md +++ b/StoneIsland/plugins/cordova-plugin-device/README.md @@ -1,3 +1,7 @@ +--- +title: Device +description: Get device information. +--- <!-- # license: Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file @@ -17,17 +21,24 @@ # under the License. --> -# cordova-plugin-device +|Android|iOS| Windows 8.1 Store | Windows 8.1 Phone | Windows 10 Store | Travis CI | +|:-:|:-:|:-:|:-:|:-:|:-:| +|[](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android,PLUGIN=cordova-plugin-device/)|[](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=ios,PLUGIN=cordova-plugin-device/)|[](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-8.1-store,PLUGIN=cordova-plugin-device/)|[](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-8.1-phone,PLUGIN=cordova-plugin-device/)|[](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-device/)|[](https://travis-ci.org/apache/cordova-plugin-device)| -[](https://travis-ci.org/apache/cordova-plugin-device) +# cordova-plugin-device This plugin defines a global `device` object, which describes the device's hardware and software. Although the object is in the global scope, it is not available until after the `deviceready` event. - document.addEventListener("deviceready", onDeviceReady, false); - function onDeviceReady() { - console.log(device.cordova); - } +```js +document.addEventListener("deviceready", onDeviceReady, false); +function onDeviceReady() { + console.log(device.cordova); +} +``` + +Report issues with this plugin on the [Apache Cordova issue tracker](https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20%28Open%2C%20%22In%20Progress%22%2C%20Reopened%29%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22Plugin%20Device%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC) + ## Installation @@ -40,6 +51,9 @@ Although the object is in the global scope, it is not available until after the - device.platform - device.uuid - device.version +- device.manufacturer +- device.isVirtual +- device.serial ## device.cordova @@ -55,7 +69,8 @@ Get the version of Cordova running on the device. - iOS - Tizen - Windows Phone 7 and 8 -- Windows 8 +- Windows +- OSX ## device.model @@ -71,18 +86,22 @@ different across versions of the same product. - iOS - Tizen - Windows Phone 7 and 8 -- Windows 8 +- Windows +- OSX ### Quick Example - // Android: Nexus One returns "Passion" (Nexus One code name) - // Motorola Droid returns "voles" - // BlackBerry: Torch 9800 returns "9800" - // Browser: Google Chrome returns "Chrome" - // Safari returns "Safari" - // iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. See http://theiphonewiki.com/wiki/index.php?title=Models - // - var model = device.model; +```js +// Android: Nexus One returns "Passion" (Nexus One code name) +// Motorola Droid returns "voles" +// BlackBerry: Torch 9800 returns "9800" +// Browser: Google Chrome returns "Chrome" +// Safari returns "Safari" +// iOS: for the iPad Mini, returns iPad2,5; iPhone 5 is iPhone 5,1. See http://theiphonewiki.com/wiki/index.php?title=Models +// OSX: returns "x86_64" +// +var model = device.model; +``` ### Android Quirks @@ -100,30 +119,34 @@ different across versions of the same product. Get the device's operating system name. - var string = device.platform; - +```js +var string = device.platform; +``` ### Supported Platforms - Android - BlackBerry 10 -- Browser4 +- Browser - Firefox OS - iOS - Tizen - Windows Phone 7 and 8 -- Windows 8 +- Windows +- OSX ### Quick Example - // Depending on the device, a few examples are: - // - "Android" - // - "BlackBerry 10" - // - Browser: returns "MacIntel" on Mac - // returns "Win32" on Windows - // - "iOS" - // - "WinCE" - // - "Tizen" - var devicePlatform = device.platform; +```js +// Depending on the device, a few examples are: +// - "Android" +// - "BlackBerry 10" +// - "browser" +// - "iOS" +// - "WinCE" +// - "Tizen" +// - "Mac OS X" +var devicePlatform = device.platform; +``` ### Windows Phone 7 Quirks @@ -137,7 +160,9 @@ Windows Phone 8 devices report the platform as `Win32NT`. Get the device's Universally Unique Identifier ([UUID](http://en.wikipedia.org/wiki/Universally_Unique_Identifier)). - var string = device.uuid; +```js +var string = device.uuid; +``` ### Description @@ -150,33 +175,36 @@ The details of how a UUID is generated are determined by the device manufacturer - iOS - Tizen - Windows Phone 7 and 8 -- Windows 8 +- Windows +- OSX ### Quick Example - // Android: Returns a random 64-bit integer (as a string, again!) - // The integer is generated on the device's first boot - // - // BlackBerry: Returns the PIN number of the device - // This is a nine-digit unique integer (as a string, though!) - // - // iPhone: (Paraphrased from the UIDevice Class documentation) - // Returns a string of hash values created from multiple hardware identifies. - // It is guaranteed to be unique for every device and can't be tied - // to the user account. - // Windows Phone 7 : Returns a hash of device+current user, - // if the user is not defined, a guid is generated and will persist until the app is uninstalled - // Tizen: returns the device IMEI (International Mobile Equipment Identity or IMEI is a number - // unique to every GSM and UMTS mobile phone. - var deviceID = device.uuid; +```js +// Android: Returns a random 64-bit integer (as a string, again!) +// The integer is generated on the device's first boot +// +// BlackBerry: Returns the PIN number of the device +// This is a nine-digit unique integer (as a string, though!) +// +// iPhone: (Paraphrased from the UIDevice Class documentation) +// Returns the [UIDevice identifierForVendor] UUID which is unique and the same for all apps installed by the same vendor. However the UUID can be different if the user deletes all apps from the vendor and then reinstalls it. +// Windows Phone 7 : Returns a hash of device+current user, +// if the user is not defined, a guid is generated and will persist until the app is uninstalled +// Tizen: returns the device IMEI (International Mobile Equipment Identity or IMEI is a number +// unique to every GSM and UMTS mobile phone. +var deviceID = device.uuid; +``` ### iOS Quirk -The `uuid` on iOS is not unique to a device, but varies for each -application, for each installation. It changes if you delete and -re-install the app, and possibly also when you upgrade iOS, or even -upgrade the app per version (apparent in iOS 5.1). The `uuid` is not -a reliable value. +The `uuid` on iOS uses the identifierForVendor property. It is unique to the device across the same vendor, but will be different for different vendors and will change if all apps from the vendor are deleted and then reinstalled. +Refer [here](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIDevice_Class/#//apple_ref/occ/instp/UIDevice/identifierForVendor) for details. +The UUID will be the same if app is restored from a backup or iCloud as it is saved in preferences. Users using older versions of this plugin will still receive the same previous UUID generated by another means as it will be retrieved from preferences. + +### OSX Quirk + +The `uuid` on OSX is generated automatically if it does not exist yet and is stored in the `standardUserDefaults` in the `CDVUUID` property. ### Windows Phone 7 and 8 Quirks @@ -200,21 +228,84 @@ Get the operating system version. - iOS - Tizen - Windows Phone 7 and 8 -- Windows 8 +- Windows +- OSX + +### Quick Example + +```js +// Android: Froyo OS would return "2.2" +// Eclair OS would return "2.1", "2.0.1", or "2.0" +// Version can also return update level "2.1-update1" +// +// BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600" +// +// Browser: Returns version number for the browser +// +// iPhone: iOS 3.2 returns "3.2" +// +// Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720 +// Windows 8: return the current OS version, ex on Windows 8.1 returns 6.3.9600.16384 +// Tizen: returns "TIZEN_20120425_2" +// OSX: El Capitan would return "10.11.2" +// +var deviceVersion = device.version; +``` + +## device.manufacturer + +Get the device's manufacturer. + + var string = device.manufacturer; + +### Supported Platforms + +- Android +- BlackBerry 10 +- iOS +- Windows Phone 7 and 8 +- Windows ### Quick Example - // Android: Froyo OS would return "2.2" - // Eclair OS would return "2.1", "2.0.1", or "2.0" - // Version can also return update level "2.1-update1" - // - // BlackBerry: Torch 9800 using OS 6.0 would return "6.0.0.600" - // - // Browser: Returns version number for the browser - // - // iPhone: iOS 3.2 returns "3.2" - // - // Windows Phone 7: returns current OS version number, ex. on Mango returns 7.10.7720 - // Tizen: returns "TIZEN_20120425_2" - var deviceVersion = device.version; +```js +// Android: Motorola XT1032 would return "motorola" +// BlackBerry: returns "BlackBerry" +// iPhone: returns "Apple" +// +var deviceManufacturer = device.manufacturer; +``` + +## device.isVirtual + +whether the device is running on a simulator. + +```js +var isSim = device.isVirtual; +``` + +### Supported Platforms + +- Android 2.1+ +- iOS +- Windows Phone 8 +- Windows +- OSX + +### OSX Quirk + +The `isVirtual` property on OS X always returns false. + +## device.serial + +Get the device hardware serial number ([SERIAL](http://developer.android.com/reference/android/os/Build.html#SERIAL)). + +```js +var string = device.serial; +``` + +### Supported Platforms + +- Android +- OSX diff --git a/StoneIsland/plugins/cordova-plugin-device/RELEASENOTES.md b/StoneIsland/plugins/cordova-plugin-device/RELEASENOTES.md index f06fc6b5..4167735b 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-device/RELEASENOTES.md +++ b/StoneIsland/plugins/cordova-plugin-device/RELEASENOTES.md @@ -20,95 +20,129 @@ --> # Release Notes -### 0.2.1 (Sept 5, 2013) -* removed extraneous print statement -* [CB-4432] copyright notice change - -### 0.2.3 (Sept 25, 2013) -* CB-4889 bumping&resetting version -* [windows8] commandProxy has moved -* [BlackBerry10] removed uneeded permission tags in plugin.xml -* CB-4889 renaming org.apache.cordova.core.device to org.apache.cordova.device -* Rename CHANGELOG.md -> RELEASENOTES.md -* updated to use commandProxy for ffos -* add firefoxos support -* [CB-4752] Incremented plugin version on dev branch. - -### 0.2.4 (Oct 28, 2013) -* CB-5128: added repo + issue tag in plugin.xml for device plugin -* CB-5085 device.cordova returning wrong value -* [CB-4915] Incremented plugin version on dev branch. +### 1.1.3 (Sep 08, 2016) +* [CB-11795](https://issues.apache.org/jira/browse/CB-11795) Add 'protective' entry to cordovaDependencies +* Add badges for paramedic builds on Jenkins +* Add pull request template. +* Readme: Add fenced code blocks with langauage hints +* [CB-10996](https://issues.apache.org/jira/browse/CB-10996) Adding front matter to `README.md` -### 0.2.5 (Dec 4, 2013) -* CB-5316 Spell Cordova as a brand unless it's a command or script -* [ubuntu] use cordova/exec/proxy -* add ubuntu platform -* Modify Device.platform logic to use amazon-fireos as the platform for Amazon Devices -* 1. Added amazon-fireos platform. 2. Change to use cordova-amazon-fireos as the platform if user agent contains 'cordova-amazon-fireos' +### 1.1.2 (Apr 15, 2016) +* Use passed device, follow create policy forf `CFUUIDCreate` +* [CB-10631](https://issues.apache.org/jira/browse/CB-10631) Fix for `device.uuid` in **iOS 5.1.1** +* Updating the comment to exclude URL +* [CB-10636](https://issues.apache.org/jira/browse/CB-10636) Add `JSHint` for plugins +* Refactored `deviceInfo` on **iOS** for better readability. -### 0.2.6 (Jan 02, 2014) -* CB-5658 Add doc/index.md for Device plugin -* CB-5504 Moving Telephony Logic out of Device +### 1.1.1 (Jan 15, 2016) +* [CB-10238](https://issues.apache.org/jira/browse/CB-10238) **OSX** Move `device-plugin` out from `cordovalib` to the plugin repository +* [CB-9923](https://issues.apache.org/jira/browse/CB-9923) Update `device.platform` documentation for **Browser** platform -### 0.2.7 (Jan 07, 2014) -* CB-5737 Fix exception on close caused by left over telephony code from CB-5504 +### 1.1.0 (Nov 18, 2015) +* [CB-10035](https://issues.apache.org/jira/browse/CB-10035) Updated `RELEASENOTES` to be newest to oldest +* Add `isVirtual` for **Windows Phone 8.x** +* Added basic **Android** support for hardware serial number +* [CB-9865](https://issues.apache.org/jira/browse/CB-9865) Better simulator detection for **iOS** +* Fixing contribute link. +* Added **WP8** implementation +* update to use `TARGET_OS_SIMULATOR` as `TARGET_IPHONE_SIMULATOR` is deprecated. +* update code to use 'isVirtual' +* create test to verify existence and type of new property 'isVirtual' +* add `isSimulator` for **iOS** & **Android** device +* Updated documentation to mention backwards compatibility +* Updated **README** to reflect new behaviour and quirks on **iOS** +* Check user defaults first to maintain backwards compatibility +* Changed `UUID` to use `[UIDevice identifierForVendor]` -### 0.2.8 (Feb 05, 2014) -* Tizen support added +### 1.0.1 (Jun 17, 2015) +* [CB-9128](https://issues.apache.org/jira/browse/CB-9128) cordova-plugin-device documentation translation: cordova-plugin-device +* Attempts to corrent npm markdown issue -### 0.2.9 (Apr 17, 2014) -* CB-5105: [Android, windows8, WP, BlackBerry10] Removed dead code for device.version -* CB-6422: [windows8] use cordova/exec/proxy -* CB-6460: Update license headers -* Add NOTICE file +### 1.0.0 (Apr 15, 2015) +* [CB-8746](https://issues.apache.org/jira/browse/CB-8746) gave plugin major version bump +* [CB-8683](https://issues.apache.org/jira/browse/CB-8683) changed plugin-id to pacakge-name +* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) properly updated translated docs to use new id +* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) updated translated docs to use new id +* Use TRAVIS_BUILD_DIR, install paramedic by npm +* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) Updated Readme +* remove defunct windows8 version +* add travis badge +* Add cross-plugin ios paramedic test running for TravisCI +* [CB-8538](https://issues.apache.org/jira/browse/CB-8538) Added package.json file -### 0.2.10 (Jun 05, 2014) -* CB-6127 Spanish and French Translations added. Github close #12 -* Changing 1.5 to 2.0 -* added firefoxos version - conversion -* added firefoxos version -* CB-6800 Add license -* CB-6491 add CONTRIBUTING.md +### 0.3.0 (Feb 04, 2015) +* Added device.manufacturer property for Android, iOS, Blackberry, WP8 +* Support for Windows Phone 8 ANID2 ANID is only supported up to Windows Phone 7.5 +* [CB-8351](https://issues.apache.org/jira/browse/CB-8351) Use a local copy of uniqueAppInstanceIdentifier rather than CordovaLib's version +* browser: Fixed a bug that caused an "cannot call method of undefined" error if the browser's user agent wasn't recognized -### 0.2.11 (Aug 06, 2014) -* [FFOS] update DeviceProxy.js -* CB-6127 Updated translations for docs -* Use Windows system calls to get better info +### 0.2.13 (Dec 02, 2014) +* Changing `device.platform` to always report the platform as "browser". +* [CB-5892](https://issues.apache.org/jira/browse/CB-5892) - Remove deprecated `window.Settings` +* [CB-7700](https://issues.apache.org/jira/browse/CB-7700) cordova-plugin-device documentation translation: cordova-plugin-device +* [CB-7571](https://issues.apache.org/jira/browse/CB-7571) Bump version of nested plugin to match parent plugin ### 0.2.12 (Sep 17, 2014) -* CB-7471 cordova-plugin-device documentation translation -* CB-7552 device.name docs have not been removed +* [CB-7471](https://issues.apache.org/jira/browse/CB-7471) cordova-plugin-device documentation translation +* [CB-7552](https://issues.apache.org/jira/browse/CB-7552) device.name docs have not been removed * [fxos] Fix cordova version * added status box and documentation to manual tests * [fxos] Fix cordova version * added status box and documentation to manual tests * Added plugin support for the browser -* CB-7262 Adds support for universal windows apps. +* [CB-7262](https://issues.apache.org/jira/browse/CB-7262) Adds support for universal windows apps. -### 0.2.13 (Dec 02, 2014) -* Changing `device.platform` to always report the platform as "browser". -* CB-5892 - Remove deprecated `window.Settings` -* CB-7700 cordova-plugin-device documentation translation: cordova-plugin-device -* CB-7571 Bump version of nested plugin to match parent plugin +### 0.2.11 (Aug 06, 2014) +* [FFOS] update DeviceProxy.js +* [CB-6127](https://issues.apache.org/jira/browse/CB-6127) Updated translations for docs +* Use Windows system calls to get better info -### 0.3.0 (Feb 04, 2015) -* Added device.manufacturer property for Android, iOS, Blackberry, WP8 -* Support for Windows Phone 8 ANID2 ANID is only supported up to Windows Phone 7.5 -* CB-8351 Use a local copy of uniqueAppInstanceIdentifier rather than CordovaLib's version -* browser: Fixed a bug that caused an "cannot call method of undefined" error if the browser's user agent wasn't recognized +### 0.2.10 (Jun 05, 2014) +* [CB-6127](https://issues.apache.org/jira/browse/CB-6127) Spanish and French Translations added. Github close #12 +* Changing 1.5 to 2.0 +* added firefoxos version - conversion +* added firefoxos version +* [CB-6800](https://issues.apache.org/jira/browse/CB-6800) Add license +* [CB-6491](https://issues.apache.org/jira/browse/CB-6491) add CONTRIBUTING.md -### 1.0.0 (Apr 15, 2015) -* CB-8746 gave plugin major version bump -* CB-8683 changed plugin-id to pacakge-name -* CB-8653 properly updated translated docs to use new id -* CB-8653 updated translated docs to use new id -* Use TRAVIS_BUILD_DIR, install paramedic by npm -* CB-8653 Updated Readme -* remove defunct windows8 version -* add travis badge -* Add cross-plugin ios paramedic test running for TravisCI -* CB-8538 Added package.json file +### 0.2.9 (Apr 17, 2014) +* [CB-5105](https://issues.apache.org/jira/browse/CB-5105): [Android, windows8, WP, BlackBerry10] Removed dead code for device.version +* [CB-6422](https://issues.apache.org/jira/browse/CB-6422): [windows8] use cordova/exec/proxy +* [CB-6460](https://issues.apache.org/jira/browse/CB-6460): Update license headers +* Add NOTICE file -### 1.0.1 (Jun 17, 2015) -* CB-9128 cordova-plugin-device documentation translation: cordova-plugin-device -* Attempts to corrent npm markdown issue +### 0.2.8 (Feb 05, 2014) +* Tizen support added + +### 0.2.7 (Jan 07, 2014) +* [CB-5737](https://issues.apache.org/jira/browse/CB-5737) Fix exception on close caused by left over telephony code from [CB-5504](https://issues.apache.org/jira/browse/CB-5504) + +### 0.2.6 (Jan 02, 2014) +* [CB-5658](https://issues.apache.org/jira/browse/CB-5658) Add doc/index.md for Device plugin +* [CB-5504](https://issues.apache.org/jira/browse/CB-5504) Moving Telephony Logic out of Device + +### 0.2.5 (Dec 4, 2013) +* [CB-5316](https://issues.apache.org/jira/browse/CB-5316) Spell Cordova as a brand unless it's a command or script +* [ubuntu] use cordova/exec/proxy +* add ubuntu platform +* Modify Device.platform logic to use amazon-fireos as the platform for Amazon Devices +* 1. Added amazon-fireos platform. 2. Change to use cordova-amazon-fireos as the platform if user agent contains 'cordova-amazon-fireos' + +### 0.2.4 (Oct 28, 2013) +* [CB-5128](https://issues.apache.org/jira/browse/CB-5128): added repo + issue tag in plugin.xml for device plugin +* [CB-5085](https://issues.apache.org/jira/browse/CB-5085) device.cordova returning wrong value +* [CB-4915](https://issues.apache.org/jira/browse/CB-4915) Incremented plugin version on dev branch. + +### 0.2.3 (Sept 25, 2013) +* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) bumping&resetting version +* [windows8] commandProxy has moved +* [BlackBerry10] removed uneeded permission tags in plugin.xml +* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) renaming org.apache.cordova.core.device to org.apache.cordova.device +* Rename CHANGELOG.md -> RELEASENOTES.md +* updated to use commandProxy for ffos +* add firefoxos support +* [CB-4752](https://issues.apache.org/jira/browse/CB-4752) Incremented plugin version on dev branch. + +### 0.2.1 (Sept 5, 2013) +* removed extraneous print statement +* [CB-4432](https://issues.apache.org/jira/browse/CB-4432) copyright notice change diff --git a/StoneIsland/plugins/cordova-plugin-device/doc/de/README.md b/StoneIsland/plugins/cordova-plugin-device/doc/de/README.md index 81f89e99..81f89e99 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-device/doc/de/README.md +++ b/StoneIsland/plugins/cordova-plugin-device/doc/de/README.md diff --git a/StoneIsland/plugins/cordova-plugin-device/doc/de/index.md b/StoneIsland/plugins/cordova-plugin-device/doc/de/index.md index e3a537ed..e3a537ed 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-device/doc/de/index.md +++ b/StoneIsland/plugins/cordova-plugin-device/doc/de/index.md diff --git a/StoneIsland/plugins/cordova-plugin-device/doc/es/README.md b/StoneIsland/plugins/cordova-plugin-device/doc/es/README.md index a27abfb8..a27abfb8 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-device/doc/es/README.md +++ b/StoneIsland/plugins/cordova-plugin-device/doc/es/README.md diff --git a/StoneIsland/plugins/cordova-plugin-device/doc/es/index.md b/StoneIsland/plugins/cordova-plugin-device/doc/es/index.md index f4a58977..f4a58977 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-device/doc/es/index.md +++ b/StoneIsland/plugins/cordova-plugin-device/doc/es/index.md diff --git a/StoneIsland/plugins/cordova-plugin-device/doc/fr/README.md b/StoneIsland/plugins/cordova-plugin-device/doc/fr/README.md index 4101fd94..4101fd94 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-device/doc/fr/README.md +++ b/StoneIsland/plugins/cordova-plugin-device/doc/fr/README.md diff --git a/StoneIsland/plugins/cordova-plugin-device/doc/fr/index.md b/StoneIsland/plugins/cordova-plugin-device/doc/fr/index.md index 163e498c..163e498c 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-device/doc/fr/index.md +++ b/StoneIsland/plugins/cordova-plugin-device/doc/fr/index.md diff --git a/StoneIsland/plugins/cordova-plugin-device/doc/it/README.md b/StoneIsland/plugins/cordova-plugin-device/doc/it/README.md index 79749626..79749626 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-device/doc/it/README.md +++ b/StoneIsland/plugins/cordova-plugin-device/doc/it/README.md diff --git a/StoneIsland/plugins/cordova-plugin-device/doc/it/index.md b/StoneIsland/plugins/cordova-plugin-device/doc/it/index.md index 98c6200a..98c6200a 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-device/doc/it/index.md +++ b/StoneIsland/plugins/cordova-plugin-device/doc/it/index.md diff --git a/StoneIsland/plugins/cordova-plugin-device/doc/ja/README.md b/StoneIsland/plugins/cordova-plugin-device/doc/ja/README.md index 5a345f87..5a345f87 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-device/doc/ja/README.md +++ b/StoneIsland/plugins/cordova-plugin-device/doc/ja/README.md diff --git a/StoneIsland/plugins/cordova-plugin-device/doc/ja/index.md b/StoneIsland/plugins/cordova-plugin-device/doc/ja/index.md index b4030fd0..b4030fd0 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-device/doc/ja/index.md +++ b/StoneIsland/plugins/cordova-plugin-device/doc/ja/index.md diff --git a/StoneIsland/plugins/cordova-plugin-device/doc/ko/README.md b/StoneIsland/plugins/cordova-plugin-device/doc/ko/README.md index a818aacb..a818aacb 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-device/doc/ko/README.md +++ b/StoneIsland/plugins/cordova-plugin-device/doc/ko/README.md diff --git a/StoneIsland/plugins/cordova-plugin-device/doc/ko/index.md b/StoneIsland/plugins/cordova-plugin-device/doc/ko/index.md index 0fe38a7a..0fe38a7a 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-device/doc/ko/index.md +++ b/StoneIsland/plugins/cordova-plugin-device/doc/ko/index.md diff --git a/StoneIsland/plugins/cordova-plugin-device/doc/pl/README.md b/StoneIsland/plugins/cordova-plugin-device/doc/pl/README.md index c38832df..c38832df 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-device/doc/pl/README.md +++ b/StoneIsland/plugins/cordova-plugin-device/doc/pl/README.md diff --git a/StoneIsland/plugins/cordova-plugin-device/doc/pl/index.md b/StoneIsland/plugins/cordova-plugin-device/doc/pl/index.md index acc8f9c8..acc8f9c8 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-device/doc/pl/index.md +++ b/StoneIsland/plugins/cordova-plugin-device/doc/pl/index.md diff --git a/StoneIsland/plugins/cordova-plugin-device/doc/ru/index.md b/StoneIsland/plugins/cordova-plugin-device/doc/ru/index.md index 263b1cd9..263b1cd9 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-device/doc/ru/index.md +++ b/StoneIsland/plugins/cordova-plugin-device/doc/ru/index.md diff --git a/StoneIsland/plugins/cordova-plugin-device/doc/zh/README.md b/StoneIsland/plugins/cordova-plugin-device/doc/zh/README.md index 9a18a55e..9a18a55e 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-device/doc/zh/README.md +++ b/StoneIsland/plugins/cordova-plugin-device/doc/zh/README.md diff --git a/StoneIsland/plugins/cordova-plugin-device/doc/zh/index.md b/StoneIsland/plugins/cordova-plugin-device/doc/zh/index.md index 5626d696..5626d696 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-device/doc/zh/index.md +++ b/StoneIsland/plugins/cordova-plugin-device/doc/zh/index.md diff --git a/StoneIsland/plugins/cordova-plugin-device/package.json b/StoneIsland/plugins/cordova-plugin-device/package.json index 388b81d5..1357f229 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-device/package.json +++ b/StoneIsland/plugins/cordova-plugin-device/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-device", - "version": "1.0.1", + "version": "1.1.3", "description": "Cordova Device Plugin", "cordova": { "id": "cordova-plugin-device", @@ -16,7 +16,8 @@ "wp8", "windows8", "windows", - "browser" + "browser", + "osx" ] }, "repository": { @@ -38,8 +39,23 @@ "cordova-wp8", "cordova-windows8", "cordova-windows", - "cordova-browser" + "cordova-browser", + "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" + }, "author": "Apache Software Foundation", - "license": "Apache 2.0" + "license": "Apache-2.0", + "engines": { + "cordovaDependencies": { + "2.0.0": { + "cordova": ">100" + } + } + }, + "devDependencies": { + "jshint": "^2.6.0" + } } diff --git a/StoneIsland/plugins/cordova-plugin-device/plugin.xml b/StoneIsland/plugins/cordova-plugin-device/plugin.xml index 172cff23..7d041252 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-device/plugin.xml +++ b/StoneIsland/plugins/cordova-plugin-device/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.0.1"> + version="1.1.3"> <name>Device</name> <description>Cordova Device Plugin</description> <license>Apache 2.0</license> @@ -158,4 +158,17 @@ </js-module> </platform> + <!-- osx --> + <platform name="osx"> + <config-file target="config.xml" parent="/*"> + <feature name="Device"> + <param name="ios-package" value="CDVDevice"/> + </feature> + </config-file> + + <header-file src="src/osx/CDVDevice.h" /> + <source-file src="src/osx/CDVDevice.m" /> + </platform> + + </plugin> diff --git a/StoneIsland/plugins/cordova-plugin-device/src/android/Device.java b/StoneIsland/plugins/cordova-plugin-device/src/android/Device.java index 5eded907..e9efcb49 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-device/src/android/Device.java +++ b/StoneIsland/plugins/cordova-plugin-device/src/android/Device.java @@ -67,13 +67,15 @@ public class Device extends CordovaPlugin { * @return True if the action was valid, false if not. */ public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { - if (action.equals("getDeviceInfo")) { + if ("getDeviceInfo".equals(action)) { JSONObject r = new JSONObject(); r.put("uuid", Device.uuid); r.put("version", this.getOSVersion()); r.put("platform", this.getPlatform()); r.put("model", this.getModel()); r.put("manufacturer", this.getManufacturer()); + r.put("isVirtual", this.isVirtual()); + r.put("serial", this.getSerialNumber()); callbackContext.success(r); } else { @@ -88,7 +90,7 @@ public class Device extends CordovaPlugin { /** * Get the OS name. - * + * * @return */ public String getPlatform() { @@ -125,6 +127,12 @@ public class Device extends CordovaPlugin { String manufacturer = android.os.Build.MANUFACTURER; return manufacturer; } + + public String getSerialNumber() { + String serial = android.os.Build.SERIAL; + return serial; + } + /** * Get the OS version. * @@ -148,7 +156,7 @@ public class Device extends CordovaPlugin { /** * Function to check if the device is manufactured by Amazon - * + * * @return */ public boolean isAmazonDevice() { @@ -158,4 +166,9 @@ public class Device extends CordovaPlugin { return false; } + public boolean isVirtual() { + return android.os.Build.FINGERPRINT.contains("generic") || + android.os.Build.PRODUCT.contains("sdk"); + } + } diff --git a/StoneIsland/plugins/cordova-plugin-device/src/blackberry10/index.js b/StoneIsland/plugins/cordova-plugin-device/src/blackberry10/index.js index 77f25a9e..ef0543bc 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-device/src/blackberry10/index.js +++ b/StoneIsland/plugins/cordova-plugin-device/src/blackberry10/index.js @@ -19,6 +19,8 @@ * */ +/* global PluginResult */ + function getModelName () { var modelName = window.qnx.webplatform.device.modelName; //Pre 10.2 (meaning Z10 or Q10) diff --git a/StoneIsland/plugins/cordova-plugin-device/src/browser/DeviceProxy.js b/StoneIsland/plugins/cordova-plugin-device/src/browser/DeviceProxy.js index fcaed20c..a8632016 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-device/src/browser/DeviceProxy.js +++ b/StoneIsland/plugins/cordova-plugin-device/src/browser/DeviceProxy.js @@ -19,7 +19,6 @@ * */ var browser = require('cordova/platform'); -var cordova = require('cordova'); function getPlatform() { return "browser"; @@ -36,6 +35,7 @@ function getVersion() { function getBrowserInfo(getModel) { var userAgent = navigator.userAgent; var returnVal = ''; + var offset; if ((offset = userAgent.indexOf('Chrome')) !== -1) { returnVal = (getModel) ? 'Chrome' : userAgent.substring(offset + 7); diff --git a/StoneIsland/plugins/cordova-plugin-device/src/firefoxos/DeviceProxy.js b/StoneIsland/plugins/cordova-plugin-device/src/firefoxos/DeviceProxy.js index 79f3a2b0..a05d7ca0 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-device/src/firefoxos/DeviceProxy.js +++ b/StoneIsland/plugins/cordova-plugin-device/src/firefoxos/DeviceProxy.js @@ -20,8 +20,6 @@ */ //example UA String for Firefox OS //Mozilla/5.0 (Mobile; rv:26.0) Gecko/26.0 Firefox/26.0 -var firefoxos = require('cordova/platform'); -var cordova = require('cordova'); //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 diff --git a/StoneIsland/plugins/cordova-plugin-device/src/ios/CDVDevice.h b/StoneIsland/plugins/cordova-plugin-device/src/ios/CDVDevice.h index a146d882..a146d882 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-device/src/ios/CDVDevice.h +++ b/StoneIsland/plugins/cordova-plugin-device/src/ios/CDVDevice.h diff --git a/StoneIsland/plugins/cordova-plugin-device/src/ios/CDVDevice.m b/StoneIsland/plugins/cordova-plugin-device/src/ios/CDVDevice.m index 5a3f4708..4d75a574 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-device/src/ios/CDVDevice.m +++ b/StoneIsland/plugins/cordova-plugin-device/src/ios/CDVDevice.m @@ -19,6 +19,7 @@ #include <sys/types.h> #include <sys/sysctl.h> +#include "TargetConditionals.h" #import <Cordova/CDV.h> #import "CDVDevice.h" @@ -49,21 +50,23 @@ { NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults]; static NSString* UUID_KEY = @"CDVUUID"; - + + // Check user defaults first to maintain backwards compaitibility with previous versions + // which didn't user identifierForVendor NSString* app_uuid = [userDefaults stringForKey:UUID_KEY]; - if (app_uuid == nil) { - CFUUIDRef uuidRef = CFUUIDCreate(kCFAllocatorDefault); - CFStringRef uuidString = CFUUIDCreateString(kCFAllocatorDefault, uuidRef); + if ([device respondsToSelector:@selector(identifierForVendor)]) { + app_uuid = [[device identifierForVendor] UUIDString]; + } else { + CFUUIDRef uuid = CFUUIDCreate(NULL); + app_uuid = (__bridge_transfer NSString *)CFUUIDCreateString(NULL, uuid); + CFRelease(uuid); + } - app_uuid = [NSString stringWithString:(__bridge NSString*)uuidString]; [userDefaults setObject:app_uuid forKey:UUID_KEY]; [userDefaults synchronize]; - - CFRelease(uuidString); - CFRelease(uuidRef); } - + return app_uuid; } @@ -78,17 +81,16 @@ - (NSDictionary*)deviceProperties { UIDevice* device = [UIDevice currentDevice]; - NSMutableDictionary* devProps = [NSMutableDictionary dictionaryWithCapacity:4]; - [devProps setObject:@"Apple" forKey:@"manufacturer"]; - [devProps setObject:[device modelVersion] forKey:@"model"]; - [devProps setObject:@"iOS" forKey:@"platform"]; - [devProps setObject:[device systemVersion] forKey:@"version"]; - [devProps setObject:[self uniqueAppInstanceIdentifier:device] forKey:@"uuid"]; - [devProps setObject:[[self class] cordovaVersion] forKey:@"cordova"]; - - NSDictionary* devReturn = [NSDictionary dictionaryWithDictionary:devProps]; - return devReturn; + return @{ + @"manufacturer": @"Apple", + @"model": [device modelVersion], + @"platform": @"iOS", + @"version": [device systemVersion], + @"uuid": [self uniqueAppInstanceIdentifier:device], + @"cordova": [[self class] cordovaVersion], + @"isVirtual": @([self isVirtual]) + }; } + (NSString*)cordovaVersion @@ -96,4 +98,15 @@ return CDV_VERSION; } +- (BOOL)isVirtual +{ + #if TARGET_OS_SIMULATOR + return true; + #elif TARGET_IPHONE_SIMULATOR + return true; + #else + return false; + #endif +} + @end diff --git a/StoneIsland/plugins/cordova-plugin-device/src/osx/CDVDevice.h b/StoneIsland/plugins/cordova-plugin-device/src/osx/CDVDevice.h new file mode 100644 index 00000000..9def2548 --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-device/src/osx/CDVDevice.h @@ -0,0 +1,28 @@ +/* + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + */ + +#import <Cordova/CDVPlugin.h> + +@interface CDVDevice : CDVPlugin + ++ (NSString*) cordovaVersion; + +- (void) getDeviceInfo:(CDVInvokedUrlCommand*)command; + +@end diff --git a/StoneIsland/plugins/cordova-plugin-device/src/osx/CDVDevice.m b/StoneIsland/plugins/cordova-plugin-device/src/osx/CDVDevice.m new file mode 100644 index 00000000..3a63588f --- /dev/null +++ b/StoneIsland/plugins/cordova-plugin-device/src/osx/CDVDevice.m @@ -0,0 +1,113 @@ +/* + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + */ + +#include <sys/sysctl.h> + +#import "CDVDevice.h" + +#define SYSTEM_VERSION_PLIST @"/System/Library/CoreServices/SystemVersion.plist" + +@implementation CDVDevice + +- (NSString*) modelVersion { + size_t size; + + sysctlbyname("hw.machine", NULL, &size, NULL, 0); + char* machine = malloc(size); + sysctlbyname("hw.machine", machine, &size, NULL, 0); + NSString* modelVersion = [NSString stringWithUTF8String:machine]; + free(machine); + + return modelVersion; +} + + +- (NSString*) getSerialNr { + NSString* serialNr; + io_service_t platformExpert = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IOPlatformExpertDevice")); + if (platformExpert) { + CFTypeRef serialNumberAsCFString = + IORegistryEntryCreateCFProperty(platformExpert, + CFSTR(kIOPlatformSerialNumberKey), + kCFAllocatorDefault, 0); + if (serialNumberAsCFString) { + serialNr = (__bridge NSString*) serialNumberAsCFString; + } + IOObjectRelease(platformExpert); + } + return serialNr; +} + +- (NSString*) uniqueAppInstanceIdentifier { + NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults]; + static NSString* UUID_KEY = @"CDVUUID"; + + NSString* app_uuid = [userDefaults stringForKey:UUID_KEY]; + + if (app_uuid == nil) { + CFUUIDRef uuidRef = CFUUIDCreate(kCFAllocatorDefault); + CFStringRef uuidString = CFUUIDCreateString(kCFAllocatorDefault, uuidRef); + + app_uuid = [NSString stringWithString:(__bridge NSString*) uuidString]; + [userDefaults setObject:app_uuid forKey:UUID_KEY]; + [userDefaults synchronize]; + + CFRelease(uuidString); + CFRelease(uuidRef); + } + + return app_uuid; +} + +- (NSString*) platform { + return [NSDictionary dictionaryWithContentsOfFile:SYSTEM_VERSION_PLIST][@"ProductName"]; +} + +- (NSString*) systemVersion { + return [NSDictionary dictionaryWithContentsOfFile:SYSTEM_VERSION_PLIST][@"ProductVersion"]; +} + +- (void) getDeviceInfo:(CDVInvokedUrlCommand*) command { + NSDictionary* deviceProperties = [self deviceProperties]; + CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:deviceProperties]; + + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; +} + +- (NSDictionary*) deviceProperties { + NSMutableDictionary* devProps = [NSMutableDictionary dictionaryWithCapacity:4]; + + devProps[@"manufacturer"] = @"Apple"; + devProps[@"model"] = [self modelVersion]; + devProps[@"platform"] = [self platform]; + devProps[@"version"] = [self systemVersion]; + devProps[@"uuid"] = [self uniqueAppInstanceIdentifier]; + devProps[@"cordova"] = [[self class] cordovaVersion]; + devProps[@"serial"] = [self getSerialNr]; + devProps[@"isVirtual"] = @NO; + + NSDictionary* devReturn = [NSDictionary dictionaryWithDictionary:devProps]; + return devReturn; +} + ++ (NSString*) cordovaVersion { + return CDV_VERSION; +} + +@end diff --git a/StoneIsland/plugins/cordova-plugin-device/src/tizen/DeviceProxy.js b/StoneIsland/plugins/cordova-plugin-device/src/tizen/DeviceProxy.js index 2afc3243..973b7162 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-device/src/tizen/DeviceProxy.js +++ b/StoneIsland/plugins/cordova-plugin-device/src/tizen/DeviceProxy.js @@ -20,7 +20,6 @@ */ var tizen = require('cordova/platform'); -var cordova = require('cordova'); module.exports = { getDeviceInfo: function(success, error) { diff --git a/StoneIsland/plugins/cordova-plugin-device/src/ubuntu/device.cpp b/StoneIsland/plugins/cordova-plugin-device/src/ubuntu/device.cpp index eb5a012d..eb5a012d 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-device/src/ubuntu/device.cpp +++ b/StoneIsland/plugins/cordova-plugin-device/src/ubuntu/device.cpp diff --git a/StoneIsland/plugins/cordova-plugin-device/src/ubuntu/device.h b/StoneIsland/plugins/cordova-plugin-device/src/ubuntu/device.h index 91cb9377..91cb9377 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-device/src/ubuntu/device.h +++ b/StoneIsland/plugins/cordova-plugin-device/src/ubuntu/device.h diff --git a/StoneIsland/plugins/cordova-plugin-device/src/ubuntu/device.js b/StoneIsland/plugins/cordova-plugin-device/src/ubuntu/device.js index 3adb110b..838586c3 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-device/src/ubuntu/device.js +++ b/StoneIsland/plugins/cordova-plugin-device/src/ubuntu/device.js @@ -19,8 +19,7 @@ * */ -var cordova = require('cordova'); -var exec = require('cordova/exec'); +/* global Cordova */ module.exports = { getInfo:function(win,fail,args) { diff --git a/StoneIsland/plugins/cordova-plugin-device/src/windows/DeviceProxy.js b/StoneIsland/plugins/cordova-plugin-device/src/windows/DeviceProxy.js index 69ed4446..f338ad3a 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-device/src/windows/DeviceProxy.js +++ b/StoneIsland/plugins/cordova-plugin-device/src/windows/DeviceProxy.js @@ -19,13 +19,14 @@ * */ +/* 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 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 MANU_KEY = "System.Devices.Manufacturer"; module.exports = { @@ -33,8 +34,6 @@ module.exports = { // deviceId aka uuid, stored in Windows.Storage.ApplicationData.current.localSettings.values.deviceId var deviceId; - var manufacturer = "unknown"; - // get deviceId, or create and store one var localSettings = Windows.Storage.ApplicationData.current.localSettings; if (localSettings.values.deviceId) { @@ -55,51 +54,42 @@ module.exports = { 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 + // 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 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 manufacturer = deviceInfo.systemManufacturer; + var model = deviceInfo.systemProductName; var Pnp = Windows.Devices.Enumeration.Pnp; - Pnp.PnpObject.findAllAsync(Pnp.PnpObjectType.deviceContainer,[MANU_KEY]) - .then(function (infoList) { - var numDevices = infoList.length; - if (numDevices) { - for (var i = 0; i < numDevices; i++) { - var devContainer = infoList[i]; - if (devContainer.id == ROOT_CONTAINER) { - manufacturer = devContainer.properties[MANU_KEY]; + Pnp.PnpObject.findAllAsync(Pnp.PnpObjectType.device, + [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; } } - } - }) - .then(function () { - Pnp.PnpObject.findAllAsync(Pnp.PnpObjectType.device, - [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; - } - } - setTimeout(function () { - win({ platform: devicePlatform, - version: versionString, - uuid: deviceId, - model: window.clientInformation.platform, - manufacturer:manufacturer}); - }, 0); - }); + setTimeout(function () { + win({ platform: devicePlatform, + version: versionString, + uuid: deviceId, + isVirtual: isVirtual, + model: model, + manufacturer:manufacturer}); + }, 0); }); } diff --git a/StoneIsland/plugins/cordova-plugin-device/src/wp/Device.cs b/StoneIsland/plugins/cordova-plugin-device/src/wp/Device.cs index 897a35af..76fe8cf2 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-device/src/wp/Device.cs +++ b/StoneIsland/plugins/cordova-plugin-device/src/wp/Device.cs @@ -1,32 +1,21 @@ /* - Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ -using System; -using System.Net; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Documents; -using System.Windows.Ink; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Animation; -using System.Windows.Shapes; using Microsoft.Phone.Info; -using System.IO.IsolatedStorage; -using System.Windows.Resources; +using System; using System.IO; -using System.Diagnostics; +using System.IO.IsolatedStorage; namespace WPCordovaClassLib.Cordova.Commands { @@ -34,55 +23,27 @@ namespace WPCordovaClassLib.Cordova.Commands { public void getDeviceInfo(string notused) { - - string res = String.Format("\"name\":\"{0}\",\"platform\":\"{1}\",\"uuid\":\"{2}\",\"version\":\"{3}\",\"model\":\"{4}\",\"manufacturer\":\"{5}\"", - this.name, - this.platform, - this.uuid, - this.version, - this.model, - this.manufacturer); - - res = "{" + res + "}"; - //Debug.WriteLine("Result::" + res); - DispatchCommandResult(new PluginResult(PluginResult.Status.OK, res)); + string res = String.Format("\"name\":\"{0}\",\"platform\":\"{1}\",\"uuid\":\"{2}\",\"version\":\"{3}\",\"model\":\"{4}\",\"manufacturer\":\"{5}\",\"isVirtual\":{6}", + DeviceStatus.DeviceName, + Environment.OSVersion.Platform.ToString(), + UUID, + Environment.OSVersion.Version.ToString(), + DeviceStatus.DeviceName, + DeviceStatus.DeviceManufacturer, + IsVirtual ? "true" : "false"); + DispatchCommandResult(new PluginResult(PluginResult.Status.OK, "{" + res + "}")); } - public string model - { - get - { - return DeviceStatus.DeviceName; - //return String.Format("{0},{1},{2}", DeviceStatus.DeviceManufacturer, DeviceStatus.DeviceHardwareVersion, DeviceStatus.DeviceFirmwareVersion); - } - } - public string manufacturer + public bool IsVirtual { - get + get { - return DeviceStatus.DeviceManufacturer; + return (Microsoft.Devices.Environment.DeviceType == Microsoft.Devices.DeviceType.Emulator); } } - public string name - { - get - { - return DeviceStatus.DeviceName; - - } - } - - public string platform - { - get - { - return Environment.OSVersion.Platform.ToString(); - } - } - - public string uuid + public string UUID { get { @@ -122,14 +83,5 @@ namespace WPCordovaClassLib.Cordova.Commands return returnVal; } } - - public string version - { - get - { - return Environment.OSVersion.Version.ToString(); - } - } - } } diff --git a/StoneIsland/plugins/cordova-plugin-device/tests/plugin.xml b/StoneIsland/plugins/cordova-plugin-device/tests/plugin.xml index bcca190e..ad4433c9 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-device/tests/plugin.xml +++ b/StoneIsland/plugins/cordova-plugin-device/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.0.1"> + version="1.1.3"> <name>Cordova Device Plugin Tests</name> <license>Apache 2.0</license> diff --git a/StoneIsland/plugins/cordova-plugin-device/tests/tests.js b/StoneIsland/plugins/cordova-plugin-device/tests/tests.js index 1f49d7e1..ac9a2810 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-device/tests/tests.js +++ b/StoneIsland/plugins/cordova-plugin-device/tests/tests.js @@ -19,6 +19,8 @@ * */ +/* jshint jasmine: true */ + exports.defineAutoTests = function() { describe('Device Information (window.device)', function () { it("should exist", function() { @@ -27,18 +29,18 @@ exports.defineAutoTests = function() { it("should contain a platform specification that is a string", function() { expect(window.device.platform).toBeDefined(); - expect((new String(window.device.platform)).length > 0).toBe(true); + 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((new String(window.device.version)).length > 0).toBe(true); + 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((new String(window.device.uuid)).length > 0).toBe(true); + expect((String(window.device.uuid)).length > 0).toBe(true); } else { expect(window.device.uuid > 0).toBe(true); } @@ -46,12 +48,12 @@ exports.defineAutoTests = function() { it("should contain a cordova specification that is a string", function() { expect(window.device.cordova).toBeDefined(); - expect((new String(window.device.cordova)).length > 0).toBe(true); + 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((new String(window.cordova.version)).length > 0).toBe(true); + expect((String(window.cordova.version)).length > 0).toBe(true); }); it("should contain device.cordova equal to cordova.version", function() { @@ -60,18 +62,30 @@ exports.defineAutoTests = function() { it("should contain a model specification that is a string", function() { expect(window.device.model).toBeDefined(); - expect((new String(window.device.model)).length > 0).toBe(true); + 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((new String(window.device.manufacturer)).length > 0).toBe(true); + 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) { - var logMessage = function (message, color) { + var logMessage = function (message, color) { var log = document.getElementById('info'); var logLine = document.createElement('div'); if (color) { @@ -79,12 +93,12 @@ exports.defineManualTests = function(contentEl, createActionButton) { } logLine.innerHTML = message; log.appendChild(logLine); - } + }; var clearLog = function () { var log = document.getElementById('info'); log.innerHTML = ''; - } + }; var device_tests = '<h3>Press Dump Device button to get device information</h3>' + '<div id="dump_device"></div>' + diff --git a/StoneIsland/plugins/cordova-plugin-device/www/device.js b/StoneIsland/plugins/cordova-plugin-device/www/device.js index b1d0d25d..f7ed19f9 100755..100644 --- a/StoneIsland/plugins/cordova-plugin-device/www/device.js +++ b/StoneIsland/plugins/cordova-plugin-device/www/device.js @@ -42,6 +42,8 @@ function Device() { this.cordova = null; this.model = null; this.manufacturer = null; + this.isVirtual = null; + this.serial = null; var me = this; @@ -56,7 +58,9 @@ function Device() { me.uuid = info.uuid; me.cordova = buildLabel; me.model = info.model; + me.isVirtual = info.isVirtual; me.manufacturer = info.manufacturer || 'unknown'; + me.serial = info.serial || 'unknown'; channel.onCordovaInfoReady.fire(); },function(e) { me.available = false; |
