-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move workarounds to a separate class
Extract workarounds (currently only one) to a separate class to avoid polluting the main code.
- Loading branch information
Showing
2 changed files
with
22 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
server/src/main/java/com/genymobile/scrcpy/Workarounds.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.genymobile.scrcpy; | ||
|
||
import android.os.Looper; | ||
|
||
public final class Workarounds { | ||
private Workarounds() { | ||
// not instantiable | ||
} | ||
|
||
public static void prepareMainLooper() { | ||
// Some devices internally create a Handler when creating an input Surface, causing an exception: | ||
// "Can't create handler inside thread that has not called Looper.prepare()" | ||
// <https://github.com/Genymobile/scrcpy/issues/240> | ||
// | ||
// Use Looper.prepareMainLooper() instead of Looper.prepare() to avoid a NullPointerException: | ||
// "Attempt to read from field 'android.os.MessageQueue android.os.Looper.mQueue' | ||
// on a null object reference" | ||
// <https://github.com/Genymobile/scrcpy/issues/921> | ||
Looper.prepareMainLooper(); | ||
} | ||
} |