mirror of https://github.com/Genymobile/scrcpy
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
1010 B
Java
29 lines
1010 B
Java
package com.genymobile.scrcpy.wrappers;
|
|
|
|
import com.genymobile.scrcpy.DisplayInfo;
|
|
import com.genymobile.scrcpy.Size;
|
|
|
|
import android.os.IInterface;
|
|
|
|
public final class DisplayManager {
|
|
private final IInterface manager;
|
|
|
|
public DisplayManager(IInterface manager) {
|
|
this.manager = manager;
|
|
}
|
|
|
|
public DisplayInfo getDisplayInfo() {
|
|
try {
|
|
Object displayInfo = manager.getClass().getMethod("getDisplayInfo", int.class).invoke(manager, 0);
|
|
Class<?> cls = displayInfo.getClass();
|
|
// width and height already take the rotation into account
|
|
int width = cls.getDeclaredField("logicalWidth").getInt(displayInfo);
|
|
int height = cls.getDeclaredField("logicalHeight").getInt(displayInfo);
|
|
int rotation = cls.getDeclaredField("rotation").getInt(displayInfo);
|
|
return new DisplayInfo(new Size(width, height), rotation);
|
|
} catch (Exception e) {
|
|
throw new AssertionError(e);
|
|
}
|
|
}
|
|
}
|