Revert "libutils: disable implicit ref base construction"
This reverts commit 9a1bf53c4b0a45ac0072d26807b145ddcf044c28.
Reason for revert: b/186028624
Change-Id: Icb8b1623df2794222ce3fe34ed5f43506ccf2f68
diff --git a/libutils/Looper.cpp b/libutils/Looper.cpp
index 4b01e5c..14e3e35 100644
--- a/libutils/Looper.cpp
+++ b/libutils/Looper.cpp
@@ -107,15 +107,14 @@
int result = pthread_once(& gTLSOnce, initTLSKey);
LOG_ALWAYS_FATAL_IF(result != 0, "pthread_once failed");
- Looper* looper = (Looper*)pthread_getspecific(gTLSKey);
- return sp<Looper>::fromExisting(looper);
+ return (Looper*)pthread_getspecific(gTLSKey);
}
sp<Looper> Looper::prepare(int opts) {
bool allowNonCallbacks = opts & PREPARE_ALLOW_NON_CALLBACKS;
sp<Looper> looper = Looper::getForThread();
if (looper == nullptr) {
- looper = sp<Looper>::make(allowNonCallbacks);
+ looper = new Looper(allowNonCallbacks);
Looper::setForThread(looper);
}
if (looper->getAllowNonCallbacks() != allowNonCallbacks) {
@@ -425,11 +424,7 @@
}
int Looper::addFd(int fd, int ident, int events, Looper_callbackFunc callback, void* data) {
- sp<SimpleLooperCallback> looperCallback;
- if (callback) {
- looperCallback = sp<SimpleLooperCallback>::make(callback);
- }
- return addFd(fd, ident, events, looperCallback, data);
+ return addFd(fd, ident, events, callback ? new SimpleLooperCallback(callback) : nullptr, data);
}
int Looper::addFd(int fd, int ident, int events, const sp<LooperCallback>& callback, void* data) {