Revert "Reland "libutils: disable implicit ref base construction""
This reverts commit 02c47655e7d3a5a2dfaf78a5dd225f5727ff8fa4.
Reason for revert: broke another test b/186468053
Change-Id: I0ec82455ad203071e523092ae3cb5f0f1df6aac7
diff --git a/libutils/Android.bp b/libutils/Android.bp
index df761a8..6201569 100644
--- a/libutils/Android.bp
+++ b/libutils/Android.bp
@@ -76,7 +76,6 @@
"-Wall",
"-Werror",
"-Wno-exit-time-destructors",
- "-DANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION",
],
header_libs: [
"libbase_headers",
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) {
diff --git a/libutils/NativeHandle.cpp b/libutils/NativeHandle.cpp
index 819a603..d437a9f 100644
--- a/libutils/NativeHandle.cpp
+++ b/libutils/NativeHandle.cpp
@@ -20,7 +20,7 @@
namespace android {
sp<NativeHandle> NativeHandle::create(native_handle_t* handle, bool ownsHandle) {
- return handle ? sp<NativeHandle>::make(handle, ownsHandle) : nullptr;
+ return handle ? new NativeHandle(handle, ownsHandle) : nullptr;
}
NativeHandle::NativeHandle(native_handle_t* handle, bool ownsHandle)
diff --git a/libutils/Threads.cpp b/libutils/Threads.cpp
index 1c8f810..540dcf4 100644
--- a/libutils/Threads.cpp
+++ b/libutils/Threads.cpp
@@ -693,7 +693,7 @@
mThread = thread_id_t(-1);
// hold a strong reference on ourself
- mHoldSelf = sp<Thread>::fromExisting(this);
+ mHoldSelf = this;
mRunning = true;
diff --git a/libutils/include/utils/NativeHandle.h b/libutils/include/utils/NativeHandle.h
index f26a1a4..73fe804 100644
--- a/libutils/include/utils/NativeHandle.h
+++ b/libutils/include/utils/NativeHandle.h
@@ -39,8 +39,6 @@
private:
// for access to the destructor
friend class LightRefBase<NativeHandle>;
- // for access to the constructor
- friend class sp<NativeHandle>;
NativeHandle(native_handle_t* handle, bool ownsHandle);
~NativeHandle();