mirror of
https://github.com/androidx/media.git
synced 2025-05-07 15:40:37 +08:00
Expose getPhysicalDisplaySize for non-primary display
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=132856997
This commit is contained in:
parent
7925342fa0
commit
f2ddfb0867
@ -911,9 +911,21 @@ public final class Util {
|
|||||||
* @return The physical display size, in pixels.
|
* @return The physical display size, in pixels.
|
||||||
*/
|
*/
|
||||||
public static Point getPhysicalDisplaySize(Context context) {
|
public static Point getPhysicalDisplaySize(Context context) {
|
||||||
// Before API 25 the platform Display object does not provide a working way to identify Android
|
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
||||||
// TVs that can show 4k resolution in a SurfaceView, so check for supported devices here.
|
return getPhysicalDisplaySize(context, windowManager.getDefaultDisplay());
|
||||||
if (Util.SDK_INT < 25) {
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the physical size of the specified display, in pixels.
|
||||||
|
*
|
||||||
|
* @param context Any context.
|
||||||
|
* @param display The display whose size is to be returned.
|
||||||
|
* @return The physical display size, in pixels.
|
||||||
|
*/
|
||||||
|
public static Point getPhysicalDisplaySize(Context context, Display display) {
|
||||||
|
if (Util.SDK_INT < 25 && display.getDisplayId() == Display.DEFAULT_DISPLAY) {
|
||||||
|
// Before API 25 the Display object does not provide a working way to identify Android TVs
|
||||||
|
// that can show 4k resolution in a SurfaceView, so check for supported devices here.
|
||||||
if ("Sony".equals(Util.MANUFACTURER) && Util.MODEL.startsWith("BRAVIA")
|
if ("Sony".equals(Util.MANUFACTURER) && Util.MODEL.startsWith("BRAVIA")
|
||||||
&& context.getPackageManager().hasSystemFeature("com.sony.dtv.hardware.panel.qfhd")) {
|
&& context.getPackageManager().hasSystemFeature("com.sony.dtv.hardware.panel.qfhd")) {
|
||||||
return new Point(3840, 2160);
|
return new Point(3840, 2160);
|
||||||
@ -947,8 +959,6 @@ public final class Util {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
|
||||||
Display display = windowManager.getDefaultDisplay();
|
|
||||||
Point displaySize = new Point();
|
Point displaySize = new Point();
|
||||||
if (Util.SDK_INT >= 23) {
|
if (Util.SDK_INT >= 23) {
|
||||||
getDisplaySizeV23(display, displaySize);
|
getDisplaySizeV23(display, displaySize);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user