/// <summary> /// 获取设备属性列表 /// </summary> /// <param name="device"></param> /// <returns></returns> public Dictionary <string, string> GetProperties(Device device) { if (DevicesProperties.ContainsKey(device.ID)) { return(DevicesProperties[device.ID]); } IntPtr devicePropertyPointer = IntPtr.Zero; uint execResultCode = IOSDeviceCoreDll.GetDeviceProperties(device.ID, ref devicePropertyPointer); var dictionary = new Dictionary <string, string>(); if (execResultCode != 0) { return(dictionary); } var properties = (DevicePropertyList)Marshal.PtrToStructure(devicePropertyPointer, typeof(DevicePropertyList)); IntPtr nodePointer = properties.PropertyNodes; //读取每一个属性值。根据DeviceProperty大小,逐大小读取。 for (int i = 0; i < properties.Length; i++) { var deviceProperty = (DeviceProperty)Marshal.PtrToStructure(nodePointer, typeof(DeviceProperty)); dictionary.Add(deviceProperty.PropertyKey, deviceProperty.PropertyValue); nodePointer += Marshal.SizeOf(typeof(DeviceProperty)); } DevicesProperties.Add(device.ID, dictionary); return(dictionary); }
/// <summary> /// 获取设备安装应用列表 /// </summary> /// <param name="device"></param> /// <returns></returns> public List <AppEntity> FindInstalledApp(Device device) { var appPointer = IntPtr.Zero; uint execResultCode = IOSDeviceCoreDll.GetALLInstalledApp(device.ID, ref appPointer); var appEntities = new List <AppEntity>(); if (execResultCode != 0) { return(appEntities); } var apps = (InstalledAppList)Marshal.PtrToStructure(appPointer, typeof(InstalledAppList)); IntPtr appNodes = apps.AppNodes; //读取每一个应用实体。根据InstalledApp大小,逐大小读取。 for (int i = 0; i < apps.Length; i++) { var appInfo = (InstalledApp)Marshal.PtrToStructure(appNodes, typeof(InstalledApp)); appEntities.Add(new AppEntity { VersionDesc = appInfo.Version, AppId = appInfo.AppId, Name = appInfo.Name, InstallPath = appInfo.AppInstallPath, InstallDate = appInfo.InstallTime.ToSafeDateTime() }); appNodes += Marshal.SizeOf(typeof(InstalledApp)); } return(appEntities); }
/// <summary> /// 采用备份方式拷贝用户数据 支持IOS8.3及其以上系统 /// </summary> /// <param name="device">设备</param> /// <param name="targetPath">目标路径</param> /// <param name="asyn"></param> /// <returns></returns> public string CopyUserData(Device device, string targetPath, IAsyncProgress asyn) { //1.初始化相关参数 InitCopyUserData(device, 100, asyn); //2.文件拷贝 var res = IOSDeviceCoreDll.CopyUserData(device.ID, targetPath, _CopyUserDataCallback); if (0 != res) { IsCopying = false; } else { while (IsCopying) { Thread.Sleep(500); } } //3.清理 ClearCopyUserData(); return(Path.Combine(targetPath, device.ID)); }
/// <summary> /// 采用备份方式拷贝用户数据 支持加密备份 支持IOS8.3及其以上系统 /// </summary> /// <param name="device">设备</param> /// <param name="targetPath">目标路径</param> /// <param name="asyn"></param> /// <param name="InputPassword">回调方法,如果有密码则调用,在方法内返回密码</param> /// <returns></returns> public string CopyUserData(Device device, string targetPath, IAsyncProgress asyn, Func <string> InputPassword) { //1.初始化相关参数 InitCopyUserData(device, 100, asyn); //2.文件拷贝 var res = IOSDeviceCoreDll.CopyUserDataPWD(targetPath, device.ID, CopyUserDataCallback, (b) => { var password = InputPassword(); var pS = Marshal.StringToHGlobalAnsi(password); Marshal.WriteIntPtr(b, pS); return(0); }); if (0 != res) { IsCopying = false; } else { while (IsCopying) { Thread.Sleep(500); } } //3.清理 ClearCopyUserData(); return(Path.Combine(targetPath, device.ID)); }
public void InitExecution(DataPumpControllableExecutionContext context) { String destPath = context.GetContextData <String>("destPath"); String sourcePath = context.GetContextData <String>("sourcePath"); string target = Path.Combine(destPath, "data"); var res = IOSDeviceCoreDll.AnalyzeItunesBackupDATAPWD(sourcePath, target, (f, t, a) => { //asyn.Advance(0, string.Format(LanguageHelper.Get("LANGKEY_HuiFuWenJian_01478"), f)); return(0); }, (b) => { var password = context.GetContextData <String>("password") ?? String.Empty; var pS = Marshal.StringToHGlobalAnsi(password); Marshal.WriteIntPtr(b, pS); return(0); }); if (0 == res) { string[] files = Directory.GetDirectories(target); foreach (string file in files) { var fileName = Path.GetFileName(file); //第三方应用 if (!fileName.Contains("com.apple.") && fileName.Contains("AppDomain-")) { var newFileName = fileName.Replace("AppDomain-", ""); Directory.Move(Path.Combine(target, fileName), Path.Combine(target, newFileName)); } } } }
protected override FileBrowingNode DoGetRootNode() { var di = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory).Root.Name; string target = Path.Combine(di, "temp", Guid.NewGuid().ToString("N"), "ItunsBackup"); FileHelper.CreateDirectorySafe(target); var result = IOSDeviceCoreDll.AnalyzeItunesBackupDATAPWD(SourceRootPath, target, BackupAnalysizeCallbackDelegate, (b) => { var password = ""; var pS = Marshal.StringToHGlobalAnsi(password); Marshal.WriteIntPtr(b, pS); return(0); }); ItunesBackupFileBrowingNode node = new ItunesBackupFileBrowingNode(); node.NodeType = FileBrowingNodeType.Directory; node.Name = "ItunsBackup"; node.SourcePath = target.TrimStart("\\"); DataSourcePath = target.TrimStart("\\"); return(node); }
private List <FileBrowingNode> GetIOSFileSystem(string folderPath, FileBrowingNode parentNode) { List <FileBrowingNode> list = new List <FileBrowingNode>(); try { // 1,设置服务 uint result = IOSDeviceCoreDll.SetIphoneFileService(IPhone.ID, IPhone.IsRoot); if (0 != result) { return(list); } IntPtr allFileInfosInDir = IntPtr.Zero; result = IOSDeviceCoreDll.GetIphoneALLFileInfosInDir(IPhone.ID, folderPath, ref allFileInfosInDir); if (result != 0 || allFileInfosInDir == IntPtr.Zero) { return(list); } //它返回的当前文件下的第一级文件系统,其中可能包括文件和文件夹。 IosFileSystemList iosFileSystemlist = allFileInfosInDir.ToStruct <IosFileSystemList>(); IntPtr fileSysNodes = iosFileSystemlist.FileSystemNodes; IosFileSystem iosFileSystem; //读取每一个文件系统实体。根据FileSystemList大小,一次解析一个文件系统,根据Type判断是文件还是文件夹。 for (int i = 0; i < iosFileSystemlist.Length && fileSysNodes != IntPtr.Zero; i++) { iosFileSystem = fileSysNodes.ToStruct <IosFileSystem>(); string name = iosFileSystem.Name.ToAnsiString(); //掉过掉Unix特有的隐藏文件“.”和"..",他们两个的作用是前进和后退。 if (name != "." && name != "..") { list.Add(new IOSDeviceFileBrowingNode() { Name = name, SourcePath = string.Format("{0}/{1}", folderPath.TrimStart('/'), name), FileSize = iosFileSystem.Size, CreateTime = DynamicConvert.ToSafeDateTime(iosFileSystem.CreateTime), NodeType = iosFileSystem.Type == 1 ? FileBrowingNodeType.Directory : FileBrowingNodeType.File, Parent = parentNode, }); } fileSysNodes = fileSysNodes.Increment <IosFileSystem>(); } } catch { } finally { // 3,关闭服务 IOSDeviceCoreDll.CloseIphoneFileService(IPhone.ID); } return(list); }
/// <summary> /// 判断手机是否可用 /// </summary> /// <param name="device"></param> /// <returns></returns> public bool IsValid(Device device) { uint execResultCode = IOSDeviceCoreDll.CheckDeviceIsOnline(device.ID); if (execResultCode == 0) { return(true); } else { LoggerManagerSingle.Instance.Error(GetErrorMsg(execResultCode)); return(false); } }
public override bool Start() { //打开IOS设备监听 var m = IOSDeviceCoreDll.DeviceMount(); m = IOSDeviceCoreDll.StartDeviceMonitoring(_StartMonitoringCallback); if (m != 1) { LoggerManagerSingle.Instance.Error(string.Format("启动IOS设备监控失败, 错误码:{0}", m)); return(false); } return(true); }
protected override string DownLoadFile(FileBrowingNode fileNode, string savePath, bool persistRelativePath, CancellationTokenSource cancellationTokenSource, FileBrowingIAsyncTaskProgress async) { FileHelper.CreateDirectory(savePath); var ifileNode = fileNode as IOSDeviceFileBrowingNode; try { var tSavePath = string.Empty; if (persistRelativePath) { tSavePath = Path.Combine(savePath, ifileNode.SourcePath).Replace('/', '\\'); } else { tSavePath = Path.Combine(savePath, ifileNode.Name).Replace('/', '\\'); } if (FileHelper.IsValid(tSavePath)) { return(tSavePath); } FileHelper.CreateDirectory(FileHelper.GetFilePath(tSavePath)); // 1,设置服务 uint result = IOSDeviceCoreDll.SetIphoneFileService(IPhone.ID, IPhone.IsRoot); // 2,下载 result = IOSDeviceCoreDll.CopyOneIosFile(IPhone.ID, ifileNode.SourcePath, tSavePath); return(tSavePath); } catch { } finally { // 3,关闭服务 IOSDeviceCoreDll.CloseIphoneFileService(IPhone.ID); } return(null); }
public void AnalyzeItunesBackupDATATest() { var rr1 = IOSDeviceCoreDll.AnalyzeItunesBackupDATA(@"H:\IOS加密备份\029fa1285bb67570265fc68f148d90084b81b48a", @"D:\111", (fn, no, all) => { Console.WriteLine("{0} {1} {2}", fn, no, all); return(0); }); var rr2 = IOSDeviceCoreDll.AnalyzeItunesBackupDATAPWD(@"H:\IOS加密备份\029fa1285bb67570265fc68f148d90084b81b48a", @"D:\111", (fn, no, all) => { Console.WriteLine("{0} {1} {2}", fn, no, all); return(0); }, (b) => { var password = "******"; var pS = Marshal.StringToHGlobalAnsi(password); Marshal.WriteIntPtr(b, pS); return(0); }); }
public override void Close() { IOSDeviceCoreDll.CloseDeviceMonitoring(); }