cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lorinb...@apache.org
Subject [20/50] [abbrv] webworks commit: Modifying device to account for API not existing on older versions of the OS and for errors with missing properties.
Date Tue, 07 May 2013 15:14:07 GMT
Modifying device to account for API not existing on older versions of the OS
and for errors with missing properties.

Reviewed by Bryan Higgins <bhiggins@blackberry.com>
Tested by Tracy Li <tli@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/0d591024
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/0d591024
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/0d591024

Branch: refs/heads/future
Commit: 0d591024cab242cdfe4fb9797585dd68ac174465
Parents: 2fa00c4
Author: Jeffrey Heifetz <jheifetz@blackberry.com>
Authored: Thu Apr 11 11:28:02 2013 -0400
Committer: Bryan Higgins <bhiggins@blackberry.com>
Committed: Fri May 3 10:13:30 2013 -0400

----------------------------------------------------------------------
 .../bin/templates/project/plugins/Device/index.js  |   36 +++++++++++++-
 1 files changed, 33 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/0d591024/blackberry10/bin/templates/project/plugins/Device/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Device/index.js b/blackberry10/bin/templates/project/plugins/Device/index.js
index 41b454c..f4849f5 100644
--- a/blackberry10/bin/templates/project/plugins/Device/index.js
+++ b/blackberry10/bin/templates/project/plugins/Device/index.js
@@ -14,15 +14,45 @@
  * limitations under the License.
  */
 
+function getModelName () {
+    var modelName = window.qnx.webplatform.device.modelName;
+    //Pre 10.2 (meaning Z10 or Q10)
+    if (typeof modelName === "undefined") {
+        if (window.screen.height === 720 && window.screen.width === 720) {
+            modelName = "Q10";
+        } else if ((window.screen.height === 1280 && window.screen.width === 768)
||
+                   (window.screen.height === 768 && window.screen.width === 1280))
{
+            modelName = "Z10";
+        } else {
+            modelName = window.qnx.webplatform.deviceName;
+        }
+    }
+
+    return modelName;
+}
+
+function getUUID () {
+    var uuid = "";
+    try {
+        //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
+    }
+    return uuid;
+}
+
 module.exports = {
     getDeviceInfo: function (success, fail, args, env) {
         var result = new PluginResult(args, env),
+            modelName = getModelName(),
+            uuid = getUUID(),
             info = {
                 platform: "blackberry10",
                 version: window.qnx.webplatform.device.scmBundle,
-                model: window.qnx.webplatform.device.modelName,
-                name: window.qnx.webplatform.device.modelName, // deprecated: please use
device.model
-                uuid: window.qnx.webplatform.device.devicePin,
+                model: modelName,
+                name: modelName, // deprecated: please use device.model
+                uuid: uuid,
                 cordova: "2.5.0"
             };
         result.ok(info);


Mime
View raw message