|
1 PhoneGap.ExtendWrtDeviceObj = function(){ |
|
2 |
|
3 if (!window.device) |
|
4 window.device = {}; |
|
5 navigator.device = window.device; |
|
6 |
|
7 try { |
|
8 |
|
9 if (window.menu) |
|
10 window.menu.hideSoftkeys(); |
|
11 |
|
12 device.available = PhoneGap.available; |
|
13 device.platform = null; |
|
14 device.version = null; |
|
15 device.name = null; |
|
16 device.uuid = null; |
|
17 |
|
18 var so = device.getServiceObject("Service.SysInfo", "ISysInfo"); |
|
19 var pf = PhoneGap.GetWrtPlatformVersion(so); |
|
20 device.platform = pf.platform; |
|
21 device.version = pf.version; |
|
22 device.uuid = PhoneGap.GetWrtDeviceProperty(so, "IMEI"); |
|
23 device.name = PhoneGap.GetWrtDeviceProperty(so, "PhoneModel"); |
|
24 } |
|
25 catch (e) { |
|
26 device.available = false; |
|
27 } |
|
28 }; |
|
29 |
|
30 PhoneGap.GetWrtDeviceProperty = function(serviceObj, key) { |
|
31 var criteria = { "Entity": "Device", "Key": key }; |
|
32 var result = serviceObj.ISysInfo.GetInfo(criteria); |
|
33 if (result.ErrorCode == 0) { |
|
34 return result.ReturnValue.StringData; |
|
35 } |
|
36 else { |
|
37 return null; |
|
38 } |
|
39 }; |
|
40 |
|
41 PhoneGap.GetWrtPlatformVersion = function(serviceObj) { |
|
42 var criteria = { "Entity": "Device", "Key": "PlatformVersion" }; |
|
43 var result = serviceObj.ISysInfo.GetInfo(criteria); |
|
44 if (result.ErrorCode == 0) { |
|
45 var version = {}; |
|
46 version.platform = result.ReturnValue.MajorVersion; |
|
47 version.version = result.ReturnValue.MinorVersion; |
|
48 return version; |
|
49 } |
|
50 else { |
|
51 return null; |
|
52 } |
|
53 }; |
|
54 |
|
55 PhoneGap.ExtendWrtDeviceObj(); |