This article explains how to resolve the Android 10 clipboard issue in scrcpy by utilizing Riru’s Clipboard Whitelist module and incorporating the ‘-K’ flag with Python’s reader.py script, allowing compatibility with specific clipboard manager apps.

com.github.kr328.clipboard.ClipboardProxy.getPrimaryClip

Magisk Module:

Riru - Clipboard Whitelist

will white list clipboard manager app.

https://github.com/Kr328/Riru-ClipboardWhitelist

https://t.me/kr328_riru_modules

script.sh:

1
2
scrcpy -K -S 2>&1 | python3 reader.py

reader.py:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import os
import subprocess
import re
class Response(object):
status = None
data = None
def parseResponse(resultString):
response = re.findall(r"^Broadcasting: Intent { flg=0x400000 cmp=ch.pete.adbclipboard/.ReadReceiver }\nBroadcast completed: result=-1, data=\"((.*\n?)+)\"$",resultString)[0][0]
return response
def readFromDevice():
adbProcess = subprocess.Popen(
['adb',
'shell', 'am',
'broadcast',
'-n', 'ch.pete.adbclipboard/.ReadReceiver'],
stdout=subprocess.PIPE)
resultString = adbProcess.communicate()[0]
print("read device response:\n{}"
.format(resultString))
try:
result = parseResponse(resultString.decode("utf-8"))
print("raw:\n",resultString)
print("result:\n",result)
return result
except:
traceback.print_exc()
return
def setClipboard(data):
with open("target.out","w+",encoding="utf-8") as f:
f.write(data)
fetch_clipboard = "cat target.out | xclip -selection c"
os.system(fetch_clipboard)
while True:
content = input()
print("CONTENT:",content)
if "Calling uid 0 does not own package com.android.shell" in content:
print("!!!!!!!!!!ERROR FETCHING CLIPBOARD!!!!!!!!!!")
data = readFromDevice()
if data is not None:
setClipboard(data)
# with open("target.out","wb"
# os.system(fetch_clipboard)

Comments