mirror of
https://github.com/nab138/isideload.git
synced 2026-03-02 06:26:16 +01:00
Start sideload method
This commit is contained in:
@@ -6,6 +6,7 @@ use rootcause::{
|
|||||||
pub mod anisette;
|
pub mod anisette;
|
||||||
pub mod auth;
|
pub mod auth;
|
||||||
pub mod dev;
|
pub mod dev;
|
||||||
|
pub mod sideload;
|
||||||
pub mod util;
|
pub mod util;
|
||||||
|
|
||||||
#[derive(Debug, thiserror::Error)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
@@ -23,6 +24,7 @@ pub enum SideloadError {
|
|||||||
DeveloperError(i64, String),
|
DeveloperError(i64, String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The default reqwest error formatter sucks and provides no info
|
||||||
struct ReqwestErrorFormatter;
|
struct ReqwestErrorFormatter;
|
||||||
|
|
||||||
impl ContextFormatterHook<reqwest::Error> for ReqwestErrorFormatter {
|
impl ContextFormatterHook<reqwest::Error> for ReqwestErrorFormatter {
|
||||||
|
|||||||
16
isideload/src/sideload/mod.rs
Normal file
16
isideload/src/sideload/mod.rs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
use idevice::provider::IdeviceProvider;
|
||||||
|
use rootcause::prelude::*;
|
||||||
|
|
||||||
|
use crate::dev::developer_session::DeveloperSession;
|
||||||
|
use crate::util::device::IdeviceInfo;
|
||||||
|
|
||||||
|
pub async fn sideload_app(
|
||||||
|
device_provider: &impl IdeviceProvider,
|
||||||
|
dev_session: &DeveloperSession,
|
||||||
|
app_path: PathBuf,
|
||||||
|
) -> Result<(), Report> {
|
||||||
|
let device_info = IdeviceInfo::from_device(device_provider).await?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
44
isideload/src/util/device.rs
Normal file
44
isideload/src/util/device.rs
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
use idevice::{IdeviceService, lockdown::LockdownClient, provider::IdeviceProvider};
|
||||||
|
use rootcause::prelude::*;
|
||||||
|
|
||||||
|
pub struct IdeviceInfo {
|
||||||
|
pub name: String,
|
||||||
|
pub udid: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl IdeviceInfo {
|
||||||
|
pub fn new(name: String, udid: String) -> Self {
|
||||||
|
Self { name, udid }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn from_device(device: &impl IdeviceProvider) -> Result<Self, Report> {
|
||||||
|
let mut lockdown = LockdownClient::connect(device)
|
||||||
|
.await
|
||||||
|
.context("Failed to connect to device lockdown")?;
|
||||||
|
let pairing = device
|
||||||
|
.get_pairing_file()
|
||||||
|
.await
|
||||||
|
.context("Failed to get device pairing file")?;
|
||||||
|
lockdown
|
||||||
|
.start_session(&pairing)
|
||||||
|
.await
|
||||||
|
.context("Failed to start lockdown session")?;
|
||||||
|
let device_name = lockdown
|
||||||
|
.get_value(Some("DeviceName"), None)
|
||||||
|
.await
|
||||||
|
.context("Failed to get device name")?
|
||||||
|
.as_string()
|
||||||
|
.ok_or_else(|| report!("Device name is not a string"))?
|
||||||
|
.to_string();
|
||||||
|
|
||||||
|
let device_udid = lockdown
|
||||||
|
.get_value(Some("UniqueDeviceID"), None)
|
||||||
|
.await
|
||||||
|
.context("Failed to get device UDID")?
|
||||||
|
.as_string()
|
||||||
|
.ok_or_else(|| report!("Device UDID is not a string"))?
|
||||||
|
.to_string();
|
||||||
|
|
||||||
|
Ok(Self::new(device_name, device_udid))
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1 +1,2 @@
|
|||||||
|
pub mod device;
|
||||||
pub mod plist;
|
pub mod plist;
|
||||||
|
|||||||
Reference in New Issue
Block a user