-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prepare tests and examples for ios devices run
- Loading branch information
Showing
14 changed files
with
737 additions
and
639 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,29 @@ | ||
use cidre::am; | ||
fn main() { | ||
let devices = am::Device::list().unwrap(); | ||
#[cfg(target_os = "macos")] | ||
mod macos { | ||
use cidre::am; | ||
|
||
pub fn main() { | ||
let devices = am::Device::list().unwrap(); | ||
|
||
for d in devices.iter() { | ||
let f = d.connected().expect("Failed to connect to device"); | ||
println!( | ||
"uuid: {:?}, if: {:?} {:?}", | ||
f.id().to_string(), | ||
f.iface_type(), | ||
f.name().to_string() | ||
); | ||
for d in devices.iter() { | ||
let f = d.connected().expect("Failed to connect to device"); | ||
println!( | ||
"uuid: {:?}, if: {:?} {:?}", | ||
f.id().to_string(), | ||
f.iface_type(), | ||
f.name().to_string() | ||
); | ||
|
||
let s = f.start_session().expect("started session"); | ||
s.show(); | ||
let s = f.start_session().expect("started session"); | ||
s.show(); | ||
} | ||
} | ||
} | ||
|
||
#[cfg(target_os = "macos")] | ||
pub use macos::main; | ||
|
||
#[cfg(not(target_os = "macos"))] | ||
fn main() { | ||
todo!() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,102 +1,113 @@ | ||
use std::ffi::c_void; | ||
|
||
use cidre::{ | ||
am::{self, device::discovery::NotificationInfo}, | ||
cf, | ||
}; | ||
|
||
const DEVICE_ID: &str = "00008120-000168A20210C01E"; | ||
|
||
pub extern "C" fn callback(info: &NotificationInfo, _context: *mut c_void) { | ||
match info.safe() { | ||
am::device::discovery::SafeInfo::Attached(device) => { | ||
let id = device.id().to_string(); | ||
if id.eq(DEVICE_ID) { | ||
println!("identifier {:?}", id); | ||
device.show(); | ||
let connected = device.connected().expect("connected"); | ||
println!("Device: {}", connected.name().to_string()); | ||
|
||
let session = connected.start_session().expect("started session"); | ||
println!( | ||
"batery level {:?}", | ||
session.battery_level().unwrap().to_i64() | ||
); | ||
// println!("batery level {}", session.battery_level().expect("level").to_string()); | ||
session.mount_developer_image().expect("mounted"); | ||
session.start_debug_server().expect("debug"); | ||
println!("disk mounted"); | ||
#[cfg(target_os = "macos")] | ||
mod macos { | ||
use std::ffi::c_void; | ||
|
||
use cidre::{ | ||
am::{self, device::discovery::NotificationInfo}, | ||
cf, | ||
}; | ||
|
||
const DEVICE_ID: &str = "00008120-000168A20210C01E"; | ||
|
||
extern "C" fn callback(info: &NotificationInfo, _context: *mut c_void) { | ||
match info.safe() { | ||
am::device::discovery::SafeInfo::Attached(device) => { | ||
let id = device.id().to_string(); | ||
if id.eq(DEVICE_ID) { | ||
println!("identifier {:?}", id); | ||
device.show(); | ||
let connected = device.connected().expect("connected"); | ||
println!("Device: {}", connected.name().to_string()); | ||
|
||
let session = connected.start_session().expect("started session"); | ||
println!( | ||
"batery level {:?}", | ||
session.battery_level().unwrap().to_i64() | ||
); | ||
// println!("batery level {}", session.battery_level().expect("level").to_string()); | ||
session.mount_developer_image().expect("mounted"); | ||
session.start_debug_server().expect("debug"); | ||
println!("disk mounted"); | ||
} | ||
} | ||
am::device::discovery::SafeInfo::Detached(_) => {} | ||
am::device::discovery::SafeInfo::NotificationStopped => {} | ||
am::device::discovery::SafeInfo::Paired(_) => {} | ||
} | ||
am::device::discovery::SafeInfo::Detached(_) => {} | ||
am::device::discovery::SafeInfo::NotificationStopped => {} | ||
am::device::discovery::SafeInfo::Paired(_) => {} | ||
} | ||
} | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
let devices = am::device::QueryBuilder::new_match_all() | ||
.udids(&[DEVICE_ID]) | ||
// .udids(&["00008120-000168A20210C01E"]) | ||
.matching_list(None) | ||
.unwrap(); | ||
|
||
if devices.is_empty() { | ||
println!("device not found"); | ||
return; | ||
} | ||
#[tokio::main] | ||
pub async fn main() { | ||
let devices = am::device::QueryBuilder::new_match_all() | ||
.udids(&[DEVICE_ID]) | ||
// .udids(&["00008120-000168A20210C01E"]) | ||
.matching_list(None) | ||
.unwrap(); | ||
|
||
let ipad = &devices[0].retained(); | ||
let connected = ipad.connected().expect("connected"); | ||
println!("Device: {}", connected.name().to_string()); | ||
|
||
let session = connected.start_session().expect("started session"); | ||
session.mount_developer_image().expect("mounted"); | ||
println!("disk mounted"); | ||
let connection = session.start_debug_server().expect("debug"); | ||
|
||
unsafe { | ||
extern "C" fn cb( | ||
_s: &cf::Socket, | ||
_cb_type: cf::SocketCbType, | ||
_address: &cf::Data, | ||
_data: *const u8, | ||
_info: *mut c_void, | ||
) { | ||
println!("??????????") | ||
if devices.is_empty() { | ||
println!("device not found"); | ||
return; | ||
} | ||
let sock = cf::Socket::create_with_native( | ||
connection.socket().unwrap(), | ||
cf::SocketCbType::READ, | ||
cb, | ||
None, | ||
) | ||
.unwrap(); | ||
let source = sock.create_runloop_source(0).unwrap(); | ||
cf::RunLoop::main().add_source(&source, cf::RunLoopMode::common()); | ||
// source.invalidate(); | ||
|
||
let n = connection.send(&[1]).unwrap(); | ||
println!("sent {}", n); | ||
} | ||
|
||
// println!("pre send"); | ||
// let n = connection.send(&[0,0,0,0]).unwrap(); | ||
// println!("post send {}", n); | ||
// connection.http_proxy().await.unwrap(); | ||
// let fd = service.socket().expect("valid socket"); | ||
// println!("FD {:?}", fd); | ||
let ipad = &devices[0].retained(); | ||
let connected = ipad.connected().expect("connected"); | ||
println!("Device: {}", connected.name().to_string()); | ||
|
||
// device::start_lldb_proxy(fd).await.unwrap(); | ||
let session = connected.start_session().expect("started session"); | ||
session.mount_developer_image().expect("mounted"); | ||
println!("disk mounted"); | ||
let connection = session.start_debug_server().expect("debug"); | ||
|
||
unsafe { | ||
extern "C" fn cb( | ||
_s: &cf::Socket, | ||
_cb_type: cf::SocketCbType, | ||
_address: &cf::Data, | ||
_data: *const u8, | ||
_info: *mut c_void, | ||
) { | ||
println!("??????????") | ||
} | ||
let sock = cf::Socket::create_with_native( | ||
connection.socket().unwrap(), | ||
cf::SocketCbType::READ, | ||
cb, | ||
None, | ||
) | ||
.unwrap(); | ||
let source = sock.create_runloop_source(0).unwrap(); | ||
cf::RunLoop::main().add_source(&source, cf::RunLoopMode::common()); | ||
// source.invalidate(); | ||
|
||
let n = connection.send(&[1]).unwrap(); | ||
println!("sent {}", n); | ||
} | ||
|
||
// println!("pre send"); | ||
// let n = connection.send(&[0,0,0,0]).unwrap(); | ||
// println!("post send {}", n); | ||
// connection.http_proxy().await.unwrap(); | ||
// let fd = service.socket().expect("valid socket"); | ||
// println!("FD {:?}", fd); | ||
|
||
// device::start_lldb_proxy(fd).await.unwrap(); | ||
|
||
// let note = am::device::Notification::with( | ||
// callback, | ||
// DeviceSpeed::ANY, | ||
// DeviceInterfaceConnectionType::Any, | ||
// std::ptr::null_mut(), | ||
// ) | ||
// .unwrap(); | ||
|
||
cf::RunLoop::run(); | ||
} | ||
} | ||
|
||
// let note = am::device::Notification::with( | ||
// callback, | ||
// DeviceSpeed::ANY, | ||
// DeviceInterfaceConnectionType::Any, | ||
// std::ptr::null_mut(), | ||
// ) | ||
// .unwrap(); | ||
#[cfg(target_os = "macos")] | ||
pub use macos::main; | ||
|
||
cf::RunLoop::run(); | ||
#[cfg(not(target_os = "macos"))] | ||
fn main() { | ||
todo!() | ||
} |
Oops, something went wrong.