Skip to content

Commit

Permalink
Use getPhysicalDisplayToken on Anroid Q+ instead of getBuiltInDisplay
Browse files Browse the repository at this point in the history
This makes the -S (screen off) parameter work on Android Q beta 4

Closes #586
  • Loading branch information
schwabe committed Jun 13, 2019
1 parent 8ca3640 commit b769083
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.annotation.SuppressLint;
import android.graphics.Rect;
import android.os.Build;
import android.os.IBinder;
import android.view.Surface;

Expand Down Expand Up @@ -77,7 +78,13 @@ public static IBinder createDisplay(String name, boolean secure) {

public static IBinder getBuiltInDisplay(int builtInDisplayId) {
try {
return (IBinder) CLASS.getMethod("getBuiltInDisplay", int.class).invoke(null, builtInDisplayId);
// 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);
} else {
return (IBinder) CLASS.getMethod("getPhysicalDisplayToken", long.class).invoke(null, builtInDisplayId);
}
} catch (Exception e) {
throw new AssertionError(e);
}
Expand Down

0 comments on commit b769083

Please sign in to comment.