1edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project/*
2edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * Copyright (C) 2008 The Android Open Source Project
3edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project *
4edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * Licensed under the Apache License, Version 2.0 (the "License");
5edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * you may not use this file except in compliance with the License.
6edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * You may obtain a copy of the License at
7edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project *
8edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project *      http://www.apache.org/licenses/LICENSE-2.0
9edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project *
10edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * Unless required by applicable law or agreed to in writing, software
11edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS,
12edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * See the License for the specific language governing permissions and
14edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project * limitations under the License.
15edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project */
16edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
17edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project#ifndef ANDROID_BINDER_H
18edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project#define ANDROID_BINDER_H
19edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
206913c46492f1153cecc647a87217fbb0b0d19689Bailey Forrest#include <atomic>
213effababf2980d029339522fdc914bdeb913d99bHans Boehm#include <stdint.h>
22c5b2c0bf8007562536b822eb060fc54a01f8e08bMathias Agopian#include <binder/IBinder.h>
23edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
24edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project// ---------------------------------------------------------------------------
25edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Projectnamespace android {
26edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
27edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Projectclass BBinder : public IBinder
28edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project{
29edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Projectpublic:
30edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project                        BBinder();
31edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
3283c0446f27b9542d6c2e724817b2b2d8d1f55085Mathias Agopian    virtual const String16& getInterfaceDescriptor() const;
33edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    virtual bool        isBinderAlive() const;
34edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    virtual status_t    pingBinder();
35edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    virtual status_t    dump(int fd, const Vector<String16>& args);
36edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
37edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    virtual status_t    transact(   uint32_t code,
38edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project                                    const Parcel& data,
39edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project                                    Parcel* reply,
40edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project                                    uint32_t flags = 0);
41edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
42edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    virtual status_t    linkToDeath(const sp<DeathRecipient>& recipient,
43edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project                                    void* cookie = NULL,
44edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project                                    uint32_t flags = 0);
45edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
46edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    virtual status_t    unlinkToDeath(  const wp<DeathRecipient>& recipient,
47edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project                                        void* cookie = NULL,
48edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project                                        uint32_t flags = 0,
49edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project                                        wp<DeathRecipient>* outRecipient = NULL);
50edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
51edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    virtual void        attachObject(   const void* objectID,
52edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project                                        void* object,
53edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project                                        void* cleanupCookie,
54edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project                                        object_cleanup_func func);
55edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    virtual void*       findObject(const void* objectID) const;
56edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    virtual void        detachObject(const void* objectID);
57edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
58edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    virtual BBinder*    localBinder();
59edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
60edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Projectprotected:
61edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    virtual             ~BBinder();
62edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
63edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    virtual status_t    onTransact( uint32_t code,
64edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project                                    const Parcel& data,
65edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project                                    Parcel* reply,
66edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project                                    uint32_t flags = 0);
67edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
68edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Projectprivate:
69edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project                        BBinder(const BBinder& o);
70edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project            BBinder&    operator=(const BBinder& o);
71edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
72edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    class Extras;
73edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
746913c46492f1153cecc647a87217fbb0b0d19689Bailey Forrest    std::atomic<Extras*> mExtras;
75edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project            void*       mReserved0;
76edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project};
77edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
78edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project// ---------------------------------------------------------------------------
79edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
80edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Projectclass BpRefBase : public virtual RefBase
81edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project{
82edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Projectprotected:
83edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project                            BpRefBase(const sp<IBinder>& o);
84edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    virtual                 ~BpRefBase();
85edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    virtual void            onFirstRef();
86edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    virtual void            onLastStrongRef(const void* id);
87edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    virtual bool            onIncStrongAttempted(uint32_t flags, const void* id);
88edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
89edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    inline  IBinder*        remote()                { return mRemote; }
90edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    inline  IBinder*        remote() const          { return mRemote; }
91edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
92edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Projectprivate:
93edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project                            BpRefBase(const BpRefBase& o);
94edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    BpRefBase&              operator=(const BpRefBase& o);
95edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
96edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    IBinder* const          mRemote;
97edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project    RefBase::weakref_type*  mRefs;
986913c46492f1153cecc647a87217fbb0b0d19689Bailey Forrest    std::atomic<int32_t>    mState;
99edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project};
100edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
101edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project}; // namespace android
102edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
103edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project// ---------------------------------------------------------------------------
104edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project
105edbf3b6af777b721cd2a1ef461947e51e88241e1The Android Open Source Project#endif // ANDROID_BINDER_H
106