arnaucube
arnaucube/commonroutesServerPublic Self-hosted repository
commonroutesServer/www/plugins/cordova-plugin-device/src/blackberry10/index.js
www/plugins/cordova-plugin-device/src/blackberry10/index.jsRaw
 1/*
 2 *
 3 * Licensed to the Apache Software Foundation (ASF) under one
 4 * or more contributor license agreements.  See the NOTICE file
 5 * distributed with this work for additional information
 6 * regarding copyright ownership.  The ASF licenses this file
 7 * to you under the Apache License, Version 2.0 (the
 8 * "License"); you may not use this file except in compliance
 9 * with the License.  You may obtain a copy of the License at
10 *
11 *   http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied.  See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20*/
21
22/* global PluginResult */
23
24function getModelName () {
25    var modelName = window.qnx.webplatform.device.modelName;
26    //Pre 10.2 (meaning Z10 or Q10)
27    if (typeof modelName === "undefined") {
28        if (window.screen.height === 720 && window.screen.width === 720) {
29            if ( window.matchMedia("(-blackberry-display-technology: -blackberry-display-oled)").matches) {
30                modelName = "Q10";
31            } else {
32                modelName = "Q5";
33            }
34        } else if ((window.screen.height === 1280 && window.screen.width === 768) ||
35                   (window.screen.height === 768 && window.screen.width === 1280)) {
36            modelName = "Z10";
37        } else {
38            modelName = window.qnx.webplatform.deviceName;
39        }
40    }
41
42    return modelName;
43}
44
45function getUUID () {
46    var uuid = "";
47    try {
48        //Must surround by try catch because this will throw if the app is missing permissions
49        uuid = window.qnx.webplatform.device.devicePin;
50    } catch (e) {
51        //DO Nothing
52    }
53    return uuid;
54}
55
56module.exports = {
57    getDeviceInfo: function (success, fail, args, env) {
58        var result = new PluginResult(args, env),
59            modelName = getModelName(),
60            uuid = getUUID(),
61            info = {
62                manufacturer: 'BlackBerry',
63                platform: "blackberry10",
64                version: window.qnx.webplatform.device.scmBundle,
65                model: modelName,
66                uuid: uuid
67            };
68
69        result.ok(info);
70    }
71};