Reland^2 "libutils: disable implicit ref base construction"
This reverts commit 2cb7593792
.
Reason for revert: reland after fixing b/186468053
Bug: 184190315
Change-Id: I2a46b7a8148db444f9bd4b24746f64217cbba947
This commit is contained in:
parent
2cb7593792
commit
a06e68cb7a
5 changed files with 13 additions and 5 deletions
|
@ -76,6 +76,7 @@ cc_defaults {
|
|||
"-Wall",
|
||||
"-Werror",
|
||||
"-Wno-exit-time-destructors",
|
||||
"-DANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION",
|
||||
],
|
||||
header_libs: [
|
||||
"libbase_headers",
|
||||
|
|
|
@ -107,14 +107,15 @@ sp<Looper> Looper::getForThread() {
|
|||
int result = pthread_once(& gTLSOnce, initTLSKey);
|
||||
LOG_ALWAYS_FATAL_IF(result != 0, "pthread_once failed");
|
||||
|
||||
return (Looper*)pthread_getspecific(gTLSKey);
|
||||
Looper* looper = (Looper*)pthread_getspecific(gTLSKey);
|
||||
return sp<Looper>::fromExisting(looper);
|
||||
}
|
||||
|
||||
sp<Looper> Looper::prepare(int opts) {
|
||||
bool allowNonCallbacks = opts & PREPARE_ALLOW_NON_CALLBACKS;
|
||||
sp<Looper> looper = Looper::getForThread();
|
||||
if (looper == nullptr) {
|
||||
looper = new Looper(allowNonCallbacks);
|
||||
looper = sp<Looper>::make(allowNonCallbacks);
|
||||
Looper::setForThread(looper);
|
||||
}
|
||||
if (looper->getAllowNonCallbacks() != allowNonCallbacks) {
|
||||
|
@ -424,7 +425,11 @@ void Looper::pushResponse(int events, const Request& request) {
|
|||
}
|
||||
|
||||
int Looper::addFd(int fd, int ident, int events, Looper_callbackFunc callback, void* data) {
|
||||
return addFd(fd, ident, events, callback ? new SimpleLooperCallback(callback) : nullptr, data);
|
||||
sp<SimpleLooperCallback> looperCallback;
|
||||
if (callback) {
|
||||
looperCallback = sp<SimpleLooperCallback>::make(callback);
|
||||
}
|
||||
return addFd(fd, ident, events, looperCallback, data);
|
||||
}
|
||||
|
||||
int Looper::addFd(int fd, int ident, int events, const sp<LooperCallback>& callback, void* data) {
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
namespace android {
|
||||
|
||||
sp<NativeHandle> NativeHandle::create(native_handle_t* handle, bool ownsHandle) {
|
||||
return handle ? new NativeHandle(handle, ownsHandle) : nullptr;
|
||||
return handle ? sp<NativeHandle>::make(handle, ownsHandle) : nullptr;
|
||||
}
|
||||
|
||||
NativeHandle::NativeHandle(native_handle_t* handle, bool ownsHandle)
|
||||
|
|
|
@ -693,7 +693,7 @@ status_t Thread::run(const char* name, int32_t priority, size_t stack)
|
|||
mThread = thread_id_t(-1);
|
||||
|
||||
// hold a strong reference on ourself
|
||||
mHoldSelf = this;
|
||||
mHoldSelf = sp<Thread>::fromExisting(this);
|
||||
|
||||
mRunning = true;
|
||||
|
||||
|
|
|
@ -39,6 +39,8 @@ public:
|
|||
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();
|
||||
|
|
Loading…
Reference in a new issue