From 7198030fce4b54820a65a10d54fae18a1ab5df84 Mon Sep 17 00:00:00 2001 From: Marco Nelissen Date: Fri, 22 May 2009 12:25:56 -0700 Subject: This should fix the simulator build. --- libs/utils/futex_synchro.c | 1 + 1 file changed, 1 insertion(+) (limited to 'libs/utils') diff --git a/libs/utils/futex_synchro.c b/libs/utils/futex_synchro.c index ba19520339ed..ab48c69218fd 100644 --- a/libs/utils/futex_synchro.c +++ b/libs/utils/futex_synchro.c @@ -28,6 +28,7 @@ // This futex glue code is need on desktop linux, but is already part of bionic. #if !defined(HAVE_FUTEX_WRAPPERS) +#include #include typedef unsigned int u32; #define asmlinkage -- cgit v1.2.3-59-g8ed1b From 6aff905048ba3b03724f17e2aba9089872e14cd2 Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Fri, 22 May 2009 13:20:23 -0700 Subject: Fix a major bug in Bundle when unparcelling from AIDL. There was a serious problem in the Bundle(Parcel) and readFromParcel() methods, where it wasn't doing the copying of the Parcel that Parcel.readBundle() does and is a basic requirement for it to work correctly. This re-arranges the code to make all of these functions (hopefully) correct. Also fix a problem in Parcel where we were not duping fds when copying data from one Parcel to another. --- core/java/android/os/Bundle.java | 68 ++++++++++++++++++++++++++++++++++------ core/java/android/os/Parcel.java | 68 +++------------------------------------- libs/utils/Parcel.cpp | 8 +++-- 3 files changed, 69 insertions(+), 75 deletions(-) (limited to 'libs/utils') diff --git a/core/java/android/os/Bundle.java b/core/java/android/os/Bundle.java index b669fa2d695f..a91655f8e8e9 100644 --- a/core/java/android/os/Bundle.java +++ b/core/java/android/os/Bundle.java @@ -78,6 +78,10 @@ public final class Bundle implements Parcelable, Cloneable { readFromParcel(parcelledData); } + /* package */ Bundle(Parcel parcelledData, int length) { + readFromParcelInner(parcelledData, length); + } + /** * Constructs a new, empty Bundle that uses a specific ClassLoader for * instantiating Parcelable and Serializable objects. @@ -155,13 +159,14 @@ public final class Bundle implements Parcelable, Cloneable { return; } - mParcelledData.setDataPosition(0); - Bundle b = mParcelledData.readBundleUnpacked(mClassLoader); - mMap = b.mMap; - - mHasFds = mParcelledData.hasFileDescriptors(); - mFdsKnown = true; - + int N = mParcelledData.readInt(); + if (N < 0) { + return; + } + if (mMap == null) { + mMap = new HashMap(); + } + mParcelledData.readMapInternal(mMap, N, mClassLoader); mParcelledData.recycle(); mParcelledData = null; } @@ -1427,7 +1432,25 @@ public final class Bundle implements Parcelable, Cloneable { * @param parcel The parcel to copy this bundle to. */ public void writeToParcel(Parcel parcel, int flags) { - parcel.writeBundle(this); + if (mParcelledData != null) { + int length = mParcelledData.dataSize(); + parcel.writeInt(length); + parcel.writeInt(0x4C444E42); // 'B' 'N' 'D' 'L' + parcel.appendFrom(mParcelledData, 0, length); + } else { + parcel.writeInt(-1); // dummy, will hold length + parcel.writeInt(0x4C444E42); // 'B' 'N' 'D' 'L' + + int oldPos = parcel.dataPosition(); + parcel.writeMapInternal(mMap); + int newPos = parcel.dataPosition(); + + // Backpatch length + parcel.setDataPosition(oldPos - 8); + int length = newPos - oldPos; + parcel.writeInt(length); + parcel.setDataPosition(newPos); + } } /** @@ -1436,8 +1459,33 @@ public final class Bundle implements Parcelable, Cloneable { * @param parcel The parcel to overwrite this bundle from. */ public void readFromParcel(Parcel parcel) { - mParcelledData = parcel; - mHasFds = mParcelledData.hasFileDescriptors(); + int length = parcel.readInt(); + if (length < 0) { + throw new RuntimeException("Bad length in parcel: " + length); + } + readFromParcelInner(parcel, length); + } + + void readFromParcelInner(Parcel parcel, int length) { + int magic = parcel.readInt(); + if (magic != 0x4C444E42) { + //noinspection ThrowableInstanceNeverThrown + String st = Log.getStackTraceString(new RuntimeException()); + Log.e("Bundle", "readBundle: bad magic number"); + Log.e("Bundle", "readBundle: trace = " + st); + } + + // Advance within this Parcel + int offset = parcel.dataPosition(); + parcel.setDataPosition(offset + length); + + Parcel p = Parcel.obtain(); + p.setDataPosition(0); + p.appendFrom(parcel, offset, length); + p.setDataPosition(0); + + mParcelledData = p; + mHasFds = p.hasFileDescriptors(); mFdsKnown = true; } diff --git a/core/java/android/os/Parcel.java b/core/java/android/os/Parcel.java index 9a71f6e0f2d4..6cfcceedfa46 100644 --- a/core/java/android/os/Parcel.java +++ b/core/java/android/os/Parcel.java @@ -457,7 +457,7 @@ public final class Parcel { * Flatten a Map into the parcel at the current dataPosition(), * growing dataCapacity() if needed. The Map keys must be String objects. */ - private void writeMapInternal(Map val) { + /* package */ void writeMapInternal(Map val) { if (val == null) { writeInt(-1); return; @@ -480,23 +480,7 @@ public final class Parcel { return; } - if (val.mParcelledData != null) { - int length = val.mParcelledData.dataSize(); - appendFrom(val.mParcelledData, 0, length); - } else { - writeInt(-1); // dummy, will hold length - int oldPos = dataPosition(); - writeInt(0x4C444E42); // 'B' 'N' 'D' 'L' - - writeMapInternal(val.mMap); - int newPos = dataPosition(); - - // Backpatch length - setDataPosition(oldPos - 4); - int length = newPos - oldPos; - writeInt(length); - setDataPosition(newPos); - } + val.writeToParcel(this, 0); } /** @@ -1352,60 +1336,18 @@ public final class Parcel { * Returns null if the previously written Bundle object was null. */ public final Bundle readBundle(ClassLoader loader) { - int offset = dataPosition(); int length = readInt(); if (length < 0) { return null; } - int magic = readInt(); - if (magic != 0x4C444E42) { - //noinspection ThrowableInstanceNeverThrown - String st = Log.getStackTraceString(new RuntimeException()); - Log.e("Bundle", "readBundle: bad magic number"); - Log.e("Bundle", "readBundle: trace = " + st); - } - - // Advance within this Parcel - setDataPosition(offset + length + 4); - - Parcel p = new Parcel(0); - p.setDataPosition(0); - p.appendFrom(this, offset, length + 4); - p.setDataPosition(0); - final Bundle bundle = new Bundle(p); + + final Bundle bundle = new Bundle(this, length); if (loader != null) { bundle.setClassLoader(loader); } return bundle; } - /** - * Read and return a new Bundle object from the parcel at the current - * dataPosition(). Returns null if the previously written Bundle object was - * null. The returned bundle will have its contents fully unpacked using - * the given ClassLoader. - */ - /* package */ Bundle readBundleUnpacked(ClassLoader loader) { - int length = readInt(); - if (length == -1) { - return null; - } - int magic = readInt(); - if (magic != 0x4C444E42) { - //noinspection ThrowableInstanceNeverThrown - String st = Log.getStackTraceString(new RuntimeException()); - Log.e("Bundle", "readBundleUnpacked: bad magic number"); - Log.e("Bundle", "readBundleUnpacked: trace = " + st); - } - Bundle m = new Bundle(loader); - int N = readInt(); - if (N < 0) { - return null; - } - readMapInternal(m.mMap, N, loader); - return m; - } - /** * Read and return a byte[] object from the parcel. */ @@ -1998,7 +1940,7 @@ public final class Parcel { private native void init(int obj); private native void destroy(); - private void readMapInternal(Map outVal, int N, + /* package */ void readMapInternal(Map outVal, int N, ClassLoader loader) { while (N > 0) { Object key = readValue(loader); diff --git a/libs/utils/Parcel.cpp b/libs/utils/Parcel.cpp index e74ad4ad8ea5..b0e37509783e 100644 --- a/libs/utils/Parcel.cpp +++ b/libs/utils/Parcel.cpp @@ -409,12 +409,16 @@ status_t Parcel::appendFrom(Parcel *parcel, size_t offset, size_t len) mObjects[idx++] = off; mObjectsSize++; - const flat_binder_object* flat + flat_binder_object* flat = reinterpret_cast(mData + off); acquire_object(proc, *flat, this); - // take note if the object is a file descriptor if (flat->type == BINDER_TYPE_FD) { + // If this is a file descriptor, we need to dup it so the + // new Parcel now owns its own fd, and can declare that we + // officially know we have fds. + flat->handle = dup(flat->handle); + flat->cookie = (void*)1; mHasFds = mFdsKnown = true; } } -- cgit v1.2.3-59-g8ed1b From f4c46b94b867f6a01bf7d0be18f667819338072f Mon Sep 17 00:00:00 2001 From: Nicolas Catania Date: Fri, 22 May 2009 13:41:38 -0700 Subject: Fix for the simultor build breakage. Added missing include sys/time.h for utimes. Detects when stat64 uses a timespec for the modif and access times and work around the missing st_*time_nsec. Apologies for the whitespace changes, emacs removed them automatically. --- libs/utils/backup_helper_file.cpp | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) (limited to 'libs/utils') diff --git a/libs/utils/backup_helper_file.cpp b/libs/utils/backup_helper_file.cpp index 8efb3eb8b74d..7ec2ce8653d9 100644 --- a/libs/utils/backup_helper_file.cpp +++ b/libs/utils/backup_helper_file.cpp @@ -26,6 +26,7 @@ #include #include #include +#include // for utimes #include #include #include @@ -607,14 +608,14 @@ backup_helper_test_four() 0x11, 0x00, 0x00, 0x00, 0x62, 0x79, 0x74, 0x65, 0x73, 0x5f, 0x6f, 0x66, 0x5f, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x33, 0xab, 0xab, 0xab, - + // bytes of padding2 0x44, 0x11, 0x22, 0x33, 0xef, 0xbe, 0xad, 0xde, 0x44, 0x33, 0x22, 0x11, 0x34, 0x23, 0x12, 0x01, 0x12, 0x00, 0x00, 0x00, 0x62, 0x79, 0x74, 0x65, 0x73, 0x5f, 0x6f, 0x66, 0x5f, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x5f, 0x32, 0xab, 0xab, - + // bytes of padding3 0x44, 0x11, 0x22, 0x33, 0xef, 0xbe, 0xad, 0xde, 0x44, 0x33, 0x22, 0x11, 0x34, 0x23, 0x12, 0x01, @@ -627,7 +628,7 @@ backup_helper_test_four() if (err != 0) { return err; } - + // read fd = open(filename, O_RDONLY); if (fd == -1) { @@ -665,7 +666,7 @@ backup_helper_test_four() matched = false; } } - + return matched ? 0 : 1; } @@ -746,7 +747,7 @@ backup_helper_test_data_writer() system("rm -r " SCRATCH_DIR); mkdir(SCRATCH_DIR, 0777); mkdir(SCRATCH_DIR "data", 0777); - + fd = creat(filename, 0666); if (fd == -1) { fprintf(stderr, "error creating: %s\n", strerror(errno)); @@ -863,7 +864,7 @@ backup_helper_test_data_reader() system("rm -r " SCRATCH_DIR); mkdir(SCRATCH_DIR, 0777); mkdir(SCRATCH_DIR "data", 0777); - + fd = creat(filename, 0666); if (fd == -1) { fprintf(stderr, "error creating: %s\n", strerror(errno)); @@ -940,9 +941,23 @@ get_mod_time(const char* filename, struct timeval times[2]) return errno; } times[0].tv_sec = st.st_atime; - times[0].tv_usec = st.st_atime_nsec / 1000; times[1].tv_sec = st.st_mtime; + + // If st_atime is a macro then struct stat64 uses struct timespec + // to store the access and modif time values and typically + // st_*time_nsec is not defined. In glibc, this is controlled by + // __USE_MISC. +#ifdef __USE_MISC +#if !defined(st_atime) || defined(st_atime_nsec) +#error "Check if this __USE_MISC conditional is still needed." +#endif + times[0].tv_usec = st.st_atim.tv_nsec / 1000; + times[1].tv_usec = st.st_mtim.tv_nsec / 1000; +#else + times[0].tv_usec = st.st_atime_nsec / 1000; times[1].tv_usec = st.st_mtime_nsec / 1000; +#endif + return 0; } @@ -987,7 +1002,7 @@ backup_helper_test_files() { BackupDataWriter dataStream(dataStreamFD); - + err = back_up_files(-1, &dataStream, newSnapshotFD, SCRATCH_DIR, files_before, 5); if (err != 0) { return err; @@ -1017,7 +1032,7 @@ backup_helper_test_files() utimes(SCRATCH_DIR "data/e", e_times); write_text_file(SCRATCH_DIR "data/g", "g\ngg\n"); unlink(SCRATCH_DIR "data/f"); - + char const* files_after[] = { "data/a", // added "data/b", // same @@ -1047,7 +1062,7 @@ backup_helper_test_files() { BackupDataWriter dataStream(dataStreamFD); - + err = back_up_files(oldSnapshotFD, &dataStream, newSnapshotFD, SCRATCH_DIR, files_after, 6); if (err != 0) { @@ -1058,7 +1073,7 @@ backup_helper_test_files() close(oldSnapshotFD); close(dataStreamFD); close(newSnapshotFD); - + return 0; } -- cgit v1.2.3-59-g8ed1b From aaf834a284a025cedd8ec1cf01d09e1790c1dcf8 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Fri, 22 May 2009 19:00:22 -0700 Subject: some work to try to reduce the code size of some native libraries - make sure that all binder Bn classes define a ctor and dtor in their respective library. This avoids duplication of the ctor/dtor in libraries where these objects are instantiated. This is also cleaner, should we want these ctor/dtor to do something one day. - same change as above for some Bp classes and various other non-binder classes - moved the definition of CHECK_INTERFACE() in IInterface.h instead of having it everywhere. - improved the CHECK_INTERFACE() macro so it calls a single method in Parcel, instead of inlining its code everywhere - IBinder::getInterfaceDescriptor() now returns a "const String16&" instead of String16, which saves calls to String16 and ~String16 - implemented a cache for BpBinder::getInterfaceDescriptor(), since this does an IPC. HOWEVER, this method never seems to be called. The cache makes BpBinder bigger, so we need to figure out if we need this method at all. --- camera/libcameraservice/CameraService.cpp | 6 ------ include/binder/Binder.h | 3 ++- include/binder/BpBinder.h | 4 +++- include/binder/IBinder.h | 6 +++--- include/binder/IInterface.h | 24 ++++++++++++++++------ include/binder/IMemory.h | 8 ++++++++ include/binder/MemoryDealer.h | 9 ++++++++ include/binder/Parcel.h | 5 +++-- include/utils/TextOutput.h | 4 ++-- include/utils/Timers.h | 10 ++++----- include/utils/threads.h | 10 ++++----- libs/binder/Binder.cpp | 17 +++++++++++++-- libs/binder/BpBinder.cpp | 33 ++++++++++++++++++++++-------- libs/binder/IInterface.cpp | 7 +++++++ libs/binder/IMemory.cpp | 24 ++++++++++++++-------- libs/binder/IPermissionController.cpp | 6 ------ libs/binder/IServiceManager.cpp | 6 ------ libs/binder/MemoryDealer.cpp | 14 ++++++++++++- libs/binder/MemoryHeapPmem.cpp | 2 +- libs/binder/Parcel.cpp | 7 ++++++- libs/ui/ICamera.cpp | 6 ------ libs/ui/ICameraClient.cpp | 6 ------ libs/ui/ICameraService.cpp | 6 ------ libs/ui/IOverlay.cpp | 6 ------ libs/ui/ISurface.cpp | 6 ------ libs/ui/ISurfaceComposer.cpp | 25 +++++++++++----------- libs/ui/ISurfaceFlingerClient.cpp | 6 ------ libs/utils/CallStack.cpp | 3 ++- libs/utils/TextOutput.cpp | 10 ++++++++- media/libmedia/IAudioFlinger.cpp | 6 ------ media/libmedia/IAudioFlingerClient.cpp | 6 ------ media/libmedia/IAudioRecord.cpp | 6 ------ media/libmedia/IAudioTrack.cpp | 6 ------ media/libmedia/IMediaMetadataRetriever.cpp | 6 ------ media/libmedia/IMediaPlayer.cpp | 6 ------ media/libmedia/IMediaPlayerClient.cpp | 6 ------ media/libmedia/IMediaPlayerService.cpp | 6 ------ media/libmedia/IMediaRecorder.cpp | 6 ------ 38 files changed, 163 insertions(+), 170 deletions(-) (limited to 'libs/utils') diff --git a/camera/libcameraservice/CameraService.cpp b/camera/libcameraservice/CameraService.cpp index 404512e1296d..453dc29369f6 100644 --- a/camera/libcameraservice/CameraService.cpp +++ b/camera/libcameraservice/CameraService.cpp @@ -1052,12 +1052,6 @@ status_t CameraService::dump(int fd, const Vector& args) } -#define CHECK_INTERFACE(interface, data, reply) \ - do { if (!data.enforceInterface(interface::getInterfaceDescriptor())) { \ - LOGW("Call incorrectly routed to " #interface); \ - return PERMISSION_DENIED; \ - } } while (0) - status_t CameraService::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { diff --git a/include/binder/Binder.h b/include/binder/Binder.h index c9b71fd48604..47b2bb9b2cff 100644 --- a/include/binder/Binder.h +++ b/include/binder/Binder.h @@ -27,7 +27,7 @@ class BBinder : public IBinder public: BBinder(); - virtual String16 getInterfaceDescriptor() const; + virtual const String16& getInterfaceDescriptor() const; virtual bool isBinderAlive() const; virtual status_t pingBinder(); virtual status_t dump(int fd, const Vector& args); @@ -71,6 +71,7 @@ private: Extras* mExtras; void* mReserved0; + static String16 sEmptyDescriptor; }; // --------------------------------------------------------------------------- diff --git a/include/binder/BpBinder.h b/include/binder/BpBinder.h index 067637eaeac4..7ef93aa39041 100644 --- a/include/binder/BpBinder.h +++ b/include/binder/BpBinder.h @@ -31,7 +31,7 @@ public: inline int32_t handle() const { return mHandle; } - virtual String16 getInterfaceDescriptor() const; + virtual const String16& getInterfaceDescriptor() const; virtual bool isBinderAlive() const; virtual status_t pingBinder(); virtual status_t dump(int fd, const Vector& args); @@ -106,6 +106,7 @@ private: }; void reportOneDeath(const Obituary& obit); + bool isDescriptorCached() const; mutable Mutex mLock; volatile int32_t mAlive; @@ -113,6 +114,7 @@ private: Vector* mObituaries; ObjectManager mObjects; Parcel* mConstantData; + mutable String16 mDescriptorCache; }; }; // namespace android diff --git a/include/binder/IBinder.h b/include/binder/IBinder.h index 737033090f4e..884b5c123739 100644 --- a/include/binder/IBinder.h +++ b/include/binder/IBinder.h @@ -56,7 +56,7 @@ public: FLAG_ONEWAY = 0x00000001 }; - inline IBinder() { } + IBinder(); /** * Check if this IBinder implements the interface named by @@ -69,7 +69,7 @@ public: * Return the canonical name of the interface provided by this IBinder * object. */ - virtual String16 getInterfaceDescriptor() const = 0; + virtual const String16& getInterfaceDescriptor() const = 0; virtual bool isBinderAlive() const = 0; virtual status_t pingBinder() = 0; @@ -147,7 +147,7 @@ public: virtual BpBinder* remoteBinder(); protected: - inline virtual ~IBinder() { } + virtual ~IBinder(); private: }; diff --git a/include/binder/IInterface.h b/include/binder/IInterface.h index 3b1e33bda123..273d92231fe2 100644 --- a/include/binder/IInterface.h +++ b/include/binder/IInterface.h @@ -27,10 +27,12 @@ namespace android { class IInterface : public virtual RefBase { public: + IInterface(); sp asBinder(); sp asBinder() const; - + protected: + virtual ~IInterface(); virtual IBinder* onAsBinder() = 0; }; @@ -49,7 +51,7 @@ class BnInterface : public INTERFACE, public BBinder { public: virtual sp queryLocalInterface(const String16& _descriptor); - virtual String16 getInterfaceDescriptor() const; + virtual const String16& getInterfaceDescriptor() const; protected: virtual IBinder* onAsBinder(); @@ -72,11 +74,14 @@ protected: #define DECLARE_META_INTERFACE(INTERFACE) \ static const String16 descriptor; \ static sp asInterface(const sp& obj); \ - virtual String16 getInterfaceDescriptor() const; \ + virtual const String16& getInterfaceDescriptor() const; \ + I##INTERFACE(); \ + virtual ~I##INTERFACE(); \ + #define IMPLEMENT_META_INTERFACE(INTERFACE, NAME) \ const String16 I##INTERFACE::descriptor(NAME); \ - String16 I##INTERFACE::getInterfaceDescriptor() const { \ + const String16& I##INTERFACE::getInterfaceDescriptor() const { \ return I##INTERFACE::descriptor; \ } \ sp I##INTERFACE::asInterface(const sp& obj) \ @@ -92,9 +97,16 @@ protected: } \ return intr; \ } \ + I##INTERFACE::I##INTERFACE() { } \ + I##INTERFACE::~I##INTERFACE() { } \ + + +#define CHECK_INTERFACE(interface, data, reply) \ + if (!data.checkInterface(this)) { return PERMISSION_DENIED; } \ + // ---------------------------------------------------------------------- -// No user-servicable parts after this... +// No user-serviceable parts after this... template inline sp BnInterface::queryLocalInterface( @@ -105,7 +117,7 @@ inline sp BnInterface::queryLocalInterface( } template -inline String16 BnInterface::getInterfaceDescriptor() const +inline const String16& BnInterface::getInterfaceDescriptor() const { return INTERFACE::getInterfaceDescriptor(); } diff --git a/include/binder/IMemory.h b/include/binder/IMemory.h index 182792cf0685..ae042cba5592 100644 --- a/include/binder/IMemory.h +++ b/include/binder/IMemory.h @@ -59,6 +59,10 @@ public: const Parcel& data, Parcel* reply, uint32_t flags = 0); + + BnMemoryHeap(); +protected: + virtual ~BnMemoryHeap(); }; // ---------------------------------------------------------------------------- @@ -85,6 +89,10 @@ public: const Parcel& data, Parcel* reply, uint32_t flags = 0); + + BnMemory(); +protected: + virtual ~BnMemory(); }; // ---------------------------------------------------------------------------- diff --git a/include/binder/MemoryDealer.h b/include/binder/MemoryDealer.h index 097767f8cf36..d05755606bd6 100644 --- a/include/binder/MemoryDealer.h +++ b/include/binder/MemoryDealer.h @@ -39,6 +39,10 @@ class HeapInterface : public virtual BnMemoryHeap public: // all values must be page-aligned virtual sp mapMemory(size_t offset, size_t size) = 0; + + HeapInterface(); +protected: + virtual ~HeapInterface(); }; // ---------------------------------------------------------------------------- @@ -61,6 +65,10 @@ public: virtual void dump(const char* what, uint32_t flags = 0) const = 0; virtual void dump(String8& res, const char* what, uint32_t flags = 0) const = 0; + + AllocatorInterface(); +protected: + virtual ~AllocatorInterface(); }; // ---------------------------------------------------------------------------- @@ -71,6 +79,7 @@ public: class SharedHeap : public HeapInterface, public MemoryHeapBase { public: + SharedHeap(); SharedHeap(size_t size, uint32_t flags = 0, char const * name = NULL); virtual ~SharedHeap(); virtual sp mapMemory(size_t offset, size_t size); diff --git a/include/binder/Parcel.h b/include/binder/Parcel.h index af1490a02973..58c2d9ad76da 100644 --- a/include/binder/Parcel.h +++ b/include/binder/Parcel.h @@ -57,7 +57,8 @@ public: status_t writeInterfaceToken(const String16& interface); bool enforceInterface(const String16& interface) const; - + bool checkInterface(IBinder*) const; + void freeData(); const size_t* objects() const; @@ -147,7 +148,7 @@ public: release_func relFunc, void* relCookie); void print(TextOutput& to, uint32_t flags = 0) const; - + private: Parcel(const Parcel& o); Parcel& operator=(const Parcel& o); diff --git a/include/utils/TextOutput.h b/include/utils/TextOutput.h index d8d86ba82cd6..de2fbbee1f2f 100644 --- a/include/utils/TextOutput.h +++ b/include/utils/TextOutput.h @@ -28,8 +28,8 @@ namespace android { class TextOutput { public: - TextOutput() { } - virtual ~TextOutput() { } + TextOutput(); + virtual ~TextOutput(); virtual status_t print(const char* txt, size_t len) = 0; virtual void moveIndent(int delta) = 0; diff --git a/include/utils/Timers.h b/include/utils/Timers.h index 96103995bb4b..577325f5c48d 100644 --- a/include/utils/Timers.h +++ b/include/utils/Timers.h @@ -108,15 +108,15 @@ namespace android { */ class DurationTimer { public: - DurationTimer(void) {} - ~DurationTimer(void) {} + DurationTimer() {} + ~DurationTimer() {} // Start the timer. - void start(void); + void start(); // Stop the timer. - void stop(void); + void stop(); // Get the duration in microseconds. - long long durationUsecs(void) const; + long long durationUsecs() const; // Subtract two timevals. Returns the difference (ptv1-ptv2) in // microseconds. diff --git a/include/utils/threads.h b/include/utils/threads.h index b3209156bc3f..e0cb66423305 100644 --- a/include/utils/threads.h +++ b/include/utils/threads.h @@ -199,11 +199,11 @@ public: // constructed and released when Autolock goes out of scope. class Autolock { public: - inline Autolock(Mutex& mutex) : mpMutex(&mutex) { mutex.lock(); } - inline Autolock(Mutex* mutex) : mpMutex(mutex) { mutex->lock(); } - inline ~Autolock() { mpMutex->unlock(); } + inline Autolock(Mutex& mutex) : mLock(mutex) { mLock.lock(); } + inline Autolock(Mutex* mutex) : mLock(*mutex) { mLock.lock(); } + inline ~Autolock() { mLock.unlock(); } private: - Mutex* mpMutex; + Mutex& mLock; }; private: @@ -291,7 +291,7 @@ protected: bool exitPending() const; private: - // Derived class must implemtent threadLoop(). The thread starts its life + // Derived class must implement threadLoop(). The thread starts its life // here. There are two ways of using the Thread object: // 1) loop: if threadLoop() returns true, it will be called again if // requestExit() wasn't called. diff --git a/libs/binder/Binder.cpp b/libs/binder/Binder.cpp index 26f29f8e98e0..0dd762212f08 100644 --- a/libs/binder/Binder.cpp +++ b/libs/binder/Binder.cpp @@ -27,6 +27,17 @@ namespace android { // --------------------------------------------------------------------------- +IBinder::IBinder() + : RefBase() +{ +} + +IBinder::~IBinder() +{ +} + +// --------------------------------------------------------------------------- + sp IBinder::queryLocalInterface(const String16& descriptor) { return NULL; @@ -58,6 +69,8 @@ public: // --------------------------------------------------------------------------- +String16 BBinder::sEmptyDescriptor; + BBinder::BBinder() : mExtras(NULL) { @@ -73,10 +86,10 @@ status_t BBinder::pingBinder() return NO_ERROR; } -String16 BBinder::getInterfaceDescriptor() const +const String16& BBinder::getInterfaceDescriptor() const { LOGW("reached BBinder::getInterfaceDescriptor (this=%p)", this); - return String16(); + return sEmptyDescriptor; } status_t BBinder::transact( diff --git a/libs/binder/BpBinder.cpp b/libs/binder/BpBinder.cpp index 56bf413c290e..5de87ec7692a 100644 --- a/libs/binder/BpBinder.cpp +++ b/libs/binder/BpBinder.cpp @@ -98,16 +98,33 @@ BpBinder::BpBinder(int32_t handle) IPCThreadState::self()->incWeakHandle(handle); } -String16 BpBinder::getInterfaceDescriptor() const +bool BpBinder::isDescriptorCached() const { + Mutex::Autolock _l(mLock); + return mDescriptorCache.size() ? true : false; +} + +const String16& BpBinder::getInterfaceDescriptor() const { - String16 res; - Parcel send, reply; - status_t err = const_cast(this)->transact( - INTERFACE_TRANSACTION, send, &reply); - if (err == NO_ERROR) { - res = reply.readString16(); + if (isDescriptorCached() == false) { + Parcel send, reply; + // do the IPC without a lock held. + status_t err = const_cast(this)->transact( + INTERFACE_TRANSACTION, send, &reply); + if (err == NO_ERROR) { + String16 res(reply.readString16()); + Mutex::Autolock _l(mLock); + // mDescriptorCache could have been assigned while the lock was + // released. + if (mDescriptorCache.size() == 0) + mDescriptorCache = res; + } } - return res; + + // we're returning a reference to a non-static object here. Usually this + // is not something smart to do, however, with binder objects it is + // (usually) safe because they are reference-counted. + + return mDescriptorCache; } bool BpBinder::isBinderAlive() const diff --git a/libs/binder/IInterface.cpp b/libs/binder/IInterface.cpp index 9f1192f011b1..29acf5ddd1aa 100644 --- a/libs/binder/IInterface.cpp +++ b/libs/binder/IInterface.cpp @@ -20,6 +20,13 @@ namespace android { // --------------------------------------------------------------------------- +IInterface::IInterface() + : RefBase() { +} + +IInterface::~IInterface() { +} + sp IInterface::asBinder() { return this ? onAsBinder() : NULL; diff --git a/libs/binder/IMemory.cpp b/libs/binder/IMemory.cpp index 13d67c07de01..6c1d2253b676 100644 --- a/libs/binder/IMemory.cpp +++ b/libs/binder/IMemory.cpp @@ -205,11 +205,11 @@ sp BpMemory::getMemory(ssize_t* offset, size_t* size) const IMPLEMENT_META_INTERFACE(Memory, "android.utils.IMemory"); -#define CHECK_INTERFACE(interface, data, reply) \ - do { if (!data.enforceInterface(interface::getInterfaceDescriptor())) { \ - LOGW("Call incorrectly routed to " #interface); \ - return PERMISSION_DENIED; \ - } } while (0) +BnMemory::BnMemory() { +} + +BnMemory::~BnMemory() { +} status_t BnMemory::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) @@ -299,11 +299,11 @@ void BpMemoryHeap::assertReallyMapped() const ssize_t size = reply.readInt32(); uint32_t flags = reply.readInt32(); - LOGE_IF(err, "binder=%p transaction failed fd=%d, size=%d, err=%d (%s)", + LOGE_IF(err, "binder=%p transaction failed fd=%d, size=%ld, err=%d (%s)", asBinder().get(), parcel_fd, size, err, strerror(-err)); int fd = dup( parcel_fd ); - LOGE_IF(fd==-1, "cannot dup fd=%d, size=%d, err=%d (%s)", + LOGE_IF(fd==-1, "cannot dup fd=%d, size=%ld, err=%d (%s)", parcel_fd, size, err, strerror(errno)); int access = PROT_READ; @@ -316,7 +316,7 @@ void BpMemoryHeap::assertReallyMapped() const mRealHeap = true; mBase = mmap(0, size, access, MAP_SHARED, fd, 0); if (mBase == MAP_FAILED) { - LOGE("cannot map BpMemoryHeap (binder=%p), size=%d, fd=%d (%s)", + LOGE("cannot map BpMemoryHeap (binder=%p), size=%ld, fd=%d (%s)", asBinder().get(), size, fd, strerror(errno)); close(fd); } else { @@ -357,8 +357,14 @@ uint32_t BpMemoryHeap::getFlags() const { IMPLEMENT_META_INTERFACE(MemoryHeap, "android.utils.IMemoryHeap"); +BnMemoryHeap::BnMemoryHeap() { +} + +BnMemoryHeap::~BnMemoryHeap() { +} + status_t BnMemoryHeap::onTransact( - uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) + uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { switch(code) { case HEAP_ID: { diff --git a/libs/binder/IPermissionController.cpp b/libs/binder/IPermissionController.cpp index a61debf3d517..bff4c9bd7d08 100644 --- a/libs/binder/IPermissionController.cpp +++ b/libs/binder/IPermissionController.cpp @@ -55,12 +55,6 @@ IMPLEMENT_META_INTERFACE(PermissionController, "android.os.IPermissionController // ---------------------------------------------------------------------- -#define CHECK_INTERFACE(interface, data, reply) \ - do { if (!data.enforceInterface(interface::getInterfaceDescriptor())) { \ - LOGW("Call incorrectly routed to " #interface); \ - return PERMISSION_DENIED; \ - } } while (0) - status_t BnPermissionController::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { diff --git a/libs/binder/IServiceManager.cpp b/libs/binder/IServiceManager.cpp index 2f265b8595d6..88774e79b90c 100644 --- a/libs/binder/IServiceManager.cpp +++ b/libs/binder/IServiceManager.cpp @@ -178,12 +178,6 @@ IMPLEMENT_META_INTERFACE(ServiceManager, "android.os.IServiceManager"); // ---------------------------------------------------------------------- -#define CHECK_INTERFACE(interface, data, reply) \ - do { if (!data.enforceInterface(interface::getInterfaceDescriptor())) { \ - LOGW("Call incorrectly routed to " #interface); \ - return PERMISSION_DENIED; \ - } } while (0) - status_t BnServiceManager::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { diff --git a/libs/binder/MemoryDealer.cpp b/libs/binder/MemoryDealer.cpp index fd6ab7ae8834..d5ffe7f6d388 100644 --- a/libs/binder/MemoryDealer.cpp +++ b/libs/binder/MemoryDealer.cpp @@ -38,7 +38,15 @@ #include namespace android { +// ---------------------------------------------------------------------------- +HeapInterface::HeapInterface() { } +HeapInterface::~HeapInterface() { } + +// ---------------------------------------------------------------------------- + +AllocatorInterface::AllocatorInterface() { } +AllocatorInterface::~AllocatorInterface() { } // ---------------------------------------------------------------------------- @@ -107,7 +115,7 @@ sp MemoryDealer::allocate(size_t size, uint32_t flags) if (new_memory != 0) { memory = new Allocation(this, offset, size, new_memory); } else { - LOGE("couldn't map [%8x, %d]", offset, size); + LOGE("couldn't map [%8lx, %u]", offset, size); if (size) { /* NOTE: it's VERY important to not free allocations of size 0 * because they're special as they don't have any record in the @@ -339,6 +347,10 @@ void SimpleBestFitAllocator::dump_l(String8& result, // ---------------------------------------------------------------------------- +SharedHeap::SharedHeap() + : HeapInterface(), MemoryHeapBase() +{ +} SharedHeap::SharedHeap(size_t size, uint32_t flags, char const * name) : MemoryHeapBase(size, flags, name) diff --git a/libs/binder/MemoryHeapPmem.cpp b/libs/binder/MemoryHeapPmem.cpp index 599c9aecd914..3806a42d37c5 100644 --- a/libs/binder/MemoryHeapPmem.cpp +++ b/libs/binder/MemoryHeapPmem.cpp @@ -108,7 +108,7 @@ void SubRegionMemory::revoke() // promote() it. #if HAVE_ANDROID_OS - if (mSize != NULL) { + if (mSize != 0) { const sp& heap(getHeap()); int our_fd = heap->heapID(); struct pmem_region sub; diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp index 3747de67abbe..f40e4bdc3e02 100644 --- a/libs/binder/Parcel.cpp +++ b/libs/binder/Parcel.cpp @@ -441,9 +441,14 @@ status_t Parcel::writeInterfaceToken(const String16& interface) return writeString16(interface); } +bool Parcel::checkInterface(IBinder* binder) const +{ + return enforceInterface(binder->getInterfaceDescriptor()); +} + bool Parcel::enforceInterface(const String16& interface) const { - String16 str = readString16(); + const String16 str(readString16()); if (str == interface) { return true; } else { diff --git a/libs/ui/ICamera.cpp b/libs/ui/ICamera.cpp index cbe8798e7496..805c2ca2be2c 100644 --- a/libs/ui/ICamera.cpp +++ b/libs/ui/ICamera.cpp @@ -221,12 +221,6 @@ IMPLEMENT_META_INTERFACE(Camera, "android.hardware.ICamera"); // ---------------------------------------------------------------------- -#define CHECK_INTERFACE(interface, data, reply) \ - do { if (!data.enforceInterface(interface::getInterfaceDescriptor())) { \ - LOGW("Call incorrectly routed to " #interface); \ - return PERMISSION_DENIED; \ - } } while (0) - status_t BnCamera::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { diff --git a/libs/ui/ICameraClient.cpp b/libs/ui/ICameraClient.cpp index c6cf75c5e951..a88fd48b58a1 100644 --- a/libs/ui/ICameraClient.cpp +++ b/libs/ui/ICameraClient.cpp @@ -66,12 +66,6 @@ IMPLEMENT_META_INTERFACE(CameraClient, "android.hardware.ICameraClient"); // ---------------------------------------------------------------------- -#define CHECK_INTERFACE(interface, data, reply) \ - do { if (!data.enforceInterface(interface::getInterfaceDescriptor())) { \ - LOGW("Call incorrectly routed to " #interface); \ - return PERMISSION_DENIED; \ - } } while (0) - status_t BnCameraClient::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { diff --git a/libs/ui/ICameraService.cpp b/libs/ui/ICameraService.cpp index 1adb4aa2cb50..84986c65c280 100644 --- a/libs/ui/ICameraService.cpp +++ b/libs/ui/ICameraService.cpp @@ -49,12 +49,6 @@ IMPLEMENT_META_INTERFACE(CameraService, "android.hardware.ICameraService"); // ---------------------------------------------------------------------- -#define CHECK_INTERFACE(interface, data, reply) \ - do { if (!data.enforceInterface(interface::getInterfaceDescriptor())) { \ - LOGW("Call incorrectly routed to " #interface); \ - return PERMISSION_DENIED; \ - } } while (0) - status_t BnCameraService::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { diff --git a/libs/ui/IOverlay.cpp b/libs/ui/IOverlay.cpp index a20b36c51f52..65e6b4f37612 100644 --- a/libs/ui/IOverlay.cpp +++ b/libs/ui/IOverlay.cpp @@ -49,12 +49,6 @@ IMPLEMENT_META_INTERFACE(Overlay, "android.ui.IOverlay"); // ---------------------------------------------------------------------- -#define CHECK_INTERFACE(interface, data, reply) \ - do { if (!data.enforceInterface(interface::getInterfaceDescriptor())) { \ - LOGW("Call incorrectly routed to " #interface); \ - return PERMISSION_DENIED; \ - } } while (0) - status_t BnOverlay::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { diff --git a/libs/ui/ISurface.cpp b/libs/ui/ISurface.cpp index a71cf2092d7f..1e60557827d1 100644 --- a/libs/ui/ISurface.cpp +++ b/libs/ui/ISurface.cpp @@ -112,12 +112,6 @@ IMPLEMENT_META_INTERFACE(Surface, "android.ui.ISurface"); // ---------------------------------------------------------------------- -#define CHECK_INTERFACE(interface, data, reply) \ - do { if (!data.enforceInterface(interface::getInterfaceDescriptor())) { \ - LOGW("Call incorrectly routed to " #interface); \ - return PERMISSION_DENIED; \ - } } while (0) - status_t BnSurface::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { diff --git a/libs/ui/ISurfaceComposer.cpp b/libs/ui/ISurfaceComposer.cpp index 4b7f3a223154..5f558a139ca2 100644 --- a/libs/ui/ISurfaceComposer.cpp +++ b/libs/ui/ISurfaceComposer.cpp @@ -156,62 +156,61 @@ IMPLEMENT_META_INTERFACE(SurfaceComposer, "android.ui.ISurfaceComposer"); // ---------------------------------------------------------------------- -#define CHECK_INTERFACE(interface, data, reply) \ - do { if (!data.enforceInterface(interface::getInterfaceDescriptor())) { \ - LOGW("Call incorrectly routed to " #interface); \ - return PERMISSION_DENIED; \ - } } while (0) - status_t BnSurfaceComposer::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { - status_t err = BnInterface::onTransact(code, data, reply, flags); - if (err == NO_ERROR) - return err; - - CHECK_INTERFACE(ISurfaceComposer, data, reply); - switch(code) { case CREATE_CONNECTION: { + CHECK_INTERFACE(ISurfaceComposer, data, reply); sp b = createConnection()->asBinder(); reply->writeStrongBinder(b); } break; case OPEN_GLOBAL_TRANSACTION: { + CHECK_INTERFACE(ISurfaceComposer, data, reply); openGlobalTransaction(); } break; case CLOSE_GLOBAL_TRANSACTION: { + CHECK_INTERFACE(ISurfaceComposer, data, reply); closeGlobalTransaction(); } break; case SET_ORIENTATION: { + CHECK_INTERFACE(ISurfaceComposer, data, reply); DisplayID dpy = data.readInt32(); int orientation = data.readInt32(); uint32_t flags = data.readInt32(); reply->writeInt32( setOrientation(dpy, orientation, flags) ); } break; case FREEZE_DISPLAY: { + CHECK_INTERFACE(ISurfaceComposer, data, reply); DisplayID dpy = data.readInt32(); uint32_t flags = data.readInt32(); reply->writeInt32( freezeDisplay(dpy, flags) ); } break; case UNFREEZE_DISPLAY: { + CHECK_INTERFACE(ISurfaceComposer, data, reply); DisplayID dpy = data.readInt32(); uint32_t flags = data.readInt32(); reply->writeInt32( unfreezeDisplay(dpy, flags) ); } break; case BOOT_FINISHED: { + CHECK_INTERFACE(ISurfaceComposer, data, reply); bootFinished(); } break; case REVOKE_GPU: { + CHECK_INTERFACE(ISurfaceComposer, data, reply); reply->writeInt32( revokeGPU() ); } break; case SIGNAL: { + CHECK_INTERFACE(ISurfaceComposer, data, reply); signal(); } break; case GET_CBLK: { + CHECK_INTERFACE(ISurfaceComposer, data, reply); sp b = getCblk()->asBinder(); reply->writeStrongBinder(b); } break; case REQUEST_GPU: { + CHECK_INTERFACE(ISurfaceComposer, data, reply); // TODO: this should be protected by a permission gpu_info_t info; sp callback @@ -232,7 +231,7 @@ status_t BnSurfaceComposer::onTransact( reply->writeInt32(res); } break; default: - return UNKNOWN_TRANSACTION; + return BBinder::onTransact(code, data, reply, flags); } return NO_ERROR; } diff --git a/libs/ui/ISurfaceFlingerClient.cpp b/libs/ui/ISurfaceFlingerClient.cpp index a93ae67ab81d..329bd6e94f0a 100644 --- a/libs/ui/ISurfaceFlingerClient.cpp +++ b/libs/ui/ISurfaceFlingerClient.cpp @@ -118,12 +118,6 @@ IMPLEMENT_META_INTERFACE(SurfaceFlingerClient, "android.ui.ISurfaceFlingerClient // ---------------------------------------------------------------------- -#define CHECK_INTERFACE(interface, data, reply) \ - do { if (!data.enforceInterface(interface::getInterfaceDescriptor())) { \ - LOGW("Call incorrectly routed to " #interface); \ - return PERMISSION_DENIED; \ - } } while (0) - status_t BnSurfaceFlingerClient::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { diff --git a/libs/utils/CallStack.cpp b/libs/utils/CallStack.cpp index 2fdaa71186b3..55b6024f6315 100644 --- a/libs/utils/CallStack.cpp +++ b/libs/utils/CallStack.cpp @@ -311,7 +311,8 @@ String8 CallStack::toStringSingleLevel(const char* prefix, int32_t level) const } else { void const* start = 0; name = MapInfo::mapAddressToName(ip, "", &start); - snprintf(tmp, 256, "pc %08lx %s", uintptr_t(ip)-uintptr_t(start), name); + snprintf(tmp, 256, "pc %08lx %s", + long(uintptr_t(ip)-uintptr_t(start)), name); res.append(tmp); } res.append("\n"); diff --git a/libs/utils/TextOutput.cpp b/libs/utils/TextOutput.cpp index cebee99e5ba8..e04823d2b57a 100644 --- a/libs/utils/TextOutput.cpp +++ b/libs/utils/TextOutput.cpp @@ -22,9 +22,17 @@ #include #include +namespace android { + // --------------------------------------------------------------------------- -namespace android { +TextOutput::TextOutput() { +} + +TextOutput::~TextOutput() { +} + +// --------------------------------------------------------------------------- TextOutput& operator<<(TextOutput& to, bool val) { diff --git a/media/libmedia/IAudioFlinger.cpp b/media/libmedia/IAudioFlinger.cpp index 09f1c361418e..6fc0cb7f50ce 100644 --- a/media/libmedia/IAudioFlinger.cpp +++ b/media/libmedia/IAudioFlinger.cpp @@ -353,12 +353,6 @@ IMPLEMENT_META_INTERFACE(AudioFlinger, "android.media.IAudioFlinger"); // ---------------------------------------------------------------------- -#define CHECK_INTERFACE(interface, data, reply) \ - do { if (!data.enforceInterface(interface::getInterfaceDescriptor())) { \ - LOGW("Call incorrectly routed to " #interface); \ - return PERMISSION_DENIED; \ - } } while (0) - status_t BnAudioFlinger::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { diff --git a/media/libmedia/IAudioFlingerClient.cpp b/media/libmedia/IAudioFlingerClient.cpp index dbc2bba0ab71..75699b494145 100644 --- a/media/libmedia/IAudioFlingerClient.cpp +++ b/media/libmedia/IAudioFlingerClient.cpp @@ -51,12 +51,6 @@ IMPLEMENT_META_INTERFACE(AudioFlingerClient, "android.media.IAudioFlingerClient" // ---------------------------------------------------------------------- -#define CHECK_INTERFACE(interface, data, reply) \ - do { if (!data.enforceInterface(interface::getInterfaceDescriptor())) { \ - LOGW("Call incorrectly routed to " #interface); \ - return PERMISSION_DENIED; \ - } } while (0) - status_t BnAudioFlingerClient::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { diff --git a/media/libmedia/IAudioRecord.cpp b/media/libmedia/IAudioRecord.cpp index 000a304660eb..8fb5d3d274cd 100644 --- a/media/libmedia/IAudioRecord.cpp +++ b/media/libmedia/IAudioRecord.cpp @@ -66,12 +66,6 @@ IMPLEMENT_META_INTERFACE(AudioRecord, "android.media.IAudioRecord"); // ---------------------------------------------------------------------- -#define CHECK_INTERFACE(interface, data, reply) \ - do { if (!data.enforceInterface(interface::getInterfaceDescriptor())) { \ - LOGW("Call incorrectly routed to " #interface); \ - return PERMISSION_DENIED; \ - } } while (0) - status_t BnAudioRecord::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { diff --git a/media/libmedia/IAudioTrack.cpp b/media/libmedia/IAudioTrack.cpp index 3d25a3ecba4e..75b861ba7dec 100644 --- a/media/libmedia/IAudioTrack.cpp +++ b/media/libmedia/IAudioTrack.cpp @@ -91,12 +91,6 @@ IMPLEMENT_META_INTERFACE(AudioTrack, "android.media.IAudioTrack"); // ---------------------------------------------------------------------- -#define CHECK_INTERFACE(interface, data, reply) \ - do { if (!data.enforceInterface(interface::getInterfaceDescriptor())) { \ - LOGW("Call incorrectly routed to " #interface); \ - return PERMISSION_DENIED; \ - } } while (0) - status_t BnAudioTrack::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { diff --git a/media/libmedia/IMediaMetadataRetriever.cpp b/media/libmedia/IMediaMetadataRetriever.cpp index dd4df99bc5a1..d16394f88d0c 100644 --- a/media/libmedia/IMediaMetadataRetriever.cpp +++ b/media/libmedia/IMediaMetadataRetriever.cpp @@ -130,12 +130,6 @@ IMPLEMENT_META_INTERFACE(MediaMetadataRetriever, "android.hardware.IMediaMetadat // ---------------------------------------------------------------------- -#define CHECK_INTERFACE(interface, data, reply) \ - do { if (!data.enforceInterface(interface::getInterfaceDescriptor())) { \ - LOGW("Call incorrectly routed to " #interface); \ - return PERMISSION_DENIED; \ - } } while (0) - status_t BnMediaMetadataRetriever::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { diff --git a/media/libmedia/IMediaPlayer.cpp b/media/libmedia/IMediaPlayer.cpp index 997251bdf717..f9e83a0f855f 100644 --- a/media/libmedia/IMediaPlayer.cpp +++ b/media/libmedia/IMediaPlayer.cpp @@ -175,12 +175,6 @@ IMPLEMENT_META_INTERFACE(MediaPlayer, "android.hardware.IMediaPlayer"); // ---------------------------------------------------------------------- -#define CHECK_INTERFACE(interface, data, reply) \ - do { if (!data.enforceInterface(interface::getInterfaceDescriptor())) { \ - LOGW("Call incorrectly routed to " #interface); \ - return PERMISSION_DENIED; \ - } } while (0) - status_t BnMediaPlayer::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { diff --git a/media/libmedia/IMediaPlayerClient.cpp b/media/libmedia/IMediaPlayerClient.cpp index d1f08bdb5852..da4f7ef06b56 100644 --- a/media/libmedia/IMediaPlayerClient.cpp +++ b/media/libmedia/IMediaPlayerClient.cpp @@ -50,12 +50,6 @@ IMPLEMENT_META_INTERFACE(MediaPlayerClient, "android.hardware.IMediaPlayerClient // ---------------------------------------------------------------------- -#define CHECK_INTERFACE(interface, data, reply) \ - do { if (!data.enforceInterface(interface::getInterfaceDescriptor())) { \ - LOGW("Call incorrectly routed to " #interface); \ - return PERMISSION_DENIED; \ - } } while (0) - status_t BnMediaPlayerClient::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { diff --git a/media/libmedia/IMediaPlayerService.cpp b/media/libmedia/IMediaPlayerService.cpp index 8fd13ae57dcc..84efc2ad0b65 100644 --- a/media/libmedia/IMediaPlayerService.cpp +++ b/media/libmedia/IMediaPlayerService.cpp @@ -115,12 +115,6 @@ IMPLEMENT_META_INTERFACE(MediaPlayerService, "android.hardware.IMediaPlayerServi // ---------------------------------------------------------------------- -#define CHECK_INTERFACE(interface, data, reply) \ - do { if (!data.enforceInterface(interface::getInterfaceDescriptor())) { \ - LOGW("Call incorrectly routed to " #interface); \ - return PERMISSION_DENIED; \ - } } while (0) - status_t BnMediaPlayerService::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { diff --git a/media/libmedia/IMediaRecorder.cpp b/media/libmedia/IMediaRecorder.cpp index dadb38a7f7c3..53b5aa3b9ce7 100644 --- a/media/libmedia/IMediaRecorder.cpp +++ b/media/libmedia/IMediaRecorder.cpp @@ -268,12 +268,6 @@ IMPLEMENT_META_INTERFACE(MediaRecorder, "android.hardware.IMediaRecorder"); // ---------------------------------------------------------------------- -#define CHECK_INTERFACE(interface, data, reply) \ - do { if (!data.enforceInterface(interface::getInterfaceDescriptor())) { \ - LOGW("Call incorrectly routed to " #interface); \ - return PERMISSION_DENIED; \ - } } while (0) - status_t BnMediaRecorder::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { -- cgit v1.2.3-59-g8ed1b