Esempio n. 1
0
        static void HasDepedencies(HttpListenerContext ctx)
        {
            if (ctx.Request.Headers["Content-Type"] == "application/json")
            {
                using (var sr = new StreamReader(ctx.Request.InputStream, ctx.Request.ContentEncoding)) {
                    // Read the JSON body
                    dynamic           data = JsonConvert.DeserializeObject <dynamic>(sr.ReadToEnd());
                    DeviceInformation device;

                    // Find the matching device udid
                    lock (Devices)
                        device = Devices.FirstOrDefault(d => d.UDID == (string)data.udid);

                    // Check if we already have the dependencies
                    if (device == null)
                    {
                        SetResponse(ctx,
                                    new { error = "Unable to find the specified device. Are you sure it is connected?" });
                    }
                    else
                    {
                        // Obtain the status of the depedencies
                        var hasDeps = DeveloperImageHelper.HasImageForDevice(device);
                        var verStr  = DeveloperImageHelper.GetSoftwareVersion(device);

                        // Automatically start download if it's missing
                        if (!hasDeps)
                        {
                            var links = DeveloperImageHelper.GetLinksForDevice(device);
                            if (links != null)
                            {
                                bool needsExtraction = links.Any(l =>
                                                                 l.Item1.EndsWith(".zip", StringComparison.InvariantCultureIgnoreCase));
                                var state = new DownloadState(links.Select(t => t.Item1).ToArray(),
                                                              links.Select(t => t.Item2).ToArray());
                                if (needsExtraction)
                                {
                                    state.DownloadCompleted += DeveloperImageZipDownloaded;
                                }
                                lock (Downloads)
                                    if (!Downloads.ContainsKey(verStr))
                                    {
                                        Downloads[verStr] = state;
                                    }
                                state.Start();
                            }
                            else
                            {
                                SetResponse(ctx,
                                            new { error = "Your device's iOS version is not supported at this time." });
                                return;
                            }
                        }

                        SetResponse(ctx, new { result = hasDeps, version = verStr });
                    }
                }
            }
        }
Esempio n. 2
0
        static void SetLocation(HttpListenerContext ctx)
        {
            if (ctx.Request.Headers["Content-Type"] == "application/json")
            {
                using (var sr = new StreamReader(ctx.Request.InputStream, ctx.Request.ContentEncoding))
                {
                    // Read the JSON body
                    dynamic           data = JsonConvert.DeserializeObject <dynamic>(sr.ReadToEnd());
                    DeviceInformation device;

                    // Find the matching device udid
                    lock (Devices)
                        device = Devices.FirstOrDefault(d => d.UDID == (string)data.udid);

                    // Check if we already have the dependencies
                    if (device == null)
                    {
                        SetResponse(ctx, new { error = "Unable to find the specified device. Are you sure it is connected?" });
                    }
                    else
                    {
                        try
                        {
                            string[] p;
                            if (DeveloperImageHelper.HasImageForDevice(device, out p))
                            {
                                device.EnableDeveloperMode(p[0], p[1]);
                                device.SetLocation(new PointLatLng {
                                    Lat = data.lat, Lng = data.lng
                                });
                                SetResponse(ctx, new { success = true });
                            }
                            else
                            {
                                throw new Exception("The developer images for the specified device are missing.");
                            }
                        }
                        catch (Exception e)
                        {
                            SetResponse(ctx, new { error = e.Message });
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        static void StopLocation(HttpListenerContext ctx)
        {
            if (ctx.Request.Headers["Content-Type"] == "application/json")
            {
                using (var sr = new StreamReader(ctx.Request.InputStream, ctx.Request.ContentEncoding)) {
                    // Read the JSON body
                    dynamic           data = JsonConvert.DeserializeObject <dynamic>(sr.ReadToEnd());
                    DeviceInformation device;

                    // Find the matching device udid
                    lock (Devices)
                        device = Devices.FirstOrDefault(d => d.UDID == (string)data.udid);

                    // Check if we already have the dependencies
                    if (device == null)
                    {
                        SetResponse(ctx,
                                    new { error = "Unable to find the specified device. Are you sure it is connected?" });
                    }
                    else
                    {
                        try {
                            if (DeveloperImageHelper.HasImageForDevice(device, out string[] p))
Esempio n. 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (lng == 0.0 || lat == 0.0)
            {
                appendTextBox("请先选择位置");
                return;
            }
            DeviceInformation deviceInformation = DeviceInformation.GetDevices().FirstOrDefault();

            if (deviceInformation == null)
            {
                appendTextBox("修改失败:未找到设备");
                return;
            }
            if (!HttpHelper.verifyDevice(deviceInformation.UDID))
            {
                System.Windows.Forms.MessageBox.Show("卡密已过期,请重新购买");
                return;
            }
            appendTextBox("正在修改定位");
            if (deviceInformation.SetLocation(new PointLatLng
            {
                Lat = lat,
                Lng = lng
            }))
            {
                appendTextBox("修改成功");
                return;
            }
            button1.Enabled = false;
            string[] paths;
            if (!DeveloperImageHelper.HasImageForDevice(deviceInformation, out paths))
            {
                string text = HttpHelper.downLoadImage(paths, textBox2);
                if (!(text == ""))
                {
                    appendTextBox(text);
                    button1.Enabled = true;
                    return;
                }
                appendTextBox("正在安装驱动程序");
            }
            try
            {
                deviceInformation.EnableDeveloperMode(paths[0], paths[1]);
                if (deviceInformation.SetLocation(new PointLatLng
                {
                    Lat = lat,
                    Lng = lng
                }))
                {
                    appendTextBox("修改成功");
                    button1.Enabled = true;
                }
                else
                {
                    appendTextBox("修改失败:请解锁手机重试");
                    button1.Enabled = true;
                }
            }
            catch (Exception)
            {
                appendTextBox("安装失败:请解锁手机重试");
                button1.Enabled = true;
            }
        }