Loading include/binder/IInterface.h +3 −3 Original line number Diff line number Diff line Loading @@ -28,8 +28,8 @@ class IInterface : public virtual RefBase { public: IInterface(); sp<IBinder> asBinder(); sp<const IBinder> asBinder() const; static sp<IBinder> asBinder(const IInterface*); static sp<IBinder> asBinder(const sp<IInterface>&); protected: virtual ~IInterface(); Loading libs/binder/AppOpsManager.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -44,7 +44,7 @@ sp<IAppOpsService> AppOpsManager::getService() int64_t startTime = 0; mLock.lock(); sp<IAppOpsService> service = mService; while (service == NULL || !service->asBinder()->isBinderAlive()) { while (service == NULL || !IInterface::asBinder(service)->isBinderAlive()) { sp<IBinder> binder = defaultServiceManager()->checkService(_appops); if (binder == NULL) { // Wait for the app ops service to come back... Loading libs/binder/IAppOpsService.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -91,14 +91,14 @@ public: data.writeInterfaceToken(IAppOpsService::getInterfaceDescriptor()); data.writeInt32(op); data.writeString16(packageName); data.writeStrongBinder(callback->asBinder()); data.writeStrongBinder(IInterface::asBinder(callback)); remote()->transact(START_WATCHING_MODE_TRANSACTION, data, &reply); } virtual void stopWatchingMode(const sp<IAppOpsCallback>& callback) { Parcel data, reply; data.writeInterfaceToken(IAppOpsService::getInterfaceDescriptor()); data.writeStrongBinder(callback->asBinder()); data.writeStrongBinder(IInterface::asBinder(callback)); remote()->transact(STOP_WATCHING_MODE_TRANSACTION, data, &reply); } Loading libs/binder/IInterface.cpp +8 −4 Original line number Diff line number Diff line Loading @@ -27,14 +27,18 @@ IInterface::IInterface() IInterface::~IInterface() { } sp<IBinder> IInterface::asBinder() // static sp<IBinder> IInterface::asBinder(const IInterface* iface) { return onAsBinder(); if (iface == NULL) return NULL; return const_cast<IInterface*>(iface)->onAsBinder(); } sp<const IBinder> IInterface::asBinder() const // static sp<IBinder> IInterface::asBinder(const sp<IInterface>& iface) { return const_cast<IInterface*>(this)->onAsBinder(); if (iface == NULL) return NULL; return iface->onAsBinder(); } // --------------------------------------------------------------------------- Loading libs/binder/IMemory.cpp +7 −6 Original line number Diff line number Diff line Loading @@ -216,7 +216,7 @@ status_t BnMemory::onTransact( CHECK_INTERFACE(IMemory, data, reply); ssize_t offset; size_t size; reply->writeStrongBinder( getMemory(&offset, &size)->asBinder() ); reply->writeStrongBinder( IInterface::asBinder(getMemory(&offset, &size)) ); reply->writeInt32(offset); reply->writeInt32(size); return NO_ERROR; Loading @@ -241,7 +241,7 @@ BpMemoryHeap::~BpMemoryHeap() { if (mRealHeap) { // by construction we're the last one if (mBase != MAP_FAILED) { sp<IBinder> binder = const_cast<BpMemoryHeap*>(this)->asBinder(); sp<IBinder> binder = IInterface::asBinder(this); if (VERBOSE) { ALOGD("UNMAPPING binder=%p, heap=%p, size=%zu, fd=%d", Loading @@ -253,7 +253,7 @@ BpMemoryHeap::~BpMemoryHeap() { } } else { // remove from list only if it was mapped before sp<IBinder> binder = const_cast<BpMemoryHeap*>(this)->asBinder(); sp<IBinder> binder = IInterface::asBinder(this); free_heap(binder); } } Loading @@ -262,7 +262,7 @@ BpMemoryHeap::~BpMemoryHeap() { void BpMemoryHeap::assertMapped() const { if (mHeapId == -1) { sp<IBinder> binder(const_cast<BpMemoryHeap*>(this)->asBinder()); sp<IBinder> binder(IInterface::asBinder(const_cast<BpMemoryHeap*>(this))); sp<BpMemoryHeap> heap(static_cast<BpMemoryHeap*>(find_heap(binder).get())); heap->assertReallyMapped(); if (heap->mBase != MAP_FAILED) { Loading Loading @@ -297,7 +297,8 @@ void BpMemoryHeap::assertReallyMapped() const uint32_t offset = reply.readInt32(); ALOGE_IF(err, "binder=%p transaction failed fd=%d, size=%zd, err=%d (%s)", asBinder().get(), parcel_fd, size, err, strerror(-err)); IInterface::asBinder(this).get(), parcel_fd, size, err, strerror(-err)); int fd = dup( parcel_fd ); ALOGE_IF(fd==-1, "cannot dup fd=%d, size=%zd, err=%d (%s)", Loading @@ -314,7 +315,7 @@ void BpMemoryHeap::assertReallyMapped() const mBase = mmap(0, size, access, MAP_SHARED, fd, offset); if (mBase == MAP_FAILED) { ALOGE("cannot map BpMemoryHeap (binder=%p), size=%zd, fd=%d (%s)", asBinder().get(), size, fd, strerror(errno)); IInterface::asBinder(this).get(), size, fd, strerror(errno)); close(fd); } else { mSize = size; Loading Loading
include/binder/IInterface.h +3 −3 Original line number Diff line number Diff line Loading @@ -28,8 +28,8 @@ class IInterface : public virtual RefBase { public: IInterface(); sp<IBinder> asBinder(); sp<const IBinder> asBinder() const; static sp<IBinder> asBinder(const IInterface*); static sp<IBinder> asBinder(const sp<IInterface>&); protected: virtual ~IInterface(); Loading
libs/binder/AppOpsManager.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -44,7 +44,7 @@ sp<IAppOpsService> AppOpsManager::getService() int64_t startTime = 0; mLock.lock(); sp<IAppOpsService> service = mService; while (service == NULL || !service->asBinder()->isBinderAlive()) { while (service == NULL || !IInterface::asBinder(service)->isBinderAlive()) { sp<IBinder> binder = defaultServiceManager()->checkService(_appops); if (binder == NULL) { // Wait for the app ops service to come back... Loading
libs/binder/IAppOpsService.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -91,14 +91,14 @@ public: data.writeInterfaceToken(IAppOpsService::getInterfaceDescriptor()); data.writeInt32(op); data.writeString16(packageName); data.writeStrongBinder(callback->asBinder()); data.writeStrongBinder(IInterface::asBinder(callback)); remote()->transact(START_WATCHING_MODE_TRANSACTION, data, &reply); } virtual void stopWatchingMode(const sp<IAppOpsCallback>& callback) { Parcel data, reply; data.writeInterfaceToken(IAppOpsService::getInterfaceDescriptor()); data.writeStrongBinder(callback->asBinder()); data.writeStrongBinder(IInterface::asBinder(callback)); remote()->transact(STOP_WATCHING_MODE_TRANSACTION, data, &reply); } Loading
libs/binder/IInterface.cpp +8 −4 Original line number Diff line number Diff line Loading @@ -27,14 +27,18 @@ IInterface::IInterface() IInterface::~IInterface() { } sp<IBinder> IInterface::asBinder() // static sp<IBinder> IInterface::asBinder(const IInterface* iface) { return onAsBinder(); if (iface == NULL) return NULL; return const_cast<IInterface*>(iface)->onAsBinder(); } sp<const IBinder> IInterface::asBinder() const // static sp<IBinder> IInterface::asBinder(const sp<IInterface>& iface) { return const_cast<IInterface*>(this)->onAsBinder(); if (iface == NULL) return NULL; return iface->onAsBinder(); } // --------------------------------------------------------------------------- Loading
libs/binder/IMemory.cpp +7 −6 Original line number Diff line number Diff line Loading @@ -216,7 +216,7 @@ status_t BnMemory::onTransact( CHECK_INTERFACE(IMemory, data, reply); ssize_t offset; size_t size; reply->writeStrongBinder( getMemory(&offset, &size)->asBinder() ); reply->writeStrongBinder( IInterface::asBinder(getMemory(&offset, &size)) ); reply->writeInt32(offset); reply->writeInt32(size); return NO_ERROR; Loading @@ -241,7 +241,7 @@ BpMemoryHeap::~BpMemoryHeap() { if (mRealHeap) { // by construction we're the last one if (mBase != MAP_FAILED) { sp<IBinder> binder = const_cast<BpMemoryHeap*>(this)->asBinder(); sp<IBinder> binder = IInterface::asBinder(this); if (VERBOSE) { ALOGD("UNMAPPING binder=%p, heap=%p, size=%zu, fd=%d", Loading @@ -253,7 +253,7 @@ BpMemoryHeap::~BpMemoryHeap() { } } else { // remove from list only if it was mapped before sp<IBinder> binder = const_cast<BpMemoryHeap*>(this)->asBinder(); sp<IBinder> binder = IInterface::asBinder(this); free_heap(binder); } } Loading @@ -262,7 +262,7 @@ BpMemoryHeap::~BpMemoryHeap() { void BpMemoryHeap::assertMapped() const { if (mHeapId == -1) { sp<IBinder> binder(const_cast<BpMemoryHeap*>(this)->asBinder()); sp<IBinder> binder(IInterface::asBinder(const_cast<BpMemoryHeap*>(this))); sp<BpMemoryHeap> heap(static_cast<BpMemoryHeap*>(find_heap(binder).get())); heap->assertReallyMapped(); if (heap->mBase != MAP_FAILED) { Loading Loading @@ -297,7 +297,8 @@ void BpMemoryHeap::assertReallyMapped() const uint32_t offset = reply.readInt32(); ALOGE_IF(err, "binder=%p transaction failed fd=%d, size=%zd, err=%d (%s)", asBinder().get(), parcel_fd, size, err, strerror(-err)); IInterface::asBinder(this).get(), parcel_fd, size, err, strerror(-err)); int fd = dup( parcel_fd ); ALOGE_IF(fd==-1, "cannot dup fd=%d, size=%zd, err=%d (%s)", Loading @@ -314,7 +315,7 @@ void BpMemoryHeap::assertReallyMapped() const mBase = mmap(0, size, access, MAP_SHARED, fd, offset); if (mBase == MAP_FAILED) { ALOGE("cannot map BpMemoryHeap (binder=%p), size=%zd, fd=%d (%s)", asBinder().get(), size, fd, strerror(errno)); IInterface::asBinder(this).get(), size, fd, strerror(errno)); close(fd); } else { mSize = size; Loading