public void Start(string block, long startedPos) { if (IsInitialized == true) { try { var result = AndroidMirrorAPI.ImageDataZone(_deviceHandle, block, startedPos / 512, -1, ImageDataCallBack); if (0 != result) { Exception(string.Format("安卓手机镜像出错!ImageDataZone失败,设备ID:{0} 错误码:{1}", _deviceSerialnumber, result)); return; } } catch (Exception ex) { MirrorFile.Close(); Console.WriteLine("{0}|{1}", CmdStrings.Progress, MirrorFile.WritedSize.ToString()); Exception(string.Format("镜像异常,设备ID:{0} 错误码:{1}", _deviceSerialnumber, ex)); return; } MirrorFile.Close(); MirrorFile.CreateMD5File(); Console.WriteLine(CmdStrings.FinishState); } }
/// <summary> /// 在Initialize方法中打开设备,并且初始化 /// </summary> public void Initialize(string deviceSerialnumber, int isHtc, string path) { IsInitialized = false; try { MirrorFile = new MirrorFile(path); _deviceSerialnumber = deviceSerialnumber; _deviceHandle = AndroidMirrorAPI.OpenDevice(deviceSerialnumber); if (IntPtr.Zero == _deviceHandle) { Exception(string.Format("安卓手机镜像出错!OpenDevice失败,设备ID:{0}", deviceSerialnumber)); return; } var result = AndroidMirrorAPI.Initialize(_deviceHandle, 61440, (IntPtr)isHtc); if (0 != result) { Exception(string.Format("安卓手机镜像出错!Initialize失败,设备ID:{0} 错误码:{1}", deviceSerialnumber, result)); return; } } catch (Exception ex) { Exception(string.Format("安卓手机镜像出错!设备ID:{0} {1}", deviceSerialnumber, ex)); return; } IsInitialized = true; }