libbinder_ndk: ABBinder objects are tagged.
This allows us to always cast an object directly to the underlying
object rather than temporarily putting it behind a proxy. This also
simplifies the AIBinder_associateClass API greatly.
As a side-effect, this also fixes reading null parcelables from
binder buffers due to a previously missing check.
Bug: 111445392
Test: runtests.sh
Change-Id: I0c9a75132f9da35a2500b1e83f218b180b2dda36
diff --git a/libs/binder/ndk/AServiceManager.cpp b/libs/binder/ndk/AServiceManager.cpp
index f61b914..3979945 100644
--- a/libs/binder/ndk/AServiceManager.cpp
+++ b/libs/binder/ndk/AServiceManager.cpp
@@ -41,7 +41,7 @@
sp<IServiceManager> sm = defaultServiceManager();
sp<IBinder> binder = sm->getService(String16(instance));
- AIBinder* ret = new ABpBinder(binder);
- AIBinder_incStrong(ret);
- return ret;
+ sp<AIBinder> ret = ABpBinder::fromBinder(binder);
+ AIBinder_incStrong(ret.get());
+ return ret.get();
}