Skip to content
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

"Turn screen off" doesn't work on my device #4544

Closed
kljjh opened this issue Dec 22, 2023 · 31 comments
Closed

"Turn screen off" doesn't work on my device #4544

kljjh opened this issue Dec 22, 2023 · 31 comments

Comments

@kljjh
Copy link

kljjh commented Dec 22, 2023

  • [√] I have read the FAQ.
  • [√] I have searched in existing issues.

Environment

  • OS: Windows10
  • scrcpy version: 2.3.1
  • installation method: Windows release
  • device model: Meizu 21
  • Android version: 14

Describe the bug
While I try to turn screen off using "scrcpy -S" or alt+o, the scrcpy will crash and abort.
The error information shows like this:

Native registration unable to find class 'com/android/server/DeviceControlService'; aborting...
WARN: Device disconnected
Aborted
@rom1v
Copy link
Collaborator

rom1v commented Dec 22, 2023

Thank you for your report.

Please post your framework.jar and services.jar:

adb pull /system/framework/framework.jar
adb pull /system/framework/services.jar

(Meizu developers definitely like to modify the Android ROM a lot, it's always this model which causes problems with many scrcpy features.)

@kljjh
Copy link
Author

kljjh commented Dec 22, 2023

Thank you for your report.

Please post your framework.jar and services.jar:

adb pull /system/framework/framework.jar
adb pull /system/framework/services.jar

(Meizu developers definitely like to modify the Android ROM a lot, it's always this model which causes problems with many scrcpy features.)

Here the files you asked for. Since GitHub doesn't support the jar file, please unzip the file manually.
Meizu21.zip

@rom1v
Copy link
Collaborator

rom1v commented Dec 22, 2023

There is no such com/android/server/DeviceControlService in these files.

Could you please list them all:

adb shell ls -l /system/framework/*.jar

@kljjh
Copy link
Author

kljjh commented Dec 22, 2023

Here is the list.
Please tell me which should I pull out.

-rw-r--r-- 1 root root    28041 2009-01-01 08:00 /system/framework/QPerformance.jar
-rw-r--r-- 1 root root     5232 2009-01-01 08:00 /system/framework/QXPerformance.jar
-rw-r--r-- 1 root root    14473 2009-01-01 08:00 /system/framework/UxPerformance.jar
-rw-r--r-- 1 root root    99521 2009-01-01 08:00 /system/framework/WfdCommon.jar
-rw-r--r-- 1 root root     4498 2009-01-01 08:00 /system/framework/abx.jar
-rw-r--r-- 1 root root   569438 2009-01-01 08:00 /system/framework/am.jar
-rw-r--r-- 1 root root    12842 2009-01-01 08:00 /system/framework/android.hidl.base-V1.0-java.jar
-rw-r--r-- 1 root root    29906 2009-01-01 08:00 /system/framework/android.hidl.manager-V1.0-java.jar
-rw-r--r-- 1 root root    33430 2009-01-01 08:00 /system/framework/android.test.base.jar
-rw-r--r-- 1 root root    64486 2009-01-01 08:00 /system/framework/android.test.mock.jar
-rw-r--r-- 1 root root   108218 2009-01-01 08:00 /system/framework/android.test.runner.jar
-rw-r--r-- 1 root root     5726 2009-01-01 08:00 /system/framework/appwidget.jar
-rw-r--r-- 1 root root    33886 2009-01-01 08:00 /system/framework/bmgr.jar
-rw-r--r-- 1 root root     7370 2009-01-01 08:00 /system/framework/bu.jar
-rw-r--r-- 1 root root     5390 2009-01-01 08:00 /system/framework/com.android.future.usb.accessory.jar
-rw-r--r-- 1 root root    26966 2009-01-01 08:00 /system/framework/com.android.location.provider.jar
-rw-r--r-- 1 root root     9570 2009-01-01 08:00 /system/framework/com.android.media.remotedisplay.jar
-rw-r--r-- 1 root root     2962 2009-01-01 08:00 /system/framework/com.android.mediadrm.signer.jar
-rw-r--r-- 1 root root     8002 2009-01-01 08:00 /system/framework/com.android.nfc_extras.jar
-rw-r--r-- 1 root root    20042 2009-01-01 08:00 /system/framework/content.jar
-rw-r--r-- 1 root root  2350507 2009-01-01 08:00 /system/framework/ext.jar
-rw-r--r-- 1 root root   240525 2009-01-01 08:00 /system/framework/flyme-telephony-common.jar
-rw-r--r-- 1 root root     3813 2009-01-01 08:00 /system/framework/framework-graphics.jar
-rw-r--r-- 1 root root 42998729 2009-01-01 08:00 /system/framework/framework.jar
-rw-r--r-- 1 root root    24026 2009-01-01 08:00 /system/framework/hid.jar
-rw-r--r-- 1 root root   602529 2009-01-01 08:00 /system/framework/ims-common.jar
-rw-r--r-- 1 root root    15638 2009-01-01 08:00 /system/framework/incident-helper-cmd.jar
-rw-r--r-- 1 root root     1682 2009-01-01 08:00 /system/framework/javax.obex.jar
-rw-r--r-- 1 root root     2578 2009-01-01 08:00 /system/framework/locksettings.jar
-rw-r--r-- 1 root root   256337 2009-01-01 08:00 /system/framework/meizu-telephony-common.jar
-rw-r--r-- 1 root root   119398 2009-01-01 08:00 /system/framework/monkey.jar
-rw-r--r-- 1 root root   491318 2009-01-01 08:00 /system/framework/org.apache.http.legacy.jar
-rw-r--r-- 1 root root    33045 2009-01-01 08:00 /system/framework/org.simalliance.openmobileapi.jar
-rw-r--r-- 1 root root    70433 2009-01-01 08:00 /system/framework/qcom.fmradio.jar
-rw-r--r-- 1 root root    13262 2009-01-01 08:00 /system/framework/requestsync.jar
-rw-r--r-- 1 root root 21786246 2009-01-01 08:00 /system/framework/services.jar
-rw-r--r-- 1 root root    10894 2009-01-01 08:00 /system/framework/sm.jar
-rw-r--r-- 1 root root    15738 2009-01-01 08:00 /system/framework/svc.jar
-rw-r--r-- 1 root root     7874 2009-01-01 08:00 /system/framework/tcmclient.jar
-rw-r--r-- 1 root root      849 2009-01-01 08:00 /system/framework/tcmiface.jar
-rw-r--r-- 1 root root    18022 2009-01-01 08:00 /system/framework/telecom.jar
-rw-r--r-- 1 root root  4381503 2009-01-01 08:00 /system/framework/telephony-common.jar
-rw-r--r-- 1 root root    42505 2009-01-01 08:00 /system/framework/telephony-ext.jar
-rw-r--r-- 1 root root   414918 2009-01-01 08:00 /system/framework/uiautomator.jar
-rw-r--r-- 1 root root    25330 2009-01-01 08:00 /system/framework/uinput.jar
-rw-r--r-- 1 root root    18266 2009-01-01 08:00 /system/framework/vendor.qti.hardware.data.connectionaidl-V1-java.jar
-rw-r--r-- 1 root root    19470 2009-01-01 08:00 /system/framework/vendor.qti.hardware.radio.qtiradio-V1-java.jar
-rw-r--r-- 1 root root   822201 2009-01-01 08:00 /system/framework/voip-common.jar
-rw-r--r-- 1 root root     4494 2009-01-01 08:00 /system/framework/vr.jar
-rw-r--r-- 1 root root     3602 2009-01-01 08:00 /system/framework/wapicertstore.jar

@rom1v
Copy link
Collaborator

rom1v commented Dec 22, 2023

Maybe meizu-telephony-common.jar?

@kljjh
Copy link
Author

kljjh commented Dec 22, 2023

Please check this:
meizu-telephony-common.zip

@rom1v
Copy link
Collaborator

rom1v commented Dec 22, 2023

Not in this one either.

Send the whole folder adb pull /system/framework 😄

@kljjh
Copy link
Author

kljjh commented Dec 22, 2023

It seems too large to upload to GitHub. Check this OneDrive sharelink:
https://1drv.ms/u/s!AkktN1hqwquGrAMyBw41ADkhPzoc?e=4vR4PO
But I have checked all the jar file manually, there is no such file com/android/server/DeviceControlService in any of them.

@rom1v
Copy link
Collaborator

rom1v commented Dec 22, 2023

But I have checked all the jar file manually, there is no such file com/android/server/DeviceControlService in any of them.

(it is not expected to be in the jar directly, you must decompile classes.dex, for example with jadx myfile.jar)

But indeed, none of them contains this DeviceControlService class.

In services.jar, sources/com/anroid/server/BootReceiver.java uses a IDeviceControlService:

import meizu.os.IDeviceControlService;
// …
IDeviceControlService asInterface = IDeviceControlService.Stub.asInterface(ServiceManager.getService("device_control"));

@kljjh
Copy link
Author

kljjh commented Dec 22, 2023

Got it. Please check if the IDeviceControlService could work in scrcpy and fix this issue. Thank you for your help. :)

@jay-dragon
Copy link

这个问题解决了吗?是不是没法解决了

@kljjh
Copy link
Author

kljjh commented Jan 30, 2024

这个问题解决了吗?是不是没法解决了

估计是吧😂flyme魔改的问题 不知道aicy识屏是不是依赖了这个 跟flyme反馈下试试呢
这个项目作者应该不是国人 issue里尽量还是用英文吧

@jay-dragon
Copy link

这个问题解决了吗?是不是没法解决了

估计是吧😂flyme魔改的问题 不知道aicy识屏是不是依赖了这个 跟flyme反馈下试试呢 这个项目作者应该不是国人 issue里尽量还是用英文吧

和flyme反馈也白扯吧,我也没想和作者说,这个问题好像作者那边也不好解决

@Stabrinai
Copy link

professional reply from FlymeOS system engineer

S40415-12022425_com meizu feedback

@rom1v
Copy link
Collaborator

rom1v commented Apr 15, 2024

Could you please copy-paste the text (so that it can be translated into English easily)?

@yume-chan
Copy link
Contributor

Translation: Please contact the software developer, or try other screen casting software instead.

@DrJHZhao
Copy link

DrJHZhao commented Jun 8, 2024

I got the same problem after I updated my Honor 60pro to Android 14

@Stabrinai
Copy link

So it should be caused by the com/android/server/DeviceControlService class being changed on Android 14?

@rom1v
Copy link
Collaborator

rom1v commented Jul 6, 2024

Yes, there were changes in Android 14. You need a recent version of scrcpy (the latest is 2.5).

@Stabrinai
Copy link

The problem still exists.

C:\Program Files\Scrcpy>scrcpy.exe -K -S
scrcpy 2.5 <https://github.com/Genymobile/scrcpy>
INFO: ADB device found:
INFO:     --> (tcpip)  192.168.1.171:40707             device  MEIZU_20
C:\Program Files\Scrcpy\scrcpy-server: 1 file pushed, 0 skipped. 30.6 MB/s (69624 bytes in 0.002s)
[server] INFO: Device: [meizu] meizu MEIZU 20 (Android 14)
INFO: Renderer: direct3d
INFO: Texture: 1080x2400
Native registration unable to find class 'com/android/server/DeviceControlService'; aborting...
ERROR: Demuxer 'audio': stream disAborted
abled due to connection error
ERROR: Controller error

@cwj2022
Copy link

cwj2022 commented Aug 1, 2024

问题仍然存在。

C:\Program Files\Scrcpy>scrcpy.exe -K -S
scrcpy 2.5 <https://github.com/Genymobile/scrcpy>
INFO: ADB device found:
INFO:     --> (tcpip)  192.168.1.171:40707             device  MEIZU_20
C:\Program Files\Scrcpy\scrcpy-server: 1 file pushed, 0 skipped. 30.6 MB/s (69624 bytes in 0.002s)
[server] INFO: Device: [meizu] meizu MEIZU 20 (Android 14)
INFO: Renderer: direct3d
INFO: Texture: 1080x2400
Native registration unable to find class 'com/android/server/DeviceControlService'; aborting...
ERROR: Demuxer 'audio': stream disAborted
abled due to connection error
ERROR: Controller error

您好,解决了吗?我也是魅族21,升级了最新的系统。这一个功能也是不可用了,请问您解决了吗?方便分享一下解决方案吗?

@rom1v
Copy link
Collaborator

rom1v commented Aug 1, 2024

Sorry, I have no solution for this device.

@kljjh
Copy link
Author

kljjh commented Nov 3, 2024

In Flyme 11.2.0.0A, the meizu updated a new feature called "息屏投屏" which could let users turn off the screen with the phone screen still awake during the cast, and it also works for scrcpy as long as a miracast connection is on. This may be helpful in addressing this issue.
image

@CudtMFrag
Copy link

5bd7a122a2105d4a700bea40dd085f34
The Meizu developer replied to this. Can this help fix the issue?
On Android 14 devices, the Linux version of scrcpy cannot enable "screen-off mirroring" (turning off the device screen while continuing to display content on the computer). This is because Android 14 has removed a critical interface, SurfaceControl#getInternalDisplayToken, which was previously used to independently control turning off the device's main screen. As a result, scrcpy is unable to implement this feature.

Additionally, this issue is not specific to scrcpy—other similar mirroring tools (native competitors) face the same limitation. It's recommended to report this issue to the developers of scrcpy for further investigation and potential improvements.

@yume-chan
Copy link
Contributor

yume-chan commented Dec 9, 2024

Please test scrcpy-server.zip (with client version 3.0.2)

Diff:

diff --git a/server/src/main/java/com/genymobile/scrcpy/wrappers/DisplayControl.java b/server/src/main/java/com/genymobile/scrcpy/wrappers/DisplayControl.java
index a57f7948..7c6f9b6b 100644
--- a/server/src/main/java/com/genymobile/scrcpy/wrappers/DisplayControl.java
+++ b/server/src/main/java/com/genymobile/scrcpy/wrappers/DisplayControl.java
@@ -6,6 +6,7 @@ import com.genymobile.scrcpy.util.Ln;
 import android.annotation.SuppressLint;
 import android.annotation.TargetApi;
 import android.os.IBinder;
+import android.system.Os;
 
 import java.lang.reflect.Method;
 
@@ -21,7 +22,11 @@ public final class DisplayControl {
             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,
+
+            String systemServerClasspath = Os.getenv("SYSTEMSERVERCLASSPATH");
+            Ln.i("Loading DisplayControl");
+            Ln.i("SYSTEMSERVERCLASSPATH: " + systemServerClasspath);
+            ClassLoader classLoader = (ClassLoader) createClassLoaderMethod.invoke(null, systemServerClasspath, null, null,
                     ClassLoader.getSystemClassLoader(), 0, true, null);
 
             displayControlClass = classLoader.loadClass("com.android.server.display.DisplayControl");

@rom1v
Copy link
Collaborator

rom1v commented Dec 9, 2024

This is because Android 14 has removed a critical interface, SurfaceControl#getInternalDisplayToken, which was previously used to independently control turning off the device's main screen. As a result, scrcpy is unable to implement this feature.

As a workaround, scrcpy uses another method for Android 14: #4456. But this method fails for some Xiaomi devices.

Please test the workaround from @yume-chan in the previous comment 🙂

@CudtMFrag
Copy link

It worked, I successfully turned off the screen after using @yume-chan's solution.

@rom1v
Copy link
Collaborator

rom1v commented Dec 9, 2024

@CudtMFrag Awesome. And can you confirm that it did not work in official 3.0.2?

@rom1v
Copy link
Collaborator

rom1v commented Dec 9, 2024

@CudtMFrag Also, in the solution from @yume-chan, some logs have been added. Could you please copy-paste the whole console output of scrcpy when you turn the screen off?

@CudtMFrag
Copy link

@rom1v Yes, when I use the official 3.0.2 whenever I try to turn off the screen scrcpy will crash.
output is here

scrcpy 3.0.2 <https://github.com/Genymobile/scrcpy>
INFO: ADB device found:
INFO:     -->   (usb)  381QYFCJ22388                   device  MEIZU_20
C:\scrcpy-win64-v3.0.2\scrcpy-...ile pushed, 0 skipped. 122.3 MB/s (165913 bytes in 0.001s)   
[server] INFO: Device: [meizu] meizu MEIZU 20 (Android 14)
INFO: Renderer: direct3d
[server] INFO: Loading DisplayControl
[server] INFO: SYSTEMSERVERCLASSPATH: /system/framework/com.android.location.provider.jar:/system/framework/services.jar:/apex/com.android.adservices/javalib/service-adservices.jar:/apex/com.android.adservices/javalib/service-sdksandbox.jar:/apex/com.android.appsearch/javalib/service-appsearch.jar:/apex/com.android.art/javalib/service-art.jar:/apex/com.android.configinfrastructure/javalib/service-configinfrastructure.jar:/apex/com.android.healthfitness/javalib/service-healthfitness.jar:/apex/com.android.media/javalib/service-media-s.jar:/apex/com.android.ondevicepersonalization/javalib/service-ondevicepersonalization.jar:/apex/com.android.permission/javalib/service-permission.jar:/apex/com.android.rkpd/javalib/service-rkp.jar:/apex/com.flyme.runtime/javalib/service-flyme.jar
[server] WARN: Could not get initial audio timestamp
INFO: Texture: 1080x2400
[server] INFO: Device display turned off

@rom1v
Copy link
Collaborator

rom1v commented Dec 9, 2024

Thank you @yume-chan, I will merge a507b4f.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants