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

Can no copy text from Magic5Pro to Windows #3885

Closed
2 tasks done
wuerbuzuo opened this issue Apr 1, 2023 · 7 comments
Closed
2 tasks done

Can no copy text from Magic5Pro to Windows #3885

wuerbuzuo opened this issue Apr 1, 2023 · 7 comments

Comments

@wuerbuzuo
Copy link

wuerbuzuo commented Apr 1, 2023

  • I have read the FAQ.
  • I have searched in existing issues.

Environment

  • OS: Windows10
  • scrcpy version: 2.0
  • installation method: Windows release
  • device model:Honor Magic5Pro
  • Android version: 13

Describe the bug
Terminal output when I press CTRL-C in scrcpy window:

[server] INFO: Device: HONOR PGT-AN10 (Android 13)
INFO: Renderer: direct3d
INFO: Initial texture: 1312x2848
[server] ERROR: Could not invoke method
java.lang.NoSuchMethodException: android.content.IClipboard$Stub$Proxy.getPrimaryClip [class java.lang.String, class java.lang.String, int]
        at java.lang.Class.getMethod(Class.java:2103)
        at java.lang.Class.getMethod(Class.java:1724)
        at com.genymobile.scrcpy.wrappers.ClipboardManager.getGetPrimaryClipMethod(ClipboardManager.java:34)
        at com.genymobile.scrcpy.wrappers.ClipboardManager.getText(ClipboardManager.java:82)
        at com.genymobile.scrcpy.Device.getClipboardText(Device.java:248)
        at com.genymobile.scrcpy.Device$2.dispatchPrimaryClipChanged(Device.java:109)
        at android.content.IOnPrimaryClipChangedListener$Stub.onTransact(IOnPrimaryClipChangedListener.java:84)
        at android.os.Binder.execTransactInternal(Binder.java:1323)
        at android.os.Binder.execTransact(Binder.java:1279)
[server] ERROR: Could not invoke method
java.lang.NoSuchMethodException: android.content.IClipboard$Stub$Proxy.getPrimaryClip [class java.lang.String, class java.lang.String, int]
        at java.lang.Class.getMethod(Class.java:2103)
        at java.lang.Class.getMethod(Class.java:1724)
        at com.genymobile.scrcpy.wrappers.ClipboardManager.getGetPrimaryClipMethod(ClipboardManager.java:34)
        at com.genymobile.scrcpy.wrappers.ClipboardManager.getText(ClipboardManager.java:82)
        at com.genymobile.scrcpy.Device.getClipboardText(Device.java:248)
        at com.genymobile.scrcpy.Device$2.dispatchPrimaryClipChanged(Device.java:109)
        at android.content.IOnPrimaryClipChangedListener$Stub.onTransact(IOnPrimaryClipChangedListener.java:84)
        at android.os.Binder.execTransactInternal(Binder.java:1323)
        at android.os.Binder.execTransact(Binder.java:1279)
@rom1v
Copy link
Collaborator

rom1v commented Apr 1, 2023

The vendor modified the method so iy is different from AOSP.

Please retrieve the framework library:

adb pull /data/system/framework.jar

and post it.

@wuerbuzuo
Copy link
Author

The vendor modified the method so iy is different from AOSP.

Please retrieve the framework library:

adb pull /data/system/framework.jar

and post it.

adb: error: failed to stat remote object '/data/system/framework.jar': No such file or directory

@rom1v
Copy link
Collaborator

rom1v commented Apr 1, 2023

Sorry, wrong path:

adb pull /system/framework/framework.jar

@wuerbuzuo
Copy link
Author

Sorry, wrong path:

adb pull /system/framework/framework.jar

FYI.
magic5framework.zip

@rom1v
Copy link
Collaborator

rom1v commented Apr 1, 2023

They added a parameter String stackTraceMsg compared to the official Android:

public ClipData getPrimaryClip(String pkg, int userId, String stackTraceMsg)
diff
diff --git a/server/src/main/java/com/genymobile/scrcpy/wrappers/ClipboardManager.java b/server/src/main/java/com/genymobile/scrcpy/wrappers/ClipboardManager.java
index cb176cc3a..7b7509755 100644
--- a/server/src/main/java/com/genymobile/scrcpy/wrappers/ClipboardManager.java
+++ b/server/src/main/java/com/genymobile/scrcpy/wrappers/ClipboardManager.java
@@ -37,8 +37,13 @@ public class ClipboardManager {
                         getPrimaryClipMethod = manager.getClass().getMethod("getPrimaryClip", String.class, String.class, int.class);
                         getMethodVersion = 1;
                     } catch (NoSuchMethodException e2) {
-                        getPrimaryClipMethod = manager.getClass().getMethod("getPrimaryClip", String.class, String.class, int.class, int.class);
-                        getMethodVersion = 2;
+                        try {
+                            getPrimaryClipMethod = manager.getClass().getMethod("getPrimaryClip", String.class, String.class, int.class, int.class);
+                            getMethodVersion = 2;
+                        } catch (NoSuchMethodException e3) {
+                            getPrimaryClipMethod = manager.getClass().getMethod("getPrimaryClip", String.class, int.class, String.class);
+                            getMethodVersion = 3;
+                        }
                     }
                 }
             }
@@ -80,8 +85,10 @@ public class ClipboardManager {
                 return (ClipData) method.invoke(manager, FakeContext.PACKAGE_NAME, FakeContext.ROOT_UID);
             case 1:
                 return (ClipData) method.invoke(manager, FakeContext.PACKAGE_NAME, null, FakeContext.ROOT_UID);
-            default:
+            case 2:
                 return (ClipData) method.invoke(manager, FakeContext.PACKAGE_NAME, null, FakeContext.ROOT_UID, 0);
+            default:
+                return (ClipData) method.invoke(manager, FakeContext.PACKAGE_NAME, FakeContext.ROOT_UID, null);
         }
     }
 

Please test this binary:

@wuerbuzuo
Copy link
Author

it works.Thank you so much!

rom1v added a commit that referenced this issue Apr 1, 2023
On Honor Magic 5 Pro, the method to get the clipboard content has been
modified in the framework.

Adapt the call to make it work also on this device.

Fixes #3885 <#3885>
@rom1v
Copy link
Collaborator

rom1v commented Apr 1, 2023

Merged into dev: f77e1c4

It will be fixed in the next release.

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

2 participants