summaryrefslogtreecommitdiff
path: root/StoneIsland/plugins/cordova-plugin-device/src
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2016-11-08 12:37:03 -0500
committerJules Laplace <jules@okfoc.us>2016-11-08 12:37:03 -0500
commitef4f212fc1482136dba1e690ec589b315b4a377f (patch)
tree0b7e16d72567fafcfd3e08d7c5c591ad07a63458 /StoneIsland/plugins/cordova-plugin-device/src
parent5fa81da81260d65113f57a293b6256d334fe8e2d (diff)
build 0.7.0
Diffstat (limited to 'StoneIsland/plugins/cordova-plugin-device/src')
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-device/src/android/Device.java19
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-device/src/blackberry10/index.js2
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-device/src/browser/DeviceProxy.js2
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-device/src/firefoxos/DeviceProxy.js2
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-device/src/ios/CDVDevice.h0
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-device/src/ios/CDVDevice.m51
-rw-r--r--StoneIsland/plugins/cordova-plugin-device/src/osx/CDVDevice.h28
-rw-r--r--StoneIsland/plugins/cordova-plugin-device/src/osx/CDVDevice.m113
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-device/src/tizen/DeviceProxy.js1
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-device/src/ubuntu/device.cpp0
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-device/src/ubuntu/device.h0
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-device/src/ubuntu/device.js3
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-device/src/windows/DeviceProxy.js68
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-device/src/wp/Device.cs100
14 files changed, 248 insertions, 141 deletions
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();
- }
- }
-
}
}