Skip to content

Commit

Permalink
Merge pull request #587 from schwabe/fix_586_screen_off_qbeta
Browse files Browse the repository at this point in the history
Use getPhysicalDisplayToken if getBuiltInDisplay is not found
  • Loading branch information
rom1v authored Jun 14, 2019
2 parents 8ca3640 + b769083 commit b29a568
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 b29a568

Please sign in to comment.