Thu, 04 Jun 2015 14:50:33 +0200
Genesis of lecture sources for Droidcon Berlin 2015 in Postbahnhof.
michael@0 | 1 | /* |
michael@0 | 2 | Licensed under the Apache License, Version 2.0 (the "License"); |
michael@0 | 3 | you may not use this file except in compliance with the License. |
michael@0 | 4 | You may obtain a copy of the License at |
michael@0 | 5 | |
michael@0 | 6 | http://www.apache.org/licenses/LICENSE-2.0 |
michael@0 | 7 | |
michael@0 | 8 | Unless required by applicable law or agreed to in writing, software |
michael@0 | 9 | distributed under the License is distributed on an "AS IS" BASIS, |
michael@0 | 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
michael@0 | 11 | See the License for the specific language governing permissions and |
michael@0 | 12 | limitations under the License. |
michael@0 | 13 | */ |
michael@0 | 14 | |
michael@0 | 15 | using System; |
michael@0 | 16 | using System.Net; |
michael@0 | 17 | using System.Windows; |
michael@0 | 18 | using System.Windows.Controls; |
michael@0 | 19 | using System.Windows.Documents; |
michael@0 | 20 | using System.Windows.Ink; |
michael@0 | 21 | using System.Windows.Input; |
michael@0 | 22 | using System.Windows.Media; |
michael@0 | 23 | using System.Windows.Media.Animation; |
michael@0 | 24 | using System.Windows.Shapes; |
michael@0 | 25 | using Microsoft.Phone.Info; |
michael@0 | 26 | using System.IO.IsolatedStorage; |
michael@0 | 27 | using System.Windows.Resources; |
michael@0 | 28 | using System.IO; |
michael@0 | 29 | using System.Diagnostics; |
michael@0 | 30 | |
michael@0 | 31 | namespace WPCordovaClassLib.Cordova.Commands |
michael@0 | 32 | { |
michael@0 | 33 | public class Device : BaseCommand |
michael@0 | 34 | { |
michael@0 | 35 | public void getDeviceInfo(string notused) |
michael@0 | 36 | { |
michael@0 | 37 | |
michael@0 | 38 | string res = String.Format("\"name\":\"{0}\",\"platform\":\"{1}\",\"uuid\":\"{2}\",\"version\":\"{3}\",\"model\":\"{4}\"", |
michael@0 | 39 | this.name, |
michael@0 | 40 | this.platform, |
michael@0 | 41 | this.uuid, |
michael@0 | 42 | this.version, |
michael@0 | 43 | this.model); |
michael@0 | 44 | |
michael@0 | 45 | res = "{" + res + "}"; |
michael@0 | 46 | //Debug.WriteLine("Result::" + res); |
michael@0 | 47 | DispatchCommandResult(new PluginResult(PluginResult.Status.OK, res)); |
michael@0 | 48 | } |
michael@0 | 49 | |
michael@0 | 50 | public string model |
michael@0 | 51 | { |
michael@0 | 52 | get |
michael@0 | 53 | { |
michael@0 | 54 | return DeviceStatus.DeviceName; |
michael@0 | 55 | //return String.Format("{0},{1},{2}", DeviceStatus.DeviceManufacturer, DeviceStatus.DeviceHardwareVersion, DeviceStatus.DeviceFirmwareVersion); |
michael@0 | 56 | } |
michael@0 | 57 | } |
michael@0 | 58 | |
michael@0 | 59 | public string name |
michael@0 | 60 | { |
michael@0 | 61 | get |
michael@0 | 62 | { |
michael@0 | 63 | return DeviceStatus.DeviceName; |
michael@0 | 64 | |
michael@0 | 65 | } |
michael@0 | 66 | } |
michael@0 | 67 | |
michael@0 | 68 | public string platform |
michael@0 | 69 | { |
michael@0 | 70 | get |
michael@0 | 71 | { |
michael@0 | 72 | return Environment.OSVersion.Platform.ToString(); |
michael@0 | 73 | } |
michael@0 | 74 | } |
michael@0 | 75 | |
michael@0 | 76 | public string uuid |
michael@0 | 77 | { |
michael@0 | 78 | get |
michael@0 | 79 | { |
michael@0 | 80 | string returnVal = ""; |
michael@0 | 81 | object id; |
michael@0 | 82 | UserExtendedProperties.TryGetValue("ANID", out id); |
michael@0 | 83 | |
michael@0 | 84 | if (id != null) |
michael@0 | 85 | { |
michael@0 | 86 | returnVal = id.ToString().Substring(2, 32); |
michael@0 | 87 | } |
michael@0 | 88 | else |
michael@0 | 89 | { |
michael@0 | 90 | returnVal = "???unknown???"; |
michael@0 | 91 | |
michael@0 | 92 | using (IsolatedStorageFile appStorage = IsolatedStorageFile.GetUserStoreForApplication()) |
michael@0 | 93 | { |
michael@0 | 94 | try |
michael@0 | 95 | { |
michael@0 | 96 | IsolatedStorageFileStream fileStream = new IsolatedStorageFileStream("DeviceID.txt", FileMode.Open, FileAccess.Read, appStorage); |
michael@0 | 97 | |
michael@0 | 98 | using (StreamReader reader = new StreamReader(fileStream)) |
michael@0 | 99 | { |
michael@0 | 100 | returnVal = reader.ReadLine(); |
michael@0 | 101 | } |
michael@0 | 102 | } |
michael@0 | 103 | catch (Exception /*ex*/) |
michael@0 | 104 | { |
michael@0 | 105 | |
michael@0 | 106 | } |
michael@0 | 107 | } |
michael@0 | 108 | } |
michael@0 | 109 | |
michael@0 | 110 | return returnVal; |
michael@0 | 111 | } |
michael@0 | 112 | } |
michael@0 | 113 | |
michael@0 | 114 | public string version |
michael@0 | 115 | { |
michael@0 | 116 | get |
michael@0 | 117 | { |
michael@0 | 118 | return Environment.OSVersion.Version.ToString(); |
michael@0 | 119 | } |
michael@0 | 120 | } |
michael@0 | 121 | |
michael@0 | 122 | } |
michael@0 | 123 | } |