Convert server to an Android project

To simplify the device server-side build, use gradle to create an APK,
even if we use it as a simple jar, by running its main() method.
This commit is contained in:
Romain Vimont
2018-01-29 17:06:44 +01:00
parent 89f6a3cfe7
commit b67907e24e
36 changed files with 390 additions and 121 deletions

View File

@@ -0,0 +1,28 @@
package com.genymobile.scrcpy.wrappers;
import android.os.IInterface;
import com.genymobile.scrcpy.DisplayInfo;
import com.genymobile.scrcpy.Size;
public 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);
}
}
}