public void Connect() { var connectivity = new MultiTargetingConnectivity(CultureInfo.CurrentUICulture.LCID); var connectableDevice = connectivity.GetConnectableDevice(DeviceId); Device = connectableDevice.Connect(); IsConnected = true; }
public Deployer(String appIdString) { this.appIdString = appIdString; MultiTargetingConnectivity connectivity = new MultiTargetingConnectivity(CultureInfo.CurrentUICulture.LCID); ConnectableDevice connectableDevice = connectivity.GetConnectableDevice(Wvga512DeviceId); this.iDevice = connectableDevice.Connect(); }
public static List<string> GetAllDeviceIDs() { MultiTargetingConnectivity connectivity = new MultiTargetingConnectivity(CultureInfo.CurrentUICulture.LCID); var connectableDevices = connectivity.GetConnectableDevices(); List<string> deviceIds = new List<string>(); foreach (var device in connectableDevices) { deviceIds.Add(device.Id); } return deviceIds; }
static void ListDevices() { MultiTargetingConnectivity mtConn = new MultiTargetingConnectivity(CultureInfo.CurrentUICulture.LCID); Collection<ConnectableDevice> deviceList = mtConn.GetConnectableDevices(); for (int index = 0; index < deviceList.Count; index++) { ConnectableDevice d = deviceList[index]; string info = string.Format("{0} : {1} : {2}", index.ToString(), d.Id, d.Name); Log(info); } }
public Deployer(string desiredDevice, bool strict) { this.deviceInfo = Devices.Instance.GetMatchingDevice(desiredDevice, strict); if (this.deviceInfo == null) { throw new ConnectivityException( string.Format( "Could not find a device to launch. You requested '{0}', but the available devices were:\n{1}", desiredDevice, Devices.Instance)); } var propertyInfo = this.deviceInfo.GetType().GetTypeInfo().GetDeclaredProperty("DeviceId"); var deviceId = (string)propertyInfo.GetValue(this.deviceInfo); var connectableDevice = new MultiTargetingConnectivity(CultureInfo.CurrentUICulture.LCID).GetConnectableDevice(deviceId); this.Device = connectableDevice.Connect(true); Logger.Info("Target emulator: '{0}'", this.DeviceName); }
static int Main(string[] args) { if (args.Length == 0) { return showHelp(); } string command = null; string wpsdk = null; string udid = null; Guid appid = Guid.Empty; int i; for (i = 0; i < args.Length; i++) { if (args[i] == "--wpsdk") { if (i + 1 < args.Length) { wpsdk = args[++i]; } } else if (command == null) { command = args[i]; if (command == "connect" && i + 1 < args.Length) { udid = args[++i]; } else if (command == "launch" && i + 1 < args.Length) { udid = args[++i]; string rawAppId = args[++i]; try { appid = Guid.Parse(rawAppId); } catch (FormatException fe) { return showHelp("Invalid app GUID format: " + rawAppId); } } } } if (wpsdk == null) { wpsdk = "10.0"; } else { // trim whatever version number they pass in to 2 digits string[] parts = wpsdk.Split(new Char [] {'.'}); wpsdk = ""; i = 0; while (i < 2) { if (wpsdk.Length > 0) { wpsdk += '.'; } if (i < parts.Length) { wpsdk += parts[i]; } else { wpsdk += '0'; } i++; } } if (!wpsdk.Equals("10.0") && !wpsdk.Equals("8.1")) { return showHelp("Unsupported wpsdk value. Please use '10.0' or '8.1'."); } int localeId = CultureInfo.CurrentUICulture.LCID; MultiTargetingConnectivity multiTargetingConnectivity = new MultiTargetingConnectivity(localeId); Collection<ConnectableDevice> devices = multiTargetingConnectivity.GetConnectableDevices(); List<ConnectableDevice> deviceList = new List<ConnectableDevice>(); i = 0; foreach (ConnectableDevice dev in devices) { // Filter to device and emulators that match the given SDK. We use 6.3 Version as the marker for 8.1 emus, assume rest are 10.0 string versionString = dev.Version.ToString(); if (!dev.IsEmulator() || (wpsdk == "8.1" && versionString.Equals("6.3")) || (wpsdk == "10.0" && !versionString.Equals("6.3"))) { deviceList.Add(dev); i++; } } if (command == "enumerate") { int id = 0; int j = 0; Console.WriteLine("{"); Console.WriteLine("\t\"devices\": ["); foreach (ConnectableDevice dev in deviceList) { string versionString = dev.Version.ToString(); if (!dev.IsEmulator()) { if (j > 0) { Console.WriteLine(","); } string sdk = "null"; if (versionString == "6.3") { sdk = "\"8.1\""; } else if (versionString == "10.0") { sdk = "\"10.0\""; // skip invalid device } else if (versionString.StartsWith("2147483647")) { continue; } Console.WriteLine("\t\t{\n"); Console.WriteLine("\t\t\t\"name\": \"" + dev.Name.Replace("\"", "\\\"") + "\","); Console.WriteLine("\t\t\t\"udid\": " + id + ","); Console.WriteLine("\t\t\t\"index\": " + id + ","); Console.WriteLine("\t\t\t\"version\": \"" + versionString + "\","); // windows 8.1: "6.3", windows 10: "10.0" Console.WriteLine("\t\t\t\"wpsdk\": " + sdk); Console.Write("\t\t}"); j++; } id++; } Console.WriteLine("\n\t],"); id = 0; j = 0; Console.WriteLine("\t\"emulators\": ["); foreach (ConnectableDevice dev in deviceList) { if (dev.IsEmulator()) { if (j > 0) { Console.WriteLine(","); } Console.WriteLine("\t\t{\n"); Console.WriteLine("\t\t\t\"name\": \"" + dev.Name.Replace("\"", "\\\"") + "\","); Console.WriteLine("\t\t\t\"udid\": \"" + wpsdk.Replace('.', '-') + "-" + id + "\","); Console.WriteLine("\t\t\t\"index\": " + id + ","); Console.WriteLine("\t\t\t\"guid\": \"" + dev.Id + "\","); Console.WriteLine("\t\t\t\"version\": \"" + dev.Version + "\","); // 6.3 for 8.1 emulators, 6.4 for 10 emulators, 2147483647.2147483647.2147483647.2147483647 for device Console.WriteLine("\t\t\t\"uapVersion\": \"" + dev.UapVersion + "\","); // blank/empty for 8.1 emulators and device, 10.0.10586.0 for win 10 emulators Console.WriteLine("\t\t\t\"wpsdk\": \"" + wpsdk + "\""); Console.Write("\t\t}"); j++; } id++; } Console.WriteLine("\n\t]"); Console.WriteLine("}"); return 0; } // This won't just connect, it will launch the emulator! if (command == "connect" || command == "launch") { if (udid == null) { return showHelp("Missing device/emulator UDID"); } // TODO Validate that the udid is either our generated udid (i.e. 10-0-1), or it's GUID, or it's an integer index value! int id = 0; // Search devices for udid! ConnectableDevice connectableDevice = null; foreach (ConnectableDevice dev in deviceList) { // Is it a matching GUID, matching UDID or matching Index value? if (dev.Id.Equals(udid) || (wpsdk.Replace('.', '-') + "-" + id).Equals(udid) || udid.Equals(id.ToString())) { connectableDevice = dev; break; } id++; } if (connectableDevice == null) { return showHelp(String.Format("Invalid device UDID '{0:D}'", udid)); } try { IDevice device = connectableDevice.Connect(); if (command == "launch") { IRemoteApplication app = device.GetApplication(appid); app.TerminateRunningInstances(); app.Launch(); Console.WriteLine("{"); Console.WriteLine("\t\"success\": true"); Console.WriteLine("}"); } else { try { string destinationIp; string sourceIp; int destinationPort; device.GetEndPoints(0, out sourceIp, out destinationIp, out destinationPort); var address = IPAddress.Parse(destinationIp); ISystemInfo systemInfo = device.GetSystemInfo(); Version version = new Version(systemInfo.OSMajor, systemInfo.OSMinor, systemInfo.OSBuildNo); Console.WriteLine("{"); Console.WriteLine("\t\"success\": true,"); Console.WriteLine("\t\"ip\": \"" + address.ToString() + "\","); Console.WriteLine("\t\"port\": " + destinationPort.ToString() + ","); Console.WriteLine("\t\"osVersion\": \"" + version.ToString() + "\","); Console.WriteLine("\t\"availablePhysical\": " + systemInfo.AvailPhys.ToString() + ","); Console.WriteLine("\t\"totalPhysical\": " + systemInfo.TotalPhys.ToString() + ","); Console.WriteLine("\t\"availableVirtual\": " + systemInfo.AvailVirtual.ToString() + ","); Console.WriteLine("\t\"totalVirtual\": " + systemInfo.TotalVirtual.ToString() + ","); Console.WriteLine("\t\"architecture\": \"" + systemInfo.ProcessorArchitecture.ToString() + "\","); Console.WriteLine("\t\"instructionSet\": \"" + systemInfo.InstructionSet.ToString() + "\","); Console.WriteLine("\t\"processorCount\": " + systemInfo.NumberOfProcessors.ToString() + ""); Console.WriteLine("}"); } catch (Exception ex) { // // ConnectableDevice throws an error when connecting to a physical Windows 10 device // physical Windows 10 devices can be connected to using 127.0.0.1. // From some point of Windows 10 SDK, IDevice.GetEndPoints throws Exception for Windows Phone 8.1 device too. // Interestingly ConnectableDevice.Version returns 8.1 _or_ 6.3 in this case. // Returning ok for now because we can still connect to the device. // if (command == "connect" && !connectableDevice.IsEmulator()) { Console.WriteLine("{"); Console.WriteLine("\t\"success\": true,"); Console.WriteLine("\t\"ip\": \"127.0.0.1\","); Console.WriteLine("\t\"osVersion\": \"" + connectableDevice.Version.ToString() + "\""); Console.WriteLine("}"); return 0; } } } return 0; } catch (Exception ex) { Console.WriteLine("{"); Console.WriteLine("\t\"success\": false,"); Console.WriteLine("\t\"message\": \"" + ex.Message.Trim().Replace("\"", "\\\"") + "\""); Console.WriteLine("}"); return 1; } } if (command != null) { return showHelp(String.Format("Invalid command '{0}'", command)); } return showHelp(); }
static ConnectableDevice GetDeviceAtIndex(int index) { MultiTargetingConnectivity mtConn = new MultiTargetingConnectivity(CultureInfo.CurrentUICulture.LCID); Collection<ConnectableDevice> deviceList = mtConn.GetConnectableDevices(); return deviceList[index]; }
/// <summary> /// Retrieve possible devices from CoreCon /// </summary> /// <returns></returns> public static List<ConnectableDevice> GetDevices() { List<ConnectableDevice> list = new List<ConnectableDevice>(); MultiTargetingConnectivity multiConnect = new MultiTargetingConnectivity(CultureInfo.CurrentCulture.LCID); foreach (ConnectableDevice device in multiConnect.GetConnectableDevices(false)) { list.Add(device); } return list; }
private void EnumDevices() { var MTC = new MultiTargetingConnectivity(1033); this._devices = MTC.GetConnectableDevices(); }
static int Main(string[] args) { MultiTargetingConnectivity WP8SDK = new MultiTargetingConnectivity(CultureInfo.CurrentCulture.LCID, false); //foreach (ConnectableDevice device in WP8SDK.GetConnectableDevices(false)) // Console.WriteLine(device.Name); bool useEmulator = true; ConnectableDevice cDevice = null; IDevice WP8Device = null; if (args.Length < 5) { Console.WriteLine("Invalid parameters"); return 1; } args[2] = args[2].Replace('/', '\\'); args[3] = args[3].Replace('/', '\\'); if (args.Length > 5) args[5] = args[5].Replace('/', '\\'); if (args[4] == "dev") useEmulator = false; try { if (useEmulator) cDevice = WP8SDK.GetConnectableDevices(false).First(d => d.Name.StartsWith("Emulator WVGA")); else cDevice = WP8SDK.GetConnectableDevices(false).First(d => d.Name.StartsWith("Device") || d.Name.StartsWith("Windows Phone 8 Device") || d.Name.StartsWith("Windows Phone Device")); } catch { Console.WriteLine("Cannot find Windows Phone 8.0 Emulator/Device."); return 3; } Console.WriteLine("Connecting to " + cDevice.Name); try { WP8Device = cDevice.Connect(); } catch { Console.WriteLine("Failed to connect to Windows Phone 8 Emulator/Device."); return 4; } Console.WriteLine("Windows Phone 8 Emulator/Device Connected..."); Guid appID = new Guid(args[0]); IRemoteApplication app; if (WP8Device.IsApplicationInstalled(appID)) { Console.WriteLine("Updating sample XAP to Windows Phone 8 Emulator/Device..."); app = WP8Device.GetApplication(appID); if (args.Length == 6) { var remoteIso = app.GetIsolatedStore(); string targetDesktopFilePath = @args[5]; try { remoteIso.ReceiveFile(Path.DirectorySeparatorChar + "rho" + Path.DirectorySeparatorChar + "rholog.txt", targetDesktopFilePath, true); } catch (Exception e) { Console.WriteLine("Can't receive rholog.txt from the " + (useEmulator ? "emulator" : "device") + ": " + e.Message); return 2; } return 0; } app.Uninstall(); } Console.WriteLine("Installing sample XAP to Windows Phone 8 Emulator/Device..."); app = WP8Device.InstallApplication( appID, appID, args[1], args[2], args[3]); Console.WriteLine("Sample XAP installed to Windows Phone 8 Emulator..."); Console.WriteLine("Launching sample app on Windows Phone 8 Emulator..."); app.Launch(); Console.WriteLine("Launched sample app on Windows Phone 8 Emulator..."); return 0; }
private static void DeployApplication( DeployAppMode mode, DeviceInfo deviceInfo, IAppManifestInfo manifestInfo, DeploymentOptions deploymentOptions, string packageFile, bool disconnect = true) { if (PackageType.Framework != manifestInfo.PackageType && WinTrust.VerifyEmbeddedSignature(packageFile)) { throw new Exception( string.Format( CultureInfo.CurrentUICulture, Resources.InvalidPackaging, new object[0])); } var connectableDevice = new MultiTargetingConnectivity(CultureInfo.CurrentUICulture.LCID).GetConnectableDevice( deviceInfo.DeviceId); var device = connectableDevice.Connect(true); var systemInfo = device.GetSystemInfo(); var deviceVersion = new Version(systemInfo.OSMajor, systemInfo.OSMinor); if (manifestInfo.PlatformVersion.CompareTo(deviceVersion) > 0) { device.Disconnect(); throw new Exception( string.Format( CultureInfo.CurrentUICulture, Resources.XapNotSupportedOnDevice, new object[0])); } var flag = IsTargetApplicableforMdilGeneration( connectableDevice, deviceVersion, manifestInfo, packageFile); ApplySideloadFlags(manifestInfo, ref deploymentOptions); if (mode == DeployAppMode.Install) { if (device.IsApplicationInstalled(manifestInfo.ProductId)) { if (manifestInfo.PackageType == PackageType.Framework) { return; } device.GetApplication(manifestInfo.ProductId).Uninstall(); } foreach (var str in DependencyFinder.GetAppDependencyPackages(packageFile)) { var manifestInfo1 = ReadAppManifestInfoFromPackage(str); DeployApplication( DeployAppMode.Install, deviceInfo, manifestInfo1, DeploymentOptions.OptOutSD, str, false); } } var app = (IRemoteApplication)null; if (mode == DeployAppMode.Update) { app = device.GetApplication(manifestInfo.ProductId); } var typeOfApp = DetermineAppType(packageFile); var applicationGenre = ((int)deploymentOptions).ToString(CultureInfo.InvariantCulture); var iconPath = ((int)manifestInfo.PackageType).ToString(CultureInfo.InvariantCulture); switch (mode) { case DeployAppMode.Install: break; case DeployAppMode.Update: break; } var path = (string)null; try { if (IsMdilFirst(typeOfApp, manifestInfo)) { if (flag) { path = GenerateNDeployMdil(packageFile, null, typeOfApp, manifestInfo); packageFile = path; } switch (mode) { case DeployAppMode.Install: app = device.InstallApplication( manifestInfo.ProductId, manifestInfo.ProductId, applicationGenre, iconPath, packageFile); break; case DeployAppMode.Update: app.UpdateApplication(applicationGenre, iconPath, packageFile); break; } } else { switch (mode) { case DeployAppMode.Install: app = device.InstallApplication( manifestInfo.ProductId, manifestInfo.ProductId, applicationGenre, iconPath, packageFile); break; case DeployAppMode.Update: app.UpdateApplication(applicationGenre, iconPath, packageFile); break; } if (flag) { path = GenerateNDeployMdil(packageFile, app, typeOfApp, manifestInfo); } } } finally { if (!GlobalOptions.LeaveBehindOptimized && !string.IsNullOrWhiteSpace(path) && File.Exists(path)) { File.Delete(path); } } if (GlobalOptions.LaunchAfterInstall && app != null) { app.Launch(); } if (!disconnect) { return; } device.Disconnect(); }
/// <summary> /// /// </summary> /// <param name="localeId"></param> /// <param name="bNoLegacyDevices"></param> /// <returns></returns> public static System.Collections.ObjectModel.Collection<ConnectableDevice> GetDevices(int localeId, bool bNoLegacyDevices = false) { var multiTargetingConnectivity = new MultiTargetingConnectivity(localeId); return multiTargetingConnectivity.GetConnectableDevices(bNoLegacyDevices); }
/// <summary> /// /// </summary> /// <param name="localeId"></param> /// <param name="deviceId"></param> /// <returns></returns> public static ConnectableDevice GetDevice(int localeId, string deviceId) { var multiTargetingConnectivity = new MultiTargetingConnectivity(localeId); return multiTargetingConnectivity.GetConnectableDevice(deviceId); }
static int Main(string[] args) { if (args.Length == 0) { return showHelp(); } int localeId = CultureInfo.CurrentUICulture.LCID; MultiTargetingConnectivity multiTargetingConnectivity = new MultiTargetingConnectivity(localeId); Collection<ConnectableDevice> devices = multiTargetingConnectivity.GetConnectableDevices(false); string command = null; string wpsdk = null; int udid = -1; int i; for (i = 0; i < args.Length; i++) { if (args[i] == "--wpsdk") { if (i + 1 < args.Length) { wpsdk = args[++i]; } } else if (command == null) { command = args[i]; if (command == "connect" && i + 1 < args.Length) { try { udid = int.Parse(args[++i]); } catch (Exception ex) { return showHelp(String.Format("Invalid device UDID '{0}'", args[i])); } } } } if (wpsdk == null) { wpsdk = "8.1"; } else { // trim whatever version number they pass in to 2 digits string[] parts = wpsdk.Split(new Char [] {'.'}); wpsdk = ""; i = 0; while (i < 2) { if (wpsdk.Length > 0) { wpsdk += '.'; } if (i < parts.Length) { wpsdk += parts[i]; } else { wpsdk += '0'; } i++; } } List<ConnectableDevice> deviceList = new List<ConnectableDevice>(); i = 0; foreach (ConnectableDevice dev in multiTargetingConnectivity.GetConnectableDevices(false)) { if (!dev.IsEmulator() || (wpsdk == "8.0" && dev.IsLegacyEmulator()) || (wpsdk != "8.0" && !dev.IsLegacyEmulator())) { deviceList.Add(dev); i++; } } if (command == "enumerate") { int id = 0; int j = 0; Console.WriteLine("{"); Console.WriteLine("\t\"devices\": ["); foreach (ConnectableDevice dev in deviceList) { if (!dev.IsEmulator()) { if (j > 0) { Console.WriteLine(","); } Console.WriteLine("\t\t{\n"); Console.WriteLine("\t\t\t\"name\": \"" + dev.Name.Replace("\"", "\\\"") + "\","); Console.WriteLine("\t\t\t\"udid\": " + id + ","); Console.WriteLine("\t\t\t\"index\": " + id + ","); Console.WriteLine("\t\t\t\"wpsdk\": null"); Console.Write("\t\t}"); j++; } id++; } Console.WriteLine("\n\t],"); id = 0; j = 0; Console.WriteLine("\t\"emulators\": ["); foreach (ConnectableDevice dev in deviceList) { if (dev.IsEmulator()) { if (j > 0) { Console.WriteLine(","); } Console.WriteLine("\t\t{\n"); Console.WriteLine("\t\t\t\"name\": \"" + dev.Name.Replace("\"", "\\\"") + "\","); Console.WriteLine("\t\t\t\"udid\": \"" + wpsdk.Replace('.', '-') + "-" + id + "\","); Console.WriteLine("\t\t\t\"index\": " + id + ","); Console.WriteLine("\t\t\t\"wpsdk\": \"" + wpsdk + "\""); Console.Write("\t\t}"); j++; } id++; } Console.WriteLine("\n\t]"); Console.WriteLine("}"); return 0; } if (command == "connect") { // validate the id if (udid == -1) { return showHelp("Missing device/emulator UDID"); } if (udid < 0 || udid >= deviceList.Count) { return showHelp(String.Format("Invalid device UDID '{0:D}'", udid)); } ConnectableDevice connectableDevice = deviceList[udid]; try { IDevice device = connectableDevice.Connect(); ISystemInfo systemInfo = device.GetSystemInfo(); Version version = new Version(systemInfo.OSMajor, systemInfo.OSMinor); Console.WriteLine("{\"success\":true}"); return 0; } catch (Exception ex) { Console.WriteLine("{"); Console.WriteLine("\t\"success\": false,"); Console.WriteLine("\t\"message\": \"" + ex.Message.Trim().Replace("\"", "\\\"") + "\""); Console.WriteLine("}"); return 1; } } if (command != null) { return showHelp(String.Format("Invalid command '{0}'", command)); } return showHelp(); }