BpBinder Class Reference

#include <support_p/RBinder.h>

Inheritance diagram for BpBinder:

IBinder SAtom List of all members.

Public Member Functions

virtual status_t AutobinderGet (const BAutobinderDef *def, void *result)
virtual status_t AutobinderInvoke (const BAutobinderDef *def, void **params, void *result)
virtual status_t AutobinderPut (const BAutobinderDef *def, const void *value)
 BpBinder (int32_t handle)
virtual status_t Effect (const SValue &in, const SValue &inBindings, const SValue &outBindings, SValue *out)
 Perform an action on the binder.
int32_t Handle ()
virtual SValue Inspect (const sptr< IBinder > &caller, const SValue &which, uint32_t flags=0)
 Probe binder for interface information.
virtual sptr< IInterfaceInterfaceFor (const SValue &descriptor, uint32_t flags=0)
 Retrieve direct interface for this binder.
virtual bool IsBinderAlive () const
 Return true if this binder still existed as of the last executed operation.
virtual status_t Link (const sptr< IBinder > &target, const SValue &bindings, uint32_t flags=0)
 Link registers the IBinder "target" for notification of events.
virtual status_t LinkToDeath (const sptr< BBinder > &target, const SValue &method, uint32_t flags=0)
 Register the IBinder "target" for a notification if this binder goes away.
virtual BBinderLocalBinder ()
 Use this function instead of a dynamic_cast<> to up-cast to a BBinder.
virtual status_t PingBinder ()
 Send a ping to the remote binder, and return status.
virtual BpBinderRemoteBinder ()
void SendObituary ()
virtual status_t Transact (uint32_t code, SParcel &data, SParcel *reply=NULL, uint32_t flags=0)
 Low-level data transfer.
virtual status_t Unlink (const wptr< IBinder > &target, const SValue &bindings, uint32_t flags=0)
 Remove a mapping previously added by Link().
virtual status_t UnlinkToDeath (const wptr< BBinder > &target, const SValue &method, uint32_t flags=0)
 Remove a previously registered death notification.
virtual ~BpBinder ()

Protected Member Functions

virtual status_t FinishAtom (const void *id)
 Objects can optionally override this function to extend the lifetime of an atom (past the last strong reference).
virtual status_t IncStrongAttempted (uint32_t flags, const void *id)
 Called during IncStrong() after an atom has been released.
virtual void InitAtom ()
 Called the first time a strong reference is acquired. All significant object initialization should go here.

Friends

class BProcess

Classes

struct  Obituary

Constructor & Destructor Documentation

BpBinder int32_t  handle  ) 
 

~BpBinder  )  [virtual]
 


Member Function Documentation

status_t AutobinderGet const BAutobinderDef def,
void *  result
[virtual]
 

Implements IBinder.

status_t AutobinderInvoke const BAutobinderDef def,
void **  params,
void *  result
[virtual]
 

Implements IBinder.

status_t AutobinderPut const BAutobinderDef def,
const void *  value
[virtual]
 

Implements IBinder.

status_t Effect const SValue in,
const SValue inBindings,
const SValue outBindings,
SValue out
[virtual]
 

Perform an action on the binder.

Either a get, put, or invocation, depending on the supplied and requested bindings.

Implements IBinder.

status_t FinishAtom const void *  id  )  [protected, virtual]
 

Objects can optionally override this function to extend the lifetime of an atom (past the last strong reference).

If you return FINISH_ATOM_ASYNC here, your object's destructor will be called asynchronously from the current thread. This is highly recommend if you must acquire a lock in the destructor, to avoid unexpected deadlocks due to things like sptr<> going out of scope while a lock is held.

If you return an error code here, the object's destructor will not be called at this point.

The default implementation will return B_OK, allowing the SAtom destruction to proceed as normal. Don't override this method unless you want some other behavior. Like InitAtom(), you do not need to call the SAtom implementation.

See also:
DecStrong()

Reimplemented from SAtom.

int32_t Handle  )  [inline]
 

status_t IncStrongAttempted uint32_t  flags,
const void *  id
[protected, virtual]
 

Called during IncStrong() after an atom has been released.

The flags will be B_ATOM_FIRST_STRONG if this is the first strong reference ever acquired on the atom. The default implementation returns B_OK if B_ATOM_FIRST_STRONG is set, otherwise it returns B_NOT_ALLOWED to make the attempted IncStrong() fail.

You can override this to return B_OK when you would like an atom to continue allowing primary references. Note that this also requires overriding FinishAtom() to return an error code, extending the lifetime of the object. Like FinishAtom(), you do not need to call the SAtom implementation.

See also:
AttemptIncStrong(), FinishAtom()

Reimplemented from SAtom.

void InitAtom  )  [protected, virtual]
 

Called the first time a strong reference is acquired. All significant object initialization should go here.

