Skip to content

Commit

Permalink
Fix workarounds for Meizu
Browse files Browse the repository at this point in the history
Workarounds.fillAppInfo() is necessary for Meizu devices even before the
first call to internalStreamScreen(), but it is harmful on other
devices (#940).

Therefore, simplify the workaround, by calling fillAppInfo() only if
Build.BRAND equals "meizu" (case insensitive).

Fixes #240 <#240> (again)
Fixes #2656 <#2656>
  • Loading branch information
rom1v committed Oct 21, 2021
1 parent 4c60963 commit ee55118
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,13 @@ public boolean consumeRotationChange() {

public void streamScreen(Device device, FileDescriptor fd) throws IOException {
Workarounds.prepareMainLooper();

try {
internalStreamScreen(device, fd);
} catch (NullPointerException e) {
// Retry with workarounds enabled:
// <https://github.com/Genymobile/scrcpy/issues/365>
// <https://github.com/Genymobile/scrcpy/issues/940>
Ln.d("Applying workarounds to avoid NullPointerException");
if (Build.BRAND.equalsIgnoreCase("meizu")) {
// <https://github.com/Genymobile/scrcpy/issues/240>
// <https://github.com/Genymobile/scrcpy/issues/2656>
Workarounds.fillAppInfo();
internalStreamScreen(device, fd);
}

internalStreamScreen(device, fd);
}

private void internalStreamScreen(Device device, FileDescriptor fd) throws IOException {
Expand Down

0 comments on commit ee55118

Please sign in to comment.