media/omx-plugin/include/ics/binder/IBinder.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/omx-plugin/include/ics/binder/IBinder.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,159 @@
     1.4 +/*
     1.5 + * Copyright (C) 2008 The Android Open Source Project
     1.6 + *
     1.7 + * Licensed under the Apache License, Version 2.0 (the "License");
     1.8 + * you may not use this file except in compliance with the License.
     1.9 + * You may obtain a copy of the License at
    1.10 + *
    1.11 + *      http://www.apache.org/licenses/LICENSE-2.0
    1.12 + *
    1.13 + * Unless required by applicable law or agreed to in writing, software
    1.14 + * distributed under the License is distributed on an "AS IS" BASIS,
    1.15 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    1.16 + * See the License for the specific language governing permissions and
    1.17 + * limitations under the License.
    1.18 + */
    1.19 +
    1.20 +#ifndef ANDROID_IBINDER_H
    1.21 +#define ANDROID_IBINDER_H
    1.22 +
    1.23 +#include <utils/Errors.h>
    1.24 +#include <utils/RefBase.h>
    1.25 +#include <utils/String16.h>
    1.26 +#include <utils/Vector.h>
    1.27 +
    1.28 +
    1.29 +#define B_PACK_CHARS(c1, c2, c3, c4) \
    1.30 +    ((((c1)<<24)) | (((c2)<<16)) | (((c3)<<8)) | (c4))
    1.31 +
    1.32 +// ---------------------------------------------------------------------------
    1.33 +namespace android {
    1.34 +
    1.35 +class BBinder;
    1.36 +class BpBinder;
    1.37 +class IInterface;
    1.38 +class Parcel;
    1.39 +
    1.40 +/**
    1.41 + * Base class and low-level protocol for a remotable object.
    1.42 + * You can derive from this class to create an object for which other
    1.43 + * processes can hold references to it.  Communication between processes
    1.44 + * (method calls, property get and set) is down through a low-level
    1.45 + * protocol implemented on top of the transact() API.
    1.46 + */
    1.47 +class IBinder : public virtual RefBase
    1.48 +{
    1.49 +public:
    1.50 +    enum {
    1.51 +        FIRST_CALL_TRANSACTION  = 0x00000001,
    1.52 +        LAST_CALL_TRANSACTION   = 0x00ffffff,
    1.53 +
    1.54 +        PING_TRANSACTION        = B_PACK_CHARS('_','P','N','G'),
    1.55 +        DUMP_TRANSACTION        = B_PACK_CHARS('_','D','M','P'),
    1.56 +        INTERFACE_TRANSACTION   = B_PACK_CHARS('_', 'N', 'T', 'F'),
    1.57 +
    1.58 +        // Corresponds to TF_ONE_WAY -- an asynchronous call.
    1.59 +        FLAG_ONEWAY             = 0x00000001
    1.60 +    };
    1.61 +
    1.62 +                          IBinder();
    1.63 +
    1.64 +    /**
    1.65 +     * Check if this IBinder implements the interface named by
    1.66 +     * @a descriptor.  If it does, the base pointer to it is returned,
    1.67 +     * which you can safely static_cast<> to the concrete C++ interface.
    1.68 +     */
    1.69 +    virtual sp<IInterface>  queryLocalInterface(const String16& descriptor);
    1.70 +
    1.71 +    /**
    1.72 +     * Return the canonical name of the interface provided by this IBinder
    1.73 +     * object.
    1.74 +     */
    1.75 +    virtual const String16& getInterfaceDescriptor() const = 0;
    1.76 +
    1.77 +    virtual bool            isBinderAlive() const = 0;
    1.78 +    virtual status_t        pingBinder() = 0;
    1.79 +    virtual status_t        dump(int fd, const Vector<String16>& args) = 0;
    1.80 +
    1.81 +    virtual status_t        transact(   uint32_t code,
    1.82 +                                        const Parcel& data,
    1.83 +                                        Parcel* reply,
    1.84 +                                        uint32_t flags = 0) = 0;
    1.85 +
    1.86 +    /**
    1.87 +     * This method allows you to add data that is transported through
    1.88 +     * IPC along with your IBinder pointer.  When implementing a Binder
    1.89 +     * object, override it to write your desired data in to @a outData.
    1.90 +     * You can then call getConstantData() on your IBinder to retrieve
    1.91 +     * that data, from any process.  You MUST return the number of bytes
    1.92 +     * written in to the parcel (including padding).
    1.93 +     */
    1.94 +    class DeathRecipient : public virtual RefBase
    1.95 +    {
    1.96 +    public:
    1.97 +        virtual void binderDied(const wp<IBinder>& who) = 0;
    1.98 +    };
    1.99 +
   1.100 +    /**
   1.101 +     * Register the @a recipient for a notification if this binder
   1.102 +     * goes away.  If this binder object unexpectedly goes away
   1.103 +     * (typically because its hosting process has been killed),
   1.104 +     * then DeathRecipient::binderDied() will be called with a reference
   1.105 +     * to this.
   1.106 +     *
   1.107 +     * The @a cookie is optional -- if non-NULL, it should be a
   1.108 +     * memory address that you own (that is, you know it is unique).
   1.109 +     *
   1.110 +     * @note You will only receive death notifications for remote binders,
   1.111 +     * as local binders by definition can't die without you dying as well.
   1.112 +     * Trying to use this function on a local binder will result in an
   1.113 +     * INVALID_OPERATION code being returned and nothing happening.
   1.114 +     *
   1.115 +     * @note This link always holds a weak reference to its recipient.
   1.116 +     *
   1.117 +     * @note You will only receive a weak reference to the dead
   1.118 +     * binder.  You should not try to promote this to a strong reference.
   1.119 +     * (Nor should you need to, as there is nothing useful you can
   1.120 +     * directly do with it now that it has passed on.)
   1.121 +     */
   1.122 +    virtual status_t        linkToDeath(const sp<DeathRecipient>& recipient,
   1.123 +                                        void* cookie = NULL,
   1.124 +                                        uint32_t flags = 0) = 0;
   1.125 +
   1.126 +    /**
   1.127 +     * Remove a previously registered death notification.
   1.128 +     * The @a recipient will no longer be called if this object
   1.129 +     * dies.  The @a cookie is optional.  If non-NULL, you can
   1.130 +     * supply a NULL @a recipient, and the recipient previously
   1.131 +     * added with that cookie will be unlinked.
   1.132 +     */
   1.133 +    virtual status_t        unlinkToDeath(  const wp<DeathRecipient>& recipient,
   1.134 +                                            void* cookie = NULL,
   1.135 +                                            uint32_t flags = 0,
   1.136 +                                            wp<DeathRecipient>* outRecipient = NULL) = 0;
   1.137 +
   1.138 +    virtual bool            checkSubclass(const void* subclassID) const;
   1.139 +
   1.140 +    typedef void (*object_cleanup_func)(const void* id, void* obj, void* cleanupCookie);
   1.141 +
   1.142 +    virtual void            attachObject(   const void* objectID,
   1.143 +                                            void* object,
   1.144 +                                            void* cleanupCookie,
   1.145 +                                            object_cleanup_func func) = 0;
   1.146 +    virtual void*           findObject(const void* objectID) const = 0;
   1.147 +    virtual void            detachObject(const void* objectID) = 0;
   1.148 +
   1.149 +    virtual BBinder*        localBinder();
   1.150 +    virtual BpBinder*       remoteBinder();
   1.151 +
   1.152 +protected:
   1.153 +    virtual          ~IBinder();
   1.154 +
   1.155 +private:
   1.156 +};
   1.157 +
   1.158 +}; // namespace android
   1.159 +
   1.160 +// ---------------------------------------------------------------------------
   1.161 +
   1.162 +#endif // ANDROID_IBINDER_H

mercurial