예제 #1
0
        public void ListeningDevice()
        {
            var num         = 0;
            var deviceError = iDevice.idevice_get_device_list(out var devices, ref num);

            if (deviceError != iDeviceError.Success)
            {
                PrintMessage("无法继续.可能本工具权限不足, 没有正确电脑下载安装苹果爱思助手:http://url.i4.cn/faIfqyaa.");
                return;
            }
            ThreadPool.QueueUserWorkItem(o =>
            {
                while (true)
                {
                    deviceError = iDevice.idevice_get_device_list(out devices, ref num);
                    if (devices.Count > 0)
                    {
                        var lst = Devices.Select(s => s.UDID).ToList().Except(devices).ToList();

                        var dst = devices.Except(Devices.Select(s => s.UDID)).ToList();

                        foreach (string udid in dst)
                        {
                            iDeviceHandle iDeviceHandle;
                            iDevice.idevice_new(out iDeviceHandle, udid).ThrowOnError();
                            LockdownClientHandle lockdownClientHandle;

                            lockdown.lockdownd_client_new_with_handshake(iDeviceHandle, out lockdownClientHandle, "Quamotion").ThrowOnError("无法读取设备Quamotion");

                            lockdown.lockdownd_get_device_name(lockdownClientHandle, out var deviceName).ThrowOnError("获取设备名称失败.");

                            lockdown.lockdownd_client_new_with_handshake(iDeviceHandle, out lockdownClientHandle, "waua").ThrowOnError("无法读取设备waua");

                            lockdown.lockdownd_get_value(lockdownClientHandle, null, "ProductVersion", out var node).ThrowOnError("获取设备系统版本失败.");

                            LibiMobileDevice.Instance.Plist.plist_get_string_val(node, out var version);

                            iDeviceHandle.Dispose();
                            lockdownClientHandle.Dispose();
                            var device = new DeviceModel
                            {
                                UDID    = udid,
                                Name    = deviceName,
                                Version = version
                            };

                            PrintMessage($"发现设备: {deviceName}  {version}");
                            LoadDevelopmentTool(device);
                            Devices.Add(device);
                        }
                    }
                    else
                    {
                        Devices.ForEach(itm => PrintMessage($"设备 {itm.Name} {itm.Version} 已断开连接."));
                        Devices.Clear();
                    }
                    Thread.Sleep(1000);
                }
            });
        }
예제 #2
0
        private void Refresh()
        {
            comboBox1.Items.Clear();

            ReadOnlyCollection <string> udids;
            int count = 0;

            var idevice = LibiMobileDevice.Instance.iDevice;

            var ret = idevice.idevice_get_device_list(out udids, ref count);

            if (ret == iDeviceError.NoDevice)
            {
                // Not actually an error in our case
                return;
            }

            ret.ThrowOnError();
            // Get the device name
            foreach (var udid in udids)
            {
                iDeviceHandle deviceHandle;
                idevice.idevice_new(out deviceHandle, udid).ThrowOnError();

                LockdownClientHandle lockdownHandle;
                lockdown.lockdownd_client_new_with_handshake(deviceHandle, out lockdownHandle, null)
                .ThrowOnError();

                string deviceName;
                lockdown.lockdownd_get_device_name(lockdownHandle, out deviceName).ThrowOnError();
                comboBox1.Items.Add(deviceName + " " + udid);
                deviceHandle.Dispose();
                lockdownHandle.Dispose();
            }

            if (comboBox1.Items.Count != 0)
            {
                comboBox1.SelectedIndex = 0;
            }
        }
