-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Honor Android 14 devices --turn-screen-off failed #4823
Comments
Temporary solution: not change the power mode for all physical displays, use SurfaceControl to change only one display instead |
My device is being affected by this bug too. @eiyooooo is there a walk-around for this issue? Thanks! |
Temporary solution: not change the power mode for all physical displays, use SurfaceControl to change only one display instead
|
Note that Android Studio somehow does work with this. Also this update of Honor is terrible. Battery drains fast on it. |
@eiyooooo Does this also work: diff --git a/server/src/main/java/com/genymobile/scrcpy/device/Device.java b/server/src/main/java/com/genymobile/scrcpy/device/Device.java
index ae4f50e59..3bd6b04c7 100644
--- a/server/src/main/java/com/genymobile/scrcpy/device/Device.java
+++ b/server/src/main/java/com/genymobile/scrcpy/device/Device.java
@@ -323,7 +323,16 @@ public final class Device {
* @param mode one of the {@code POWER_MODE_*} constants
*/
public static boolean setScreenPowerMode(int mode) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
+ boolean applyToMultiPhysicalDisplays = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q;
+
+ if (applyToMultiPhysicalDisplays && Build.BRAND.equalsIgnoreCase("honor") && SurfaceControl.hasGetBuildInDisplayMethod()) {
+ // Workaround for Honor devices with Android 14:
+ // - <https://github.com/Genymobile/scrcpy/issues/4823>
+ // - <https://github.com/Genymobile/scrcpy/issues/4943>
+ applyToMultiPhysicalDisplays = false;
+ }
+
+ if (applyToMultiPhysicalDisplays) {
// 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();
diff --git a/server/src/main/java/com/genymobile/scrcpy/wrappers/SurfaceControl.java b/server/src/main/java/com/genymobile/scrcpy/wrappers/SurfaceControl.java
index fc18a8e27..2ac1344e8 100644
--- a/server/src/main/java/com/genymobile/scrcpy/wrappers/SurfaceControl.java
+++ b/server/src/main/java/com/genymobile/scrcpy/wrappers/SurfaceControl.java
@@ -94,6 +94,15 @@ public final class SurfaceControl {
return getBuiltInDisplayMethod;
}
+ public static boolean hasGetBuildInDisplayMethod() {
+ try {
+ getGetBuiltInDisplayMethod();
+ return true;
+ } catch (NoSuchMethodException e) {
+ return false;
+ }
+ }
+
public static IBinder getBuiltInDisplay() {
try {
Method method = getGetBuiltInDisplayMethod(); ? |
@rom1v Send me the files to run, and I will try... |
@AndroidDeveloperLB The patch above applied on current
|
I make a little improvement at #5109. |
@rom1v About this: Seems to work fine too (on the device I've mentioned). |
Fixes #4823 <#4823> PR #5109 <#5109> Signed-off-by: Romain Vimont <[email protected]>
Merged 👍 9d1d79b
It is very specific to Honor on Android 14 where the alternate method exists. |
Fixes Genymobile#4823 <Genymobile#4823> PR Genymobile#5109 <Genymobile#5109> Signed-off-by: Romain Vimont <[email protected]>
Fixes Genymobile#4823 <Genymobile#4823> PR Genymobile#5109 <Genymobile#5109> Signed-off-by: Romain Vimont <[email protected]>
This is #4544 (comment) with #5109 reverted: scrcpy-server.zip (for client version 3.1) Please test Alt + O/Alt + Shift + O on Honor devices Diffdiff --git a/server/src/main/java/com/genymobile/scrcpy/device/Device.java b/server/src/main/java/com/genymobile/scrcpy/device/Device.java
index 3553dc27..5f84e3b0 100644
--- a/server/src/main/java/com/genymobile/scrcpy/device/Device.java
+++ b/server/src/main/java/com/genymobile/scrcpy/device/Device.java
@@ -135,20 +135,8 @@ public final class Device {
return ServiceManager.getDisplayManager().requestDisplayPower(displayId, on);
}
- boolean applyToMultiPhysicalDisplays = Build.VERSION.SDK_INT >= AndroidVersions.API_29_ANDROID_10;
-
- if (applyToMultiPhysicalDisplays
- && Build.VERSION.SDK_INT >= AndroidVersions.API_34_ANDROID_14
- && Build.BRAND.equalsIgnoreCase("honor")
- && SurfaceControl.hasGetBuildInDisplayMethod()) {
- // Workaround for Honor devices with Android 14:
- // - <https://github.com/Genymobile/scrcpy/issues/4823>
- // - <https://github.com/Genymobile/scrcpy/issues/4943>
- applyToMultiPhysicalDisplays = false;
- }
-
int mode = on ? POWER_MODE_NORMAL : POWER_MODE_OFF;
- if (applyToMultiPhysicalDisplays) {
+ if (Build.VERSION.SDK_INT >= AndroidVersions.API_29_ANDROID_10) {
// On Android 14, these internal methods have been moved to DisplayControl
boolean useDisplayControl =
Build.VERSION.SDK_INT >= AndroidVersions.API_34_ANDROID_14 && !SurfaceControl.hasGetPhysicalDisplayIdsMethod();
diff --git a/server/src/main/java/com/genymobile/scrcpy/wrappers/SurfaceControl.java b/server/src/main/java/com/genymobile/scrcpy/wrappers/SurfaceControl.java
index 3bae4a37..b8b41b91 100644
--- a/server/src/main/java/com/genymobile/scrcpy/wrappers/SurfaceControl.java
+++ b/server/src/main/java/com/genymobile/scrcpy/wrappers/SurfaceControl.java
@@ -95,15 +95,6 @@ public final class SurfaceControl {
return getBuiltInDisplayMethod;
}
- public static boolean hasGetBuildInDisplayMethod() {
- try {
- getGetBuiltInDisplayMethod();
- return true;
- } catch (NoSuchMethodException e) {
- return false;
- }
- }
-
public static IBinder getBuiltInDisplay() {
try {
Method method = getGetBuiltInDisplayMethod(); |
Environment
Describe the bug
When server reaching here
scrcpy/server/src/main/java/com/genymobile/scrcpy/wrappers/DisplayControl.java
Line 31 in 206809a
server get killed, cause by
The text was updated successfully, but these errors were encountered: