Genymobile / scrcpy

Display and control your Android device
Apache License 2.0
108.54k stars 10.45k forks source link

Unable to copy / paste between device and computer #4614

Open 2011 opened 7 months ago

2011 commented 7 months ago

Environment

Describe the bug unable to copy / paste between device and computer

Every time I try to copy text on the device (whether through selecting "copy" in Android or using the Ctrl+C sequence), I get the following on computer terminal:

[server] ERROR: Could not invoke method
java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Method.invoke(Native Method)
        at com.genymobile.scrcpy.wrappers.ClipboardManager.getPrimaryClip(ClipboardManager.java:80)
        at com.genymobile.scrcpy.wrappers.ClipboardManager.getText(ClipboardManager.java:118)
        at com.genymobile.scrcpy.Device.getClipboardText(Device.java:285)
        at com.genymobile.scrcpy.Device$3.dispatchPrimaryClipChanged(Device.java:142)
        at android.content.IOnPrimaryClipChangedListener$Stub.onTransact(IOnPrimaryClipChangedListener.java:52)
        at android.os.Binder.execTransact(Binder.java:731)
Caused by: java.lang.SecurityException: Calling uid 0 does not own package com.android.shell
        at android.os.Parcel.createException(Parcel.java:1950)
        at android.os.Parcel.readException(Parcel.java:1918)
        at android.os.Parcel.readException(Parcel.java:1868)
        at android.content.IClipboard$Stub$Proxy.getPrimaryClip(IClipboard.java:215)
        ... 7 more
Caused by: android.os.RemoteException: Remote stack trace:
        at com.android.server.clipboard.ClipboardService.addActiveOwnerLocked(Unknown Source:57)
        at com.android.server.clipboard.ClipboardService.access$600(Unknown Source:0)
        at com.android.server.clipboard.ClipboardService$ClipboardImpl.getPrimaryClip(Unknown Source:30)
        at android.content.IClipboard$Stub.onTransact(IClipboard.java:81)
        at com.android.server.clipboard.ClipboardService$ClipboardImpl.onTransact(Unknown Source:0)
rom1v commented 7 months ago

Is your device rooted? #1606

(btw you should upgrade to the latest version)

2011 commented 7 months ago

Is your device rooted? #1606

Yes (unfortunately necessary for two of the most important functions of any computational device - backups and firewall).

Out put from the commands shown in the referenced issue:

# id
uid=0(root) gid=0(root) groups=0(root),1004(input),1007(log),1011(adb),1015(sdcard_rw),1028(sdcard_r),3001(net_bt_admin),3002(net_bt),3003(inet),3006(net_bw_stats),3009(readproc),3011(uhid) context=u:r:su:s0

# getprop ro.build.flavor
franklin-user

Just typing "adb shell" automatically gives me a root shell.

(btw you should upgrade to the latest version)

Did that (to 2.3.1) while anticipating a reply (as expected, no change). :)

I searched settings for "clipboard," and found nothing.

Does some obvious or simple workaround exist (nothing seemed clear to me from reading the issue that you referenced)?

rom1v commented 7 months ago

I have no good solution for this clipboard issue with rooted devices.

Just typing "adb shell" automatically gives me a root shell.

You can temporarily execute adb unroot, then adb shell will give a non-root shell (until you execute adb root again).

2011 commented 7 months ago

I have no good solution for this clipboard issue with rooted devices.

Why can't scrcpy automatically run as an ordinary user?

You can temporarily execute adb unroot, then adb shell will give a non-root shell (until you execute adb root again).

That doesn't work. The second that I type adb unroot -s , the device disappears, and I can no longer access it (even by killing and restarting the adb daemon). To access the device again, I have to reboot it.