Function binder_ndk_sys::AIBinder_new

source ยท
pub unsafe extern "C" fn AIBinder_new(
    clazz: *const AIBinder_Class,
    args: *mut c_void,
) -> *mut AIBinder
Expand description

Creates a new binder object of the appropriate class.

Ownership of args is passed to this object. The lifecycle is implemented with AIBinder_incStrong and AIBinder_decStrong. When the reference count reaches zero, onDestroy is called.

When this is called, the refcount is implicitly 1. So, calling decStrong exactly one time is required to delete this object.

Once an AIBinder object is created using this API, re-creating that AIBinder for the same instance of the same class will break pointer equality for that specific AIBinder object. For instance, if someone erroneously created two AIBinder instances representing the same callback object and passed one to a hypothetical addCallback function and then later another one to a hypothetical removeCallback function, the remote process would have no way to determine that these two objects are actually equal using the AIBinder pointer alone (which they should be able to do). Also see the suggested memory ownership model suggested above.

Available since API level 29.

\param clazz the type of the object to be created. \param args the args to pass to AIBinder_onCreate for that class.

\return a binder object representing the newly instantiated object.