Touchgui/plugins/org.apache.cordova.device/src/blackberry10/index.js

changeset 0
e8ccd40d0ef6
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/Touchgui/plugins/org.apache.cordova.device/src/blackberry10/index.js	Thu Jun 04 14:50:33 2015 +0200
     1.3 @@ -0,0 +1,68 @@
     1.4 +/*
     1.5 + *
     1.6 + * Licensed to the Apache Software Foundation (ASF) under one
     1.7 + * or more contributor license agreements.  See the NOTICE file
     1.8 + * distributed with this work for additional information
     1.9 + * regarding copyright ownership.  The ASF licenses this file
    1.10 + * to you under the Apache License, Version 2.0 (the
    1.11 + * "License"); you may not use this file except in compliance
    1.12 + * with the License.  You may obtain a copy of the License at
    1.13 + *
    1.14 + *   http://www.apache.org/licenses/LICENSE-2.0
    1.15 + *
    1.16 + * Unless required by applicable law or agreed to in writing,
    1.17 + * software distributed under the License is distributed on an
    1.18 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    1.19 + * KIND, either express or implied.  See the License for the
    1.20 + * specific language governing permissions and limitations
    1.21 + * under the License.
    1.22 + *
    1.23 +*/
    1.24 +
    1.25 +function getModelName () {
    1.26 +    var modelName = window.qnx.webplatform.device.modelName;
    1.27 +    //Pre 10.2 (meaning Z10 or Q10)
    1.28 +    if (typeof modelName === "undefined") {
    1.29 +        if (window.screen.height === 720 && window.screen.width === 720) {
    1.30 +            if ( window.matchMedia("(-blackberry-display-technology: -blackberry-display-oled)").matches) {
    1.31 +                modelName = "Q10";
    1.32 +            } else {
    1.33 +                modelName = "Q5";
    1.34 +            }
    1.35 +        } else if ((window.screen.height === 1280 && window.screen.width === 768) ||
    1.36 +                   (window.screen.height === 768 && window.screen.width === 1280)) {
    1.37 +            modelName = "Z10";
    1.38 +        } else {
    1.39 +            modelName = window.qnx.webplatform.deviceName;
    1.40 +        }
    1.41 +    }
    1.42 +
    1.43 +    return modelName;
    1.44 +}
    1.45 +
    1.46 +function getUUID () {
    1.47 +    var uuid = "";
    1.48 +    try {
    1.49 +        //Must surround by try catch because this will throw if the app is missing permissions
    1.50 +        uuid = window.qnx.webplatform.device.devicePin;
    1.51 +    } catch (e) {
    1.52 +        //DO Nothing
    1.53 +    }
    1.54 +    return uuid;
    1.55 +}
    1.56 +
    1.57 +module.exports = {
    1.58 +    getDeviceInfo: function (success, fail, args, env) {
    1.59 +        var result = new PluginResult(args, env),
    1.60 +            modelName = getModelName(),
    1.61 +            uuid = getUUID(),
    1.62 +            info = {
    1.63 +                platform: "blackberry10",
    1.64 +                version: window.qnx.webplatform.device.scmBundle,
    1.65 +                model: modelName,
    1.66 +                uuid: uuid
    1.67 +            };
    1.68 +
    1.69 +        result.ok(info);
    1.70 +    }
    1.71 +};

mercurial