Merge \\"Remove FD from the right Looper\\" into nyc-dev am: db13dd41a9
am: c86a2e325e
Change-Id: I85ed478cf265fbc1857b08b89f32fb2aa358e284
This commit is contained in:
@@ -232,6 +232,19 @@ public final class Choreographer {
|
||||
return sThreadInstance.get();
|
||||
}
|
||||
|
||||
/** Destroys the calling thread's choreographer
|
||||
* @hide
|
||||
*/
|
||||
public static void releaseInstance() {
|
||||
Choreographer old = sThreadInstance.get();
|
||||
sThreadInstance.remove();
|
||||
old.dispose();
|
||||
}
|
||||
|
||||
private void dispose() {
|
||||
mDisplayEventReceiver.dispose();
|
||||
}
|
||||
|
||||
/**
|
||||
* The amount of time, in milliseconds, between each frame of the animation.
|
||||
* <p>
|
||||
|
||||
@@ -217,6 +217,7 @@ public class BackdropFrameRenderer extends Thread implements Choreographer.Frame
|
||||
synchronized (this) {
|
||||
// Make sure no more messages are being sent.
|
||||
mChoreographer = null;
|
||||
Choreographer.releaseInstance();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -75,14 +75,12 @@ NativeDisplayEventReceiver::NativeDisplayEventReceiver(JNIEnv* env,
|
||||
NativeDisplayEventReceiver::~NativeDisplayEventReceiver() {
|
||||
JNIEnv* env = AndroidRuntime::getJNIEnv();
|
||||
env->DeleteGlobalRef(mReceiverWeakGlobal);
|
||||
ALOGV("receiver %p ~ dtor display event receiver.", this);
|
||||
}
|
||||
|
||||
void NativeDisplayEventReceiver::dispose() {
|
||||
ALOGV("receiver %p ~ Disposing display event receiver.", this);
|
||||
|
||||
if (!mReceiver.initCheck()) {
|
||||
mMessageQueue->getLooper()->removeFd(mReceiver.getFd());
|
||||
}
|
||||
DisplayEventDispatcher::dispose();
|
||||
}
|
||||
|
||||
void NativeDisplayEventReceiver::dispatchVsync(nsecs_t timestamp, int32_t id, uint32_t count) {
|
||||
@@ -137,7 +135,7 @@ static jlong nativeInit(JNIEnv* env, jclass clazz, jobject receiverWeak,
|
||||
}
|
||||
|
||||
static void nativeDispose(JNIEnv* env, jclass clazz, jlong receiverPtr) {
|
||||
sp<NativeDisplayEventReceiver> receiver =
|
||||
NativeDisplayEventReceiver* receiver =
|
||||
reinterpret_cast<NativeDisplayEventReceiver*>(receiverPtr);
|
||||
receiver->dispose();
|
||||
receiver->decStrong(gDisplayEventReceiverClassInfo.clazz); // drop reference held by the object
|
||||
|
||||
Reference in New Issue
Block a user