src/api-impl/android/os/Looper.java: avoid some crashes

This commit is contained in:
Mis012
2023-01-09 13:54:11 +01:00
parent f081cdff3b
commit b10bbaeae2

View File

@@ -105,9 +105,10 @@ public final class Looper {
/** Returns the application's main looper, which lives in the main thread of the application. /** Returns the application's main looper, which lives in the main thread of the application.
*/ */
public static Looper getMainLooper() { public static Looper getMainLooper() {
synchronized (Looper.class) { return new Looper();
/* synchronized (Looper.class) {
return sMainLooper; return sMainLooper;
} }*/
} }
/** /**
@@ -167,10 +168,11 @@ public final class Looper {
* null if the calling thread is not associated with a Looper. * null if the calling thread is not associated with a Looper.
*/ */
public static Looper myLooper() { public static Looper myLooper() {
if(sThreadLocal.get() == null) { return new Looper();
/* if(sThreadLocal.get() == null) {
prepare(false); prepare(false);
} }
return sThreadLocal.get(); return sThreadLocal.get();*/
} }
/** /**
@@ -290,7 +292,8 @@ public final class Looper {
* Return the Thread associated with this Looper. * Return the Thread associated with this Looper.
*/ */
public Thread getThread() { public Thread getThread() {
return mThread; return Thread.currentThread(); // ugly hack
// return mThread;
} }
/** @hide */ /** @hide */