diff --git a/_frida/__init__.pyi b/_frida/__init__.pyi index bdb09fc..f37482d 100644 --- a/_frida/__init__.pyi +++ b/_frida/__init__.pyi @@ -299,6 +299,11 @@ class Device(Object): Open a device-specific communication channel. """ ... + def unpair(self) -> None: + """ + Unpair device. + """ + ... def query_system_parameters(self) -> Dict[str, Any]: """ Returns a dictionary of information about the host system. diff --git a/examples/unpair.py b/examples/unpair.py new file mode 100644 index 0000000..6ad81ac --- /dev/null +++ b/examples/unpair.py @@ -0,0 +1,4 @@ +import frida + +device = frida.get_usb_device() +device.unpair() diff --git a/frida/core.py b/frida/core.py index a5ba6c5..07ae609 100644 --- a/frida/core.py +++ b/frida/core.py @@ -1035,6 +1035,14 @@ def open_channel(self, address: str) -> IOStream: return IOStream(self._impl.open_channel(address)) + @cancellable + def unpair(self) -> None: + """ + Unpair device + """ + + self._impl.unpair() + @cancellable def get_bus(self) -> Bus: """ diff --git a/src/_frida.c b/src/_frida.c index 1a6d4d7..5510bb2 100644 --- a/src/_frida.c +++ b/src/_frida.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013-2022 Ole André Vadla Ravnås + * Copyright (C) 2013-2023 Ole André Vadla Ravnås * * Licence: wxWindows Library Licence, Version 3.1 */ @@ -389,6 +389,7 @@ static FridaSessionOptions * PyDevice_parse_session_options (const gchar * realm static PyObject * PyDevice_inject_library_file (PyDevice * self, PyObject * args); static PyObject * PyDevice_inject_library_blob (PyDevice * self, PyObject * args); static PyObject * PyDevice_open_channel (PyDevice * self, PyObject * args); +static PyObject * PyDevice_unpair (PyDevice * self); static PyObject * PyApplication_new_take_handle (FridaApplication * handle); static int PyApplication_init (PyApplication * self, PyObject * args, PyObject * kw); @@ -565,6 +566,7 @@ static PyMethodDef PyDevice_methods[] = { "inject_library_file", (PyCFunction) PyDevice_inject_library_file, METH_VARARGS, "Inject a library file to a PID." }, { "inject_library_blob", (PyCFunction) PyDevice_inject_library_blob, METH_VARARGS, "Inject a library blob to a PID." }, { "open_channel", (PyCFunction) PyDevice_open_channel, METH_VARARGS, "Open a device-specific communication channel." }, + { "unpair", (PyCFunction) PyDevice_unpair, METH_NOARGS, "Unpair device." }, { NULL } }; @@ -2835,6 +2837,20 @@ PyDevice_open_channel (PyDevice * self, PyObject * args) return PyIOStream_new_take_handle (stream); } +static PyObject * +PyDevice_unpair (PyDevice * self) +{ + GError * error = NULL; + + Py_BEGIN_ALLOW_THREADS + frida_device_unpair_sync (PY_GOBJECT_HANDLE (self), g_cancellable_get_current (), &error); + Py_END_ALLOW_THREADS + if (error != NULL) + return PyFrida_raise (error); + + Py_RETURN_NONE; +} + static PyObject * PyApplication_new_take_handle (FridaApplication * handle)