You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2014/06/17 20:29:41 UTC

[1/2] git commit: Use Windows system calls to get better info

Repository: cordova-plugin-device
Updated Branches:
  refs/heads/master 64751b490 -> 34664d6a9


Use Windows system calls to get better info

Use the hardware GUID as a basis for the device uuid (to persist between reinstalls)
Look at the HAL device driver version to work out what version of Windows we're actually running on (because running a Win8 app on Win8.1 will report as if it's still running on Win8)

Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/commit/878a314a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/tree/878a314a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/diff/878a314a

Branch: refs/heads/master
Commit: 878a314a84a7280e5c155bbebea13dd97f47e514
Parents: a9944dc
Author: Eion Robb <ei...@robbmob.com>
Authored: Thu May 1 12:22:01 2014 +1200
Committer: Eion Robb <ei...@robbmob.com>
Committed: Thu May 1 12:22:01 2014 +1200

----------------------------------------------------------------------
 src/windows8/DeviceProxy.js | 52 ++++++++++++++++++++++++++++++++--------
 1 file changed, 42 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/blob/878a314a/src/windows8/DeviceProxy.js
----------------------------------------------------------------------
diff --git a/src/windows8/DeviceProxy.js b/src/windows8/DeviceProxy.js
index 3a2aed3..3ddc9b2 100644
--- a/src/windows8/DeviceProxy.js
+++ b/src/windows8/DeviceProxy.js
@@ -32,16 +32,48 @@ module.exports = {
 
         var localSettings = Windows.Storage.ApplicationData.current.localSettings;
 
-        if (localSettings.values.deviceId) {
-            deviceId = localSettings.values.deviceId;
-        }
-        else {
-            deviceId = localSettings.values.deviceId = utils.createUUID();
-        }
-
-        setTimeout(function () {
-            win({ platform: "windows8", version: "8", uuid: deviceId, model: window.clientInformation.platform });
-        }, 0);
+	    if (localSettings.values.deviceId) {
+	    	deviceId = localSettings.values.deviceId;
+	    }
+	    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;
+    			deviceId = Windows.Storage.Streams.DataReader.fromBuffer(ASHWID).readGuid();
+    		} catch (e) {
+    			// Couldn't get the hardware UUID
+    			deviceId = createUUID();
+    		}
+    		//...so cache it per-install
+    		localSettings.values.deviceId = deviceId;
+    	}
+    	
+    	var versionString = window.clientInformation.userAgent.match(/Windows NT ([0-9.]+)/)[1];
+    	
+    	(function(self){
+    		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 pnpObject = Windows.Devices.Enumeration.Pnp.PnpObject;
+    		pnpObject.findAllAsync(Windows.Devices.Enumeration.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: "windows8", version: versionString, uuid: deviceId, model: window.clientInformation.platform });
+                }, 0);
+    		});
+    	})(this);
     }
 
 };


[2/2] git commit: Merge branch 'patch-1' of https://github.com/EionRobb/cordova-plugin-device

Posted by pu...@apache.org.
Merge branch 'patch-1' of https://github.com/EionRobb/cordova-plugin-device


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/commit/34664d6a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/tree/34664d6a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/diff/34664d6a

Branch: refs/heads/master
Commit: 34664d6a9af166f1edb45c83f81a61782f7f3dcf
Parents: 64751b4 878a314
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Tue Jun 17 11:29:59 2014 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Tue Jun 17 11:29:59 2014 -0700

----------------------------------------------------------------------
 src/windows8/DeviceProxy.js | 52 ++++++++++++++++++++++++++++++++--------
 1 file changed, 42 insertions(+), 10 deletions(-)
----------------------------------------------------------------------