You can override it and do any setup you need. Note that you do not need to call the SAtom implementation. (So you can derive from two different SAtom implementations and safely call down to both of their IncStrong() methods.)

See also:
IncStrong()

Reimplemented from SAtom.

SValue Inspect const sptr< IBinder > &  caller,
const SValue which,
uint32_t  flags = 0
[virtual]
 

Probe binder for interface information.

Return interfaces implemented by this binder object that are requested by which. This is a composition of all interfaces, expressed as { descriptor -> binder } mappings, which are selected through which.

Much more information on Inspect() can be found at Binder Inspect() Details.

Implements IBinder.

sptr< IInterface > InterfaceFor const SValue descriptor,
uint32_t  flags = 0
[virtual]
 

Retrieve direct interface for this binder.

Given a SValue interface descriptor, return an IInterface implementing it. The default implementation of this function returns NULL, meaning it does not implement a direct interface to it. If the return is non-NULL, you are guaranteed to be able to static_cast<> the returned interface into the requested subclass and have it work.

Note that this is NOT the same as calling Inspect(), which performs conversion between different IBinder objects. This method converts to an IInterface only for this binder object.

Implements IBinder.

bool IsBinderAlive  )  const [virtual]
 

Return true if this binder still existed as of the last executed operation.

Implements IBinder.

status_t Link const sptr< IBinder > &  target,
const SValue bindings,
uint32_t  flags = 0
[virtual]
 

Link registers the IBinder "target" for notification of events.

The bindings is a mapping of keys that will get pushed on this IBinder, to keys that will get pushed on the "target" IBinder. e.g.

  • If you call link thus: binder1->Link(binder2, SValue("A", "B"));
  • When "A" is pushed on binder1: binder1->Push(SValue("A", "C"));
  • The following will get called on binder2: binder2->Effect(SValue("B", "C"), SValue::wild, SValue::undefined, NULL);

Implements IBinder.

status_t LinkToDeath const sptr< BBinder > &  target,
const SValue method,
uint32_t  flags = 0
[virtual]
 

Register the IBinder "target" for a notification if this binder goes away.

The method is the name of a method to call if this binder unexpectedly goes away. This is accomplished by performing an Effect() on target with the given method. Prior to doing so, a mapping { 0 -> this } is added to the method name, so that the first parameter of the function is the dying binder. I.e., your method should look like:

SomethingDied(const wptr<IBinder>& who)

Note:
You will only receive death notifications for remote binders, as local binders by definition can't die without you dying as well.

This link always holds a weak reference to its target.

You will only receive a weak reference to the dead binder. You should not try to promote this to a strong reference. (Nor should you need to, as there is nothing useful you can directly do with it now that it has passed on.)

Implements IBinder.

BBinder * LocalBinder  )  [virtual]
 

Use this function instead of a dynamic_cast<> to up-cast to a BBinder.

Since multiple BBinder instances can appear in a single object, a regular dynamic_cast<> is ambiguous. Note that there is a default implementation of this (which returns NULL) so that we can call the method even if the object has been destroyed. (That is, if we only have a weak reference on it.)

Reimplemented from IBinder.

status_t PingBinder  )  [virtual]
 

Send a ping to the remote binder, and return status.

If this is a local binder, ping always returns B_OK. If this is a remote binder, it performs a Transact() to the local binder and returns that status. This should be either B_OK or B_BINDER_DEAD.

Implements IBinder.

BpBinder * RemoteBinder  )  [virtual]
 

void SendObituary  ) 
 

status_t Transact uint32_t  code,
SParcel data,
SParcel reply = NULL,
uint32_t  flags = 0
[virtual]
 

Low-level data transfer.

This is the Binder's IPC primitive. It allows you to send a parcel of data to another Binder (possibly in another process or language) and get a parcel of data back. The parcel can contain IBinder objects to transfer references between environments. The code can be any arbitrary value, though some standard codes are defined for parts of the higher-level IBinder protocol (B_EFFECT_TRANSACTION, B_INSPECT_TRANSACTION, etc). The flags are used for internal IPC implementation and must always be set to 0 when calling. If your implementation of Transact() returns an error code (instead of B_OK), that code will be propagated back to the caller WITHOUT any reply data.

Implements IBinder.

status_t Unlink const wptr< IBinder > &  target,
const SValue bindings,
uint32_t  flags = 0
[virtual]
 

Remove a mapping previously added by Link().

Implements IBinder.

status_t UnlinkToDeath const wptr< BBinder > &  target,
const SValue method,
uint32_t  flags = 0
[virtual]
 

Remove a previously registered death notification.

The target and method must exactly match the values passed in to LinkToDeath().

Implements IBinder.


Friends And Related Function Documentation

friend class BProcess [friend]
 


The documentation for this class was generated from the following files: