IT. Expert System.

Android Reference



Class Binder

    • Constructor Detail

      • Binder

        public Binder()
        Default constructor initializes the object.
    • Method Detail

      • getCallingPid

        public static final int getCallingPid()
        Return the ID of the process that sent you the current transaction that is being processed. This pid can be used with higher-level system services to determine its identity and check permissions. If the current thread is not currently executing an incoming transaction, then its own pid is returned.
      • getCallingUid

        public static final int getCallingUid()
        Return the Linux uid assigned to the process that sent you the current transaction that is being processed. This uid can be used with higher-level system services to determine its identity and check permissions. If the current thread is not currently executing an incoming transaction, then its own uid is returned.
      • getCallingUserHandle

        public static final UserHandle getCallingUserHandle()
        Return the UserHandle assigned to the process that sent you the current transaction that is being processed. This is the user of the caller. It is distinct from getCallingUid() in that a particular user will have multiple distinct apps running under it each with their own uid. If the current thread is not currently executing an incoming transaction, then its own UserHandle is returned.
      • clearCallingIdentity

        public static final long clearCallingIdentity()
        Reset the identity of the incoming IPC on the current thread. This can be useful if, while handling an incoming call, you will be calling on interfaces of other objects that may be local to your process and need to do permission checks on the calls coming into them (so they will check the permission of your own local process, and not whatever process originally called you).
        Returns an opaque token that can be used to restore the original calling identity by passing it to restoreCallingIdentity(long).
        See Also:
        getCallingPid(), getCallingUid(), restoreCallingIdentity(long)
      • restoreCallingIdentity

        public static final void restoreCallingIdentity(long token)
        Restore the identity of the incoming IPC on the current thread back to a previously identity that was returned by clearCallingIdentity().
        token - The opaque token that was previously returned by clearCallingIdentity().
        See Also:
      • setThreadStrictModePolicy

        public static final void setThreadStrictModePolicy(int policyMask)
        Sets the native thread-local StrictMode policy mask.

        The StrictMode settings are kept in two places: a Java-level threadlocal for libcore/Dalvik, and a native threadlocal (set here) for propagation via Binder calls. This is a little unfortunate, but necessary to break otherwise more unfortunate dependencies either of Dalvik on Android, or Android native-only code on Dalvik.

        See Also:
      • getThreadStrictModePolicy

        public static final int getThreadStrictModePolicy()
        Gets the current native thread-local StrictMode policy mask.
        See Also:
      • flushPendingCommands

        public static final void flushPendingCommands()
        Flush any Binder commands pending in the current thread to the kernel driver. This can be useful to call before performing an operation that may block for a long time, to ensure that any pending object references have been released in order to prevent the process from holding on to objects longer than it needs to.
      • joinThreadPool

        public static final void joinThreadPool()
        Add the calling thread to the IPC thread pool. This function does not return until the current process is exiting.
      • attachInterface

        public void attachInterface(IInterface owner,
                           String descriptor)
        Convenience method for associating a specific interface with the Binder. After calling, queryLocalInterface() will be implemented for you to return the given owner IInterface when the corresponding descriptor is requested.
      • getInterfaceDescriptor

        public String getInterfaceDescriptor()
        Default implementation returns an empty interface name.
        Specified by:
        getInterfaceDescriptor in interface IBinder
      • pingBinder

        public boolean pingBinder()
        Default implementation always returns true -- if you got here, the object is alive.
        Specified by:
        pingBinder in interface IBinder
        Returns false if the hosting process is gone, otherwise the result (always by default true) returned by the pingBinder() implementation on the other side.
      • isBinderAlive

        public boolean isBinderAlive()
        Check to see if the process that the binder is in is still alive. Note that if you're calling on a local binder, this always returns true because your process is alive if you're calling it.
        Specified by:
        isBinderAlive in interface IBinder
        false if the process is not alive. Note that if it returns true, the process may have died while the call is returning.
      • queryLocalInterface

        public IInterface queryLocalInterface(String descriptor)
        Use information supplied to attachInterface() to return the associated IInterface if it matches the requested descriptor.
        Specified by:
        queryLocalInterface in interface IBinder
      • onTransact

        protected boolean onTransact(int code,
                         Parcel data,
                         Parcel reply,
                         int flags)
                              throws RemoteException
        Default implementation is a stub that returns false. You will want to override this to do the appropriate unmarshalling of transactions.

        If you want to call this, call transact().

      • dump

        protected void dump(FileDescriptor fd,
                PrintWriter fout,
                String[] args)
        Print the object's state into the given stream.
        fd - The raw file descriptor that the dump is being sent to.
        fout - The file to which you should dump your state. This will be closed for you after you return.
        args - additional arguments to the dump request.
      • transact

        public final boolean transact(int code,
                       Parcel data,
                       Parcel reply,
                       int flags)
                               throws RemoteException
        Default implementation rewinds the parcels and calls onTransact. On the remote side, transact calls into the binder to do the IPC.
        Specified by:
        transact in interface IBinder
        code - The action to perform. This should be a number between IBinder.FIRST_CALL_TRANSACTION and IBinder.LAST_CALL_TRANSACTION.
        data - Marshalled data to send to the target. Must not be null. If you are not sending any data, you must create an empty Parcel that is given here.
        reply - Marshalled data to be received from the target. May be null if you are not interested in the return value.
        flags - Additional operation flags. Either 0 for a normal RPC, or IBinder.FLAG_ONEWAY for a one-way RPC.
      • unlinkToDeath

        public boolean unlinkToDeath(IBinder.DeathRecipient recipient,
                            int flags)
        Local implementation is a no-op.
        Specified by:
        unlinkToDeath in interface IBinder
        Returns true if the recipient is successfully unlinked, assuring you that its DeathRecipient.binderDied() method will not be called. Returns false if the target IBinder has already died, meaning the method has been (or soon will be) called.
      • finalize

        protected void finalize()
                         throws Throwable
        Description copied from class: Object
        Invoked when the garbage collector has detected that this instance is no longer reachable. The default implementation does nothing, but this method can be overridden to free resources.

        Note that objects that override finalize are significantly more expensive than objects that don't. Finalizers may be run a long time after the object is no longer reachable, depending on memory pressure, so it's a bad idea to rely on them for cleanup. Note also that finalizers are run on a single VM-wide finalizer thread, so doing blocking work in a finalizer is a bad idea. A finalizer is usually only necessary for a class that has a native peer and needs to call a native method to destroy that peer. Even then, it's better to provide an explicit close method (and implement Closeable), and insist that callers manually dispose of instances. This works well for something like files, but less well for something like a BigInteger where typical calling code would have to deal with lots of temporaries. Unfortunately, code that creates lots of temporaries is the worst kind of code from the point of view of the single finalizer thread.

        If you must use finalizers, consider at least providing your own ReferenceQueue and having your own thread process that queue.

        Unlike constructors, finalizers are not automatically chained. You are responsible for calling super.finalize() yourself.

        Uncaught exceptions thrown by finalizers are ignored and do not terminate the finalizer thread. See Effective Java Item 7, "Avoid finalizers" for more.

        finalize in class Object


Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)





Java Script








Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 3971 / 159426280. Delta: 0.08706 с