예제 #3
0
        private int create_new_device(string udid, ref DeviceModel device)
        {
            iDeviceHandle iDeviceHandle;

            iDevice.idevice_new(out iDeviceHandle, udid).ThrowOnError();
            LockdownClientHandle lockdownClientHandle;

            var ret_handshake = lockdown.lockdownd_client_new_with_handshake(iDeviceHandle,
                                                                             out lockdownClientHandle, "Quamotion");

            if (ret_handshake != 0)
            {
                return(-1);
            }

            var ret_get_devname = lockdown.lockdownd_get_device_name(lockdownClientHandle,
                                                                     out var deviceName);

            if (ret_get_devname != 0)
            {
                return(-1);
            }

            ret_handshake = lockdown.lockdownd_client_new_with_handshake(iDeviceHandle,
                                                                         out lockdownClientHandle, "waua");
            if (ret_handshake != 0)
            {
                return(-1);
            }

            var ret_get_value = lockdown.lockdownd_get_value(lockdownClientHandle, null,
                                                             "ProductVersion", out var node);

            if (ret_get_devname != 0)
            {
                return(-1);
            }

            LibiMobileDevice.Instance.Plist.plist_get_string_val(node, out var version);

            ret_get_value = lockdown.lockdownd_get_value(lockdownClientHandle, null,
                                                         "BuildVersion", out node);
            if (ret_get_devname != 0)
            {
                return(-1);
            }

            LibiMobileDevice.Instance.Plist.plist_get_string_val(node, out var bldVersion);

            iDeviceHandle.Dispose();
            lockdownClientHandle.Dispose();

            device.UDID         = udid;
            device.Name         = deviceName;
            device.Version      = version;
            device.BuildVersion = bldVersion;
            device.ShortVersion = string.Join(".", version.Split('.').Take(2));
            device.FullVersion  = string.Join(".", version.Split('.').Take(2)) + "(" + bldVersion + ")";
            device.isDevMode    = DeviceUtils.is_device_on_dev_mode(udid);

            return(0);
        }
예제 #4
0
        public void ListeningDevice()
        {
            var num         = 0;
            var deviceError = iDevice.idevice_get_device_list(out var devices, ref num);

            if (deviceError != iDeviceError.Success)
            {
                PrintMessage("Please install iTunes first!");
                return;
            }
            ThreadPool.QueueUserWorkItem(o =>
            {
                while (true)
                {
                    deviceError = iDevice.idevice_get_device_list(out devices, ref num);
                    if (devices.Count > 0)
                    {
                        var lst = Devices.Select(s => s.UDID).ToList().Except(devices).ToList();

                        var dst = devices.Except(Devices.Select(s => s.UDID)).ToList();

                        foreach (string udid in dst)
                        {
                            var info = new iMobileDevice.Usbmuxd.UsbmuxdDeviceInfo();
                            LibiMobileDevice.Instance.Usbmuxd.usbmuxd_get_device_by_udid(udid, ref info);
                            if (info.product_id == 0)
                            {
                                continue;
                            }
                            iDeviceHandle iDeviceHandle;
                            iDevice.idevice_new(out iDeviceHandle, udid).ThrowOnError();
                            LockdownClientHandle lockdownClientHandle;

                            lockdown.lockdownd_client_new_with_handshake(iDeviceHandle, out lockdownClientHandle, "Quamotion").ThrowOnError("无法读取设备Quamotion");

                            lockdown.lockdownd_get_device_name(lockdownClientHandle, out var deviceName).ThrowOnError("获取设备名称失败.");

                            lockdown.lockdownd_client_new_with_handshake(iDeviceHandle, out lockdownClientHandle, "waua").ThrowOnError("无法读取设备waua");

                            lockdown.lockdownd_get_value(lockdownClientHandle, null, "ProductVersion", out var node).ThrowOnError("获取设备系统版本失败.");

                            LibiMobileDevice.Instance.Plist.plist_get_string_val(node, out var version);

                            iDeviceHandle.Dispose();
                            lockdownClientHandle.Dispose();
                            var device = new DeviceModel
                            {
                                UDID    = udid,
                                Name    = deviceName,
                                Version = version
                            };

                            PrintMessage($"Found device: {deviceName}  {version}");
                            LoadDevelopmentTool(device);
                            Devices.Add(device);
                        }
                    }
                    else
                    {
                        Devices.ForEach(itm => PrintMessage($"Device {itm.Name} {itm.Version} disconnected."));
                        Devices.Clear();
                    }
                    Thread.Sleep(1000);
                }
            });
        }
예제 #5
0
        public static List <DeviceInformation> GetDevices()
        {
            IiDeviceApi  iDevice  = LibiMobileDevice.Instance.iDevice;
            ILockdownApi lockdown = LibiMobileDevice.Instance.Lockdown;
            IPlistApi    plist    = LibiMobileDevice.Instance.Plist;
            int          count    = 0;
            ReadOnlyCollection <string> devices;

            if (iDevice.idevice_get_device_list(out devices, ref count) != 0)
            {
                return(new List <DeviceInformation>());
            }
            iDeviceHandle            device = null;
            LockdownClientHandle     client = null;
            PlistHandle              value  = null;
            List <DeviceInformation> list   = new List <DeviceInformation>();

            foreach (string item in devices.Distinct())
            {
                try
                {
                    string deviceName;
                    if (iDevice.idevice_new(out device, item) == iDeviceError.Success && lockdown.lockdownd_client_new_with_handshake(device, out client, "iFakeLocation") == LockdownError.Success && lockdown.lockdownd_get_device_name(client, out deviceName) == LockdownError.Success)
                    {
                        DeviceInformation deviceInformation = new DeviceInformation(deviceName, item);
                        if (lockdown.lockdownd_get_value(client, null, null, out value) == LockdownError.Success && plist.plist_get_node_type(value) == PlistType.Dict)
                        {
                            deviceInformation.ReadProperties(value);
                            if (!deviceInformation.Properties.ContainsKey("HostAttached") || (bool)deviceInformation.Properties["HostAttached"])
                            {
                                list.Add(deviceInformation);
                            }
                        }
                    }
                }
                finally
                {
                    if (value != null)
                    {
                        value.Close();
                    }
                    if (client != null)
                    {
                        client.Close();
                    }
                    if (device != null)
                    {
                        device.Close();
                    }
                }
            }
            return(list);
        }
예제 #6
0
        //主要业务逻辑处理
        public void ListeningDevice()
        {
            var num         = 0;
            var deviceError = iDevice.idevice_get_device_list(out var devices, ref num);

            if (deviceError != iDeviceError.Success)
            {
                PrintMessage("Cannot continue! Maybe you don't install the itunes or lighting-line is fake!");
                PrintMessage("the error message is :" + deviceError);
                return;
            }
            ThreadPool.QueueUserWorkItem(o =>
            {
                while (true)
                {
                    deviceError = iDevice.idevice_get_device_list(out devices, ref num);
                    if (devices.Count > 0)
                    {
                        var lst = Devices.Select(s => s.UDID).ToList().Except(devices).ToList();

                        var dst = devices.Except(Devices.Select(s => s.UDID)).ToList();

                        foreach (string udid in dst)
                        {
                            iDeviceHandle iDeviceHandle;
                            iDevice.idevice_new(out iDeviceHandle, udid).ThrowOnError();
                            //获取UUID
                            String uuid;
                            iDevice.idevice_get_udid(iDeviceHandle, out uuid);
                            Uid = uuid;

                            LockdownClientHandle lockdownClientHandle;

                            lockdown.lockdownd_client_new_with_handshake(iDeviceHandle, out lockdownClientHandle, "Quamotion").ThrowOnError("无法读取设备Quamotion");

                            lockdown.lockdownd_get_device_name(lockdownClientHandle, out var deviceName).ThrowOnError("获取设备名称失败.");

                            lockdown.lockdownd_client_new_with_handshake(iDeviceHandle, out lockdownClientHandle, "waua").ThrowOnError("无法读取设备waua");

                            lockdown.lockdownd_get_value(lockdownClientHandle, null, "ProductVersion", out var node).ThrowOnError("获取设备系统版本失败.");

                            LibiMobileDevice.Instance.Plist.plist_get_string_val(node, out var version);

                            iDeviceHandle.Dispose();
                            lockdownClientHandle.Dispose();
                            var device = new DeviceModel
                            {
                                UDID    = udid,
                                Name    = deviceName,
                                Version = version
                            };

                            PrintMessage($"发现设备: {deviceName}  {version}");
                            LoadDevelopmentTool(device);
                            Devices.Add(device);
                        }
                    }
                    else
                    {
                        Devices.ForEach(itm => PrintMessage($"设备 {itm.Name} {itm.Version} 已断开连接."));
                        Devices.Clear();
                    }
                    Thread.Sleep(1000);
                }
            });
        }