fix: workaround for getDisplayIds on Android 13

This commit is contained in:
Sergey Volkov 2022-07-22 18:44:10 +03:00
parent 451ebee56f
commit ac7ffeb91c
2 changed files with 13 additions and 1 deletions

View file

@ -7,7 +7,7 @@ android {
minSdkVersion 21
targetSdkVersion 30
versionCode 11900
versionName "1.19-ws2"
versionName "1.19-ws3"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {

View file

@ -1,9 +1,13 @@
package com.genymobile.scrcpy.wrappers;
import com.genymobile.scrcpy.DisplayInfo;
import com.genymobile.scrcpy.Ln;
import com.genymobile.scrcpy.Size;
import android.os.IInterface;
import android.view.Display;
import java.lang.reflect.Method;
public final class DisplayManager {
private final IInterface manager;
@ -34,6 +38,14 @@ public final class DisplayManager {
public int[] getDisplayIds() {
try {
return (int[]) manager.getClass().getMethod("getDisplayIds").invoke(manager);
} catch (NoSuchMethodException e) {
Ln.d("Failed to get display ids");
Ln.d("Available methods:");
for (Method m: manager.getClass().getMethods()) {
Ln.d(m.getName());
}
Ln.d("///");
return new int[]{Display.DEFAULT_DISPLAY};
} catch (Exception e) {
throw new AssertionError(e);
}