Genymobile / scrcpy

Display and control your Android device
Apache License 2.0
102.8k stars 10k forks source link

Honor Android 14 devices --turn-screen-off failed #4823

Open eiyooooo opened 1 month ago

eiyooooo commented 1 month ago

Environment

Describe the bug When server reaching here

https://github.com/Genymobile/scrcpy/blob/206809a99affad9a7aa58fcf7593cea71f48954d/server/src/main/java/com/genymobile/scrcpy/wrappers/DisplayControl.java#L31

server get killed, cause by

Native registration unable to find class 'com/android/server/TrustedUIService'; aborting...
eiyooooo commented 1 month ago

Temporary solution: not change the power mode for all physical displays, use SurfaceControl to change only one display instead

zoukyle commented 3 weeks ago

My device is being affected by this bug too. @eiyooooo is there a walk-around for this issue? Thanks!

eiyooooo commented 3 weeks ago

Is there a walk-around for this issue?

Temporary solution: not change the power mode for all physical displays, use SurfaceControl to change only one display instead

git diff
diff --git a/server/src/main/java/com/genymobile/scrcpy/Device.java b/server/src/main/java/com/genymobile/scrcpy/Device.java
index 8d0ee231..671ef2c5 100644
--- a/server/src/main/java/com/genymobile/scrcpy/Device.java
+++ b/server/src/main/java/com/genymobile/scrcpy/Device.java
@@ -319,7 +319,8 @@ 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) {
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q
+                && !(Build.BRAND.toLowerCase() + Build.MANUFACTURER.toLowerCase()).contains("honor")) {
             // On Android 14, these internal methods have been moved to DisplayControl
: