Skip to content

Commit

Permalink
Use getPhysicalDisplayToken if getBuiltInDisplay is not found
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 26ace0e
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,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 26ace0e

Please sign in to comment.