public bool TryUninstall(string ApplicationIdentifier) { DateTime StartTime = DateTime.Now; ReconnectWithInstallProxy(); TypedPtr <CFString> CF_ApplicationIdentifier = MobileDevice.CFStringMakeConstantString(ApplicationIdentifier); IntPtr CF_ClientOptions = IntPtr.Zero; IntPtr ExtraKey = IntPtr.Zero; IntPtr ExtraValue = IntPtr.Zero; IntPtr ConnectionHandle = IntPtr.Zero; int Result = MobileDevice.AMDeviceMethods.SecureUninstallApplication(ConnectionHandle, iPhoneHandle, CF_ApplicationIdentifier, CF_ClientOptions, UninstallProgressCallback, IntPtr.Zero); if (Result == 0) { Console.WriteLine("Uninstall of \"{0}\" completed successfully in {2:0.00} seconds", ApplicationIdentifier, Result, (DateTime.Now - StartTime).TotalSeconds); } else { Console.WriteLine("Uninstall of \"{0}\" failed with {1} in {2:0.00} seconds", ApplicationIdentifier, MobileDevice.GetErrorString(Result), (DateTime.Now - StartTime).TotalSeconds); } return(Result == 0); }
void ReconnectWithInstallProxy() { Reconnect(); if (MobileDevice.AMDeviceMethods.StartService(iPhoneHandle, MobileDevice.CFStringMakeConstantString("com.apple.mobile.installation_proxy"), ref hInstallService, IntPtr.Zero) != 0) { Console.WriteLine("Unable to start installation_proxy service!"); } }
// Default level is 6, and 0,3,7 are regularly used. Bump the logging level up to 7 to get verbose logs. void SetLoggingLevel(int Threshold) { Int32 LoggingThreshold = Math.Min(Math.Max(0, Threshold), 7); MobileDevice.CFPreferencesSetAppValue( (IntPtr)MobileDevice.CFStringMakeConstantString("LogLevel"), (IntPtr)MobileDevice.CFNumberCreate(LoggingThreshold), (IntPtr)MobileDevice.CFStringMakeConstantString("com.apple.MobileDevice")); }
unsafe private bool ConnectToPhone() { if (MobileDevice.AMDeviceConnect(iPhoneHandle) == 1) { //int connid; throw new Exception("Phone in recovery mode, support not yet implemented"); //connid = MobileDevice.AMDeviceGetConnectionID(ref iPhoneHandle); //MobileDevice.AMRestoreModeDeviceCreate(0, connid, 0); //return false; } if (MobileDevice.AMDeviceIsPaired(iPhoneHandle) == 0) { return(false); } int chk = MobileDevice.AMDeviceValidatePairing(iPhoneHandle); if (chk != 0) { return(false); } if (MobileDevice.AMDeviceStartSession(iPhoneHandle) == 1) { return(false); } if (MobileDevice.AMDeviceStartService(iPhoneHandle, MobileDevice.CFStringMakeConstantString("com.apple.afc2"), ref hService, null) != 0) { if (MobileDevice.AMDeviceStartService(iPhoneHandle, MobileDevice.CFStringMakeConstantString("com.apple.afc"), ref hService, null) != 0) { return(false); } } else { wasAFC2 = true; } if (MobileDevice.AFCConnectionOpen(hService, 0, ref hAFC) != 0) { return(false); } connected = true; return(true); }
public bool ConnectToPhone() { SetLoggingLevel(7); // Make sure we can connect to the phone and that it has been paired with this machine previously if (MobileDevice.AMDeviceMethods.Connect(iPhoneHandle) != 0) { return(false); } if (MobileDevice.AMDeviceMethods.IsPaired(iPhoneHandle) != 1) { return(false); } if (MobileDevice.AMDeviceMethods.ValidatePairing(iPhoneHandle) != 0) { return(false); } // Start a session if (MobileDevice.AMDeviceMethods.StartSession(iPhoneHandle) == 1) { return(false); } if (MobileDevice.AMDeviceMethods.StartService(iPhoneHandle, MobileDevice.CFStringMakeConstantString("com.apple.afc"), ref hService, IntPtr.Zero) != 0) { return(false); } // Open a file sharing connection if (MobileDevice.AFC.ConnectionOpen(hService, 0, out AFCCommsHandle) != 0) { return(false); } connected = true; return(true); }
public bool ConnectToBundle(string BundleName) { Reconnect(); TypedPtr <CFString> CFBundleName = MobileDevice.CFStringMakeConstantString(BundleName); // Open the bundle int Result = MobileDevice.AMDeviceMethods.StartHouseArrestService(iPhoneHandle, CFBundleName, IntPtr.Zero, ref hService, 0); if (Result != 0) { Console.WriteLine("Failed to connect to bundle '{0}' with {1}", BundleName, MobileDevice.GetErrorString(Result)); return(false); } // Open a file sharing connection if (MobileDevice.AFC.ConnectionOpen(hService, 0, out AFCCommsHandle) != 0) { return(false); } return(true); }
private unsafe bool ConnectToPhone() { if (MobileDevice.AMDeviceConnect(this.iPhoneHandle) == 1) { throw new Exception("Phone in recovery mode, support not yet implemented"); } if (MobileDevice.AMDeviceIsPaired(this.iPhoneHandle) == 0) { return(false); } if (MobileDevice.AMDeviceValidatePairing(this.iPhoneHandle) != 0) { return(false); } if (MobileDevice.AMDeviceStartSession(this.iPhoneHandle) == 1) { return(false); } if (MobileDevice.AMDeviceStartService(this.iPhoneHandle, MobileDevice.CFStringMakeConstantString("com.apple.afc2"), ref this.hService, null) != 0) { if (MobileDevice.AMDeviceStartService(this.iPhoneHandle, MobileDevice.CFStringMakeConstantString("com.apple.afc"), ref this.hService, null) != 0) { return(false); } } else { this.wasAFC2 = true; } if (MobileDevice.AFCConnectionOpen(this.hService, 0, ref this.hAFC) != 0) { return(false); } this.connected = true; return(true); }