Compare commits
4 Commits
crossbuild
...
turnscreen
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5d4b8a7e6d | ||
|
|
eed06b141a | ||
|
|
825d7f72c0 | ||
|
|
2370298b61 |
@@ -6,9 +6,10 @@ cd "$DIR"
|
|||||||
mkdir -p "$PREBUILT_DATA_DIR"
|
mkdir -p "$PREBUILT_DATA_DIR"
|
||||||
cd "$PREBUILT_DATA_DIR"
|
cd "$PREBUILT_DATA_DIR"
|
||||||
|
|
||||||
DEP_DIR=libusb-1.0.26
|
VERSION=1.0.26
|
||||||
|
DEP_DIR="libusb-$VERSION"
|
||||||
|
|
||||||
FILENAME=libusb-1.0.26-binaries.7z
|
FILENAME="libusb-$VERSION-binaries.7z"
|
||||||
SHA256SUM=9c242696342dbde9cdc47239391f71833939bf9f7aa2bbb28cdaabe890465ec5
|
SHA256SUM=9c242696342dbde9cdc47239391f71833939bf9f7aa2bbb28cdaabe890465ec5
|
||||||
|
|
||||||
if [[ -d "$DEP_DIR" ]]
|
if [[ -d "$DEP_DIR" ]]
|
||||||
@@ -17,20 +18,21 @@ then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
get_file "https://github.com/libusb/libusb/releases/download/v1.0.26/$FILENAME" "$FILENAME" "$SHA256SUM"
|
get_file "https://github.com/libusb/libusb/releases/download/v$VERSION/$FILENAME" \
|
||||||
|
"$FILENAME" "$SHA256SUM"
|
||||||
|
|
||||||
mkdir "$DEP_DIR"
|
mkdir "$DEP_DIR"
|
||||||
cd "$DEP_DIR"
|
cd "$DEP_DIR"
|
||||||
|
|
||||||
7z x "../$FILENAME" \
|
7z x "../$FILENAME" \
|
||||||
libusb-1.0.26-binaries/libusb-MinGW-Win32/ \
|
"libusb-$VERSION-binaries/libusb-MinGW-Win32/" \
|
||||||
libusb-1.0.26-binaries/libusb-MinGW-Win32/ \
|
"libusb-$VERSION-binaries/libusb-MinGW-Win32/" \
|
||||||
libusb-1.0.26-binaries/libusb-MinGW-x64/ \
|
"libusb-$VERSION-binaries/libusb-MinGW-x64/" \
|
||||||
libusb-1.0.26-binaries/libusb-MinGW-x64/
|
"libusb-$VERSION-binaries/libusb-MinGW-x64/"
|
||||||
|
|
||||||
mv libusb-1.0.26-binaries/libusb-MinGW-Win32 .
|
mv "libusb-$VERSION-binaries/libusb-MinGW-Win32" .
|
||||||
mv libusb-1.0.26-binaries/libusb-MinGW-x64 .
|
mv "libusb-$VERSION-binaries/libusb-MinGW-x64" .
|
||||||
rm -rf libusb-1.0.26-binaries
|
rm -rf "libusb-$VERSION-binaries"
|
||||||
|
|
||||||
# Rename the dll to get the same library name on all platforms
|
# Rename the dll to get the same library name on all platforms
|
||||||
mv libusb-MinGW-Win32/bin/msys-usb-1.0.dll libusb-MinGW-Win32/bin/libusb-1.0.dll
|
mv libusb-MinGW-Win32/bin/msys-usb-1.0.dll libusb-MinGW-Win32/bin/libusb-1.0.dll
|
||||||
|
|||||||
@@ -6,10 +6,11 @@ cd "$DIR"
|
|||||||
mkdir -p "$PREBUILT_DATA_DIR"
|
mkdir -p "$PREBUILT_DATA_DIR"
|
||||||
cd "$PREBUILT_DATA_DIR"
|
cd "$PREBUILT_DATA_DIR"
|
||||||
|
|
||||||
DEP_DIR=SDL2-2.28.4
|
VERSION=2.28.5
|
||||||
|
DEP_DIR="SDL2-$VERSION"
|
||||||
|
|
||||||
FILENAME=SDL2-devel-2.28.4-mingw.tar.gz
|
FILENAME="SDL2-devel-$VERSION-mingw.tar.gz"
|
||||||
SHA256SUM=779d091072cf97291f80030f5232d97aa3d48ab0f2c14fe0b9d9a33c593cdc35
|
SHA256SUM=3c0c655c2ebf67cad48fead72761d1601740ded30808952c3274ba223d226c21
|
||||||
|
|
||||||
if [[ -d "$DEP_DIR" ]]
|
if [[ -d "$DEP_DIR" ]]
|
||||||
then
|
then
|
||||||
@@ -17,7 +18,8 @@ then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
get_file "https://libsdl.org/release/$FILENAME" "$FILENAME" "$SHA256SUM"
|
get_file "https://github.com/libsdl-org/SDL/releases/download/release-$VERSION/$FILENAME" \
|
||||||
|
"$FILENAME" "$SHA256SUM"
|
||||||
|
|
||||||
mkdir "$DEP_DIR"
|
mkdir "$DEP_DIR"
|
||||||
cd "$DEP_DIR"
|
cd "$DEP_DIR"
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ build-win32: prepare-deps
|
|||||||
rm -rf "$(WIN32_BUILD_DIR)"
|
rm -rf "$(WIN32_BUILD_DIR)"
|
||||||
mkdir -p "$(WIN32_BUILD_DIR)/local"
|
mkdir -p "$(WIN32_BUILD_DIR)/local"
|
||||||
cp -r app/prebuilt-deps/data/ffmpeg-6.1-scrcpy-3/win32/. "$(WIN32_BUILD_DIR)/local/"
|
cp -r app/prebuilt-deps/data/ffmpeg-6.1-scrcpy-3/win32/. "$(WIN32_BUILD_DIR)/local/"
|
||||||
cp -r app/prebuilt-deps/data/SDL2-2.28.4/i686-w64-mingw32/. "$(WIN32_BUILD_DIR)/local/"
|
cp -r app/prebuilt-deps/data/SDL2-2.28.5/i686-w64-mingw32/. "$(WIN32_BUILD_DIR)/local/"
|
||||||
cp -r app/prebuilt-deps/data/libusb-1.0.26/libusb-MinGW-Win32/. "$(WIN32_BUILD_DIR)/local/"
|
cp -r app/prebuilt-deps/data/libusb-1.0.26/libusb-MinGW-Win32/. "$(WIN32_BUILD_DIR)/local/"
|
||||||
meson setup "$(WIN32_BUILD_DIR)" \
|
meson setup "$(WIN32_BUILD_DIR)" \
|
||||||
--pkg-config-path="$(WIN32_BUILD_DIR)/local/lib/pkgconfig" \
|
--pkg-config-path="$(WIN32_BUILD_DIR)/local/lib/pkgconfig" \
|
||||||
@@ -88,7 +88,7 @@ build-win64: prepare-deps
|
|||||||
rm -rf "$(WIN64_BUILD_DIR)"
|
rm -rf "$(WIN64_BUILD_DIR)"
|
||||||
mkdir -p "$(WIN64_BUILD_DIR)/local"
|
mkdir -p "$(WIN64_BUILD_DIR)/local"
|
||||||
cp -r app/prebuilt-deps/data/ffmpeg-6.1-scrcpy-3/win64/. "$(WIN64_BUILD_DIR)/local/"
|
cp -r app/prebuilt-deps/data/ffmpeg-6.1-scrcpy-3/win64/. "$(WIN64_BUILD_DIR)/local/"
|
||||||
cp -r app/prebuilt-deps/data/SDL2-2.28.4/x86_64-w64-mingw32/. "$(WIN64_BUILD_DIR)/local/"
|
cp -r app/prebuilt-deps/data/SDL2-2.28.5/x86_64-w64-mingw32/. "$(WIN64_BUILD_DIR)/local/"
|
||||||
cp -r app/prebuilt-deps/data/libusb-1.0.26/libusb-MinGW-x64/. "$(WIN64_BUILD_DIR)/local/"
|
cp -r app/prebuilt-deps/data/libusb-1.0.26/libusb-MinGW-x64/. "$(WIN64_BUILD_DIR)/local/"
|
||||||
meson setup "$(WIN64_BUILD_DIR)" \
|
meson setup "$(WIN64_BUILD_DIR)" \
|
||||||
--pkg-config-path="$(WIN64_BUILD_DIR)/local/lib/pkgconfig" \
|
--pkg-config-path="$(WIN64_BUILD_DIR)/local/lib/pkgconfig" \
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.genymobile.scrcpy;
|
package com.genymobile.scrcpy;
|
||||||
|
|
||||||
import com.genymobile.scrcpy.wrappers.ClipboardManager;
|
import com.genymobile.scrcpy.wrappers.ClipboardManager;
|
||||||
|
import com.genymobile.scrcpy.wrappers.DisplayControl;
|
||||||
import com.genymobile.scrcpy.wrappers.InputManager;
|
import com.genymobile.scrcpy.wrappers.InputManager;
|
||||||
import com.genymobile.scrcpy.wrappers.ServiceManager;
|
import com.genymobile.scrcpy.wrappers.ServiceManager;
|
||||||
import com.genymobile.scrcpy.wrappers.SurfaceControl;
|
import com.genymobile.scrcpy.wrappers.SurfaceControl;
|
||||||
@@ -315,8 +316,12 @@ public final class Device {
|
|||||||
*/
|
*/
|
||||||
public static boolean setScreenPowerMode(int mode) {
|
public static boolean setScreenPowerMode(int mode) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
|
// On Android 14, these internal methods have been moved to DisplayControl
|
||||||
|
boolean useDisplayControl =
|
||||||
|
Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE && !SurfaceControl.hasPhysicalDisplayIdsMethod();
|
||||||
|
|
||||||
// Change the power mode for all physical displays
|
// Change the power mode for all physical displays
|
||||||
long[] physicalDisplayIds = SurfaceControl.getPhysicalDisplayIds();
|
long[] physicalDisplayIds = useDisplayControl ? DisplayControl.getPhysicalDisplayIds() : SurfaceControl.getPhysicalDisplayIds();
|
||||||
if (physicalDisplayIds == null) {
|
if (physicalDisplayIds == null) {
|
||||||
Ln.e("Could not get physical display ids");
|
Ln.e("Could not get physical display ids");
|
||||||
return false;
|
return false;
|
||||||
@@ -324,7 +329,8 @@ public final class Device {
|
|||||||
|
|
||||||
boolean allOk = true;
|
boolean allOk = true;
|
||||||
for (long physicalDisplayId : physicalDisplayIds) {
|
for (long physicalDisplayId : physicalDisplayIds) {
|
||||||
IBinder binder = SurfaceControl.getPhysicalDisplayToken(physicalDisplayId);
|
IBinder binder = useDisplayControl ? DisplayControl.getPhysicalDisplayToken(
|
||||||
|
physicalDisplayId) : SurfaceControl.getPhysicalDisplayToken(physicalDisplayId);
|
||||||
allOk &= SurfaceControl.setDisplayPowerMode(binder, mode);
|
allOk &= SurfaceControl.setDisplayPowerMode(binder, mode);
|
||||||
}
|
}
|
||||||
return allOk;
|
return allOk;
|
||||||
|
|||||||
@@ -0,0 +1,80 @@
|
|||||||
|
package com.genymobile.scrcpy.wrappers;
|
||||||
|
|
||||||
|
import com.genymobile.scrcpy.Ln;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.annotation.TargetApi;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.IBinder;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
|
@SuppressLint({"PrivateApi", "SoonBlockedPrivateApi", "BlockedPrivateApi"})
|
||||||
|
@TargetApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
|
||||||
|
public final class DisplayControl {
|
||||||
|
|
||||||
|
private static final Class<?> CLASS;
|
||||||
|
|
||||||
|
static {
|
||||||
|
Class<?> displayControlClass = null;
|
||||||
|
try {
|
||||||
|
Class<?> classLoaderFactoryClass = Class.forName("com.android.internal.os.ClassLoaderFactory");
|
||||||
|
Method createClassLoaderMethod = classLoaderFactoryClass.getDeclaredMethod("createClassLoader", String.class, String.class, String.class,
|
||||||
|
ClassLoader.class, int.class, boolean.class, String.class);
|
||||||
|
ClassLoader classLoader = (ClassLoader) createClassLoaderMethod.invoke(null, "/system/framework/services.jar", null, null,
|
||||||
|
ClassLoader.getSystemClassLoader(), 0, true, null);
|
||||||
|
|
||||||
|
displayControlClass = classLoader.loadClass("com.android.server.display.DisplayControl");
|
||||||
|
|
||||||
|
Method loadMethod = Runtime.class.getDeclaredMethod("loadLibrary0", Class.class, String.class);
|
||||||
|
loadMethod.setAccessible(true);
|
||||||
|
loadMethod.invoke(Runtime.getRuntime(), displayControlClass, "android_servers");
|
||||||
|
} catch (Throwable e) {
|
||||||
|
Ln.e("Could not initialize DisplayControl", e);
|
||||||
|
// Do not throw an exception here, the methods will fail when they are called
|
||||||
|
}
|
||||||
|
CLASS = displayControlClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Method getPhysicalDisplayTokenMethod;
|
||||||
|
private static Method getPhysicalDisplayIdsMethod;
|
||||||
|
|
||||||
|
private DisplayControl() {
|
||||||
|
// only static methods
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Method getGetPhysicalDisplayTokenMethod() throws NoSuchMethodException {
|
||||||
|
if (getPhysicalDisplayTokenMethod == null) {
|
||||||
|
getPhysicalDisplayTokenMethod = CLASS.getMethod("getPhysicalDisplayToken", long.class);
|
||||||
|
}
|
||||||
|
return getPhysicalDisplayTokenMethod;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IBinder getPhysicalDisplayToken(long physicalDisplayId) {
|
||||||
|
try {
|
||||||
|
Method method = getGetPhysicalDisplayTokenMethod();
|
||||||
|
return (IBinder) method.invoke(null, physicalDisplayId);
|
||||||
|
} catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
|
||||||
|
Ln.e("Could not invoke method", e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Method getGetPhysicalDisplayIdsMethod() throws NoSuchMethodException {
|
||||||
|
if (getPhysicalDisplayIdsMethod == null) {
|
||||||
|
getPhysicalDisplayIdsMethod = CLASS.getMethod("getPhysicalDisplayIds");
|
||||||
|
}
|
||||||
|
return getPhysicalDisplayIdsMethod;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long[] getPhysicalDisplayIds() {
|
||||||
|
try {
|
||||||
|
Method method = getGetPhysicalDisplayIdsMethod();
|
||||||
|
return (long[]) method.invoke(null);
|
||||||
|
} catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
|
||||||
|
Ln.e("Could not invoke method", e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -139,6 +139,15 @@ public final class SurfaceControl {
|
|||||||
return getPhysicalDisplayIdsMethod;
|
return getPhysicalDisplayIdsMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean hasPhysicalDisplayIdsMethod() {
|
||||||
|
try {
|
||||||
|
getGetPhysicalDisplayIdsMethod();
|
||||||
|
return true;
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static long[] getPhysicalDisplayIds() {
|
public static long[] getPhysicalDisplayIds() {
|
||||||
try {
|
try {
|
||||||
Method method = getGetPhysicalDisplayIdsMethod();
|
Method method = getGetPhysicalDisplayIdsMethod();
|
||||||
|
|||||||
Reference in New Issue
Block a user