Merge "Workaround a robelectric related NPE in SurfaceSyncGroup.addTimer" into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
a380a318d3
@@ -26,6 +26,7 @@ import android.os.Debug;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.HandlerThread;
|
import android.os.HandlerThread;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
|
import android.os.Looper;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.Trace;
|
import android.os.Trace;
|
||||||
import android.util.ArraySet;
|
import android.util.ArraySet;
|
||||||
@@ -800,22 +801,25 @@ public final class SurfaceSyncGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addTimeout() {
|
private void addTimeout() {
|
||||||
|
Looper looper = null;
|
||||||
synchronized (sHandlerThreadLock) {
|
synchronized (sHandlerThreadLock) {
|
||||||
if (sHandlerThread == null) {
|
if (sHandlerThread == null) {
|
||||||
sHandlerThread = new HandlerThread("SurfaceSyncGroupTimer");
|
sHandlerThread = new HandlerThread("SurfaceSyncGroupTimer");
|
||||||
sHandlerThread.start();
|
sHandlerThread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
looper = sHandlerThread.getLooper();
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
if (mTimeoutAdded || mTimeoutDisabled) {
|
if (mTimeoutAdded || mTimeoutDisabled || looper == null) {
|
||||||
// We only need one timeout for the entire SurfaceSyncGroup since we just want to
|
// We only need one timeout for the entire SurfaceSyncGroup since we just want to
|
||||||
// ensure it doesn't stay stuck forever.
|
// ensure it doesn't stay stuck forever.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mHandler == null) {
|
if (mHandler == null) {
|
||||||
mHandler = new Handler(sHandlerThread.getLooper());
|
mHandler = new Handler(looper);
|
||||||
}
|
}
|
||||||
|
|
||||||
mTimeoutAdded = true;
|
mTimeoutAdded = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user