Skip to content

Add lockdown location simulation to ffi#77

Merged
jkcoxson merged 3 commits intojkcoxson:masterfrom
uncor3:master
Mar 5, 2026
Merged

Add lockdown location simulation to ffi#77
jkcoxson merged 3 commits intojkcoxson:masterfrom
uncor3:master

Conversation

@uncor3
Copy link
Contributor

@uncor3 uncor3 commented Feb 27, 2026

#76

@neoarz
Copy link
Contributor

neoarz commented Feb 28, 2026

hey amazing pr

just a nitpick i had is that, every other service in the FFI layer has both a _connect and a _new variant, like for example, amfi_new, heartbeat_new,house_arrest_client_new etc..

you could maybe add something like this

#[unsafe(no_mangle)]
pub unsafe extern "C" fn lockdown_location_simulation_new(
    socket: *mut IdeviceHandle,
    client: *mut *mut LocationSimulationServiceHandle,
) -> *mut IdeviceFfiError {
    if socket.is_null() || client.is_null() {
        return ffi_err!(IdeviceError::FfiInvalidArg);
    }
    let socket = unsafe { Box::from_raw(socket) }.0;
    let r = LocationSimulationService::new(socket);
    let boxed = Box::new(LocationSimulationServiceHandle(r));
    unsafe { *client = Box::into_raw(boxed) };
    null_mut()
}

pub unsafe extern "C" fn lockdown_location_simulation_set(
handle: *mut *mut LocationSimulationServiceHandle,
latitude: *const libc::c_char,
longtiude: *const libc::c_char,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

longitude is spelled incorrectly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/// `latitude` and `longitude` must be valid, null-terminated C strings.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn lockdown_location_simulation_set(
handle: *mut *mut LocationSimulationServiceHandle,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be a single *mut

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/// `handle` must be a valid pointer to a `LocationSimulationServiceHandle` returned by `lockdown_location_simulation_connect`.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn lockdown_location_simulation_clear(
handle: *mut *mut LocationSimulationServiceHandle,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this still needs to be a single mut

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@neoarz
Copy link
Contributor

neoarz commented Mar 1, 2026

other than that looks good!

@uncor3
Copy link
Contributor Author

uncor3 commented Mar 1, 2026

@neoarz Can you merge or are we going to wait for @jkcoxson ?

Copy link
Contributor

@neoarz neoarz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait for jackson to review and merge

@jkcoxson
Copy link
Owner

jkcoxson commented Mar 5, 2026

Thanks everyone!

@jkcoxson jkcoxson merged commit eff708c into jkcoxson:master Mar 5, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants