Merge pull request #587 from schwabe/fix_586_screen_off_qbeta

Use getPhysicalDisplayToken if getBuiltInDisplay is not found
This commit is contained in:
Romain Vimont 2019-06-14 10:04:12 +02:00 committed by GitHub
commit b29a568f08
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,6 +2,7 @@ package com.genymobile.scrcpy.wrappers;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.graphics.Rect; import android.graphics.Rect;
import android.os.Build;
import android.os.IBinder; import android.os.IBinder;
import android.view.Surface; import android.view.Surface;
@ -77,7 +78,13 @@ public final class SurfaceControl {
public static IBinder getBuiltInDisplay(int builtInDisplayId) { public static IBinder getBuiltInDisplay(int builtInDisplayId) {
try { try {
// Android Q does not have this method anymore but has a
// replacement.
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
return (IBinder) CLASS.getMethod("getBuiltInDisplay", int.class).invoke(null, builtInDisplayId); return (IBinder) CLASS.getMethod("getBuiltInDisplay", int.class).invoke(null, builtInDisplayId);
} else {
return (IBinder) CLASS.getMethod("getPhysicalDisplayToken", long.class).invoke(null, builtInDisplayId);
}
} catch (Exception e) { } catch (Exception e) {
throw new AssertionError(e); throw new AssertionError(e);
} }